Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / ContextMenuStripActionList.cs / 1 / ContextMenuStripActionList.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms.Design { using System.Design; using System.Runtime.InteropServices; using System.ComponentModel; using System.Diagnostics; using System; using System.Security; using System.Security.Permissions; using System.Collections; using System.ComponentModel.Design; using System.Windows.Forms; ///internal class ContextMenuStripActionList : DesignerActionList { private ToolStripDropDown _toolStripDropDown; private bool _autoShow = false; /// public ContextMenuStripActionList(ToolStripDropDownDesigner designer) : base (designer.Component) { _toolStripDropDown = (ToolStripDropDown)designer.Component; } //helper function to get the property on the actual Control private object GetProperty(string propertyName) { PropertyDescriptor getProperty = TypeDescriptor.GetProperties(_toolStripDropDown)[propertyName]; Debug.Assert( getProperty != null, "Could not find given property in control."); if( getProperty != null ) { return getProperty.GetValue(_toolStripDropDown); } return null; } //helper function to change the property on the actual Control private void ChangeProperty(string propertyName, object value) { PropertyDescriptor changingProperty = TypeDescriptor.GetProperties(_toolStripDropDown)[propertyName]; Debug.Assert( changingProperty != null, "Could not find given property in control." ); if( changingProperty != null ) { changingProperty.SetValue(_toolStripDropDown, value); } } /// /// /// Controls whether the Chrome is Automatically shown on selection /// public override bool AutoShow { get { return _autoShow; } set { if(_autoShow != value) { _autoShow = value; } } } ////// /// Sets ShowImageMargin /// public bool ShowImageMargin { get { return (bool)GetProperty("ShowImageMargin"); } set { if (value != ShowImageMargin) { ChangeProperty("ShowImageMargin", (object)value); } } } ////// /// Sets ShowCheckMargin /// public bool ShowCheckMargin { get { return (bool)GetProperty("ShowCheckMargin"); } set { if (value != ShowCheckMargin) { ChangeProperty("ShowCheckMargin", (object)value); } } } ////// /// Sets RenderMode /// public ToolStripRenderMode RenderMode { get { return (ToolStripRenderMode)GetProperty("RenderMode"); } set { if (value != RenderMode) { ChangeProperty("RenderMode", (object)value); } } } ////// /// The Main method to group the ActionItems and pass it to the Panel. /// public override DesignerActionItemCollection GetSortedActionItems() { DesignerActionItemCollection items = new DesignerActionItemCollection(); items.Add(new DesignerActionPropertyItem(SR.GetString(SR.ToolStripActionList_RenderMode), SR.GetString(SR.ToolStripActionList_RenderMode), SR.GetString(SR.ToolStripActionList_Layout), SR.GetString(SR.ToolStripActionList_RenderModeDesc))); if (_toolStripDropDown is ToolStripDropDownMenu) { items.Add(new DesignerActionPropertyItem(SR.GetString(SR.ContextMenuStripActionList_ShowImageMargin), SR.GetString(SR.ContextMenuStripActionList_ShowImageMargin), SR.GetString(SR.ToolStripActionList_Layout), SR.GetString(SR.ContextMenuStripActionList_ShowImageMarginDesc))); items.Add(new DesignerActionPropertyItem(SR.GetString(SR.ContextMenuStripActionList_ShowCheckMargin), SR.GetString(SR.ContextMenuStripActionList_ShowCheckMargin), SR.GetString(SR.ToolStripActionList_Layout), SR.GetString(SR.ContextMenuStripActionList_ShowCheckMarginDesc))); } return items; } } } // 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
- Panel.cs
- AsyncCompletedEventArgs.cs
- NumericExpr.cs
- ModelItemDictionary.cs
- VectorAnimation.cs
- TransactionChannelFaultConverter.cs
- StylusDevice.cs
- UseLicense.cs
- EqualityComparer.cs
- Point4D.cs
- AtomServiceDocumentSerializer.cs
- RouteValueExpressionBuilder.cs
- TypeLoadException.cs
- DesignerVerbCollection.cs
- ProviderException.cs
- LockRenewalTask.cs
- IQueryable.cs
- PreloadedPackages.cs
- ReturnEventArgs.cs
- DebugInfoGenerator.cs
- ITreeGenerator.cs
- PolyBezierSegment.cs
- SchemaCompiler.cs
- SqlErrorCollection.cs
- AttachedPropertyMethodSelector.cs
- Stroke.cs
- SQLBytes.cs
- SourceChangedEventArgs.cs
- ColorMap.cs
- IdentityReference.cs
- WebPartExportVerb.cs
- CanonicalFontFamilyReference.cs
- UnauthorizedWebPart.cs
- XmlSchemaGroup.cs
- MemoryRecordBuffer.cs
- InputElement.cs
- XmlSignificantWhitespace.cs
- DatePickerAutomationPeer.cs
- ToolStripContentPanelRenderEventArgs.cs
- SecurityContextCookieSerializer.cs
- NavigatorInput.cs
- EventBookmark.cs
- TypeDelegator.cs
- ImageBrush.cs
- DataObjectSettingDataEventArgs.cs
- AsymmetricKeyExchangeFormatter.cs
- TextParentUndoUnit.cs
- XslUrlEditor.cs
- IPAddressCollection.cs
- WebServiceParameterData.cs
- Int64KeyFrameCollection.cs
- TdsParser.cs
- TypeDescriptionProviderAttribute.cs
- SymbolEqualComparer.cs
- LicFileLicenseProvider.cs
- BuildProviderUtils.cs
- PipelineModuleStepContainer.cs
- AmbientLight.cs
- DSACryptoServiceProvider.cs
- BindingExpressionBase.cs
- StringReader.cs
- DefaultPropertiesToSend.cs
- NavigationProperty.cs
- SerializationEventsCache.cs
- CompiledXpathExpr.cs
- CommentEmitter.cs
- ObjectDataSourceSelectingEventArgs.cs
- RegexGroupCollection.cs
- SelectedCellsChangedEventArgs.cs
- DnsEndPoint.cs
- UInt32Converter.cs
- SafeCryptContextHandle.cs
- TextViewSelectionProcessor.cs
- KeyGesture.cs
- FunctionParameter.cs
- wpf-etw.cs
- CellParaClient.cs
- SqlBooleanMismatchVisitor.cs
- MarginsConverter.cs
- NavigationPropertyEmitter.cs
- HiddenFieldPageStatePersister.cs
- KeySplineConverter.cs
- LocalFileSettingsProvider.cs
- SerializationSectionGroup.cs
- BufferedReadStream.cs
- DefaultValueConverter.cs
- SurrogateSelector.cs
- WebPartConnectionsConfigureVerb.cs
- ObjectPropertyMapping.cs
- __Filters.cs
- ClientConvert.cs
- SQLBinaryStorage.cs
- BamlRecordHelper.cs
- XmlSchemaSimpleTypeUnion.cs
- CommonProperties.cs
- DataKeyArray.cs
- CachedPathData.cs
- StaticContext.cs
- Listbox.cs
- GenerateScriptTypeAttribute.cs