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; }
/// <summary> /// Initializes this instance. /// </summary> private void Initialize() { // Set size of control. A icon is 48x48 px Size = new Size(240, 48); var img = new Image[] { Properties.Resources.Line, Properties.Resources.Triangle, Properties.Resources.Quad, Properties.Resources.Polygon, Properties.Resources.Ellipse }; var command = new[] { new DrawPadTools.CommandObject(DrawPadTools.DrawPadCommand.DrawShape, new Core.Line()), new DrawPadTools.CommandObject(DrawPadTools.DrawPadCommand.DrawShape, new Core.IsoscelesTriangle()), new DrawPadTools.CommandObject(DrawPadTools.DrawPadCommand.DrawShape, new Core.Oblong()), new DrawPadTools.CommandObject(DrawPadTools.DrawPadCommand.DrawShape, new Core.Polygon {DrawMethod = Core.DrawMethod.ByClick}), new DrawPadTools.CommandObject(DrawPadTools.DrawPadCommand.DrawShape, new Core.Ellipse()) }; // Initialize control _lytMain = new TableLayoutPanel(); _btnTools = new MetroButton[5]; // have 6 tools _lytMain.SuspendLayout(); SuspendLayout(); // // btnTools // for (int i = 0; i < 5; i++) { _btnTools[i] = new MetroButton { Dock = DockStyle.Fill, HoverColor = Color.FromArgb(230, 230, 230), PressColor = Color.FromArgb(77, 77, 77), Image = img[i], Location = new Point(3, 3), Size = new Size(42, 42), TabIndex = i, Text = String.Format("Tool{0}", i), Name = String.Format("btnTool{0}", i), Tag = command[i], UseVisualStyleBackColor = true }; _btnTools[i].Click += Tools_Click; } // // lytMain // _lytMain.ColumnCount = 5; for (int i = 0; i < 5; i++) { _lytMain.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 48F)); _lytMain.Controls.Add(_btnTools[i], i, 0); } _lytMain.RowCount = 1; _lytMain.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); _lytMain.Dock = DockStyle.Fill; _lytMain.Margin = new Padding(0); _lytMain.Location = new Point(2, 2); _lytMain.Size = new Size(240, 48); _lytMain.TabIndex = 3; _lytMain.Name = "lytMain"; // // This Control // BackColor = Color.White; Controls.Add(_lytMain); _lytMain.ResumeLayout(false); ResumeLayout(false); }
public LayerControl() { _btnRemove = new MetroButton(); _btnDown = new MetroButton(); _btnUp = new MetroButton(); SuspendLayout(); _btnRemove.Name = "_btnRemove"; _btnRemove.Size = new Size(60, 40); _btnRemove.Location = new Point(0, 0); _btnRemove.TabIndex = 1; _btnRemove.Image = Properties.Resources.Remove; _btnRemove.Tag = LayerCommand.Remove; _btnRemove.Click += Button_Click; _btnUp.Size = new Size(60, 40); _btnUp.Location = new Point(60, 0); _btnUp.Image = Properties.Resources.Up; _btnUp.Tag = LayerCommand.Up; _btnUp.Click += Button_Click; _btnDown.Size = new Size(60, 40); _btnDown.Location = new Point(120, 0); _btnDown.Image = Properties.Resources.Down; _btnDown.Tag = LayerCommand.Down; _btnDown.Click += Button_Click; Controls.Add(_btnRemove); Controls.Add(_btnUp); Controls.Add(_btnDown); base.BackColor = Color.White; Size = new Size(180, 40); ResumeLayout(false); }
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; }