Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / WinForms / Managed / System / WinForms / ContextMenuStrip.cs / 1 / ContextMenuStrip.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms { using System; using System.ComponentModel; using System.Drawing; using System.Runtime.InteropServices; using System.Security; using System.Security.Permissions; ///this class is just a conceptual wrapper around ToolStripDropDownMenu. [ ComVisible(true), ClassInterface(ClassInterfaceType.AutoDispatch), DefaultEvent("Opening"), SRDescription(SR.DescriptionContextMenuStrip) ] public class ContextMenuStrip : ToolStripDropDownMenu { /// /// Summary of ContextMenuStrip. /// public ContextMenuStrip(IContainer container) : base() { // this constructor ensures ContextMenuStrip is disposed properly since its not parented to the form. if (container == null) { throw new ArgumentNullException("container"); } container.Add(this); } public ContextMenuStrip(){ } protected override void Dispose(bool disposing) { base.Dispose(disposing); } [ Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), SRDescription(SR.ContextMenuStripSourceControlDescr) ] public Control SourceControl { [UIPermission(SecurityAction.Demand, Window=UIPermissionWindow.AllWindows)] get { return SourceControlInternal; } } // minimal Clone implementation for DGV support only. internal ContextMenuStrip Clone() { // VERY limited support for cloning. ContextMenuStrip contextMenuStrip = new ContextMenuStrip(); // copy over events contextMenuStrip.Events.AddHandlers(this.Events); contextMenuStrip.AutoClose = AutoClose; contextMenuStrip.AutoSize = AutoSize; contextMenuStrip.Bounds = Bounds; contextMenuStrip.ImageList = ImageList; contextMenuStrip.ShowCheckMargin = ShowCheckMargin; contextMenuStrip.ShowImageMargin = ShowImageMargin; // copy over relevant properties for (int i = 0; i < Items.Count; i++) { ToolStripItem item = Items[i]; if (item is ToolStripSeparator) { contextMenuStrip.Items.Add(new ToolStripSeparator()); } else if (item is ToolStripMenuItem) { ToolStripMenuItem menuItem = item as ToolStripMenuItem; contextMenuStrip.Items.Add(menuItem.Clone()); } } return contextMenuStrip; } // internal overload so we know whether or not to show mnemonics. internal void ShowInternal(Control source, Point location, bool isKeyboardActivated) { Show(source, location); // if we were activated by keyboard - show mnemonics. if (isKeyboardActivated) { ToolStripManager.ModalMenuFilter.Instance.ShowUnderlines = true; } } internal void ShowInTaskbar(int x, int y) { // we need to make ourselves a topmost window WorkingAreaConstrained = false; Rectangle bounds = CalculateDropDownLocation(new Point(x,y), ToolStripDropDownDirection.AboveLeft); Rectangle screenBounds = Screen.FromRectangle(bounds).Bounds; if (bounds.Y < screenBounds.Y) { bounds = CalculateDropDownLocation(new Point(x,y), ToolStripDropDownDirection.BelowLeft); } else if (bounds.X < screenBounds.X) { bounds = CalculateDropDownLocation(new Point(x,y), ToolStripDropDownDirection.AboveRight); } bounds = WindowsFormsUtils.ConstrainToBounds(screenBounds, bounds); Show(bounds.X, bounds.Y); } protected override void SetVisibleCore(bool visible) { if (!visible) { WorkingAreaConstrained = true; } base.SetVisibleCore(visible); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms { using System; using System.ComponentModel; using System.Drawing; using System.Runtime.InteropServices; using System.Security; using System.Security.Permissions; ///this class is just a conceptual wrapper around ToolStripDropDownMenu. [ ComVisible(true), ClassInterface(ClassInterfaceType.AutoDispatch), DefaultEvent("Opening"), SRDescription(SR.DescriptionContextMenuStrip) ] public class ContextMenuStrip : ToolStripDropDownMenu { /// /// Summary of ContextMenuStrip. /// public ContextMenuStrip(IContainer container) : base() { // this constructor ensures ContextMenuStrip is disposed properly since its not parented to the form. if (container == null) { throw new ArgumentNullException("container"); } container.Add(this); } public ContextMenuStrip(){ } protected override void Dispose(bool disposing) { base.Dispose(disposing); } [ Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), SRDescription(SR.ContextMenuStripSourceControlDescr) ] public Control SourceControl { [UIPermission(SecurityAction.Demand, Window=UIPermissionWindow.AllWindows)] get { return SourceControlInternal; } } // minimal Clone implementation for DGV support only. internal ContextMenuStrip Clone() { // VERY limited support for cloning. ContextMenuStrip contextMenuStrip = new ContextMenuStrip(); // copy over events contextMenuStrip.Events.AddHandlers(this.Events); contextMenuStrip.AutoClose = AutoClose; contextMenuStrip.AutoSize = AutoSize; contextMenuStrip.Bounds = Bounds; contextMenuStrip.ImageList = ImageList; contextMenuStrip.ShowCheckMargin = ShowCheckMargin; contextMenuStrip.ShowImageMargin = ShowImageMargin; // copy over relevant properties for (int i = 0; i < Items.Count; i++) { ToolStripItem item = Items[i]; if (item is ToolStripSeparator) { contextMenuStrip.Items.Add(new ToolStripSeparator()); } else if (item is ToolStripMenuItem) { ToolStripMenuItem menuItem = item as ToolStripMenuItem; contextMenuStrip.Items.Add(menuItem.Clone()); } } return contextMenuStrip; } // internal overload so we know whether or not to show mnemonics. internal void ShowInternal(Control source, Point location, bool isKeyboardActivated) { Show(source, location); // if we were activated by keyboard - show mnemonics. if (isKeyboardActivated) { ToolStripManager.ModalMenuFilter.Instance.ShowUnderlines = true; } } internal void ShowInTaskbar(int x, int y) { // we need to make ourselves a topmost window WorkingAreaConstrained = false; Rectangle bounds = CalculateDropDownLocation(new Point(x,y), ToolStripDropDownDirection.AboveLeft); Rectangle screenBounds = Screen.FromRectangle(bounds).Bounds; if (bounds.Y < screenBounds.Y) { bounds = CalculateDropDownLocation(new Point(x,y), ToolStripDropDownDirection.BelowLeft); } else if (bounds.X < screenBounds.X) { bounds = CalculateDropDownLocation(new Point(x,y), ToolStripDropDownDirection.AboveRight); } bounds = WindowsFormsUtils.ConstrainToBounds(screenBounds, bounds); Show(bounds.X, bounds.Y); } protected override void SetVisibleCore(bool visible) { if (!visible) { WorkingAreaConstrained = true; } base.SetVisibleCore(visible); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ArrayTypeMismatchException.cs
- CopyOfAction.cs
- HtmlElement.cs
- PaintValueEventArgs.cs
- ViewgenContext.cs
- MSHTMLHostUtil.cs
- ModuleConfigurationInfo.cs
- ConnectionPool.cs
- CodeSnippetStatement.cs
- HtmlInputCheckBox.cs
- ScrollItemPatternIdentifiers.cs
- InvalidOperationException.cs
- DispatchOperationRuntime.cs
- WsiProfilesElementCollection.cs
- LoginName.cs
- QueryConverter.cs
- EncoderNLS.cs
- SvcMapFileSerializer.cs
- ImplicitInputBrush.cs
- MenuItemAutomationPeer.cs
- StrokeNodeData.cs
- HwndMouseInputProvider.cs
- ResXResourceReader.cs
- ResetableIterator.cs
- querybuilder.cs
- MessageTraceRecord.cs
- Screen.cs
- initElementDictionary.cs
- elementinformation.cs
- TransformProviderWrapper.cs
- CodeExpressionRuleDeclaration.cs
- TagPrefixInfo.cs
- StylusButtonCollection.cs
- KnownBoxes.cs
- PointCollectionValueSerializer.cs
- BroadcastEventHelper.cs
- View.cs
- AssociationSetEnd.cs
- EventLogPropertySelector.cs
- Timer.cs
- CultureInfo.cs
- ComNativeDescriptor.cs
- FormsAuthenticationUserCollection.cs
- LoadedEvent.cs
- SudsWriter.cs
- DivideByZeroException.cs
- QueueProcessor.cs
- LinearKeyFrames.cs
- KeyboardEventArgs.cs
- ProfileManager.cs
- XmlSchemaSimpleContent.cs
- SemanticResolver.cs
- TextEffectResolver.cs
- securestring.cs
- Subtree.cs
- MappingSource.cs
- OdbcParameter.cs
- AttributeCollection.cs
- ContextMarshalException.cs
- CodeValidator.cs
- XmlSerializerVersionAttribute.cs
- SweepDirectionValidation.cs
- AssemblyNameProxy.cs
- ListItemConverter.cs
- DataGridViewCellStyleBuilderDialog.cs
- Brushes.cs
- ValueConversionAttribute.cs
- DragEvent.cs
- WCFModelStrings.Designer.cs
- ToolboxItemAttribute.cs
- ObjectCloneHelper.cs
- DataGridViewIntLinkedList.cs
- EdmConstants.cs
- DirectoryNotFoundException.cs
- AssemblyCollection.cs
- ButtonChrome.cs
- SymLanguageVendor.cs
- DependentList.cs
- TextParentUndoUnit.cs
- StyleHelper.cs
- TableItemProviderWrapper.cs
- DataColumnMapping.cs
- DbProviderSpecificTypePropertyAttribute.cs
- ThicknessAnimation.cs
- InkPresenterAutomationPeer.cs
- RepeaterDesigner.cs
- ManagementInstaller.cs
- WmlCommandAdapter.cs
- ListMarkerSourceInfo.cs
- SqlClientWrapperSmiStreamChars.cs
- HttpWebResponse.cs
- SqlClientPermission.cs
- CodeCatchClause.cs
- FileLogRecord.cs
- HttpHandlerAction.cs
- WpfSharedXamlSchemaContext.cs
- InfoCardServiceInstallComponent.cs
- XmlWrappingReader.cs
- HideDisabledControlAdapter.cs
- PersonalizationAdministration.cs