Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / ToolStripMenuItemCodeDomSerializer.cs / 1 / ToolStripMenuItemCodeDomSerializer.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope="member", Target="System.Windows.Forms.Design.ToolStripMenuItemCodeDomSerializer..ctor()")] namespace System.Windows.Forms.Design { using System; using System.Diagnostics; using System.CodeDom; using System.ComponentModel; using System.ComponentModel.Design; using System.ComponentModel.Design.Serialization; ////// The Reason for having a CustomSerializer for ToolStripMenuItem is the existance of Dummy ToolStripMenuItem for ContextMenuStrips. /// We add this Dummy ToolStripMenuItem on the "Non Site" ToolStrip to Host the DropDown which facilitates the entry of New MenuItems. /// These items are then added to the ContextMenuStrip that we are designing. /// But we dont want the Dummy ToolStripMenuItem to Serialize and hence the need for this Custom Serializer. /// internal class ToolStripMenuItemCodeDomSerializer : System.ComponentModel.Design.Serialization.CodeDomSerializer { ////// We implement this for the abstract method on CodeDomSerializer. /// public override object Deserialize(IDesignerSerializationManager manager, object codeObject) { return GetBaseSerializer(manager).Deserialize(manager, codeObject); } ////// This is a small helper method that returns the serializer for base Class /// private CodeDomSerializer GetBaseSerializer(IDesignerSerializationManager manager) { return (CodeDomSerializer)manager.GetSerializer(typeof(Component), typeof(CodeDomSerializer)); } ////// /// We implement this for the abstract method on CodeDomSerializer. This method /// takes an object graph, and serializes the object into CodeDom elements. /// public override object Serialize(IDesignerSerializationManager manager, object value) { ToolStripMenuItem item = value as ToolStripMenuItem; ToolStrip parent = item.GetCurrentParent() as ToolStrip; //Dont Serialize if we are Dummy Item ... if ((item != null) && !(item.IsOnDropDown) && (parent != null) && (parent .Site == null)) { //dont serialize anything... return null; } else { CodeDomSerializer baseSerializer = (CodeDomSerializer)manager.GetSerializer(typeof(ImageList).BaseType, typeof(CodeDomSerializer)); return baseSerializer.Serialize(manager, value); } } } } // 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
- SoapSchemaExporter.cs
- TextEndOfSegment.cs
- XPathSingletonIterator.cs
- CommandDevice.cs
- TextOutput.cs
- ListBase.cs
- BitmapInitialize.cs
- SQLMoneyStorage.cs
- CodePageUtils.cs
- InternalRelationshipCollection.cs
- counter.cs
- CookielessHelper.cs
- _SslState.cs
- DiscoveryReference.cs
- X500Name.cs
- CorrelationValidator.cs
- XmlIgnoreAttribute.cs
- WebBrowsableAttribute.cs
- TaskCanceledException.cs
- Collection.cs
- SchemaMerger.cs
- DataGridViewButtonCell.cs
- Drawing.cs
- DataStorage.cs
- PermissionRequestEvidence.cs
- CmsInterop.cs
- AttachedPropertyInfo.cs
- TimeSpanSecondsConverter.cs
- TableHeaderCell.cs
- IsolatedStorageFilePermission.cs
- XmlCharType.cs
- MeshGeometry3D.cs
- ProtocolsConfigurationHandler.cs
- AnnotationComponentChooser.cs
- PointAnimationUsingPath.cs
- ByeMessage11.cs
- RecognizedPhrase.cs
- ElementProxy.cs
- BindingOperations.cs
- MergeEnumerator.cs
- KeyValuePairs.cs
- TextBoxBase.cs
- TypeDependencyAttribute.cs
- PersonalizationDictionary.cs
- DeploymentSectionCache.cs
- ListViewCancelEventArgs.cs
- StrokeSerializer.cs
- RolePrincipal.cs
- InheritanceContextChangedEventManager.cs
- BrowserCapabilitiesCodeGenerator.cs
- While.cs
- UnsafeNativeMethods.cs
- ProcessModuleCollection.cs
- TableParaClient.cs
- hebrewshape.cs
- InstanceDataCollection.cs
- StylusOverProperty.cs
- HandlerFactoryCache.cs
- StylusCollection.cs
- ValueOfAction.cs
- GenericIdentity.cs
- LoadMessageLogger.cs
- Normalization.cs
- _SpnDictionary.cs
- FixedPageProcessor.cs
- RIPEMD160Managed.cs
- Color.cs
- SrgsRuleRef.cs
- DiscoveryUtility.cs
- SmiXetterAccessMap.cs
- SafeNativeMethods.cs
- EndPoint.cs
- LinqDataSourceContextEventArgs.cs
- StrokeNodeOperations.cs
- TemplateApplicationHelper.cs
- GlobalizationSection.cs
- WebConfigurationHost.cs
- KeyGesture.cs
- XamlPoint3DCollectionSerializer.cs
- QueryAccessibilityHelpEvent.cs
- PackWebResponse.cs
- DesignerToolStripControlHost.cs
- ComponentManagerBroker.cs
- WsatServiceCertificate.cs
- TreeNodeBinding.cs
- IsolatedStorageFilePermission.cs
- HelloMessage11.cs
- UnsafeNativeMethods.cs
- MexHttpBindingCollectionElement.cs
- PixelFormats.cs
- Enlistment.cs
- Exceptions.cs
- FormViewInsertedEventArgs.cs
- BitmapSizeOptions.cs
- Processor.cs
- DataServiceProviderMethods.cs
- ImageIndexConverter.cs
- NamespaceEmitter.cs
- CellLabel.cs
- IdentityHolder.cs