/// <summary> /// Initializes a new instance of the <see cref="MenuBuilder"/> class. /// </summary> /// <param name="manager">The manager.</param> /// <param name="parentControl">The control where we are a buttons to.</param> public MenuBuilder(NodeManager manager, Control parentControl) { this.Windows = new Collection<Window>(); this.ButtonNames = new Collection<string>(); this.theme = new Theme(); this.Manager = manager; this.parent = parentControl; }
public static void RemoveControl(this Control parent, Control child) { #if DEBUG if (parent == null) { throw new ArgumentNullException("parent"); } if (child == null) { throw new ArgumentNullException("child"); } #endif child.Parent = null; child.Manager = null; parent.Children.Remove(child); }
/// <summary> /// Destroys me. /// </summary> /// <param name="control">The control.</param> public void DestroyMe(Control control) { for (var i = Children.Count - 1; i >= 0; i--) { var child = Children[i]; if (child != control) { continue; } Children.Remove(child); var cnt = child as Control; if (cnt == null) { continue; } cnt.UnloadContent(); } }
/// <summary>Adds the control to my grid.</summary> /// <param name="gridIndexX">The grid index position x.</param> /// <param name="gridIndexY">The grid index position y.</param> /// <param name="control">The control to add to given location.</param> /// <exception cref="System.ArgumentNullException">Control that was null.</exception> public void AddGridControl(int gridIndexX, int gridIndexY, Control control) { #if DEBUG if (control == null) { throw new ArgumentNullException("control"); } #endif if (gridIndexX >= 0 && gridIndexX < this.ConfigColumnCount && gridIndexY >= 0 && gridIndexY < this.ConfigRowCount && this.controlArray[gridIndexX][gridIndexY] == null) { this.controlArray[gridIndexX][gridIndexY] = control; var position = this.GridPosition(gridIndexX, gridIndexY); control.Config.PositionX = position.X; control.Config.PositionY = position.Y; control.Config.Width = this.cellWidth; control.Config.Height = this.cellHeight; if (control is Label) { var pos = new DVector2(control.Config.PositionX, control.Config.PositionY); pos += new DVector2(this.cellWidth / 2.0f, this.cellHeight / 2.0f); control.State.DrawPosition = pos; } this.AddControl(control); control.LoadContent(); } }
/// <summary> /// Sets the focus to given control. /// </summary> /// <param name="control">The control.</param> public void SetFocusedControl(Control control) { if (this.FocusedNode != null && this.FocusedNode != control) { this.FocusedNode = control; } }
/// <summary> /// Add a control to the scene-graph as a foreground item which will be rendered after all controls. /// </summary> /// <param name="control">The control that we add to the foreground.</param> public void AddForegroundControl(Control control) { if (this.sceneGraph != null) { this.ForegroundSceneNodes.Children.Add(control); } }
/// <summary> /// Removes a control from the user-interface. /// </summary> /// <param name="control">The control.</param> public void RemoveControl(Control control) { if (this.sceneGraph != null) { this.SceneNodes.Children.Remove(control); } }
/// <summary> /// Initializes a new instance of the <see cref="ControlEventArgs"/> class. /// </summary> /// <param name="control">The Control.</param> public ControlEventArgs(Control control) { this.Control = control; }
/// <summary> /// Create buttons in the given control. /// </summary> /// <param name="parentControl">The parent control.</param> public void CreateButtonsInControl(Control parentControl) { var y = this.theme.ControlLargeSpacing + (this.theme.ControlHeight * 2); foreach (var testWindow in this.Windows) { // create a button to go and show the window var btn = new Button(testWindow.Title) { ConfigText = testWindow.Name, Tag = testWindow.GetType().FullName, Config = { PositionY = y, PositionX = this.theme.ControlLargeSpacing } }; btn.Clicked += this.OnButtonClicked; y = y + this.theme.ControlHeight + this.theme.ControlSmallSpacing; // add the button to the window parentControl.AddControl(btn); } }