| |||||||||||||||||
| Source File | Conditionals | Statements | Methods | TOTAL | |||||||||||||
| Web\WebBuilders\ItemTemplates\PercentItemTemplate.cs | - | 0,0 % | 0,0 % | 0,0 % |
|
||||||||||||
| 1 | #region Copyright | |
| 2 | /* | |
| 3 | ShowX. Maps business objects into presentation layer. | |
| 4 | Copyright (C) 2005 Jesus Diaz. | |
| 5 | ||
| 6 | This library is free software; you can redistribute it and/or | |
| 7 | modify it under the terms of the GNU Lesser General Public | |
| 8 | License as published by the Free Software Foundation; either | |
| 9 | version 2.1 of the License, or (at your option) any later version. | |
| 10 | ||
| 11 | This library is distributed in the hope that it will be useful, | |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 | Lesser General Public License for more details. | |
| 15 | ||
| 16 | You should have received a copy of the GNU Lesser General Public | |
| 17 | License along with this library; if not, write to the Free Software | |
| 18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
| 19 | ||
| 20 | For project details see: http://showx.sourceforge.net | |
| 21 | */ | |
| 22 | #endregion | |
| 23 | ||
| 24 | using System; | |
| 25 | using System.Reflection; | |
| 26 | using System.Web.UI; | |
| 27 | using System.Web.UI.WebControls; | |
| 28 | using ShowX.Config; | |
| 29 | using ShowX.Model; | |
| 30 | using ShowX.Web.WebControls; | |
| 31 | using DataGrid = System.Web.UI.WebControls.DataGrid; | |
| 32 | ||
| 33 | namespace ShowX.Web.WebBuilders.ItemTemplates | |
| 34 | { | |
| 35 | ||
| 36 | /// <summary> | |
| 37 | /// This template build a cell inserting a progress bar control. Mainly used for | |
| 38 | /// Properties marked with the XPercent attribute | |
| 39 | /// </summary> | |
| 40 | class PercentItemTemplate : ITemplate { | |
| 41 | ||
| 42 | /// <summary> | |
| 43 | /// Information of the property to map | |
| 44 | /// </summary> | |
| 45 | protected PropertyInfo propertyInfo; | |
| 46 | ||
| 47 | /// <summary> | |
| 48 | /// Constructor | |
| 49 | /// </summary> | |
| 50 | /// <param name="propertyInfo">Information of the property to map</param> | |
| 51 | 0 | public PercentItemTemplate(PropertyInfo propertyInfo) |
| 52 | { | |
| 53 | this.propertyInfo = propertyInfo; | |
| 54 | } | |
| 55 | ||
| 56 | /// <summary> | |
| 57 | /// Method called when instantiating a TemplateColumn by using this | |
| 58 | /// ITemplate implementation | |
| 59 | /// </summary> | |
| 60 | /// <param name="container">Container that instantiate this Template</param> | |
| 61 | 0 | public void InstantiateIn(Control container) |
| 62 | { | |
| 63 | // XPercent xp = propertyInfo | |
| 64 | // .GetCustomAttributes(typeof(XPercent),true)[0] as XPercent; | |
| 65 | ||
| 66 | IXPercentMap xp = Configuration.Session.MappingHandler | |
| 67 | .GetPropertyMap(propertyInfo) as IXPercentMap; | |
| 68 | ||
| 69 | ProgressBar pb = new ProgressBar(xp.MaxPoperty,propertyInfo); | |
| 70 | pb.ShowName = false; | |
| 71 | ||
| 72 | pb.DataBinding += new EventHandler(TemplateControl_DataBinding); | |
| 73 | container.Controls.Add(pb); | |
| 74 | } | |
| 75 | ||
| 76 | /// <summary> | |
| 77 | /// DataBinding Event related with a control of the template. Very useful to | |
| 78 | /// assign correct values to template controls. | |
| 79 | /// </summary> | |
| 80 | /// <param name="sender">Sender who invoke the data binding</param> | |
| 81 | /// <param name="e">Arguments of the event</param> | |
| 82 | 0 | private void TemplateControl_DataBinding(object sender, EventArgs e) |
| 83 | { | |
| 84 | ProgressBar pb; | |
| 85 | pb = (ProgressBar) sender; | |
| 86 | DataGridItem container = (DataGridItem) pb.NamingContainer; | |
| 87 | ||
| 88 | DataGrid dg = container.Parent.Parent | |
| 89 | as DataGrid; | |
| 90 | ||
| 91 | pb.XInstance = container.DataItem; | |
| 92 | ||
| 93 | int pos = container.DataSetIndex - dg.PageSize*dg.CurrentPageIndex; | |
| 94 | ||
| 95 | pb.TextStyle = (pos % 2 == 0) | |
| 96 | ? dg.ItemStyle : dg.AlternatingItemStyle; | |
| 97 | } | |
| 98 | } | |
| 99 | } |
|
||||||||