void CreateButton(ICalibrationStepInfo info) { StatusImageButton button = new StatusImageButton(); button.Size = new Size(this.FlowPanel.Width - 10, 64); button.Text = info.Label; button.Tag = info; button.Image = info.Image(); button.OffImageType = eOffButtonType.NotSelected; button.Click += new EventHandler(Button_Click); FlowPanel.Controls.Add(button); _buttons.Add(button); }
void SetSelected(StatusImageButton button) { ICalibrationStepInfo info = button.Tag as ICalibrationStepInfo; if (info != null) { Control view = info.CreateControl(); foreach (StatusImageButton b in _buttons) { b.On = (b == button); } Viewer.SetCurrentView(view); } }
public void OnButtonClick(object sender, EventArgs e) { ViewControler controler = Controler; if (controler != null && !controler.Lock) { StatusImageButton ctrl = sender as StatusImageButton; if (ctrl != null && ctrl.Tag != null) { ViewType type = (ViewType)(ctrl.Tag); controler.ChangeView(type); AlignOnOff(); } } }
private void CreateButton(ViewType type, bool on = true) { int size = this.flowLayoutPanel1.Height; StatusImageButton button = new StatusImageButton(); this.flowLayoutPanel1.Controls.Add(button); button.Image = type.Bitmap(); button.Location = new System.Drawing.Point(0, 0); button.Name = type.ToString(); button.Tag = type; button.OffImageType = Sardauscan.Gui.Controls.eOffButtonType.NotSelected; button.On = on; button.Size = new System.Drawing.Size(size, size); button.Click += OnButtonClick; button.Margin = new Padding(0); this.ToolTip.SetToolTip(button, type.ToString()); flowLayoutPanel1.Width = size * flowLayoutPanel1.Controls.Count; flowLayoutPanel1.Height = size; }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LaserControl)); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.button1 = new Sardauscan.Gui.Controls.StatusImageButton(); this.button2 = new Sardauscan.Gui.Controls.StatusImageButton(); this.button3 = new Sardauscan.Gui.Controls.StatusImageButton(); this.RightButton = new Sardauscan.Gui.Controls.StatusImageButton(); this.tableLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // // tableLayoutPanel1 // this.tableLayoutPanel1.ColumnCount = 4; this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 27.27273F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 22.72727F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 22.72727F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 27.27273F)); this.tableLayoutPanel1.Controls.Add(this.button1, 0, 0); this.tableLayoutPanel1.Controls.Add(this.button2, 3, 0); this.tableLayoutPanel1.Controls.Add(this.button3, 1, 0); this.tableLayoutPanel1.Controls.Add(this.RightButton, 2, 0); this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.RowCount = 1; this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel1.Size = new System.Drawing.Size(239, 38); this.tableLayoutPanel1.TabIndex = 3; // // button1 // this.button1.BackColor = System.Drawing.Color.White; this.button1.Cursor = System.Windows.Forms.Cursors.Hand; this.button1.ForeColor = System.Drawing.SystemColors.ControlText; this.button1.Image = ((System.Drawing.Image)(resources.GetObject("button1.Image"))); this.button1.Location = new System.Drawing.Point(3, 3); this.button1.Name = "button1"; this.button1.OffImageType = Sardauscan.Gui.Controls.eOffButtonType.NotSelected; this.button1.On = true; this.button1.Size = new System.Drawing.Size(30, 32); this.button1.TabIndex = 0; this.button1.Tag = "0"; this.button1.Click += new System.EventHandler(this.button_Click); // // button2 // this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.button2.BackColor = System.Drawing.Color.White; this.button2.Cursor = System.Windows.Forms.Cursors.Hand; this.button2.ForeColor = System.Drawing.SystemColors.ControlText; this.button2.Image = ((System.Drawing.Image)(resources.GetObject("button2.Image"))); this.button2.Location = new System.Drawing.Point(206, 3); this.button2.Name = "button2"; this.button2.OffImageType = Sardauscan.Gui.Controls.eOffButtonType.NotSelected; this.button2.On = true; this.button2.Size = new System.Drawing.Size(30, 32); this.button2.TabIndex = 1; this.button2.Tag = "3"; this.button2.Click += new System.EventHandler(this.button_Click); // // button3 // this.button3.BackColor = System.Drawing.Color.White; this.button3.Cursor = System.Windows.Forms.Cursors.Hand; this.button3.ForeColor = System.Drawing.SystemColors.ControlText; this.button3.Image = ((System.Drawing.Image)(resources.GetObject("button3.Image"))); this.button3.Location = new System.Drawing.Point(68, 3); this.button3.Name = "button3"; this.button3.OffImageType = Sardauscan.Gui.Controls.eOffButtonType.NotSelected; this.button3.On = true; this.button3.Size = new System.Drawing.Size(30, 32); this.button3.TabIndex = 2; this.button3.Tag = "1"; this.button3.Click += new System.EventHandler(this.button_Click); // // RightButton // this.RightButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.RightButton.BackColor = System.Drawing.Color.White; this.RightButton.Cursor = System.Windows.Forms.Cursors.Hand; this.RightButton.ForeColor = System.Drawing.SystemColors.ControlText; this.RightButton.Image = ((System.Drawing.Image)(resources.GetObject("RightButton.Image"))); this.RightButton.Location = new System.Drawing.Point(140, 3); this.RightButton.Name = "RightButton"; this.RightButton.OffImageType = Sardauscan.Gui.Controls.eOffButtonType.NotSelected; this.RightButton.On = true; this.RightButton.Size = new System.Drawing.Size(30, 32); this.RightButton.TabIndex = 0; this.RightButton.Tag = "2"; this.RightButton.Click += new System.EventHandler(this.button_Click); // // LaserControl // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.Controls.Add(this.tableLayoutPanel1); this.Name = "LaserControl"; this.Size = new System.Drawing.Size(239, 38); this.tableLayoutPanel1.ResumeLayout(false); this.ResumeLayout(false); }