public static ToolStripDropDownDirection FlipDirectionOnXAxis(ToolStripDropDownDirection direction) { switch (direction) { case ToolStripDropDownDirection.Left: return ToolStripDropDownDirection.Right; case ToolStripDropDownDirection.Right: return ToolStripDropDownDirection.Left; case ToolStripDropDownDirection.AboveLeft: return ToolStripDropDownDirection.AboveRight; case ToolStripDropDownDirection.AboveRight: return ToolStripDropDownDirection.AboveLeft; case ToolStripDropDownDirection.BelowLeft: return ToolStripDropDownDirection.BelowRight; default: Debug.Assert(direction == ToolStripDropDownDirection.BelowRight); return ToolStripDropDownDirection.BelowLeft; } }
public ToolStrip (params ToolStripItem[] items) : base () { SetStyle (ControlStyles.AllPaintingInWmPaint, true); SetStyle (ControlStyles.OptimizedDoubleBuffer, true); SetStyle (ControlStyles.Selectable, false); SetStyle (ControlStyles.SupportsTransparentBackColor, true); this.SuspendLayout (); this.items = new ToolStripItemCollection (this, items, true); this.allow_merge = true; base.AutoSize = true; this.SetAutoSizeMode (AutoSizeMode.GrowAndShrink); this.back_color = Control.DefaultBackColor; this.can_overflow = true; base.CausesValidation = false; this.default_drop_down_direction = ToolStripDropDownDirection.BelowRight; this.displayed_items = new ToolStripItemCollection (this, null, true); this.Dock = this.DefaultDock; base.Font = new Font ("Tahoma", 8.25f); this.fore_color = Control.DefaultForeColor; this.grip_margin = this.DefaultGripMargin; this.grip_style = ToolStripGripStyle.Visible; this.image_scaling_size = new Size (16, 16); this.layout_style = ToolStripLayoutStyle.HorizontalStackWithOverflow; this.orientation = Orientation.Horizontal; if (!(this is ToolStripDropDown)) this.overflow_button = new ToolStripOverflowButton (this); this.renderer = null; this.render_mode = ToolStripRenderMode.ManagerRenderMode; this.show_item_tool_tips = this.DefaultShowItemToolTips; base.TabStop = false; this.text_direction = ToolStripTextDirection.Horizontal; this.ResumeLayout (); // Register with the ToolStripManager ToolStripManager.AddToolStrip (this); }
public void Show (Control control, Point position, ToolStripDropDownDirection direction) { if (control == null) throw new ArgumentNullException ("control"); XplatUI.SetOwner (Handle, control.Handle); Show (control.PointToScreen (position), direction); }
public void Show (Point position, ToolStripDropDownDirection direction) { this.PerformLayout (); Point show_point = position; Point max_screen = new Point (SystemInformation.VirtualScreen.Width, SystemInformation.VirtualScreen.Height); if (this is ContextMenuStrip) { // If we are going to go offscreen, adjust our direction so we don't... // X direction switch (direction) { case ToolStripDropDownDirection.AboveLeft: if (show_point.X - this.Width < 0) direction = ToolStripDropDownDirection.AboveRight; break; case ToolStripDropDownDirection.BelowLeft: if (show_point.X - this.Width < 0) direction = ToolStripDropDownDirection.BelowRight; break; case ToolStripDropDownDirection.Left: if (show_point.X - this.Width < 0) direction = ToolStripDropDownDirection.Right; break; case ToolStripDropDownDirection.AboveRight: if (show_point.X + this.Width > max_screen.X) direction = ToolStripDropDownDirection.AboveLeft; break; case ToolStripDropDownDirection.BelowRight: case ToolStripDropDownDirection.Default: if (show_point.X + this.Width > max_screen.X) direction = ToolStripDropDownDirection.BelowLeft; break; case ToolStripDropDownDirection.Right: if (show_point.X + this.Width > max_screen.X) direction = ToolStripDropDownDirection.Left; break; } // Y direction switch (direction) { case ToolStripDropDownDirection.AboveLeft: if (show_point.Y - this.Height < 0) direction = ToolStripDropDownDirection.BelowLeft; break; case ToolStripDropDownDirection.AboveRight: if (show_point.Y - this.Height < 0) direction = ToolStripDropDownDirection.BelowRight; break; case ToolStripDropDownDirection.BelowLeft: if (show_point.Y + this.Height > max_screen.Y && show_point.Y - this.Height > 0) direction = ToolStripDropDownDirection.AboveLeft; break; case ToolStripDropDownDirection.BelowRight: case ToolStripDropDownDirection.Default: if (show_point.Y + this.Height > max_screen.Y && show_point.Y - this.Height > 0) direction = ToolStripDropDownDirection.AboveRight; break; case ToolStripDropDownDirection.Left: if (show_point.Y + this.Height > max_screen.Y && show_point.Y - this.Height > 0) direction = ToolStripDropDownDirection.AboveLeft; break; case ToolStripDropDownDirection.Right: if (show_point.Y + this.Height > max_screen.Y && show_point.Y - this.Height > 0) direction = ToolStripDropDownDirection.AboveRight; break; } } switch (direction) { case ToolStripDropDownDirection.AboveLeft: show_point.Y -= this.Height; show_point.X -= this.Width; break; case ToolStripDropDownDirection.AboveRight: show_point.Y -= this.Height; break; case ToolStripDropDownDirection.BelowLeft: show_point.X -= this.Width; break; case ToolStripDropDownDirection.Left: show_point.X -= this.Width; break; case ToolStripDropDownDirection.Right: break; } // Fix offscreen horizontal positions if ((show_point.X + this.Width) > max_screen.X) show_point.X = max_screen.X - this.Width; if (show_point.X < 0) show_point.X = 0; // Fix offscreen vertical positions if ((show_point.Y + this.Height) > max_screen.Y) show_point.Y = max_screen.Y - this.Height; if (show_point.Y < 0) show_point.Y = 0; if (this.Location != show_point) this.Location = show_point; CancelEventArgs e = new CancelEventArgs (); this.OnOpening (e); if (e.Cancel) return; // The tracker lets us know when the form is clicked or loses focus ToolStripManager.AppClicked += new EventHandler (ToolStripMenuTracker_AppClicked); ToolStripManager.AppFocusChange += new EventHandler (ToolStripMenuTracker_AppFocusChange); base.Show (); ToolStripManager.SetActiveToolStrip (this, ToolStripManager.ActivatedByKeyboard); this.OnOpened (EventArgs.Empty); }
protected ToolStripDropDownItem(string text, Image image, EventHandler onClick, string name) : base(text, image, onClick, name) { this.toolStripDropDownDirection = ToolStripDropDownDirection.Default; }
protected ToolStripDropDownItem() { this.toolStripDropDownDirection = ToolStripDropDownDirection.Default; }
private Rectangle DropDownDirectionToDropDownBounds(ToolStripDropDownDirection dropDownDirection, Rectangle dropDownBounds) { Point empty = Point.Empty; switch (dropDownDirection) { case ToolStripDropDownDirection.AboveLeft: empty.X = -dropDownBounds.Width + base.Width; empty.Y = -dropDownBounds.Height + 1; break; case ToolStripDropDownDirection.AboveRight: empty.Y = -dropDownBounds.Height + 1; break; case ToolStripDropDownDirection.BelowLeft: empty.X = -dropDownBounds.Width + base.Width; empty.Y = base.Height - 1; break; case ToolStripDropDownDirection.BelowRight: empty.Y = base.Height - 1; break; case ToolStripDropDownDirection.Left: empty.X = -dropDownBounds.Width; break; case ToolStripDropDownDirection.Right: empty.X = base.Width; if (!base.IsOnDropDown) { empty.X--; } break; } Point point2 = base.TranslatePoint(Point.Empty, ToolStripPointType.ToolStripItemCoords, ToolStripPointType.ScreenCoords); dropDownBounds.Location = new Point(point2.X + empty.X, point2.Y + empty.Y); dropDownBounds = WindowsFormsUtils.ConstrainToScreenWorkingAreaBounds(dropDownBounds); return dropDownBounds; }
private ToolStripDropDownDirection RTLTranslateDropDownDirection(ToolStripDropDownDirection dropDownDirection, RightToLeft rightToLeft) { switch (dropDownDirection) { case ToolStripDropDownDirection.AboveLeft: return ToolStripDropDownDirection.AboveRight; case ToolStripDropDownDirection.AboveRight: return ToolStripDropDownDirection.AboveLeft; case ToolStripDropDownDirection.BelowRight: return ToolStripDropDownDirection.BelowLeft; case ToolStripDropDownDirection.BelowLeft: return ToolStripDropDownDirection.BelowRight; case ToolStripDropDownDirection.Right: return ToolStripDropDownDirection.Left; case ToolStripDropDownDirection.Left: return ToolStripDropDownDirection.Right; } Debug.Fail("Why are we here"); // dont expect it to come to this but just in case here are the real defaults. if (IsOnDropDown) { return (rightToLeft == RightToLeft.Yes) ? ToolStripDropDownDirection.Left : ToolStripDropDownDirection.Right; } else { return (rightToLeft == RightToLeft.Yes) ? ToolStripDropDownDirection.BelowLeft : ToolStripDropDownDirection.BelowRight; } }
internal Rectangle CalculateDropDownLocation(Point start, ToolStripDropDownDirection dropDownDirection) { Point empty = Point.Empty; if (!base.IsHandleCreated) { LayoutTransaction.DoLayout(this, this, PropertyNames.PreferredSize); } Rectangle bounds = new Rectangle(Point.Empty, this.GetSuggestedSize()); switch (dropDownDirection) { case ToolStripDropDownDirection.AboveLeft: empty.X = -bounds.Width; empty.Y = -bounds.Height; break; case ToolStripDropDownDirection.AboveRight: empty.Y = -bounds.Height; break; case ToolStripDropDownDirection.BelowLeft: case ToolStripDropDownDirection.Left: empty.X = -bounds.Width; break; } bounds.Location = new Point(start.X + empty.X, start.Y + empty.Y); if (this.WorkingAreaConstrained) { bounds = WindowsFormsUtils.ConstrainToScreenWorkingAreaBounds(bounds); } return bounds; }
public void Show(System.Drawing.Point position, ToolStripDropDownDirection direction) { }
public ToolStripDropDown() { this.dropDownLocation = Point.Empty; this.dropShadowEnabled = true; this.autoClose = true; this.autoSize = true; this.state = new BitVector32(); this.displayLocation = new Point(0, 0); this.childDropDownDirection = ToolStripDropDownDirection.Default; bool isRestrictedWindow = this.IsRestrictedWindow; base.SuspendLayout(); this.Initialize(); base.ResumeLayout(false); }
public void Show(Control control, Point position, ToolStripDropDownDirection direction) { if (control == null) { throw new ArgumentNullException("control"); } this.SourceControlInternal = control; this.displayLocation = this.CalculateDropDownLocation(control.PointToScreen(position), direction).Location; this.Location = this.displayLocation; this.ShowCore(); }
public void Show(Point position, ToolStripDropDownDirection direction) { this.displayLocation = this.CalculateDropDownLocation(position, direction).Location; this.Location = this.displayLocation; this.ShowCore(); }
private Rectangle DropDownDirectionToDropDownBounds(ToolStripDropDownDirection dropDownDirection, Rectangle dropDownBounds) { Point offset = Point.Empty; switch (dropDownDirection) { case ToolStripDropDownDirection.AboveLeft: offset.X = - dropDownBounds.Width + this.Width; offset.Y = - dropDownBounds.Height+1; break; case ToolStripDropDownDirection.AboveRight: offset.Y = - dropDownBounds.Height+1; break; case ToolStripDropDownDirection.BelowRight: offset.Y = this.Height-1; break; case ToolStripDropDownDirection.BelowLeft: offset.X = - dropDownBounds.Width + this.Width; offset.Y = this.Height-1; break; case ToolStripDropDownDirection.Right: offset.X = this.Width; if (!IsOnDropDown) { // overlap the toplevel toolstrip offset.X -=1; } break; case ToolStripDropDownDirection.Left: offset.X = - dropDownBounds.Width; break; } Point itemScreenLocation = this.TranslatePoint(Point.Empty, ToolStripPointType.ToolStripItemCoords, ToolStripPointType.ScreenCoords); dropDownBounds.Location = new Point(itemScreenLocation.X + offset.X, itemScreenLocation.Y + offset.Y); dropDownBounds = WindowsFormsUtils.ConstrainToScreenWorkingAreaBounds(dropDownBounds); return dropDownBounds; }
private Rectangle GetDropDownBounds(ToolStripDropDownDirection dropDownDirection) { Rectangle dropDownBounds = new Rectangle(Point.Empty, this.DropDown.GetSuggestedSize()); dropDownBounds = this.DropDownDirectionToDropDownBounds(dropDownDirection, dropDownBounds); Rectangle b = new Rectangle(base.TranslatePoint(Point.Empty, ToolStripPointType.ToolStripItemCoords, ToolStripPointType.ScreenCoords), this.Size); if (Rectangle.Intersect(dropDownBounds, b).Height > 1) { bool flag = this.RightToLeft == RightToLeft.Yes; if (Rectangle.Intersect(dropDownBounds, b).Width > 1) { dropDownBounds = this.DropDownDirectionToDropDownBounds(!flag ? ToolStripDropDownDirection.Right : ToolStripDropDownDirection.Left, dropDownBounds); } if (Rectangle.Intersect(dropDownBounds, b).Width > 1) { dropDownBounds = this.DropDownDirectionToDropDownBounds(!flag ? ToolStripDropDownDirection.Left : ToolStripDropDownDirection.Right, dropDownBounds); } } return dropDownBounds; }
private Rectangle GetDropDownBounds(ToolStripDropDownDirection dropDownDirection) { Rectangle dropDownBounds = new Rectangle(Point.Empty, DropDown.GetSuggestedSize()); // calculate the offset from the upper left hand corner of the item. dropDownBounds = DropDownDirectionToDropDownBounds(dropDownDirection, dropDownBounds); // we should make sure we dont obscure the owner item. Rectangle itemScreenBounds = new Rectangle(this.TranslatePoint(Point.Empty, ToolStripPointType.ToolStripItemCoords, ToolStripPointType.ScreenCoords), this.Size); if (Rectangle.Intersect(dropDownBounds, itemScreenBounds).Height > 1) { bool rtl = (RightToLeft == RightToLeft.Yes); // try positioning to the left if (Rectangle.Intersect(dropDownBounds, itemScreenBounds).Width > 1) { dropDownBounds = DropDownDirectionToDropDownBounds(!rtl ? ToolStripDropDownDirection.Right : ToolStripDropDownDirection.Left, dropDownBounds); } // try positioning to the right if (Rectangle.Intersect(dropDownBounds, itemScreenBounds).Width > 1) { dropDownBounds = DropDownDirectionToDropDownBounds(!rtl ? ToolStripDropDownDirection.Left : ToolStripDropDownDirection.Right, dropDownBounds); } } return dropDownBounds; }
private ToolStripDropDownDirection RTLTranslateDropDownDirection(ToolStripDropDownDirection dropDownDirection, RightToLeft rightToLeft) { switch (dropDownDirection) { case ToolStripDropDownDirection.AboveLeft: return ToolStripDropDownDirection.AboveRight; case ToolStripDropDownDirection.AboveRight: return ToolStripDropDownDirection.AboveLeft; case ToolStripDropDownDirection.BelowLeft: return ToolStripDropDownDirection.BelowRight; case ToolStripDropDownDirection.BelowRight: return ToolStripDropDownDirection.BelowLeft; case ToolStripDropDownDirection.Left: return ToolStripDropDownDirection.Right; case ToolStripDropDownDirection.Right: return ToolStripDropDownDirection.Left; } if (base.IsOnDropDown) { if (rightToLeft != RightToLeft.Yes) { return ToolStripDropDownDirection.Right; } return ToolStripDropDownDirection.Left; } if (rightToLeft != RightToLeft.Yes) { return ToolStripDropDownDirection.BelowRight; } return ToolStripDropDownDirection.BelowLeft; }
public ToolStrip() { this.hwndThatLostFocus = IntPtr.Zero; this.lastInsertionMarkRect = Rectangle.Empty; this.toolStripGripStyle = ToolStripGripStyle.Visible; this.activeDropDowns = new ArrayList(1); this.currentRendererType = typeof(System.Type); this.toolStripDropDownDirection = ToolStripDropDownDirection.Default; this.largestDisplayedItemSize = Size.Empty; this.imageScalingSize = new Size(0x10, 0x10); this.mouseEnterWhenShown = InvalidMouseEnter; base.SuspendLayout(); this.CanOverflow = true; this.TabStop = false; this.MenuAutoExpand = false; base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.SupportsTransparentBackColor, true); base.SetStyle(ControlStyles.Selectable, false); this.SetToolStripState(0xc0, true); base.SetState2(0x810, true); ToolStripManager.ToolStrips.Add(this); this.layoutEngine = new ToolStripSplitStackLayout(this); this.Dock = this.DefaultDock; this.AutoSize = true; this.CausesValidation = false; Size defaultSize = this.DefaultSize; base.SetAutoSizeMode(AutoSizeMode.GrowAndShrink); this.ShowItemToolTips = this.DefaultShowItemToolTips; base.ResumeLayout(true); }
//------------------------------------------------------------------------------------- private new void Show(Point p, ToolStripDropDownDirection dir) { }