Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / NewItemsContextMenuStrip.cs / 1 / NewItemsContextMenuStrip.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.Windows.Forms.Design { using System; using System.Collections.Generic; using System.Text; using System.Collections.Specialized; using System.Windows.Forms; using System.ComponentModel; internal class NewItemsContextMenuStrip : GroupedContextMenuStrip { IComponent component = null; EventHandler onClick = null; bool convertTo = false; IServiceProvider serviceProvider = null; ToolStripItem currentItem; public NewItemsContextMenuStrip(IComponent component, ToolStripItem currentItem, EventHandler onClick, bool convertTo, IServiceProvider serviceProvider) { this.component = component; this.onClick = onClick; this.convertTo = convertTo; this.serviceProvider = serviceProvider; this.currentItem = currentItem; IUIService uis = serviceProvider.GetService(typeof(IUIService)) as IUIService; if (uis != null) { this.Renderer =(ToolStripProfessionalRenderer)uis.Styles["VsRenderer"]; } } protected override void OnOpening(CancelEventArgs e) { this.Groups["StandardList"].Items.Clear(); this.Groups["CustomList"].Items.Clear(); Populated = false; // plumb through the standard and custom items. foreach (ToolStripItem item in ToolStripDesignerUtils.GetStandardItemMenuItems(component, onClick, convertTo)) { this.Groups["StandardList"].Items.Add(item); if (convertTo) { ItemTypeToolStripMenuItem toolItem = item as ItemTypeToolStripMenuItem; if (toolItem != null && currentItem != null && toolItem.ItemType == currentItem.GetType()) { toolItem.Enabled = false; } } } foreach (ToolStripItem item in ToolStripDesignerUtils.GetCustomItemMenuItems(component, onClick, convertTo, serviceProvider)) { this.Groups["CustomList"].Items.Add(item); if (convertTo) { ItemTypeToolStripMenuItem toolItem = item as ItemTypeToolStripMenuItem; if (toolItem != null && currentItem != null && toolItem.ItemType == currentItem.GetType()) { toolItem.Enabled = false; } } } base.OnOpening(e); } // Please refer to VsW: 505199 for more details. We dont want the runtime behavior for this Design Time only DropDown and hence we overide the ProcessDialogKey and // just close the DropDown instead of running through the runtime implementation for RIGHT/LEFT Keys which ends up setting ModalMenuFilter. protected override bool ProcessDialogKey(Keys keyData) { Keys keyCode = (Keys)keyData & Keys.KeyCode; switch (keyCode) { case Keys.Left: case Keys.Right: this.Close(); return true; } return base.ProcessDialogKey(keyData); } } } // 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
- OrderPreservingPipeliningMergeHelper.cs
- ExpressionParser.cs
- ColorConvertedBitmapExtension.cs
- SqlGatherProducedAliases.cs
- ScrollViewer.cs
- ClassicBorderDecorator.cs
- PackWebRequestFactory.cs
- NativeCppClassAttribute.cs
- DataGridParentRows.cs
- UnSafeCharBuffer.cs
- InstalledFontCollection.cs
- LinearQuaternionKeyFrame.cs
- EncryptedPackage.cs
- TableColumn.cs
- ChtmlTextWriter.cs
- DynamicRendererThreadManager.cs
- SafeEventLogReadHandle.cs
- CapabilitiesState.cs
- DbFunctionCommandTree.cs
- ReachFixedDocumentSerializer.cs
- ClientTargetCollection.cs
- PageDeviceFont.cs
- Repeater.cs
- WorkflowDebuggerSteppingAttribute.cs
- mediaclock.cs
- SafeBitVector32.cs
- TableStyle.cs
- DataRecordInfo.cs
- XPathQilFactory.cs
- recordstatescratchpad.cs
- GatewayDefinition.cs
- ViewKeyConstraint.cs
- DES.cs
- DesignerVerbCollection.cs
- OleDbError.cs
- HtmlTernaryTree.cs
- PlatformNotSupportedException.cs
- SubclassTypeValidatorAttribute.cs
- DesignerTransactionCloseEvent.cs
- CommandLibraryHelper.cs
- PrintController.cs
- CodeBinaryOperatorExpression.cs
- Int16.cs
- Enlistment.cs
- HttpApplication.cs
- EntityException.cs
- DataGridViewCellConverter.cs
- AssemblyAttributes.cs
- ScriptRegistrationManager.cs
- SByteConverter.cs
- UIElementParagraph.cs
- PictureBox.cs
- ProgressBarRenderer.cs
- StructuredTypeInfo.cs
- DataPager.cs
- OdbcParameter.cs
- __ComObject.cs
- SchemaAttDef.cs
- SrgsItemList.cs
- EnumMember.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- PageFunction.cs
- TemplateEditingFrame.cs
- Hyperlink.cs
- SelectionRangeConverter.cs
- DataGridViewCellParsingEventArgs.cs
- LambdaCompiler.Logical.cs
- DataGridViewCellLinkedList.cs
- ResolveDuplexAsyncResult.cs
- DataGridViewCellMouseEventArgs.cs
- CustomCredentialPolicy.cs
- BlockingCollection.cs
- WebPartZoneCollection.cs
- NavigationService.cs
- SqlSelectClauseBuilder.cs
- IPAddress.cs
- DeviceFilterEditorDialog.cs
- WmpBitmapDecoder.cs
- TraceContextRecord.cs
- LinqDataSourceValidationException.cs
- AttachmentService.cs
- XmlAnyElementAttribute.cs
- ReadWriteSpinLock.cs
- FormViewDeleteEventArgs.cs
- SqlReferenceCollection.cs
- QilFunction.cs
- IgnoreSectionHandler.cs
- MetadataUtil.cs
- MaskInputRejectedEventArgs.cs
- MeasureItemEvent.cs
- CDSsyncETWBCLProvider.cs
- TextEvent.cs
- IntegerValidator.cs
- RtfToXamlLexer.cs
- CFStream.cs
- WebScriptServiceHostFactory.cs
- Matrix.cs
- StrokeNodeOperations2.cs
- FrugalMap.cs
- PageContentCollection.cs