/// <summary> /// Initializes a new instance of the <see cref="ColorSlider"/> class. /// </summary> /// <param name="parent">Parent control.</param> public ColorSlider(ControlBase parent) : base(parent) { SetSize(32, 128); MouseInputEnabled = true; m_Depressed = false; }
/// <summary> /// Initializes a new instance of the <see cref="RadioButton"/> class. /// </summary> /// <param name="parent">Parent control.</param> public RadioButton(ControlBase parent) : base(parent) { SetSize(15, 15); MouseInputEnabled = true; IsTabable = false; }
public static void Add(ControlBase control, Animation animation) { animation.m_Control = control; if (!m_Animations.ContainsKey(control)) m_Animations[control] = new List<Animation>(); m_Animations[control].Add(animation); }
/// <summary> /// Initializes a new instance of the <see cref="CrossSplitter"/> class. /// </summary> /// <param name="parent">Parent control.</param> public CrossSplitter(ControlBase parent) : base(parent) { m_Sections = new ControlBase[4]; m_VSplitter = new SplitterBar(this); m_VSplitter.SetPosition(0, 128); m_VSplitter.Dragged += OnVerticalMoved; m_VSplitter.Cursor = Cursors.SizeNS; m_HSplitter = new SplitterBar(this); m_HSplitter.SetPosition(128, 0); m_HSplitter.Dragged += OnHorizontalMoved; m_HSplitter.Cursor = Cursors.SizeWE; m_CSplitter = new SplitterBar(this); m_CSplitter.SetPosition(128, 128); m_CSplitter.Dragged += OnCenterMoved; m_CSplitter.Cursor = Cursors.SizeAll; m_HVal = 0.5f; m_VVal = 0.5f; SetPanel(0, null); SetPanel(1, null); SetPanel(2, null); SetPanel(3, null); SplitterSize = 5; SplittersVisible = false; m_ZoomedSection = -1; }
public RadioButton(ControlBase parent) : base(parent) { Control.RadioButtonGroup rbg = new Control.RadioButtonGroup(this, "Sample radio group"); rbg.SetPosition(10, 10); rbg.AddOption("Option 1"); rbg.AddOption("Option 2"); rbg.AddOption("Option 3"); rbg.AddOption("\u0627\u0644\u0622\u0646 \u0644\u062D\u0636\u0648\u0631"); //rbg.SizeToContents(); // it's auto rbg.SelectionChanged += OnChange; Control.LabeledRadioButton rb1 = new LabeledRadioButton(this); rb1.Text = "Option 1"; rb1.SetPosition(300, 10); Control.LabeledRadioButton rb2 = new LabeledRadioButton(this); rb2.Text = "Option 2222222222222222222222222222222222"; rb2.SetPosition(300, 30); Control.LabeledRadioButton rb3 = new LabeledRadioButton(this); rb3.Text = "\u0627\u0644\u0622\u0646 \u0644\u062D\u0636\u0648\u0631"; rb3.SetPosition(300, 50); //this.DrawDebugOutlines = true; }
/// <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; }
/// <summary> /// Initializes a new instance of the <see cref="MenuStrip"/> class. /// </summary> /// <param name="parent">Parent control.</param> public MenuStrip(ControlBase parent) : base(parent) { SetBounds(0, 0, 200, 22); Dock = Pos.Top; m_InnerPanel.Padding = new Padding(5, 0, 0, 0); }
internal bool m_Alt; // for alternate coloring /// <summary> /// Initializes a new instance of the <see cref="CategoryButton"/> class. /// </summary> /// <param name="parent">Parent control.</param> public CategoryButton(ControlBase parent) : base(parent) { Alignment = Pos.Left | Pos.CenterV; m_Alt = false; IsToggle = true; TextPadding = new Padding(3, 0, 3, 0); }
void OpenMsgbox(ControlBase control) { MessageBox window = new MessageBox(GetCanvas(), String.Format("Window {0} MessageBox window = new MessageBox(GetCanvas(), String.Format( MessageBox window = new MessageBox(GetCanvas(), String.Format(", m_WindowCount)); window.SetPosition(rand.Next(700), rand.Next(400)); m_WindowCount++; }
/// <summary> /// Initializes a new instance of the <see cref="TabControl"/> class. /// </summary> /// <param name="parent">Parent control.</param> public TabControl(ControlBase parent) : base(parent) { m_Scroll = new ScrollBarButton[2]; m_ScrollOffset = 0; m_TabStrip = new TabStrip(this); m_TabStrip.StripPosition = Pos.Top; // Make this some special control? m_Scroll[0] = new ScrollBarButton(this); m_Scroll[0].SetDirectionLeft(); m_Scroll[0].Clicked += ScrollPressedLeft; m_Scroll[0].SetSize(14, 16); m_Scroll[1] = new ScrollBarButton(this); m_Scroll[1].SetDirectionRight(); m_Scroll[1].Clicked += ScrollPressedRight; m_Scroll[1].SetSize(14, 16); m_InnerPanel = new TabControlInner(this); m_InnerPanel.Dock = Pos.Fill; m_InnerPanel.SendToBack(); IsTabable = false; }
public override void DrawButton(ControlBase control, bool depressed, bool hovered, bool disabled) { int w = control.Width; int h = control.Height; DrawButton(w, h, depressed, hovered); }
/// <summary> /// Enables tooltip display for the specified control. /// </summary> /// <param name="control">Target control.</param> public static void Enable(ControlBase control) { if (null == control.ToolTip) return; g_ToolTip = control; }
/// <summary> /// Moves the control to the left of its parent. /// </summary> /// <param name="control"></param> public static void AlignLeft(ControlBase control) { ControlBase parent = control.Parent; if (null == parent) return; control.SetPosition(parent.Padding.Left, control.Y); }
/// <summary> /// Initializes a new instance of the <see cref="NumericUpDown"/> class. /// </summary> /// <param name="parent">Parent control.</param> public NumericUpDown(ControlBase parent) : base(parent) { SetSize(100, 20); m_Splitter = new Splitter(this); m_Splitter.Dock = Pos.Right; m_Splitter.SetSize(13, 13); m_Up = new UpDownButton_Up(m_Splitter); m_Up.Clicked += OnButtonUp; m_Up.IsTabable = false; m_Splitter.SetPanel(0, m_Up, false); m_Down = new UpDownButton_Down(m_Splitter); m_Down.Clicked += OnButtonDown; m_Down.IsTabable = false; m_Down.Padding = new Padding(0, 1, 1, 0); m_Splitter.SetPanel(1, m_Down, false); m_Max = 100; m_Min = 0; m_Value = 0f; Text = "0"; }
public CheckBox(ControlBase parent) : base(parent) { Control.CheckBox check = new Control.CheckBox(this); check.SetPosition(10, 10); check.Checked += OnChecked; check.UnChecked += OnUnchecked; check.CheckChanged += OnCheckChanged; Control.LabeledCheckBox labeled = new Control.LabeledCheckBox(this); labeled.Text = "Labeled CheckBox"; labeled.Checked += OnChecked; labeled.UnChecked += OnUnchecked; labeled.CheckChanged += OnCheckChanged; Align.PlaceDownLeft(labeled, check, 10); Control.LabeledCheckBox labeled2 = new Control.LabeledCheckBox(this); labeled2.Text = "I'm autosized"; labeled2.SizeToChildren(); Align.PlaceDownLeft(labeled2, labeled, 10); Control.CheckBox check2 = new Control.CheckBox(this); check2.IsDisabled = true; Align.PlaceDownLeft(check2, labeled2, 20); }
/// <summary> /// Centers the control vertically inside its parent. /// </summary> /// <param name="control"></param> public static void CenterVertically(ControlBase control) { ControlBase parent = control.Parent; if (null == parent) return; control.SetPosition(control.X, (parent.Height - control.Height) / 2); }
/// <summary> /// Disables tooltip display for the specified control. /// </summary> /// <param name="control">Target control.</param> public static void Disable(ControlBase control) { if (g_ToolTip == control) { g_ToolTip = null; } }
/// <summary> /// Initializes a new instance of the <see cref="CheckBox"/> class. /// </summary> /// <param name="parent">Parent control.</param> public CheckBox(ControlBase parent) : base(parent) { SetSize(15, 15); //m_Checked = true; // [omeg] why?! //Toggle(); }
/// <summary> /// Initializes a new instance of the <see cref="RadioButtonGroup"/> class. /// </summary> /// <param name="parent">Parent control.</param> /// <param name="label">Label for the outlining GroupBox.</param> public RadioButtonGroup(ControlBase parent, String label) : base(parent) { IsTabable = false; KeyboardInputEnabled = true; Text = label; AutoSizeToContents = true; }
/// <summary> /// Initializes a new instance of the <see cref="TreeNodeLabel"/> class. /// </summary> /// <param name="parent">Parent control.</param> public TreeNodeLabel(ControlBase parent) : base(parent) { Alignment = Pos.Left | Pos.CenterV; ShouldDrawBackground = false; Height = 16; TextPadding = new Padding(3, 0, 3, 0); }
/// <summary> /// Initializes a new instance of the <see cref="Modal"/> class. /// </summary> /// <param name="parent">Parent control.</param> public Modal(ControlBase parent) : base(parent) { KeyboardInputEnabled = true; MouseInputEnabled = true; ShouldDrawBackground = true; SetBounds(0, 0, GetCanvas().Width, GetCanvas().Height); }
/// <summary> /// Moves the control to the right of its parent. /// </summary> /// <param name="control"></param> public static void AlignRight(ControlBase control) { ControlBase parent = control.Parent; if (null == parent) return; control.SetPosition(parent.Width - control.Width - parent.Padding.Right, control.Y); }
/// <summary> /// Centers the control horizontally inside its parent. /// </summary> /// <param name="control"></param> public static void CenterHorizontally(ControlBase control) { ControlBase parent = control.Parent; if (null == parent) return; control.SetPosition(parent.Padding.Left + (((parent.Width - parent.Padding.Left - parent.Padding.Right) - control.Width) / 2), control.Y); }
/// <summary> /// Initializes a new instance of the <see cref="Resizer"/> class. /// </summary> /// <param name="parent">Parent control.</param> public Resizer(ControlBase parent) : base(parent) { m_ResizeDir = Pos.Left; MouseInputEnabled = true; SetSize(6, 6); Target = parent; }
/// <summary> /// Initializes a new instance of the <see cref="CategoryHeaderButton"/> class. /// </summary> /// <param name="parent">Parent control.</param> public CategoryHeaderButton(ControlBase parent) : base(parent) { ShouldDrawBackground = false; IsToggle = true; Alignment = Pos.Center; TextPadding = new Padding(3, 0, 3, 0); }
/// <summary> /// Initializes a new instance of the <see cref="ColorPicker"/> class. /// </summary> /// <param name="parent">Parent control.</param> public ColorPicker(ControlBase parent) : base(parent) { MouseInputEnabled = true; SetSize(256, 150); CreateControls(); SelectedColor = Color.FromArgb(255, 50, 60, 70); }
public static void Cancel(ControlBase control) { if (m_Animations.ContainsKey(control)) { m_Animations[control].Clear(); m_Animations.Remove(control); } }
public TabTitleBar(ControlBase parent) : base(parent) { MouseInputEnabled = true; TextPadding = new Padding(5, 2, 5, 2); Padding = new Padding(1, 2, 1, 2); DragAndDrop_SetPackage(true, "TabWindowMove"); }
public Docking(ControlBase parent) : base(parent) { font = Skin.DefaultFont.Copy(); font.Size = 20; outer = new Control.Label(this); outer.SetBounds(10, 10, 400, 400); Control.Label inner1 = new Control.Label(outer); inner1.Text = "1"; inner1.Font = font; inner1.SetSize(100, 100); inner1.Dock = Pos.Left; Control.Label inner2 = new Control.Label(outer); inner2.Text = "2"; inner2.Font = font; inner2.SetSize(100, 100); inner2.Dock = Pos.Top; Control.Label inner3 = new Control.Label(outer); inner3.Text = "3"; inner3.Font = font; inner3.SetSize(100, 100); inner3.Dock = Pos.Right; Control.Label inner4 = new Control.Label(outer); inner4.Text = "4"; inner4.Font = font; inner4.SetSize(100, 100); inner4.Dock = Pos.Bottom; Control.Label inner5 = new Control.Label(outer); inner5.Text = "5"; inner5.Font = font; inner5.SetSize(100, 100); inner5.Dock = Pos.Fill; outer.DrawDebugOutlines = true; inner1.UserData = CreateControls(inner1, 0, "Control 1", 440, 10); inner2.UserData = CreateControls(inner2, 1, "Control 2", 650, 10); inner3.UserData = CreateControls(inner3, 2, "Control 3", 440, 170); inner4.UserData = CreateControls(inner4, 3, "Control 4", 650, 170); inner5.UserData = CreateControls(inner5, 4, "Control 5", 440, 330); Control.Label l_padding = new Control.Label(this); l_padding.Text = "Padding:"; l_padding.SetSize(50, 15); Align.PlaceDownLeft(l_padding, outer, 20); Control.HorizontalSlider padding = new Control.HorizontalSlider(this); padding.Min = 0; padding.Max = 200; padding.Value = 10; padding.SetSize(100, 20); padding.ValueChanged += PaddingChanged; Align.PlaceRightBottom(padding, l_padding); //DrawDebugOutlines = true; }
void ColorChanged(ControlBase control) { IColorPicker picker = control as IColorPicker; Color c = picker.SelectedColor; HSV hsv = c.ToHSV(); String text = String.Format("Color changed: RGB: {0:X2}{1:X2}{2:X2} HSV: {3:F1} {4:F2} {5:F2}", c.R, c.G, c.B, hsv.h, hsv.s, hsv.v); UnitPrint(text); }
/// <summary> /// Get a child control or component of this component. /// </summary> /// <param name="name">Name.</param> /// <returns>Control or component.</returns> public object GetControl(string name) { if (m_View == null) { throw new NullReferenceException("Unable to get a control. Component contains no view."); } Gwen.Control.ControlBase control = null; if (m_View.Name == name) { control = m_View; } else { control = m_View.FindChildByName(name, true); } if (control == null) { return(null); } if (control.Component != null) { if (control.Component != this) { return(control.Component); } else { return(control); } } else { return(control); } }
/// <summary> /// Override this function if you want to handle all XML based events in the same function. /// </summary> /// <param name="eventName">Name of the event.</param> /// <param name="handlerName">Element handler defined in the XML.</param> /// <param name="sender">Event sender control.</param> /// <param name="args">Event arguments.</param> /// <returns>True if the event was handled, false otherwise.</returns> /// <remarks>No need to call the base implementation.</remarks> public virtual bool HandleEvent(string eventName, string handlerName, Gwen.Control.ControlBase sender, System.EventArgs args) { return(false); }
public void OnValueChanged(Gwen.Control.ControlBase sender, ValueChangedEventArgs args) { m_unit.UnitPrint(sender.Name + ": ValueChanged " + args.Value); }
public override bool HandleEvent(string eventName, string handlerName, Gwen.Control.ControlBase sender, System.EventArgs args) { if (handlerName == "OnButtonClicked") { m_unit.UnitPrint(sender.Name + ": Clicked"); return(true); } else if (handlerName == "OnItemSelected") { m_unit.UnitPrint(sender.Name + ": ItemSelected " + ((MenuItem)((ItemSelectedEventArgs)args).SelectedItem).Text); return(true); } else if (handlerName == "OnSelectionChanged") { m_unit.UnitPrint(sender.Name + ": SelectionChanged " + ((LabeledRadioButton)((ItemSelectedEventArgs)args).SelectedItem).Text); return(true); } else if (handlerName == "OnValueChanged") { float value = 0.0f; if (sender is Gwen.Control.NumericUpDown) { value = ((Gwen.Control.NumericUpDown)sender).Value; } else if (sender is Gwen.Control.VerticalSlider) { value = ((Gwen.Control.VerticalSlider)sender).Value; } else if (sender is Gwen.Control.HorizontalSlider) { value = ((Gwen.Control.HorizontalSlider)sender).Value; } m_unit.UnitPrint(sender.Name + ": ValueChanged " + value); return(true); } else if (handlerName == "OnTextChanged") { if (sender is Gwen.Control.TextBox) { m_unit.UnitPrint(sender.Name + ": TextChanged " + ((Gwen.Control.TextBox)sender).Text); } else if (sender is Gwen.Control.MultilineTextBox) { m_unit.UnitPrint(sender.Name + ": TextChanged " + ((Gwen.Control.MultilineTextBox)sender).Text); } return(true); } else if (handlerName == "OnSubmitPressed") { m_unit.UnitPrint(sender.Name + ": SubmitPressed " + ((Gwen.Control.TextBox)sender).Text); return(true); } else if (handlerName == "OnCheckChanged") { if (sender is Gwen.Control.CheckBox) { m_unit.UnitPrint(sender.Name + ": CheckChanged " + ((Gwen.Control.CheckBox)sender).IsChecked); } else if (sender is Gwen.Control.LabeledCheckBox) { m_unit.UnitPrint(sender.Name + ": CheckChanged " + ((Gwen.Control.LabeledCheckBox)sender).IsChecked); } return(true); } else if (handlerName == "OnRowSelected") { m_unit.UnitPrint(sender.Name + ": RowSelected " + ((ListBoxRow)((ItemSelectedEventArgs)args).SelectedItem).Text); return(true); } else if (handlerName == "OnSelected") { m_unit.UnitPrint(((Gwen.Control.TreeNode)sender).TreeControl.Name + ": Selected " + ((Gwen.Control.TreeNode)sender).Text); return(true); } else if (handlerName == "OnClosed") { m_unit.UnitPrint(sender.Name + ": Closed "); return(true); } else { return(false); } }