public Button(string Text, Window window) : base(window) { Selected = new ButtonSelectedEvent(ButtonSelected); Margin = 4; FlowLayout layout = new FlowLayout(true); layout.centered = false; label = new Label(Text, window); label.Color = Color.LightGray; this.AddControl(label); this.Name = "Button"; Color = System.Drawing.Color.White; atlas = new HagsAtlas("window-theme/button/button.png"); atlas["topleft"] = new Rectangle(0, 0, 3, 3); atlas["left"] = new Rectangle(0, 3, 3, 15); atlas["bottomleft"] = new Rectangle(0, 18, 3, 3); atlas["top"] = new Rectangle(3, 0, 34, 3); atlas["middle"] = new Rectangle(3, 3, 34, 15); atlas["bottom"] = new Rectangle(3, 18, 34, 3); atlas["topright"] = new Rectangle(37,0,3,3); atlas["right"] = new Rectangle(37, 3, 3, 15); atlas["bottomright"] = new Rectangle(37, 18, 3, 3); stateOffets.Add(ButtonState.HOVER, new Point(0, 21)); stateOffets.Add(ButtonState.DOWN, new Point(0, 43)); }
public TextBox(Window window) : base(window) { PreferredSize = new Size(240, 26); atlas = new HagsAtlas("window-theme/textframe.png"); //HagsAtlas.SerializeToXML(atlas); atlas["topleft"] = new Rectangle(0, 0, 3, 3); atlas["top"] = new Rectangle(5, 0, 3, 3); atlas["topright"] = new Rectangle(28, 0, 3, 3); atlas["left"] = new Rectangle(0, 5, 3, 3); atlas["middle"] = new Rectangle(5, 5, 3, 3); atlas["right"] = new Rectangle(28, 5, 3, 3); atlas["bottomleft"] = new Rectangle(0, 28, 3, 3); atlas["bottom"] = new Rectangle(5, 28, 3, 3); atlas["bottomright"] = new Rectangle(28, 28, 3, 3); // Load theme WhiteTexture = TextureManager.CreateTexture(1, 1, Format.A8R8G8B8, new SlimDX.Color4(Color.White)); //WhiteTexture = TextureManager.Instance.LoadTexture("window-theme/White.bmp"); // Fixed sized font measurement ASize = new Rectangle(); Renderer.Instance.Fonts["textbox"].MeasureString(Renderer.Instance.sprite, "A", DrawTextFormat.Left, ref ASize); // Little prefferedsize tweak int goodHeight = ASize.Height + atlas["top"].Height + atlas["bottom"].Height; if (goodHeight > PreferredSize.Height) { PreferredSize.Height = goodHeight; } }
public Label(string text, float fontSize, System.Drawing.Color fontColor, Window window) : base(window) { this.Name = "Label"; Text = text; Alignment = Align.LEFT; Color = fontColor; }
public Window Window; // window control is part of #endregion Fields #region Constructors public Control(Window window) { this.Window = window; MouseDown = new ControlEvents.MouseDown(MouseDownEvent); MouseMove = new ControlEvents.MouseMove(MouseMoveEvent); MouseUp = new ControlEvents.MouseUp(MouseUpEvent); MouseEnter = new ControlEvents.MouseEnter(MouseEnterEvent); MouseExit = new ControlEvents.MouseExit(MouseExitEvent); KeyDown = new ControlEvents.KeyDown(KeyDownEvent); }
public Container(Window window) : base(window) { MouseDown += new ControlEvents.MouseDown(ContainerMouseDownEvent); MouseMove += new ControlEvents.MouseMove(ContainerMouseMoveEvent); MouseUp += new ControlEvents.MouseUp(ContainerMouseUpEvent); MouseEnter += new ControlEvents.MouseEnter(ContainerMouseEnterEvent); MouseExit += new ControlEvents.MouseExit(ContainerMouseExitEvent); KeyDown += new ControlEvents.KeyDown(ContainerKeyDownEvent); }
public ServerListItemUI(Window window, serverInfo_t info) : base(window) { this.Layout = new FlowLayout(true); this.info = info; this.joinButton = new Button("Join", window); joinButton.Selected += new Button.ButtonSelectedEvent(JoinServer); serverIP = new Label("Address: " + info.adr.ToString(), window); this.AddControl(serverIP); this.AddControl(joinButton); }
public ProgressBar(Window window) : base(window) { sprite = new Sprite(Renderer.Instance.device); pixmap = TextureManager.Instance.LoadTexture("window-theme/progressbar.png"); progress = TextureManager.Instance.LoadTexture("window-theme/progress.png"); coords = new Rectangle[9]; coords[0] = new Rectangle(0 ,0 ,5,5); coords[1] = new Rectangle(5, 0, 5, 5); coords[2] = new Rectangle(10, 0, 5, 5); coords[3] = new Rectangle(0, 5, 5, 5); coords[4] = new Rectangle(5, 5, 5, 5); coords[5] = new Rectangle(10, 5, 5, 5); coords[6] = new Rectangle(0, 15, 5, 5); coords[7] = new Rectangle(5, 15, 5, 5); coords[8] = new Rectangle(10, 15, 5, 5); PreferredSize.Height = 20; PreferredSize.Width = MAXSIZE; }
// Add windows to display and positions it according to its needs. public void AddWindow(Window window) { window.Zvalue = nextZvalue++; SetWindowPosition(window); window.LayoutUpdate(false); Windows.Add(window); }
public Label(string text, Align Alignment, Window window) : this(text, window) { this.Alignment = Alignment; }
// Sends all mouse event to a particular window until it releases its lock public bool GetMouseLock(Window window) { // Is the lock free? if (!_MouseLock && MouseLockWindow == null) { MouseLockWindow = window; _MouseLock = true; return true; } else return false; }
public Label(string text, Window window) : this(text, 10f, System.Drawing.Color.White, window) { }
public Panel(LayoutManager Layout,Window window) : base(window) { this.Layout = Layout; }
public Panel(Window window) : base(window) { }
// Decide window position public void SetWindowPosition(Window window) { Dimension pos = new Dimension(); switch (window.WindowSpawnPosition) { case Corner.NONE: goto default; case Corner.MIDDLE: pos = new Dimension((Renderer.Instance.RenderSize.Width / 2) - (window.Bound.Width/2), (Renderer.Instance.RenderSize.Height / 2) - (window.Bound.Height/2)); window.Position = pos; break; case Corner.TOPLEFT: window.Position = new Dimension(); break; case Corner.TOPRIGHT: pos = new Dimension(Renderer.Instance.device.Viewport.Width - window.Bound.Width, 0); window.Position = pos; break; case Corner.BOTLEFT: pos = new Dimension(0, Renderer.Instance.device.Viewport.Height - window.Bound.Height); window.Position = pos; break; case Corner.BOTRIGHT: pos = new Dimension(Renderer.Instance.device.Viewport.Width - window.Bound.Width, Renderer.Instance.device.Viewport.Height - window.Bound.Height); window.Position = pos; break; case Corner.TOP: pos = new Dimension((Renderer.Instance.device.Viewport.Width / 2) - (window.Bound.Width / 2), 0); window.Position = pos; break; case Corner.BOT: pos = new Dimension((Renderer.Instance.device.Viewport.Width / 2) - (window.Bound.Width / 2), Renderer.Instance.device.Viewport.Height - window.Bound.Height); window.Position = pos; break; case Corner.LEFT: pos = new Dimension(0, (Renderer.Instance.device.Viewport.Height / 2) - (window.Bound.Height / 2)); window.Position = pos; break; case Corner.RIGHT: pos = new Dimension(Renderer.Instance.device.Viewport.Width - window.Bound.Width, (Renderer.Instance.device.Viewport.Height / 2) - (window.Bound.Height / 2)); window.Position = pos; break; default: window.Position = nextPosition; // Check if next position exceeds screen if (nextPosition.X + window.Size.Width > Renderer.Instance.device.Viewport.Width) { // reset x nextPosition.X = 70; } if (nextPosition.Y + window.Size.Height > Renderer.Instance.device.Viewport.Height) { // reset Y nextPosition.Y = 70; } nextPosition += new Dimension(30, 30); break; } window.LayoutUpdate(true); }
public void ReleaseMouseLock() { _MouseLock = false; MouseLockWindow = null; }
public void MoveToFront(Window window) { window.Zvalue = nextZvalue++; }
// Incomming mouse event from Input layer public void HandleMouseEvent(MouseEvent evt) { // Ignore if UI not in focus if (!ShowManager) return; // Special case for windows that has privileged focus over mouse if (MouseLock && MouseLockWindow != null) { // Check button statechange and send events if ((evt.Type & MouseEvent.EventType.MOUSEDOWN) > 0) { MouseLockWindow.MouseDown(evt); // Send window to front, if necessary if (MouseLockWindow.Zvalue < nextZvalue - 1) MouseLockWindow.Zvalue = nextZvalue++; } if ((evt.Type & MouseEvent.EventType.MOUSEUP) > 0) MouseLockWindow.MouseUp(evt); if ((evt.Type & MouseEvent.EventType.MOVE) > 0 && MouseLockWindow != null) MouseLockWindow.MouseMove(evt); } // Iterate windows and try to find one that has been hit else { // sort windows - most recent focussed first Windows.Sort(new WindowComparer()); // Iterate over windows untill a window is hit bool windowHit = false; foreach (Window window in Windows) { if (!window.Visible) continue; // Check against bounds if (window.Bound.Contains(evt.Position)) { windowHit = true; //window.Update(); // Entering new window? if (LastWindowMouseEnter != window) { // Notify old window if (LastWindowMouseEnter != null) LastWindowMouseEnter.MouseExit(evt); LastWindowMouseEnter = window; // Notify new window window.MouseEnter(evt); } // Check button statechange and send events if ((evt.Type & MouseEvent.EventType.MOUSEDOWN) > 0) { window.MouseDown(evt); // Send window to front, if necessary if (window.Zvalue < nextZvalue - 1) window.Zvalue = nextZvalue++; } if ((evt.Type & MouseEvent.EventType.MOUSEUP) > 0) window.MouseUp(evt); if ((evt.Type & MouseEvent.EventType.MOVE) > 0) window.MouseMove(evt); break; } } // No window hit - show default cursor if (!windowHit) Cursor = 0; } }