/// <summary> /// Constructor /// </summary> /// <param name="parent">Parent control</param> /// <param name="type">Type</param> public ControlPanel(Control parent, int type) { this.parent = parent; this.type = type; bord = parent as ISetBorders; MouseDown += new MouseEventHandler(onMouseDownEventHandler); MouseUp += new MouseEventHandler(onMouseUpEventHandler); MouseMove += new MouseEventHandler(onMouseMoveEventHandler); switch (type) { case 0: Cursor = Cursors.SizeNWSE; break; case 1: Cursor = Cursors.SizeNESW; break; case 2: Cursor = Cursors.SizeNWSE; break; case 3: Cursor = Cursors.SizeNESW; break; default: break; } }
/// <summary> /// Removes panels /// </summary> /// <param name="control">Parent control</param> public static void RemovePanels(Control control) { Control p = control.Parent; if (p == null) { return; } ISetBorders s = control as ISetBorders; for (int i = 0; i < 4; i++) { Control c = s[i]; if (!p.Controls.Contains(c)) { continue; } try { if (c != null) { if (!c.IsDisposed) { p.Controls.Remove(c); } } } catch (Exception) { } } }
/// <summary> /// Moves control /// </summary> /// <param name="c">The control</param> /// <param name="dx">The X - shift</param> /// <param name="dy">The Y - shift</param> new public static void Move(Control c, int dx, int dy) { c.Left += dx; c.Top += dy; ISetBorders s = c as ISetBorders; for (int i = 0; i < 4; i++) { s[i].Left += dx; s[i].Top += dy; } }
/// <summary> /// Deactivates all controls /// </summary> /// <param name="control">Parent control</param> public static void DeactivateAll(Control control) { foreach (Control c in control.Controls) { if (!(c is ISetBorders)) { continue; } ISetBorders s = c as ISetBorders; if (s == null) { continue; } s.Deactivate(); } }
/// <summary> /// Gets active text box /// </summary> /// <param name="control">Parent control</param> /// <returns>The active text box</returns> public static TextBox GetActiveTextBox(Control control) { foreach (Control c in control.Controls) { if (!(c is TextBox) & !(c is ISetBorders)) { continue; } ISetBorders s = c as ISetBorders; if (s.IsActive) { return(c as TextBox); } } return(null); }
/// <summary> /// Deactivates other controls /// </summary> /// <param name="control">Active ontrol</param> public static void DeactivateOther(Control control) { Control p = control.Parent; foreach (Control c in p.Controls) { if (c == control) { continue; } if (!(c is ISetBorders)) { continue; } ISetBorders s = c as ISetBorders; if (s == null) { continue; } s.Deactivate(); } }