Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / PropertyGridInternal / CategoryGridEntry.cs / 1305376 / CategoryGridEntry.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- //#define PAINT_CATEGORY_TRIANGLE /* */ namespace System.Windows.Forms.PropertyGridInternal { using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System; using System.Collections; using System.Reflection; using System.ComponentModel; using System.ComponentModel.Design; using System.Windows.Forms; using System.Drawing; using Microsoft.Win32; internal class CategoryGridEntry : GridEntry { internal string name; private Brush backBrush = null; private static Hashtable categoryStates = null; [ SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors") // GridEntry classes are internal so we have complete // control over who does what in the constructor. ] public CategoryGridEntry(PropertyGrid ownerGrid, GridEntry peParent,string name, GridEntry[] childGridEntries) : base(ownerGrid, peParent) { this.name = name; #if DEBUG for (int n = 0;n < childGridEntries.Length; n++) { Debug.Assert(childGridEntries[n] != null, "Null item in category subproperty list"); } #endif if (categoryStates == null) { categoryStates = new Hashtable(); } lock (categoryStates) { if (!categoryStates.ContainsKey(name)) { categoryStates.Add(name, true); } } this.IsExpandable = true; for (int i = 0; i < childGridEntries.Length; i++) { childGridEntries[i].ParentGridEntry = this; } this.ChildCollection = new GridEntryCollection(this, childGridEntries); lock (categoryStates) { this.InternalExpanded = (bool)categoryStates[name]; } this.SetFlag(GridEntry.FLAG_LABEL_BOLD,true); } ////// /// Returns true if this GridEntry has a value field in the right hand column. /// internal override bool HasValue { get { return false; } } protected override void Dispose(bool disposing) { if (disposing) { if (backBrush != null) { backBrush.Dispose(); backBrush = null; } if (ChildCollection != null) { ChildCollection = null; } } base.Dispose(disposing); } public override void DisposeChildren() { // categories should never dispose // return; } // we don't want this guy participating in property depth. public override int PropertyDepth { get { return base.PropertyDepth - 1; } } protected override Brush GetBackgroundBrush(Graphics g) { return this.GridEntryHost.GetLineBrush(g); } protected override Color LabelTextColor { get { return ownerGrid.CategoryForeColor; } } public override bool Expandable { get { return !GetFlagSet(FL_EXPANDABLE_FAILED); } } internal override bool InternalExpanded { set { base.InternalExpanded = value; lock (categoryStates) { categoryStates[this.name] = value; } } } public override GridItemType GridItemType { get { return GridItemType.Category; } } public override string HelpKeyword { get { return null; } } public override string PropertyLabel { get { return name; } } internal override int PropertyLabelIndent { get { // we give an extra pixel for breathing room // we want to make sure that we return 0 for property depth here instead of PropertyGridView gridHost = this.GridEntryHost; // we call base.PropertyDepth here because we don't want the subratction to happen. return 1+gridHost.GetOutlineIconSize()+OUTLINE_ICON_PADDING + (base.PropertyDepth * gridHost.GetDefaultOutlineIndent()); } } public override string GetPropertyTextValue(object o) { return ""; } public override Type PropertyType { get { return typeof(void); } } ////// /// Gets the owner of the current value. This is usually the value of the /// root entry, which is the object being browsed /// public override object GetChildValueOwner(GridEntry childEntry) { return ParentGridEntry.GetChildValueOwner(childEntry); } protected override bool CreateChildren(bool diffOldChildren) { return true; } public override string GetTestingInfo() { string str = "object = ("; str += FullLabel; str += "), Category = (" + this.PropertyLabel + ")"; return str; } public override void PaintLabel(System.Drawing.Graphics g, Rectangle rect, Rectangle clipRect, bool selected, bool paintFullLabel) { base.PaintLabel(g, rect, clipRect, false, true); // now draw the focus rect if (selected && hasFocus) { bool bold = ((this.Flags & GridEntry.FLAG_LABEL_BOLD) != 0); Font font = GetFont(bold); int labelWidth = GetLabelTextWidth(this.PropertyLabel, g, font); int indent = PropertyLabelIndent-2; Rectangle focusRect = new Rectangle(indent, rect.Y, labelWidth+3, rect.Height-1); ControlPaint.DrawFocusRectangle(g, focusRect); } // draw the line along the top if (parentPE.GetChildIndex(this) > 0) { g.DrawLine(SystemPens.Control, rect.X-1, rect.Y-1, rect.Width+2, rect.Y - 1); } } public override void PaintValue(object val, System.Drawing.Graphics g, Rectangle rect, Rectangle clipRect, PaintValueFlags paintFlags) { base.PaintValue(val, g, rect, clipRect, paintFlags & ~PaintValueFlags.DrawSelected); // draw the line along the top if (parentPE.GetChildIndex(this) > 0) { g.DrawLine(SystemPens.Control, rect.X-2, rect.Y-1,rect.Width+1, rect.Y-1); } } internal override bool NotifyChildValue(GridEntry pe, int type) { return parentPE.NotifyChildValue(pe, type); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- LicenseContext.cs
- SoapReflectionImporter.cs
- SqlLiftWhereClauses.cs
- assemblycache.cs
- shaperfactoryquerycacheentry.cs
- XPathNavigatorKeyComparer.cs
- GcHandle.cs
- Activator.cs
- WorkflowExecutor.cs
- XPathNodeIterator.cs
- MergablePropertyAttribute.cs
- MarshalDirectiveException.cs
- ComplexTypeEmitter.cs
- PrinterResolution.cs
- XmlSchemaSimpleContentExtension.cs
- JsonClassDataContract.cs
- TextContainerHelper.cs
- HMAC.cs
- XamlTemplateSerializer.cs
- QueryOperationResponseOfT.cs
- UIPropertyMetadata.cs
- DependencyPropertyKey.cs
- XamlDesignerSerializationManager.cs
- ProfilePropertyNameValidator.cs
- MetadataExporter.cs
- X509Certificate.cs
- Exceptions.cs
- WebPartEditorCancelVerb.cs
- PersonalizableAttribute.cs
- SiteMapDataSourceView.cs
- ListControl.cs
- SystemInfo.cs
- ObjectStateEntryDbDataRecord.cs
- CodeActivityContext.cs
- TextOnlyOutput.cs
- OdbcFactory.cs
- ListViewItem.cs
- EntityDataSourceEntityTypeFilterConverter.cs
- SecurityTokenException.cs
- _ConnectOverlappedAsyncResult.cs
- WebFormDesignerActionService.cs
- NativeObjectSecurity.cs
- ExpressionsCollectionConverter.cs
- CloudCollection.cs
- MenuStrip.cs
- SystemException.cs
- ActivityDesignerAccessibleObject.cs
- FlowDocumentPage.cs
- VariantWrapper.cs
- SqlErrorCollection.cs
- StdValidatorsAndConverters.cs
- StatusBarPanelClickEvent.cs
- SafeArrayRankMismatchException.cs
- DataGridSortCommandEventArgs.cs
- MouseGesture.cs
- _Semaphore.cs
- FormsAuthenticationCredentials.cs
- MatrixAnimationUsingPath.cs
- SymbolMethod.cs
- ProvidersHelper.cs
- shaperfactoryquerycacheentry.cs
- ContextActivityUtils.cs
- InternalDispatchObject.cs
- SerializeAbsoluteContext.cs
- FileFormatException.cs
- RunInstallerAttribute.cs
- DirectoryInfo.cs
- Win32Exception.cs
- Aggregates.cs
- MessageDescriptionCollection.cs
- StorageConditionPropertyMapping.cs
- WindowsRichEdit.cs
- StringToken.cs
- SerTrace.cs
- WindowsAuthenticationEventArgs.cs
- DiscriminatorMap.cs
- DataSourceView.cs
- RequestNavigateEventArgs.cs
- DynamicUpdateCommand.cs
- OleDbInfoMessageEvent.cs
- FormsAuthentication.cs
- AppDomain.cs
- PathGradientBrush.cs
- TypeHelpers.cs
- ItemCheckEvent.cs
- WorkflowCompensationBehavior.cs
- MD5.cs
- DataGridColumn.cs
- ExitEventArgs.cs
- ContainerParaClient.cs
- GroupBoxRenderer.cs
- CodeExpressionCollection.cs
- ColumnHeaderConverter.cs
- StickyNote.cs
- ElementsClipboardData.cs
- ContainerParaClient.cs
- Currency.cs
- Psha1DerivedKeyGenerator.cs
- FileUpload.cs
- WorkflowTransactionService.cs