Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / ToolStripOverflowButton.cs / 1305376 / ToolStripOverflowButton.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms { using System; using System.Collections; using System.ComponentModel; using System.Drawing; using System.Diagnostics; using System.Windows.Forms.Design; ////// /// ToolStripOverflowButton /// [ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.None)] public class ToolStripOverflowButton : ToolStripDropDownButton { // we need to cache this away as the Parent property gets reset a lot. private ToolStrip parentToolStrip; ///[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] internal ToolStripOverflowButton(ToolStrip parentToolStrip) { SupportsItemClick = false; this.parentToolStrip = parentToolStrip; } /// protected internal override Padding DefaultMargin { get { return Padding.Empty; } } /// public override bool HasDropDownItems { get { return this.ParentInternal.OverflowItems.Count > 0; } } internal override bool OppositeDropDownAlign { get { return true; } } internal ToolStrip ParentToolStrip { get { return parentToolStrip; } } [ Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden) ] public new bool RightToLeftAutoMirrorImage { get { return base.RightToLeftAutoMirrorImage; } set { base.RightToLeftAutoMirrorImage = value; } } protected override AccessibleObject CreateAccessibilityInstance() { return new ToolStripOverflowButtonAccessibleObject(this); } /// protected override ToolStripDropDown CreateDefaultDropDown() { // AutoGenerate a Winbar DropDown - set the property so we hook events return new ToolStripOverflow(this); } /// public override Size GetPreferredSize(Size constrainingSize) { Size preferredSize = constrainingSize; if (this.ParentInternal != null) { if (this.ParentInternal.Orientation == Orientation.Horizontal) { preferredSize.Width = Math.Min(constrainingSize.Width, 16); } else { preferredSize.Height = Math.Min(constrainingSize.Height, 16); } } return preferredSize + this.Padding.Size; } // make sure the Overflow button extends from edge-edge. (Ignore Padding/Margin). internal protected override void SetBounds(Rectangle bounds) { if (ParentInternal != null && ParentInternal.LayoutEngine is ToolStripSplitStackLayout) { if (ParentInternal.Orientation == Orientation.Horizontal) { bounds.Height = ParentInternal.Height; bounds.Y = 0; } else { bounds.Width = ParentInternal.Width; bounds.X = 0; } } base.SetBounds(bounds); } /// protected override void OnPaint(PaintEventArgs e) { if (this.ParentInternal != null) { ToolStripRenderer renderer = this.ParentInternal.Renderer; renderer.DrawOverflowButtonBackground(new ToolStripItemRenderEventArgs(e.Graphics, this)); } } internal class ToolStripOverflowButtonAccessibleObject : ToolStripDropDownItemAccessibleObject { private string stockName; public ToolStripOverflowButtonAccessibleObject(ToolStripOverflowButton owner) : base(owner){ } public override string Name { get { string name = Owner.AccessibleName; if (name != null) { return name; } if (string.IsNullOrEmpty(stockName)) { stockName = SR.GetString(SR.ToolStripOptions); } return stockName; } set { base.Name = value; } } } } } // 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
- EventMappingSettingsCollection.cs
- SplashScreenNativeMethods.cs
- DoubleConverter.cs
- WinCategoryAttribute.cs
- RotateTransform3D.cs
- Misc.cs
- JpegBitmapDecoder.cs
- PolyBezierSegment.cs
- TrustManagerMoreInformation.cs
- InvalidAsynchronousStateException.cs
- LineServicesCallbacks.cs
- ObjectListDesigner.cs
- OracleMonthSpan.cs
- RelatedEnd.cs
- RenderTargetBitmap.cs
- SortExpressionBuilder.cs
- XmlElementAttributes.cs
- CodeAttributeDeclaration.cs
- WorkflowViewElement.cs
- EncodingTable.cs
- Pen.cs
- TimeSpan.cs
- SafeUserTokenHandle.cs
- AttributeCollection.cs
- VisualSerializer.cs
- OutputScope.cs
- TypedTableBaseExtensions.cs
- DependencyPropertyConverter.cs
- CachedRequestParams.cs
- Encoding.cs
- FixedSOMContainer.cs
- BindingExpressionUncommonField.cs
- PathGeometry.cs
- TimeStampChecker.cs
- XmlNamespaceDeclarationsAttribute.cs
- Stack.cs
- BodyGlyph.cs
- SettingsProperty.cs
- DateRangeEvent.cs
- DefaultCommandConverter.cs
- BamlVersionHeader.cs
- RegexRunnerFactory.cs
- MsmqIntegrationSecurity.cs
- ProcessThread.cs
- WebSysDefaultValueAttribute.cs
- OAVariantLib.cs
- DESCryptoServiceProvider.cs
- MapPathBasedVirtualPathProvider.cs
- WorkflowWebHostingModule.cs
- HtmlTableCell.cs
- AmbiguousMatchException.cs
- DropSource.cs
- PrinterResolution.cs
- InvalidateEvent.cs
- QueryOutputWriter.cs
- FastPropertyAccessor.cs
- BindingMAnagerBase.cs
- AtomPub10ServiceDocumentFormatter.cs
- WizardPanelChangingEventArgs.cs
- HttpCapabilitiesEvaluator.cs
- ReadContentAsBinaryHelper.cs
- BooleanExpr.cs
- TypeLoader.cs
- httpstaticobjectscollection.cs
- BindingEntityInfo.cs
- ActivityCodeDomSerializationManager.cs
- ObjectTypeMapping.cs
- RequestUriProcessor.cs
- _Events.cs
- ColorKeyFrameCollection.cs
- FunctionImportMapping.ReturnTypeRenameMapping.cs
- DataGridViewCellValueEventArgs.cs
- ApplicationDirectory.cs
- HwndProxyElementProvider.cs
- ModuleElement.cs
- RectIndependentAnimationStorage.cs
- WrapPanel.cs
- WebConvert.cs
- InlineCollection.cs
- HttpCapabilitiesBase.cs
- ProtectedConfigurationSection.cs
- TrimSurroundingWhitespaceAttribute.cs
- ObjectToken.cs
- WCFServiceClientProxyGenerator.cs
- DataGridViewSelectedColumnCollection.cs
- ZipIORawDataFileBlock.cs
- StorageEntityContainerMapping.cs
- AccessKeyManager.cs
- XmlObjectSerializerReadContextComplex.cs
- DataTableExtensions.cs
- BufferedGraphics.cs
- SqlDataSourceQueryEditor.cs
- FragmentNavigationEventArgs.cs
- UrlMapping.cs
- StringFreezingAttribute.cs
- Win32.cs
- ThreadInterruptedException.cs
- SQLString.cs
- ComPlusDiagnosticTraceSchemas.cs
- ExceptionUtility.cs