Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / WinForms / Managed / System / WinForms / ToolStripOverflow.cs / 1 / ToolStripOverflow.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.Diagnostics.CodeAnalysis;
using System.Windows.Forms.Layout;
using System.Security;
using System.Security.Permissions;
using System.Runtime.InteropServices;
///
///
/// ToolStripOverflow
///
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
public class ToolStripOverflow : ToolStripDropDown, IArrangedElement {
#if DEBUG
internal static readonly TraceSwitch PopupLayoutDebug = new TraceSwitch("PopupLayoutDebug", "Debug ToolStripPopup Layout code");
#else
internal static readonly TraceSwitch PopupLayoutDebug;
#endif
private ToolStripOverflowButton ownerItem;
///
public ToolStripOverflow (ToolStripItem parentItem) : base(parentItem) {
if (parentItem == null) {
throw new ArgumentNullException("parentItem");
}
ownerItem = parentItem as ToolStripOverflowButton;
}
///
protected internal override ToolStripItemCollection DisplayedItems {
get {
if (ParentToolStrip != null) {
ToolStripItemCollection items = ParentToolStrip.OverflowItems;
return items;
}
return new ToolStripItemCollection(null, false);
}
}
public override ToolStripItemCollection Items {
get {
return new ToolStripItemCollection(null, /*ownedCollection=*/false, /*readonly=*/true);
}
}
private ToolStrip ParentToolStrip {
get {
if (ownerItem != null) {
return ownerItem.ParentToolStrip;
}
return null;
}
}
///
///
ArrangedElementCollection IArrangedElement.Children {
get { return DisplayedItems; }
}
///
///
IArrangedElement IArrangedElement.Container {
get { return ParentInternal; }
}
///
///
bool IArrangedElement.ParticipatesInLayout {
get { return GetState(STATE_VISIBLE); }
}
///
///
PropertyStore IArrangedElement.Properties {
get { return Properties; }
}
///
///
void IArrangedElement.SetBounds(Rectangle bounds, BoundsSpecified specified) {
SetBoundsCore(bounds.X, bounds.Y, bounds.Width, bounds.Height, specified);
}
///
///
/// Summary of CreateLayoutEngine.
///
///
public override LayoutEngine LayoutEngine {
get {
return FlowLayout.Instance;
}
}
protected override AccessibleObject CreateAccessibilityInstance() {
return new ToolStripOverflowAccessibleObject(this);
}
[SuppressMessage("Microsoft.Security", "CA2119:SealMethodsThatSatisfyPrivateInterfaces")]
public override Size GetPreferredSize(Size constrainingSize) {
constrainingSize.Width = 200;
return base.GetPreferredSize(constrainingSize);
}
protected override void OnLayout(LayoutEventArgs e) {
if (ParentToolStrip != null && ParentToolStrip.IsInDesignMode) {
if (FlowLayout.GetFlowDirection(this) != FlowDirection.TopDown) {
FlowLayout.SetFlowDirection(this, FlowDirection.TopDown);
}
if (FlowLayout.GetWrapContents(this)) {
FlowLayout.SetWrapContents(this, false);
}
}
else {
if (FlowLayout.GetFlowDirection(this) != FlowDirection.LeftToRight) {
FlowLayout.SetFlowDirection(this, FlowDirection.LeftToRight);
}
if (!FlowLayout.GetWrapContents(this)) {
FlowLayout.SetWrapContents(this, true);
}
}
base.OnLayout(e);
}
///
protected override void SetDisplayedItems() {
// do nothing here.... this is really for the setting the overflow/displayed items on the
// main winbar. Our working item collection is our displayed item collection... calling
// base would clear it out.
Size biggestItemSize = Size.Empty;
for (int j = 0; j < DisplayedItems.Count; j++) {
ToolStripItem item = DisplayedItems[j];
if (((IArrangedElement)item).ParticipatesInLayout) {
HasVisibleItems = true;
biggestItemSize = LayoutUtils.UnionSizes(biggestItemSize, item.Bounds.Size);
}
}
SetLargestItemSize(biggestItemSize);
}
private class ToolStripOverflowAccessibleObject : ToolStripAccessibleObject {
public ToolStripOverflowAccessibleObject(ToolStripOverflow owner)
: base(owner) {
}
public override AccessibleObject GetChild(int index) {
return ((ToolStripOverflow)Owner).DisplayedItems[index].AccessibilityObject;
}
public override int GetChildCount() {
return ((ToolStripOverflow)Owner).DisplayedItems.Count;
}
}
}
}
// 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.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Windows.Forms.Layout;
using System.Security;
using System.Security.Permissions;
using System.Runtime.InteropServices;
///
///
/// ToolStripOverflow
///
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
public class ToolStripOverflow : ToolStripDropDown, IArrangedElement {
#if DEBUG
internal static readonly TraceSwitch PopupLayoutDebug = new TraceSwitch("PopupLayoutDebug", "Debug ToolStripPopup Layout code");
#else
internal static readonly TraceSwitch PopupLayoutDebug;
#endif
private ToolStripOverflowButton ownerItem;
///
public ToolStripOverflow (ToolStripItem parentItem) : base(parentItem) {
if (parentItem == null) {
throw new ArgumentNullException("parentItem");
}
ownerItem = parentItem as ToolStripOverflowButton;
}
///
protected internal override ToolStripItemCollection DisplayedItems {
get {
if (ParentToolStrip != null) {
ToolStripItemCollection items = ParentToolStrip.OverflowItems;
return items;
}
return new ToolStripItemCollection(null, false);
}
}
public override ToolStripItemCollection Items {
get {
return new ToolStripItemCollection(null, /*ownedCollection=*/false, /*readonly=*/true);
}
}
private ToolStrip ParentToolStrip {
get {
if (ownerItem != null) {
return ownerItem.ParentToolStrip;
}
return null;
}
}
///
///
ArrangedElementCollection IArrangedElement.Children {
get { return DisplayedItems; }
}
///
///
IArrangedElement IArrangedElement.Container {
get { return ParentInternal; }
}
///
///
bool IArrangedElement.ParticipatesInLayout {
get { return GetState(STATE_VISIBLE); }
}
///
///
PropertyStore IArrangedElement.Properties {
get { return Properties; }
}
///
///
void IArrangedElement.SetBounds(Rectangle bounds, BoundsSpecified specified) {
SetBoundsCore(bounds.X, bounds.Y, bounds.Width, bounds.Height, specified);
}
///
///
/// Summary of CreateLayoutEngine.
///
///
public override LayoutEngine LayoutEngine {
get {
return FlowLayout.Instance;
}
}
protected override AccessibleObject CreateAccessibilityInstance() {
return new ToolStripOverflowAccessibleObject(this);
}
[SuppressMessage("Microsoft.Security", "CA2119:SealMethodsThatSatisfyPrivateInterfaces")]
public override Size GetPreferredSize(Size constrainingSize) {
constrainingSize.Width = 200;
return base.GetPreferredSize(constrainingSize);
}
protected override void OnLayout(LayoutEventArgs e) {
if (ParentToolStrip != null && ParentToolStrip.IsInDesignMode) {
if (FlowLayout.GetFlowDirection(this) != FlowDirection.TopDown) {
FlowLayout.SetFlowDirection(this, FlowDirection.TopDown);
}
if (FlowLayout.GetWrapContents(this)) {
FlowLayout.SetWrapContents(this, false);
}
}
else {
if (FlowLayout.GetFlowDirection(this) != FlowDirection.LeftToRight) {
FlowLayout.SetFlowDirection(this, FlowDirection.LeftToRight);
}
if (!FlowLayout.GetWrapContents(this)) {
FlowLayout.SetWrapContents(this, true);
}
}
base.OnLayout(e);
}
///
protected override void SetDisplayedItems() {
// do nothing here.... this is really for the setting the overflow/displayed items on the
// main winbar. Our working item collection is our displayed item collection... calling
// base would clear it out.
Size biggestItemSize = Size.Empty;
for (int j = 0; j < DisplayedItems.Count; j++) {
ToolStripItem item = DisplayedItems[j];
if (((IArrangedElement)item).ParticipatesInLayout) {
HasVisibleItems = true;
biggestItemSize = LayoutUtils.UnionSizes(biggestItemSize, item.Bounds.Size);
}
}
SetLargestItemSize(biggestItemSize);
}
private class ToolStripOverflowAccessibleObject : ToolStripAccessibleObject {
public ToolStripOverflowAccessibleObject(ToolStripOverflow owner)
: base(owner) {
}
public override AccessibleObject GetChild(int index) {
return ((ToolStripOverflow)Owner).DisplayedItems[index].AccessibilityObject;
}
public override int GetChildCount() {
return ((ToolStripOverflow)Owner).DisplayedItems.Count;
}
}
}
}
// 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
- SQLDecimal.cs
- SliderAutomationPeer.cs
- BufferAllocator.cs
- VirtualizedCellInfoCollection.cs
- ExceptionUtil.cs
- CrossSiteScriptingValidation.cs
- TextServicesDisplayAttribute.cs
- DataGridViewCellValueEventArgs.cs
- SqlDelegatedTransaction.cs
- InternalTypeHelper.cs
- SerialStream.cs
- CompilerHelpers.cs
- TypeHelper.cs
- ReadOnlyObservableCollection.cs
- Timer.cs
- OAVariantLib.cs
- SectionUpdates.cs
- HwndSourceParameters.cs
- EllipseGeometry.cs
- WebPartHeaderCloseVerb.cs
- HScrollBar.cs
- FlowLayout.cs
- WithStatement.cs
- dsa.cs
- Material.cs
- MaterialCollection.cs
- ToolStripSystemRenderer.cs
- MultipartIdentifier.cs
- LoadedOrUnloadedOperation.cs
- VisualBasicHelper.cs
- IriParsingElement.cs
- CheckBoxFlatAdapter.cs
- Blend.cs
- CodeDelegateInvokeExpression.cs
- FloaterBaseParaClient.cs
- ToolStripContentPanelRenderEventArgs.cs
- UriParserTemplates.cs
- ConfigurationUtility.cs
- ComponentChangingEvent.cs
- GenericAuthenticationEventArgs.cs
- EditorZoneBase.cs
- SimpleMailWebEventProvider.cs
- SerializationObjectManager.cs
- InputElement.cs
- ColorTypeConverter.cs
- SatelliteContractVersionAttribute.cs
- BamlResourceSerializer.cs
- TimerElapsedEvenArgs.cs
- TargetConverter.cs
- PrivacyNoticeBindingElement.cs
- TimeManager.cs
- MaterialCollection.cs
- NamedPermissionSet.cs
- UnmanagedMarshal.cs
- XamlBuildTaskServices.cs
- SmiEventStream.cs
- ScriptHandlerFactory.cs
- OdbcConnectionStringbuilder.cs
- PropertyDescriptorComparer.cs
- PipelineDeploymentState.cs
- InputQueue.cs
- DataStreams.cs
- SystemWebCachingSectionGroup.cs
- CqlIdentifiers.cs
- ProjectionPlanCompiler.cs
- DeferrableContent.cs
- DataServiceHost.cs
- ISAPIApplicationHost.cs
- PropertyInformation.cs
- Deflater.cs
- DataObject.cs
- DocumentAutomationPeer.cs
- CodeEntryPointMethod.cs
- ToolStripPanel.cs
- _UriSyntax.cs
- SerializationFieldInfo.cs
- PopupRootAutomationPeer.cs
- SecureStringHasher.cs
- ButtonField.cs
- IndexingContentUnit.cs
- QueryStringParameter.cs
- GroupBox.cs
- EdmToObjectNamespaceMap.cs
- MetadataUtil.cs
- ToggleButton.cs
- HashAlgorithm.cs
- unsafenativemethodsother.cs
- ThicknessAnimation.cs
- TransactionBridge.cs
- InvariantComparer.cs
- SafeBitVector32.cs
- Int32AnimationUsingKeyFrames.cs
- FieldTemplateFactory.cs
- LoginCancelEventArgs.cs
- TableLayoutCellPaintEventArgs.cs
- FlowLayoutPanelDesigner.cs
- DocumentPageHost.cs
- TypeConverter.cs
- BroadcastEventHelper.cs
- ComponentEditorPage.cs