/// <summary> /// Triggered when a button is clicked /// </summary> private void OnWindowButtonClick(WindowButtons type) { switch (type) { case WindowButtons.Close: Close(); break; case WindowButtons.Minimize: WindowState = FormWindowState.Minimized; break; case WindowButtons.Maximize: WindowState = FormWindowState.Maximized; break; case WindowButtons.Restore: WindowState = FormWindowState.Normal; break; case WindowButtons.CloseAllVisible: OnCloseAllNotif?.Invoke(this, EventArgs.Empty); break; } }
private void WindowButton_Click(object sender, EventArgs e) { MetroFormButton btn = sender as MetroFormButton; if (btn != null) { WindowButtons btnFlag = (WindowButtons)btn.Tag; if (btnFlag == WindowButtons.Close) { Close(); } else if (btnFlag == WindowButtons.Minimize) { WindowState = FormWindowState.Minimized; } else if (btnFlag == WindowButtons.Maximize) { if (WindowState == FormWindowState.Normal) { WindowState = FormWindowState.Maximized; btn.Text = "2"; } else { WindowState = FormWindowState.Normal; btn.Text = "1"; } } else if (btnFlag == WindowButtons.Help) { OnHelpButtonClicked(new CancelEventArgs(false)); btn.Text = "s"; } } }
public FarmingPanel(DwarfGUI gui, GUIComponent parent, WorldManager world, WindowButtons buttons = WindowButtons.CloseButton) : base(gui, parent, buttons) { MinWidth = 512; MinHeight = 256; Setup(world); }
/// <summary> /// Add a particular button on the right top of the form /// </summary> private void AddWindowButton(WindowButtons button) { var newButton = new YamuiFormButton(this) { Type = button, }; _windowButtonList.Add(button, newButton); }
public Window(int x, int y, int width, int height, WindowButtons buttons = WindowButtons.None) { Area = new Rectangle(x, y, width, height); if (buttons.HasFlag(WindowButtons.Close)) { _btn_Close = new WindowButton(0, 0); } }
private void AddControlBox(WindowButtons button) { if (windowButtonList == null) { windowButtonList = new Dictionary <WindowButtons, Label>(); } if (windowButtonList.ContainsKey(button)) { return; } LabelButton newButton = new LabelButton(); if (button == WindowButtons.Close) { newButton.Text = "r"; newButton.Name = "btnClose"; newButton.FlatAppearance.MouseOverBackColor = Color.Red; newButton.FlatAppearance.MouseDownBackColor = Color.OrangeRed; btnClose = newButton; } else if (button == WindowButtons.Minimize) { newButton.Text = "0"; newButton.Name = "btnMin"; btnMin = newButton; } else if (button == WindowButtons.Maximize) { newButton.Name = "btnMax"; if (WindowState == FormWindowState.Normal) { newButton.Text = "1"; } else { newButton.Text = "2"; } btnMax = newButton; } newButton.Tag = button; newButton.AutoSize = false; newButton.Size = new Size(30, 25); newButton.Font = new Font("Webdings", 9.25f); newButton.Anchor = AnchorStyles.Top | AnchorStyles.Right; newButton.TextAlign = ContentAlignment.MiddleCenter; newButton.BackColor = ControlBoxBackColor; newButton.ForeColor = ControlBoxForeColor; newButton.TabStop = false; newButton.Click += new EventHandler(ControlBox_Click); Controls.Add(newButton); windowButtonList.Add(button, newButton); }
private void AddWindowButton(WindowButtons button) { if (windowButtonList == null) { windowButtonList = new Dictionary <WindowButtons, MetroFormButton>(); } if (windowButtonList.ContainsKey(button)) { return; } MetroFormButton newButton = new MetroFormButton(); if (button == WindowButtons.Close) { newButton.Text = "r"; } else if (button == WindowButtons.Minimize) { newButton.Text = "0"; } else if (button == WindowButtons.Maximize) { if (WindowState == FormWindowState.Normal) { newButton.Text = "1"; } else { newButton.Text = "2"; } } newButton.Tag = button; newButton.Size = new Size(25, 20); //Moneim switch (RightToLeft) { case RightToLeft.No: newButton.Anchor = AnchorStyles.Top | AnchorStyles.Right; break; case RightToLeft.Yes: newButton.Anchor = AnchorStyles.Top | AnchorStyles.Left; break; } newButton.Click += new EventHandler(WindowButton_Click); Controls.Add(newButton); windowButtonList.Add(button, newButton); }
private string GetButtonText(WindowButtons button) { switch (button) { case WindowButtons.Close: return("r"); case WindowButtons.Minimize: return("0"); case WindowButtons.Maximize: return(WindowState == FormWindowState.Normal ? "1" : "2"); } throw new InvalidOperationException(); }
private void DrawButton(ref int x, WindowButtons buttonType, PaintEventArgs e, bool show) { var button = _windowButtonList[buttonType]; button.Show = show; if (show) { button.ClientRectangle = new Rectangle(x, BorderWidth, FormButtonWidth, FormButtonHeight); button.OnPaint(e); x -= button.ClientRectangle.Width; } }
public Window(DwarfGUI gui, GUIComponent parent, WindowButtons buttons = WindowButtons.NoButtons) : base(gui, parent) { IsDragging = false; IsResizing = false; Mode = buttons == WindowButtons.NoButtons ? PanelMode.Window : PanelMode.WindowEx; if (buttons == WindowButtons.CloseButton) { CloseButton = new Button(GUI, this, "", GUI.DefaultFont, Button.ButtonMode.ImageButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.CloseButton)); CloseButton.OnClicked += CloseButton_OnClicked; } }
public TradeDialog(DwarfGUI gui, GUIComponent parent, WorldManager world, Faction otherFaction, List <ResourceAmount> resources, WindowButtons buttons) : base(gui, parent, buttons) { World = World; IsResizeable = false; IsDraggable = false; TradePanel = new TradePanel(GUI, this, world.PlayerFaction, otherFaction, resources) { WidthSizeMode = SizeMode.Fit, HeightSizeMode = SizeMode.Fit }; TradePanel.OnTraded += TradePanel_OnTraded; TradePanel.OnCanceled += TradePanel_OnCanceled; }
public static void DisableButtons(this Window window, WindowButtons buttons) { IntPtr handle = new System.Windows.Interop.WindowInteropHelper(window).Handle; int currentStyle = GetWindowLong(handle, GWL_STYLE); if (buttons.HasFlag(WindowButtons.Maximize)) { currentStyle &= ~WS_MAXIMIZEBOX; } if (buttons.HasFlag(WindowButtons.Minimize)) { currentStyle &= ~WS_MINIMIZEBOX; } SetWindowLong(handle, GWL_STYLE, currentStyle); }
public MagicMenu(DwarfGUI gui, GUIComponent parent, GameMaster master, WindowButtons buttons = WindowButtons.CloseButton) : base(gui, parent, buttons) { Master = master; MinWidth = 512; MinHeight = 256; Selector = new TabSelector(GUI, this, 2) { WidthSizeMode = SizeMode.Fit, HeightSizeMode = SizeMode.Fit, LocalBounds = new Rectangle(0, 0, MinWidth, MinHeight) }; SpellTriggered = spell => { }; CreateSpellsTab(); CreateResearchTab(); Selector.SetTab("Known Spells"); }
private void AddWindowButton(WindowButtons button) { if (windowButtonList == null) { windowButtonList = new Dictionary <WindowButtons, MetroFormButton>(); } if (windowButtonList.ContainsKey(button)) { return; } MetroFormButton newButton = new MetroFormButton(); if (button == WindowButtons.Close) { newButton.Text = "r"; } else if (button == WindowButtons.Minimize) { newButton.Text = "0"; } else if (button == WindowButtons.Maximize) { if (WindowState == FormWindowState.Normal) { newButton.Text = "1"; } else { newButton.Text = "2"; } } else if (button == WindowButtons.Help) { newButton.Text = "s"; } newButton.Tag = button; newButton.Size = new Size(30, 20); newButton.Anchor = AnchorStyles.Top | AnchorStyles.Right; newButton.Click += new EventHandler(WindowButton_Click); Controls.Add(newButton); windowButtonList.Add(button, newButton); }
/// <summary> /// Add a particular button on the right top of the form /// </summary> private void AddWindowButton(WindowButtons button) { if (_windowButtonList == null) { _windowButtonList = new Dictionary <WindowButtons, YamuiFormButton>(); } if (_windowButtonList.ContainsKey(button)) { return; } var newButton = new YamuiFormButton(); switch (button) { case WindowButtons.Close: newButton.Text = @"r"; _mainFormToolTip.SetToolTip(newButton, "<b>Close</b> this window"); break; case WindowButtons.Minimize: newButton.Text = @"0"; _mainFormToolTip.SetToolTip(newButton, "<b>Minimize</b> this window"); break; case WindowButtons.Maximize: newButton.Text = WindowState == FormWindowState.Normal ? @"1" : @"2"; _mainFormToolTip.SetToolTip(newButton, "<b>" + (WindowState == FormWindowState.Normal ? "Maximize" : "Restore") + "</b> this window"); break; case WindowButtons.CloseAllVisible: newButton.Text = ((char)(126)).ToString(); _mainFormToolTip.SetToolTip(newButton, "<b>Close all</b> notification windows"); break; } newButton.Tag = button; newButton.Size = new Size(25, 20); newButton.Anchor = AnchorStyles.Top | AnchorStyles.Right; newButton.TabStop = false; //remove the form controls from the tab stop newButton.Click += OnWindowButtonClick; Controls.Add(newButton); _windowButtonList.Add(button, newButton); }
private void AddWindowButton(WindowButtons button) { if (windowButtonList == null) { windowButtonList = new Dictionary <WindowButtons, MetroFormButton>(); } if (windowButtonList.ContainsKey(button)) { return; } MetroFormButton newButton = new MetroFormButton(); if (button == WindowButtons.Close) { newButton.Text = "r"; } else if (button == WindowButtons.Minimize) { newButton.Text = "0"; } else if (button == WindowButtons.Maximize) { if (WindowState == FormWindowState.Normal) { newButton.Text = "1"; } else { newButton.Text = "2"; } } newButton.Style = Style; newButton.Theme = Theme; newButton.Tag = button; newButton.Size = new Size(25, 22); newButton.Anchor = AnchorStyles.Top | AnchorStyles.Right; newButton.TabStop = false; //remove the form controls from the tab stop newButton.Click += WindowButton_Click; Controls.Add(newButton); windowButtonList.Add(button, newButton); }
public void AddNewWindowButton(WindowButtons button) // Method for adding WindowButtons (ex: Close window, minimize window, etc.) This method was copied from the MetroFramework source, but I needed the window buttons to go on the header panel instead. { if (windowButtonList == null) { windowButtonList = new Dictionary <WindowButtons, MetroFormButton>(); } if (windowButtonList.ContainsKey(button)) { return; } MetroFormButton newButton = new MetroFormButton(); if (button == WindowButtons.Close) { newButton.Text = "r"; } else if (button == WindowButtons.Minimize) { newButton.Text = "0"; } else if (button == WindowButtons.Maximize) { if (WindowState == FormWindowState.Normal) { newButton.Text = "1"; } else { newButton.Text = "2"; } } newButton.Style = Style; newButton.Theme = MetroThemeStyle.Dark; // Changed from default newButton.Tag = button; newButton.Size = new Size(25, 20); newButton.Anchor = AnchorStyles.None; // Changed from default, I set all anchors to none for now, just so I didn't have to worry about those messing with the display newButton.TabStop = false; newButton.Click += WindowButton_Click; Header.Controls.Add(newButton); // Changed to add the buttons on the header layer, instead of form1, as the header panel would cover the window buttons windowButtonList.Add(button, newButton); }
private void AddWindowButton(WindowButtons button) { if (_windowButtons[(int)button] != null) { throw new InvalidOperationException(); } MetroFormButton newButton = new MetroFormButton { Text = GetButtonText(button), Tag = button, Size = new Size(25, 20), Anchor = AnchorStyles.Top | AnchorStyles.Right }; newButton.Click += WindowButton_Click; Controls.Add(newButton); _windowButtons[(int)button] = newButton; }
private void AddWindowButton(WindowButtons button) { if (_windowButtons[(int)button] != null) { throw new InvalidOperationException(); } var btnPostion = new Point { Y = _borderWidth }; if ((int)button - 1 < 0) { btnPostion.X = Width - _borderWidth - WINBUTTON_WIDTH; } else { btnPostion.X = _windowButtons[(int)button - 1].Location.X - WINBUTTON_WIDTH; } var newButton = new MetroButton { Text = GetButtonText(button), Font = new Font("Webdings", 9.25f), Tag = button, Location = btnPostion, Size = new Size(WINBUTTON_WIDTH, WINBUTTON_WIDTH), BackColor = Color.White, Anchor = AnchorStyles.Top | AnchorStyles.Right }; if (button == WindowButtons.Close) { newButton.HoverColor = Color.FromArgb(0xe0, 0x43, 0x43); newButton.PressColor = Color.FromArgb(0x99, 0x3d, 0x3d); } newButton.Click += WindowButton_Click; Controls.Add(newButton); _windowButtons[(int)button] = newButton; }
public static TradeDialog Popup(DwarfGUI gui, GUIComponent parent, Faction faction, WindowButtons buttons = WindowButtons.CloseButton) { int w = gui.Graphics.Viewport.Width - 200; int h = gui.Graphics.Viewport.Height - 200; int x = gui.Graphics.Viewport.Width / 2 - w / 2; int y = gui.Graphics.Viewport.Height / 2 - h / 2; return Popup(gui, w, h, parent, x, y, buttons, faction); }
public static TradeDialog Popup(DwarfGUI gui, int w, int h, GUIComponent parent, int x, int y, WindowButtons buttons, Faction faction, List <ResourceAmount> resources) { TradeDialog d = new TradeDialog(gui, parent, faction, resources, buttons) { LocalBounds = new Rectangle(x, y, w, h), MinWidth = w, MinHeight = h, DrawOrder = 100, IsModal = true }; return(d); }
public static TradeDialog Popup(DwarfGUI gui, GUIComponent parent, Faction faction, List <ResourceAmount> resources, WindowButtons buttons = WindowButtons.CloseButton) { int w = gui.Graphics.Viewport.Width; int h = gui.Graphics.Viewport.Height; int x = 0; int y = 0; return(Popup(gui, w, h, parent, x, y, buttons, faction, resources)); }
public Dialog(DwarfGUI gui, GUIComponent parent, WindowButtons button = WindowButtons.NoButtons) : base(gui, parent, button) { }
private void AddWindowButton(WindowButtons button) { if (_windowButtons[(int)button] != null) throw new InvalidOperationException(); var btnPostion = new Point {Y = _borderWidth}; if ((int) button - 1 < 0) { btnPostion.X = Width - _borderWidth - WINBUTTON_WIDTH; } else { btnPostion.X = _windowButtons[(int) button - 1].Location.X - WINBUTTON_WIDTH; } var newButton = new MetroButton { Text = GetButtonText(button), Font = new Font("Webdings", 9.25f), Tag = button, Location = btnPostion, Size = new Size(WINBUTTON_WIDTH, WINBUTTON_WIDTH), BackColor = Color.White, Anchor = AnchorStyles.Top | AnchorStyles.Right }; if (button == WindowButtons.Close) { newButton.HoverColor = Color.FromArgb(0xe0, 0x43, 0x43); newButton.PressColor = Color.FromArgb(0x99, 0x3d, 0x3d); } newButton.Click += WindowButton_Click; Controls.Add(newButton); _windowButtons[(int)button] = newButton; }
private void AddWindowButton(WindowButtons button) { if (windowButtonList == null) windowButtonList = new Dictionary<WindowButtons, MetroFormButton>(); if (windowButtonList.ContainsKey(button)) return; MetroFormButton newButton = new MetroFormButton(); if (button == WindowButtons.Close) { newButton.Text = "r"; } else if (button == WindowButtons.Minimize) { newButton.Text = "0"; } else if (button == WindowButtons.Maximize) { if (WindowState == FormWindowState.Normal) newButton.Text = "1"; else newButton.Text = "2"; } newButton.BackColor = MetroColors.Brown; newButton.UseCustomBackColor = true; newButton.Style = Style; newButton.Theme = Theme; newButton.Tag = button; newButton.Size = new Size(25, 20); newButton.Anchor = AnchorStyles.Top | AnchorStyles.Right; newButton.TabStop = false; //remove the form controls from the tab stop newButton.Click += WindowButton_Click; Controls.Add(newButton); windowButtonList.Add(button, newButton); }
Dialog(DwarfGUI gui, GUIComponent parent, WindowButtons button = WindowButtons.NoButtons) : base(gui, parent, button) { }
private string GetButtonText(WindowButtons button) { switch (button) { case WindowButtons.Close: return "r"; case WindowButtons.Minimize: return "0"; case WindowButtons.Maximize: return WindowState == FormWindowState.Normal ? "1" : "2"; } throw new InvalidOperationException(); }
public static TradeDialog Popup(DwarfGUI gui, int w, int h, GUIComponent parent, int x, int y, WindowButtons buttons, Faction faction) { TradeDialog d = new TradeDialog(gui, parent, faction, buttons) { LocalBounds = new Rectangle(x, y, w, h), MinWidth = w - 150, MinHeight = h - 150, DrawOrder = 100, IsModal = true }; return d; }
private void AddWindowButton(WindowButtons button) { if (windowButtonList == null) windowButtonList = new Dictionary<WindowButtons, MetroFormButton>(); if (windowButtonList.ContainsKey(button)) return; MetroFormButton newButton = new MetroFormButton(); if (button == WindowButtons.Close) { newButton.Text = "r"; } else if (button == WindowButtons.Minimize) { newButton.Text = "0"; } else if (button == WindowButtons.Maximize) { if (WindowState == FormWindowState.Normal) newButton.Text = "1"; else newButton.Text = "2"; } newButton.Style = Style; newButton.Theme = Theme; newButton.Tag = button; newButton.Size = new Size(25, 20); newButton.Anchor = AnchorStyles.Top | AnchorStyles.Right; newButton.Click += WindowButton_Click; Controls.Add(newButton); windowButtonList.Add(button, newButton); }
public TradeDialog(DwarfGUI gui, GUIComponent parent, Faction otherFaction, WindowButtons buttons) : base(gui, parent,buttons) { TradePanel = new TradePanel(GUI, this, PlayState.PlayerFaction, otherFaction) { WidthSizeMode = SizeMode.Fit, HeightSizeMode = SizeMode.Fit }; TradePanel.OnTraded += TradePanel_OnTraded; }
/// <summary> /// Adds the window button. /// </summary> /// <param name="button">The button.</param> private void AddWindowButton(WindowButtons button) { if (windowButtonList.ContainsKey(button)) return; MetroFormButton newButton = new MetroFormButton(); if (button == WindowButtons.Close) { newButton.Text = "r"; } else if (button == WindowButtons.Minimize) { newButton.Text = "0"; } else if (button == WindowButtons.Maximize) { if (WindowState == FormWindowState.Normal) newButton.Text = "1"; else newButton.Text = "2"; } else if (button == WindowButtons.Pin) { newButton.Text = TopMost ? "=" : "ë"; } newButton.Style = Style; newButton.Theme = Theme; newButton.Tag = button; newButton.Size = new Size(25, 20); newButton.Anchor = AnchorStyles.Top | AnchorStyles.Right; newButton.TabStop = false; //remove the form controls from the tab stop newButton.Click += WindowButton_Click; Controls.Add(newButton); windowButtonList.Add(button, newButton); }
private void AddWindowButton(WindowButtons button) { if (_windowButtonList == null) _windowButtonList = new Dictionary<WindowButtons, YamuiFormButton>(); if (_windowButtonList.ContainsKey(button)) return; var newButton = new YamuiFormButton(); switch (button) { case WindowButtons.Close: newButton.Text = @"r"; _mainFormToolTip.SetToolTip(newButton, "<b>Close</b> this window"); break; case WindowButtons.Minimize: newButton.Text = @"0"; _mainFormToolTip.SetToolTip(newButton, "<b>Minimize</b> this window"); break; case WindowButtons.Maximize: newButton.Text = WindowState == FormWindowState.Normal ? @"1" : @"2"; _mainFormToolTip.SetToolTip(newButton, "<b>" + (WindowState == FormWindowState.Normal ? "Maximize" : "Restore") + "</b> this window"); break; case WindowButtons.CloseAllVisible: newButton.Text = ((char)(126)).ToString(); _mainFormToolTip.SetToolTip(newButton, "<b>Close all visible</b> notification windows"); break; } newButton.Tag = button; newButton.Size = new Size(25, 20); newButton.Anchor = AnchorStyles.Top | AnchorStyles.Right; newButton.TabStop = false; //remove the form controls from the tab stop newButton.Click += WindowButton_Click; Controls.Add(newButton); _windowButtonList.Add(button, newButton); }
private void AddWindowButton(WindowButtons button) { if (_windowButtons[(int)button] != null ) throw new InvalidOperationException(); MetroFormButton newButton = new MetroFormButton { Text = GetButtonText(button), Tag = button, Size = new Size(25, 20), Anchor = AnchorStyles.Top | AnchorStyles.Right }; newButton.Click += WindowButton_Click; Controls.Add(newButton); _windowButtons[(int)button] = newButton; }