Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / ToolStripActionList.cs / 1 / ToolStripActionList.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.Diagnostics.CodeAnalysis; using System; using System.Security; using System.Security.Permissions; using System.Collections; using System.ComponentModel.Design; using System.Windows.Forms; ///// IMPORTANT NOTE //THE CONTENTS OF THIS FILE ARE NOT ARRANGED IN ALPHABETICAL ORDER BUT MAP THERE POSITION IN THE "CHROME" // internal class ToolStripActionList : DesignerActionList { private ToolStrip _toolStrip; private bool _autoShow = false; private ToolStripDesigner designer; private ChangeToolStripParentVerb changeParentVerb = null; private StandardMenuStripVerb standardItemsVerb = null; /// public ToolStripActionList(ToolStripDesigner designer) : base(designer.Component) { _toolStrip = (ToolStrip)designer.Component; this.designer = designer; changeParentVerb = new ChangeToolStripParentVerb(SR.GetString(SR.ToolStripDesignerEmbedVerb), designer); if (!(_toolStrip is StatusStrip)) { standardItemsVerb = new StandardMenuStripVerb(SR.GetString(SR.ToolStripDesignerStandardItemsVerb), designer); } } /// /// False if were inherited and can't be modified. /// private bool CanAddItems { get { // Make sure the component is not being inherited -- we can't delete these! // InheritanceAttribute ia = (InheritanceAttribute)TypeDescriptor.GetAttributes(_toolStrip)[typeof(InheritanceAttribute)]; if (ia == null || ia.InheritanceLevel == InheritanceLevel.NotInherited) { return true; } return false; } } private bool IsReadOnly { get { // Make sure the component is not being inherited -- we can't delete these! // InheritanceAttribute ia = (InheritanceAttribute)TypeDescriptor.GetAttributes(_toolStrip)[typeof(InheritanceAttribute)]; if (ia == null || ia.InheritanceLevel == InheritanceLevel.InheritedReadOnly) { return true; } return false; } } //helper function to get the property on the actual Control [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] private object GetProperty(string propertyName) { PropertyDescriptor getProperty = TypeDescriptor.GetProperties(_toolStrip)[propertyName]; Debug.Assert( getProperty != null, "Could not find given property in control."); if( getProperty != null ) { return getProperty.GetValue(_toolStrip); } return null; } //helper function to change the property on the actual Control [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] private void ChangeProperty(string propertyName, object value) { PropertyDescriptor changingProperty = TypeDescriptor.GetProperties(_toolStrip)[propertyName]; Debug.Assert( changingProperty != null, "Could not find given property in control." ); if( changingProperty != null ) { changingProperty.SetValue(_toolStrip, value); } } ////// /// Controls whether the Chrome is Automatically shown on selection /// [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] public override bool AutoShow { get { return _autoShow; } set { if(_autoShow != value) { _autoShow = value; } } } ////// /// Sets Dock /// public DockStyle Dock { [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] get { return (DockStyle)GetProperty("Dock"); } [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] set { if (value != Dock) { ChangeProperty("Dock", (object)value); } } } ////// /// Sets RenderMode /// public ToolStripRenderMode RenderMode { [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] get { return (ToolStripRenderMode)GetProperty("RenderMode"); } [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] set { if (value != RenderMode) { ChangeProperty("RenderMode", (object)value); } } } ////// /// Sets GripStyle /// public ToolStripGripStyle GripStyle { [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] get { return (ToolStripGripStyle)GetProperty("GripStyle"); } [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] set { if (value != GripStyle) { ChangeProperty("GripStyle", (object)value); } } } [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] private void InvokeEmbedVerb() { // Hide the Panel... DesignerActionUIService actionUIService = (DesignerActionUIService)_toolStrip.Site.GetService(typeof(DesignerActionUIService)); if (actionUIService != null) { actionUIService.HideUI(_toolStrip); } changeParentVerb.ChangeParent(); } [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] private void InvokeInsertStandardItemsVerb() { standardItemsVerb.InsertItems(); } ////// /// The Main method to group the ActionItems and pass it to the Panel. /// public override DesignerActionItemCollection GetSortedActionItems() { DesignerActionItemCollection items = new DesignerActionItemCollection(); if (!IsReadOnly) { items.Add(new DesignerActionMethodItem(this, "InvokeEmbedVerb", SR.GetString(SR.ToolStripDesignerEmbedVerb), "", SR.GetString(SR.ToolStripDesignerEmbedVerbDesc), true)); } if (CanAddItems) { if (!(_toolStrip is StatusStrip)) { items.Add(new DesignerActionMethodItem(this, "InvokeInsertStandardItemsVerb", SR.GetString(SR.ToolStripDesignerStandardItemsVerb),"", SR.GetString(SR.ToolStripDesignerStandardItemsVerbDesc), true)); } items.Add(new DesignerActionPropertyItem("RenderMode", SR.GetString(SR.ToolStripActionList_RenderMode), SR.GetString(SR.ToolStripActionList_Layout), SR.GetString(SR.ToolStripActionList_RenderModeDesc))); } if (!(_toolStrip.Parent is ToolStripPanel)) { items.Add(new DesignerActionPropertyItem("Dock", SR.GetString(SR.ToolStripActionList_Dock), SR.GetString(SR.ToolStripActionList_Layout), SR.GetString(SR.ToolStripActionList_DockDesc))); } if (!(_toolStrip is StatusStrip)) { items.Add(new DesignerActionPropertyItem("GripStyle", SR.GetString(SR.ToolStripActionList_GripStyle), SR.GetString(SR.ToolStripActionList_Layout), SR.GetString(SR.ToolStripActionList_GripStyleDesc))); } 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
- XPathScanner.cs
- ByteAnimation.cs
- SafeHandles.cs
- DataGridPageChangedEventArgs.cs
- Ops.cs
- TcpActivation.cs
- HtmlInputPassword.cs
- SmiXetterAccessMap.cs
- TextRange.cs
- ArrayWithOffset.cs
- dbenumerator.cs
- XPathAxisIterator.cs
- DataSourceHelper.cs
- TokenBasedSet.cs
- FixedDocument.cs
- _RequestCacheProtocol.cs
- ProfessionalColors.cs
- ReadOnlyDictionary.cs
- IncrementalHitTester.cs
- CommonXSendMessage.cs
- NullableFloatMinMaxAggregationOperator.cs
- IERequestCache.cs
- RadioButtonStandardAdapter.cs
- ParamArrayAttribute.cs
- FieldMetadata.cs
- SingleKeyFrameCollection.cs
- PixelShader.cs
- DocumentXPathNavigator.cs
- HealthMonitoringSection.cs
- ContainerVisual.cs
- NodeInfo.cs
- RegistryConfigurationProvider.cs
- Pkcs9Attribute.cs
- KeyValueSerializer.cs
- SettingsPropertyIsReadOnlyException.cs
- QuarticEase.cs
- ControlDesignerState.cs
- BamlStream.cs
- InlineObject.cs
- FreezableDefaultValueFactory.cs
- AlternationConverter.cs
- ResourceReferenceExpressionConverter.cs
- XamlClipboardData.cs
- SqlDataSourceConfigureSelectPanel.cs
- ClickablePoint.cs
- BitmapImage.cs
- HtmlInputReset.cs
- CustomLineCap.cs
- Exceptions.cs
- SamlAuthenticationClaimResource.cs
- HyperLink.cs
- SoapObjectReader.cs
- AssemblyBuilderData.cs
- FormattedTextSymbols.cs
- SchemeSettingElementCollection.cs
- SqlException.cs
- ComponentSerializationService.cs
- XXXInfos.cs
- DecoderReplacementFallback.cs
- XmlIgnoreAttribute.cs
- FixedTextPointer.cs
- ChannelFactoryBase.cs
- WaitForChangedResult.cs
- DbProviderManifest.cs
- GifBitmapDecoder.cs
- ProgramPublisher.cs
- ToolboxCategory.cs
- ReadWriteSpinLock.cs
- EpmAttributeNameBuilder.cs
- PackageDocument.cs
- WpfGeneratedKnownTypes.cs
- milrender.cs
- CodeGeneratorOptions.cs
- VerifyHashRequest.cs
- EntityDataSourceReferenceGroup.cs
- TypeGeneratedEventArgs.cs
- Win32MouseDevice.cs
- WebServiceClientProxyGenerator.cs
- ImmComposition.cs
- securitymgrsite.cs
- RsaSecurityTokenAuthenticator.cs
- DesignerActionService.cs
- RtfToken.cs
- XmlDownloadManager.cs
- RegexMatch.cs
- MarginCollapsingState.cs
- DataGridColumnHeaderAutomationPeer.cs
- EncodingFallbackAwareXmlTextWriter.cs
- AppDomainAttributes.cs
- OrderedDictionary.cs
- DataGridViewColumnCollection.cs
- DropShadowBitmapEffect.cs
- XPathNodeInfoAtom.cs
- XamlTypeMapper.cs
- InvalidOperationException.cs
- GuidelineSet.cs
- XsdDateTime.cs
- TemplatePartAttribute.cs
- TreeIterators.cs
- ISAPIApplicationHost.cs