Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WebForms / System / Web / UI / Design / WebControls / FormViewAutoFormat.cs / 1 / FormViewAutoFormat.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.Design.WebControls { using System.ComponentModel.Design; using System.Data; using System.Design; using System.Diagnostics; using System.Drawing; using System.Globalization; using System.Text; using System.Web.UI.WebControls; internal sealed class FormViewAutoFormat : DesignerAutoFormat { private string headerForeColor; private string headerBackColor; private int headerFont; private string footerForeColor; private string footerBackColor; private int footerFont; private string borderColor; private string borderWidth; private int borderStyle = -1; private int gridLines = -1; private int cellSpacing; private int cellPadding = -1; private string foreColor; private string backColor; private string rowForeColor; private string rowBackColor; private int itemFont; private string editRowForeColor; private string editRowBackColor; private int editRowFont; private string pagerForeColor; private string pagerBackColor; private int pagerFont; private int pagerAlign; private int pagerButtons; const int FONT_BOLD = 1; const int FONT_ITALIC = 2; public FormViewAutoFormat(DataRow schemeData) : base(SR.GetString(schemeData["SchemeName"].ToString())) { Load(schemeData); } public override void Apply(Control control) { Debug.Assert(control is FormView, "FormViewAutoFormat:ApplyScheme- control is not FormView"); if (control is FormView) { Apply(control as FormView); } } private void Apply(FormView view) { view.HeaderStyle.ForeColor = ColorTranslator.FromHtml(headerForeColor); view.HeaderStyle.BackColor = ColorTranslator.FromHtml(headerBackColor); view.HeaderStyle.Font.Bold = ((headerFont & FONT_BOLD) != 0); view.HeaderStyle.Font.Italic = ((headerFont & FONT_ITALIC) != 0); view.HeaderStyle.Font.ClearDefaults(); view.FooterStyle.ForeColor = ColorTranslator.FromHtml(footerForeColor); view.FooterStyle.BackColor = ColorTranslator.FromHtml(footerBackColor); view.FooterStyle.Font.Bold = ((footerFont & FONT_BOLD) != 0); view.FooterStyle.Font.Italic = ((footerFont & FONT_ITALIC) != 0); view.FooterStyle.Font.ClearDefaults(); view.BorderWidth = new Unit(borderWidth, CultureInfo.InvariantCulture); switch (gridLines) { case 0: view.GridLines = GridLines.None; break; case 1: view.GridLines = GridLines.Horizontal; break; case 2: view.GridLines = GridLines.Vertical; break; case 3: view.GridLines = GridLines.Both; break; default: view.GridLines = GridLines.None; break; } if ((borderStyle >= 0) && (borderStyle <= 9)) { view.BorderStyle = (System.Web.UI.WebControls.BorderStyle)borderStyle; } else { view.BorderStyle = System.Web.UI.WebControls.BorderStyle.NotSet; } view.BorderColor = ColorTranslator.FromHtml(borderColor); view.CellPadding = cellPadding; view.CellSpacing = cellSpacing; view.ForeColor = ColorTranslator.FromHtml(foreColor); view.BackColor = ColorTranslator.FromHtml(backColor); view.RowStyle.ForeColor = ColorTranslator.FromHtml(rowForeColor); view.RowStyle.BackColor = ColorTranslator.FromHtml(rowBackColor); view.RowStyle.Font.Bold = ((itemFont & FONT_BOLD) != 0); view.RowStyle.Font.Italic = ((itemFont & FONT_ITALIC) != 0); view.RowStyle.Font.ClearDefaults(); view.EditRowStyle.ForeColor = ColorTranslator.FromHtml(editRowForeColor); view.EditRowStyle.BackColor = ColorTranslator.FromHtml(editRowBackColor); view.EditRowStyle.Font.Bold = ((editRowFont & FONT_BOLD) != 0); view.EditRowStyle.Font.Italic = ((editRowFont & FONT_ITALIC) != 0); view.EditRowStyle.Font.ClearDefaults(); view.PagerStyle.ForeColor = ColorTranslator.FromHtml(pagerForeColor); view.PagerStyle.BackColor = ColorTranslator.FromHtml(pagerBackColor); view.PagerStyle.Font.Bold = ((pagerFont & FONT_BOLD) != 0); view.PagerStyle.Font.Italic = ((pagerFont & FONT_ITALIC) != 0); view.PagerStyle.HorizontalAlign = (HorizontalAlign)pagerAlign; view.PagerStyle.Font.ClearDefaults(); view.PagerSettings.Mode = (PagerButtons)pagerButtons; } private int GetIntProperty(string propertyTag, DataRow schemeData) { object data = schemeData[propertyTag]; if ((data != null) && !data.Equals(DBNull.Value)) return Int32.Parse(data.ToString(), CultureInfo.InvariantCulture); else return 0; } private int GetIntProperty(string propertyTag, int defaultValue, DataRow schemeData) { object data = schemeData[propertyTag]; if ((data != null) && !data.Equals(DBNull.Value)) return Int32.Parse(data.ToString(), CultureInfo.InvariantCulture); else return defaultValue; } public override Control GetPreviewControl(Control runtimeControl) { Control control = base.GetPreviewControl(runtimeControl); if (control != null) { IDesignerHost host = (IDesignerHost)runtimeControl.Site.GetService(typeof(IDesignerHost)); FormView formView = control as FormView; if (formView != null && host != null) { TemplateBuilder itemTemplate = formView.ItemTemplate as TemplateBuilder; if ((itemTemplate != null && itemTemplate.Text.Length == 0) || formView.ItemTemplate == null) { string text = "#### ####
#### ####
#### ####
#### ####"; formView.ItemTemplate = ControlParser.ParseTemplate(host, text); formView.RowStyle.HorizontalAlign = HorizontalAlign.Center; } formView.HorizontalAlign = HorizontalAlign.Center; formView.Width = new Unit(80, UnitType.Percentage); } } return control; } private string GetStringProperty(string propertyTag, DataRow schemeData) { object data = schemeData[propertyTag]; if ((data != null) && !data.Equals(DBNull.Value)) return data.ToString(); else return String.Empty; } private void Load(DataRow schemeData) { Debug.Assert(schemeData != null); foreColor = GetStringProperty("ForeColor", schemeData); backColor = GetStringProperty("BackColor", schemeData); borderColor = GetStringProperty("BorderColor", schemeData); borderWidth = GetStringProperty("BorderWidth", schemeData); borderStyle = GetIntProperty("BorderStyle", -1, schemeData); cellSpacing = GetIntProperty("CellSpacing", schemeData); cellPadding = GetIntProperty("CellPadding", -1, schemeData); gridLines = GetIntProperty("GridLines", -1, schemeData); rowForeColor = GetStringProperty("RowForeColor", schemeData); rowBackColor = GetStringProperty("RowBackColor", schemeData); itemFont = GetIntProperty("RowFont", schemeData); editRowForeColor = GetStringProperty("EditRowForeColor", schemeData); editRowBackColor = GetStringProperty("EditRowBackColor", schemeData); editRowFont = GetIntProperty("EditRowFont", schemeData); headerForeColor = GetStringProperty("HeaderForeColor", schemeData); headerBackColor = GetStringProperty("HeaderBackColor", schemeData); headerFont = GetIntProperty("HeaderFont", schemeData); footerForeColor = GetStringProperty("FooterForeColor", schemeData); footerBackColor = GetStringProperty("FooterBackColor", schemeData); footerFont = GetIntProperty("FooterFont", schemeData); pagerForeColor = GetStringProperty("PagerForeColor", schemeData); pagerBackColor = GetStringProperty("PagerBackColor", schemeData); pagerFont = GetIntProperty("PagerFont", schemeData); pagerAlign = GetIntProperty("PagerAlign", schemeData); pagerButtons = GetIntProperty("PagerButtons", 1, schemeData); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CannotUnloadAppDomainException.cs
- UnaryNode.cs
- XmlTypeAttribute.cs
- UIElement3D.cs
- ListViewItemEventArgs.cs
- xsdvalidator.cs
- TemplatePagerField.cs
- EnumerableValidator.cs
- SpecialFolderEnumConverter.cs
- CursorConverter.cs
- GreenMethods.cs
- LocalizationComments.cs
- ConfigXmlSignificantWhitespace.cs
- RuleInfoComparer.cs
- _UriTypeConverter.cs
- ErrorFormatterPage.cs
- TerminateSequenceResponse.cs
- ToolTipAutomationPeer.cs
- QilFactory.cs
- SettingsContext.cs
- SqlDependencyListener.cs
- PolyQuadraticBezierSegment.cs
- XmlEntityReference.cs
- thaishape.cs
- TriggerActionCollection.cs
- SeparatorAutomationPeer.cs
- PathSegmentCollection.cs
- HyperLinkStyle.cs
- DefaultHttpHandler.cs
- ArraySet.cs
- ByteKeyFrameCollection.cs
- WizardForm.cs
- AsyncContentLoadedEventArgs.cs
- TrustLevel.cs
- WmiPutTraceRecord.cs
- BinaryParser.cs
- SqlCacheDependency.cs
- UnknownBitmapDecoder.cs
- SelectedDatesCollection.cs
- SecureUICommand.cs
- PrePrepareMethodAttribute.cs
- IndexedGlyphRun.cs
- EventArgs.cs
- PageAsyncTaskManager.cs
- ConfigurationLocationCollection.cs
- WebPartDescription.cs
- DbMetaDataColumnNames.cs
- EntityTransaction.cs
- TrustLevelCollection.cs
- AdornerPresentationContext.cs
- ImageAttributes.cs
- PageThemeParser.cs
- CodeIdentifier.cs
- FontDifferentiator.cs
- ControlParameter.cs
- DataObjectCopyingEventArgs.cs
- TokenBasedSetEnumerator.cs
- MachineKeyValidationConverter.cs
- NumericUpDownAcceleration.cs
- DocumentPaginator.cs
- DecimalMinMaxAggregationOperator.cs
- AttachedPropertyBrowsableAttribute.cs
- ScriptingRoleServiceSection.cs
- ProviderUtil.cs
- wmiprovider.cs
- SynchronizationLockException.cs
- SimpleHandlerBuildProvider.cs
- TemplateBindingExtensionConverter.cs
- EndPoint.cs
- ViewBox.cs
- ParameterToken.cs
- Transform3DGroup.cs
- BuildProviderCollection.cs
- DataServiceContext.cs
- CodeRemoveEventStatement.cs
- D3DImage.cs
- UpdatePanelTrigger.cs
- EmissiveMaterial.cs
- PermissionSet.cs
- NGCPageContentSerializerAsync.cs
- StylusPlugin.cs
- DashStyle.cs
- ParameterBuilder.cs
- BitmapEffectRenderDataResource.cs
- Stroke2.cs
- TitleStyle.cs
- ConstructorNeedsTagAttribute.cs
- CustomCredentialPolicy.cs
- RepeatBehavior.cs
- DataGridColumnReorderingEventArgs.cs
- RawStylusInputCustomDataList.cs
- RegexCompilationInfo.cs
- EntitySqlQueryCacheEntry.cs
- SByte.cs
- SymbolResolver.cs
- ObjectDataSourceDisposingEventArgs.cs
- _NegoStream.cs
- SingleResultAttribute.cs
- ArgumentException.cs
- SelectionHighlightInfo.cs