frmInitializeLengthAndWidthRectangle.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
  11. {
  12. public partial class frmInitializeLengthAndWidthRectangle : Form
  13. {
  14. public double length { get; set;}
  15. public double width { get; set; }
  16. public frmInitializeLengthAndWidthRectangle()
  17. {
  18. InitializeComponent();
  19. }
  20. private void btn_ok_Click(object sender, EventArgs e)
  21. {
  22. double dlength = 0;double dwidth = 0;
  23. if(double.TryParse(tB_length.Text,out dlength)&& double.TryParse(tB_width.Text, out dwidth))
  24. {
  25. length = dlength;
  26. width = dwidth;
  27. }
  28. else
  29. {
  30. MessageBox.Show("Please enter the correct numeric format!");
  31. this.DialogResult= DialogResult.None;
  32. return;
  33. }
  34. this.DialogResult = DialogResult.OK;
  35. }
  36. private void btn_cannel_Click(object sender, EventArgs e)
  37. {
  38. this.DialogResult = DialogResult.Cancel;
  39. this.Close();
  40. }
  41. }
  42. }