Code:
/ FX-1434 / FX-1434 / 1.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
- HtmlTitle.cs
- FileDialogPermission.cs
- PersonalizationProviderHelper.cs
- XPathExpr.cs
- SpeakCompletedEventArgs.cs
- MessageEncodingBindingElementImporter.cs
- Int32CAMarshaler.cs
- RequiredAttributeAttribute.cs
- StylusTip.cs
- FontNameConverter.cs
- ViewCellRelation.cs
- State.cs
- ServiceHostingEnvironment.cs
- XmlSignatureManifest.cs
- Error.cs
- FlowDocumentPaginator.cs
- IDictionary.cs
- DataErrorValidationRule.cs
- LocalizationComments.cs
- Pen.cs
- DataControlReference.cs
- ArraySortHelper.cs
- OdbcConnectionHandle.cs
- Stack.cs
- FileChangesMonitor.cs
- Visual3D.cs
- EdmSchemaError.cs
- Matrix3DStack.cs
- LogArchiveSnapshot.cs
- ApplicationTrust.cs
- ByteKeyFrameCollection.cs
- RoamingStoreFileUtility.cs
- StreamResourceInfo.cs
- Evidence.cs
- PolicyStatement.cs
- LinqDataSourceValidationException.cs
- ImageClickEventArgs.cs
- Deflater.cs
- While.cs
- X509IssuerSerialKeyIdentifierClause.cs
- ControlBuilder.cs
- SubMenuStyle.cs
- SqlTriggerAttribute.cs
- LineSegment.cs
- XmlElementList.cs
- UnsafeNativeMethods.cs
- ComponentDispatcherThread.cs
- SimpleWorkerRequest.cs
- DurableMessageDispatchInspector.cs
- TemplatePropertyEntry.cs
- Stroke.cs
- URIFormatException.cs
- EventLogTraceListener.cs
- _KerberosClient.cs
- ServicePoint.cs
- Stroke2.cs
- RestHandler.cs
- Mapping.cs
- SrgsItemList.cs
- ContractMapping.cs
- ItemsControlAutomationPeer.cs
- TextRange.cs
- SequenceDesigner.cs
- WCFModelStrings.Designer.cs
- SchemaConstraints.cs
- VirtualPathUtility.cs
- Vector3DAnimationUsingKeyFrames.cs
- TextTreeTextElementNode.cs
- FontTypeConverter.cs
- DefinitionBase.cs
- AutomationPatternInfo.cs
- NativeMethods.cs
- Query.cs
- WebSysDisplayNameAttribute.cs
- InvokeGenerator.cs
- WindowsEditBoxRange.cs
- MatrixTransform3D.cs
- DrawingCollection.cs
- XmlUtilWriter.cs
- Dump.cs
- OracleBoolean.cs
- CodeAttributeDeclaration.cs
- CaseInsensitiveOrdinalStringComparer.cs
- StringReader.cs
- HttpWriter.cs
- MaterialGroup.cs
- XhtmlBasicLiteralTextAdapter.cs
- DbModificationCommandTree.cs
- safePerfProviderHandle.cs
- StartUpEventArgs.cs
- DocumentApplicationJournalEntry.cs
- TaskFileService.cs
- EventSourceCreationData.cs
- ValueExpressions.cs
- DataGridCell.cs
- CompositeScriptReferenceEventArgs.cs
- InfoCardRSACryptoProvider.cs
- ResourceReferenceExpression.cs
- XamlClipboardData.cs
- StylusButtonEventArgs.cs