public form_Main() { InitializeComponent(); this.pictureBox1.Controls.AddRange( new Control[] { this.vScrollBar1, this.hScrollBar1 }); foreach (string name in Enum.GetNames(typeof(Unit.UnitOfMeasurement))) { combo_Units.Items.Add(name); combo_CalibrateUnits.Items.Add(name); } combo_Units.SelectedIndex = 0; combo_CalibrateUnits.SelectedIndex = 0; this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); toolStrip_Calibrate.Visible = false; Annotation.Scale = scale; Unit.Scale = scale; ButtonStates.RestoreState(toolStrip1); }
private void Form1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { // abort if (select) { button_Select.Checked = false; select = false; ButtonStates.RestoreState(toolStrip1); } if (calibrationMode) { button_Calibrate.Checked = false; calibrationMode = false; ButtonStates.RestoreState(toolStrip1); } if (lengthMode) { button_Length.Checked = false; lengthMode = false; ButtonStates.RestoreState(toolStrip1); } if (areaMode) { button_Area.Checked = false; areaMode = false; ButtonStates.RestoreState(toolStrip1); } pictureBox1.Invalidate(); } }
private void button_Select_Click(object sender, EventArgs e) { if (button_Select.Checked == true) { ButtonStates.SetState(toolStrip1, sender); select = true; } else { ButtonStates.RestoreState(toolStrip1); select = false; selectPt = new Point(-1, -1); pb.UnwireControl(); for (int i = 0; i < pictureBox1.Controls.Count; i++) { Control control = pictureBox1.Controls[i]; foreach (Annotation annotation in annotations) { // annotation.Unwire(); if (control.Tag != null) { if (annotation.Tag == (int)control.Tag) { annotation.Update(control); } } } // pictureBox1.Controls.Remove(control); } while (pictureBox1.Controls.Count > 0) { pictureBox1.Controls.Remove(pictureBox1.Controls[0]); } foreach (Annotation annotation in annotations) { annotation.Unwire(); } // pictureBox1.Focus(); pictureBox1.Invalidate(); } }
private void button_CalibrateYes_Click(object sender, EventArgs e) { toolStrip_Calibrate.Visible = false; Length l = new Length(distance, scale); Length.Calibrate(l.RawValue(), double.Parse(label_CalibrateValue.Text), (Unit.UnitOfMeasurement)combo_CalibrateUnits.SelectedIndex); // Length.Calibrate(distance, double.Parse(label_CalibrateValue.Text), (Unit.UnitOfMeasurement)combo_CalibrateUnits.SelectedIndex); Area.Calibrate(l.RawValue(), double.Parse(label_CalibrateValue.Text), (Unit.UnitOfMeasurement)combo_CalibrateUnits.SelectedIndex); //string s = l.Text((Unit.UnitOfMeasurement)combo_CalibrateUnits.SelectedIndex); button_Calibrate.Checked = false; ButtonStates.RestoreState(toolStrip1); }
private void button_Area_Click(object sender, EventArgs e) { if (button_Area.Checked == true) { areaMode = true; start = new Point(-1, -1); end = new Point(-1, -1); ButtonStates.SetState(toolStrip1, sender); } else { areaMode = false; ButtonStates.RestoreState(toolStrip1);//, sender); } }
private void button_Calibrate_Click(object sender, EventArgs e) { if (button_Calibrate.Checked == true) { calibrationMode = true; ButtonStates.SetState(toolStrip1, sender); start = new Point(-1, -1); end = new Point(-1, -1); } else { calibrationMode = false; ButtonStates.RestoreState(toolStrip1);//, sender); } }
private void button_CalibrateNo_Click(object sender, EventArgs e) { ButtonStates.RestoreState(toolStrip1);//, sender); }