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
- Type.cs
- AttachedPropertyDescriptor.cs
- WebPartMenu.cs
- PropertyBuilder.cs
- XsdDuration.cs
- ExpressionHelper.cs
- ForceCopyBuildProvider.cs
- EditorZoneBase.cs
- WebControl.cs
- WmlListAdapter.cs
- TableParagraph.cs
- ValidatedMobileControlConverter.cs
- RectangleF.cs
- LoginViewDesigner.cs
- Int32EqualityComparer.cs
- ListViewInsertionMark.cs
- ParameterToken.cs
- CompleteWizardStep.cs
- ToolboxBitmapAttribute.cs
- codemethodreferenceexpression.cs
- XPathAncestorIterator.cs
- SchemaLookupTable.cs
- FontResourceCache.cs
- CodeExporter.cs
- SymDocumentType.cs
- ViewStateModeByIdAttribute.cs
- WindowsRichEditRange.cs
- GroupBoxDesigner.cs
- Size.cs
- basenumberconverter.cs
- SecurityCookieModeValidator.cs
- XamlInt32CollectionSerializer.cs
- FullTextLine.cs
- EDesignUtil.cs
- TraceLog.cs
- NameScope.cs
- DesignerTransaction.cs
- XD.cs
- ViewLoader.cs
- XmlSerializerObjectSerializer.cs
- ServiceNameElementCollection.cs
- EntityDataSourceDataSelectionPanel.cs
- MemberHolder.cs
- CollectionsUtil.cs
- CurrentChangingEventArgs.cs
- DefaultProxySection.cs
- Vector3DConverter.cs
- XmlSchemaComplexContentRestriction.cs
- BitmapEffectGeneralTransform.cs
- DesignerCategoryAttribute.cs
- RequestStatusBarUpdateEventArgs.cs
- HttpProcessUtility.cs
- OpenFileDialog.cs
- Deflater.cs
- PassportPrincipal.cs
- SoapFormatterSinks.cs
- HttpContextWrapper.cs
- Panel.cs
- UserMapPath.cs
- TypeDescriptorContext.cs
- SecurityChannelFaultConverter.cs
- DataView.cs
- LinkTarget.cs
- FunctionNode.cs
- GroupAggregateExpr.cs
- ConstantExpression.cs
- OperatingSystem.cs
- TraceData.cs
- PageCatalogPartDesigner.cs
- ControlBindingsCollection.cs
- ResizeGrip.cs
- LexicalChunk.cs
- CodeAccessSecurityEngine.cs
- FixedFlowMap.cs
- UInt16Storage.cs
- SerialPort.cs
- xmlfixedPageInfo.cs
- DesignerTransactionCloseEvent.cs
- Constraint.cs
- XsltOutput.cs
- GeometryDrawing.cs
- SqlExpander.cs
- RemotingException.cs
- TCEAdapterGenerator.cs
- OciLobLocator.cs
- BamlResourceContent.cs
- DataGridViewRowPostPaintEventArgs.cs
- RequestUriProcessor.cs
- ToolStripContainer.cs
- ConfigurationManagerHelper.cs
- XPathNodePointer.cs
- PageCodeDomTreeGenerator.cs
- CrossContextChannel.cs
- RangeBase.cs
- ImportOptions.cs
- ProfilePropertyMetadata.cs
- ContractInferenceHelper.cs
- PrintPreviewControl.cs
- WebAdminConfigurationHelper.cs
- NullableLongMinMaxAggregationOperator.cs