/// <summary> /// Initializes a new instance of the <see cref="ScrollControl"/> class. /// </summary> /// <param name="parent">Parent control.</param> public ScrollControl(ControlBase parent) : base(parent) { MouseInputEnabled = false; m_VerticalScrollBar = new VerticalScrollBar(this); m_VerticalScrollBar.Dock = Pos.Right; m_VerticalScrollBar.BarMoved += VBarMoved; m_CanScrollV = true; m_VerticalScrollBar.NudgeAmount = 30; m_HorizontalScrollBar = new HorizontalScrollBar(this); m_HorizontalScrollBar.Dock = Pos.Bottom; m_HorizontalScrollBar.BarMoved += HBarMoved; m_CanScrollH = true; m_HorizontalScrollBar.NudgeAmount = 30; m_InnerPanel = new ControlBase(this); m_InnerPanel.SetPosition(0, 0); m_InnerPanel.Margin = Margin.Five; m_InnerPanel.SendToBack(); m_InnerPanel.MouseInputEnabled = false; m_AutoHideBars = false; }
public override void DragAndDrop_Hover(Package p, int x, int y) { Point localPos = CanvasPosToLocal(new Point(x, y)); ControlBase droppedOn = GetControlAt(localPos.X, localPos.Y); if (droppedOn != null && droppedOn != this) { Point dropPos = droppedOn.CanvasPosToLocal(new Point(x, y)); m_TabDragControl.SetBounds(new Rectangle(0, 0, 3, Height)); m_TabDragControl.BringToFront(); m_TabDragControl.SetPosition(droppedOn.X - 1, 0); if (dropPos.X > droppedOn.Width / 2) { m_TabDragControl.MoveBy(droppedOn.Width - 1, 0); } m_TabDragControl.Dock = Dock.None; } else { m_TabDragControl.Dock = Dock.Left; m_TabDragControl.BringToFront(); } }
/// <summary> /// Moves the control to the top of its parent. /// </summary> /// <param name="control"></param> public static void AlignTop(Controls.ControlBase control) { Controls.ControlBase parent = control.Parent; if (null == parent) { return; } control.SetPosition(control.X, control.Margin.Top + parent.Padding.Top); }
/// <summary> /// Moves the control to the left of its parent. /// </summary> /// <param name="control"></param> public static void AlignLeft(Controls.ControlBase control) { Controls.ControlBase parent = control.Parent; if (null == parent) { return; } control.SetPosition(parent.Padding.Left + control.Margin.Left, control.Y); }
/// <summary> /// Stretches the control inside it's parent /// </summary> public static void StretchHorizontally(Controls.ControlBase control) { Controls.ControlBase parent = control.Parent; if (parent == null) { return; } control.SetPosition(control.Margin.Left + parent.Padding.Left, control.Y); control.Width = parent.Width - parent.Padding.Right; }
/// <summary> /// Moves the control to the bottom of its parent. /// </summary> /// <param name="control"></param> public static void AlignBottom(Controls.ControlBase control) { Controls.ControlBase parent = control.Parent; if (null == parent) { return; } control.SetPosition(control.X, (parent.Height - control.Height) - (control.Margin.Bottom + parent.Padding.Bottom)); }
/// <summary> /// Centers the control vertically inside its parent. /// </summary> /// <param name="control"></param> public static void CenterVertically(Controls.ControlBase control) { Controls.ControlBase parent = control.Parent; if (null == parent) { return; } control.SetPosition(control.X + control.Margin.Left, ((parent.Height - control.Height) / 2) + control.Margin.Top); }
/// <summary> /// Moves the control to the right of its parent. /// </summary> /// <param name="control"></param> public static void AlignRight(Controls.ControlBase control) { Controls.ControlBase parent = control.Parent; if (null == parent) { return; } control.SetPosition(parent.Width - control.Width - parent.Padding.Right - control.Margin.Right, control.Y); }
/// <summary> /// Centers the control horizontally inside its parent. /// </summary> /// <param name="control"></param> public static void CenterHorizontally(Controls.ControlBase control) { Controls.ControlBase parent = control.Parent; if (null == parent) { return; } control.SetPosition(parent.Padding.Left + control.Margin.Left + (((parent.Width - parent.Padding.Left - parent.Padding.Right) - control.Width) / 2), control.Y + control.Margin.Top); }
/// <summary> /// Centers the control inside its parent. /// </summary> /// <param name="control">Control to center.</param> public static void Center(Controls.ControlBase control) { Controls.ControlBase parent = control.Parent; if (parent == null) { return; } control.SetPosition( parent.Padding.Left + control.Margin.Left + (((parent.Width - parent.Padding.Left - parent.Padding.Right) - control.Width) / 2), control.Margin.Top + (parent.Height - control.Height) / 2); }
/// <summary> /// Places the control to the right of other control (bottom aligned), taking margins into account. /// </summary> /// <param name="control">Control to place.</param> /// <param name="anchor">Anchor control.</param> /// <param name="spacing">Optional spacing.</param> public static void PlaceRightBottom(Controls.ControlBase control, Controls.ControlBase anchor, int spacing = 0) { control.SetPosition(anchor.Right + anchor.Margin.Right + spacing + control.Margin.Right, anchor.Y - control.Height + anchor.Height + control.Margin.Top); }
/// <summary> /// Places the control below other control (left aligned), taking margins into account. /// </summary> /// <param name="control">Control to place.</param> /// <param name="anchor">Anchor control.</param> /// <param name="spacing">Optional spacing.</param> public static void PlaceDownLeft(Controls.ControlBase control, Controls.ControlBase anchor, int spacing = 0) { control.SetPosition(anchor.X + control.Margin.Left, anchor.Bottom + anchor.Margin.Bottom + spacing + control.Margin.Top); }