Просмотр исходного кода

Optimize the two-point method for drawing rectangles

cxs 1 месяц назад
Родитель
Сommit
9d06526cf4

+ 10 - 6
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSamplespaceWindow.cs

@@ -467,11 +467,7 @@ namespace OTSMeasureApp
                 newGDI.SetDisplayRefPoint(m_visualStage.GetDisplayRefPoint());
 
                 newGDI.IsWorkSample = true;
-
-
                 sam.SetMeasureGDIObject(newGDI);
-
-
                 m_DrawPolygonFinishGDIObject = null;
                 m_DrawMeasureGDIObject = null;
 
@@ -479,13 +475,21 @@ namespace OTSMeasureApp
 
                 SetWorkSampleMeasureArea(para);
 
-
+                if(frmInput.IsInclinedPlaneFocus) m_MeasureAppForm.m_ProjParam.GetWorkSample().GetMsrParams().SlopParam = frmInput.GetCSlopFocusParam();
             }
+        }
+
+
+
+
+
+
+
+
 
 
 
 
-        }
         public void SetWorkSampleMeasureArea(SampleMeasurePara SMeasurePara)
         {
 

+ 277 - 35
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/frmInitializeTwoPointRectangle.Designer.cs

@@ -29,14 +29,18 @@
         private void InitializeComponent()
         {
             this.groupBox1 = new System.Windows.Forms.GroupBox();
-            this.btnwrite1 = new System.Windows.Forms.Button();
+            this.tB_LTPointWD = new System.Windows.Forms.TextBox();
+            this.label8 = new System.Windows.Forms.Label();
+            this.btn_gtLTPoint = new System.Windows.Forms.Button();
             this.bn_FirstPoint = new System.Windows.Forms.Button();
             this.label2 = new System.Windows.Forms.Label();
             this.tB_LTPointX = new System.Windows.Forms.TextBox();
             this.label3 = new System.Windows.Forms.Label();
             this.tB_LTPointY = new System.Windows.Forms.TextBox();
             this.groupBox2 = new System.Windows.Forms.GroupBox();
-            this.btnwrite2 = new System.Windows.Forms.Button();
+            this.tBx_RBPointWD = new System.Windows.Forms.TextBox();
+            this.label7 = new System.Windows.Forms.Label();
+            this.btn_gtRBPoint = new System.Windows.Forms.Button();
             this.tB_RBPointY = new System.Windows.Forms.TextBox();
             this.label5 = new System.Windows.Forms.Label();
             this.tB_RBPointX = new System.Windows.Forms.TextBox();
@@ -44,40 +48,78 @@
             this.bn_SecondPoint = new System.Windows.Forms.Button();
             this.bn_Cancel = new System.Windows.Forms.Button();
             this.bn_OK = new System.Windows.Forms.Button();
+            this.panel1 = new System.Windows.Forms.Panel();
+            this.panel2 = new System.Windows.Forms.Panel();
+            this.panel3 = new System.Windows.Forms.Panel();
+            this.tBx_Magnification = new System.Windows.Forms.TextBox();
+            this.label10 = new System.Windows.Forms.Label();
+            this.cB_Inclinedplanefocus = new System.Windows.Forms.CheckBox();
+            this.groupBox3 = new System.Windows.Forms.GroupBox();
+            this.tBx_TheThirdPointWD = new System.Windows.Forms.TextBox();
+            this.label9 = new System.Windows.Forms.Label();
+            this.btn_gtTheThirdPoint = new System.Windows.Forms.Button();
+            this.bn_TheThirdPoint = new System.Windows.Forms.Button();
+            this.label1 = new System.Windows.Forms.Label();
+            this.tBx_TheThirdPointX = new System.Windows.Forms.TextBox();
+            this.label6 = new System.Windows.Forms.Label();
+            this.tBx_TheThirdPointY = new System.Windows.Forms.TextBox();
             this.groupBox1.SuspendLayout();
             this.groupBox2.SuspendLayout();
+            this.panel3.SuspendLayout();
+            this.groupBox3.SuspendLayout();
             this.SuspendLayout();
             // 
             // groupBox1
             // 
-            this.groupBox1.Controls.Add(this.btnwrite1);
+            this.groupBox1.Controls.Add(this.tB_LTPointWD);
+            this.groupBox1.Controls.Add(this.label8);
+            this.groupBox1.Controls.Add(this.btn_gtLTPoint);
             this.groupBox1.Controls.Add(this.bn_FirstPoint);
             this.groupBox1.Controls.Add(this.label2);
             this.groupBox1.Controls.Add(this.tB_LTPointX);
             this.groupBox1.Controls.Add(this.label3);
             this.groupBox1.Controls.Add(this.tB_LTPointY);
-            this.groupBox1.Location = new System.Drawing.Point(36, 49);
+            this.groupBox1.Location = new System.Drawing.Point(13, 13);
             this.groupBox1.Margin = new System.Windows.Forms.Padding(2);
             this.groupBox1.Name = "groupBox1";
             this.groupBox1.Padding = new System.Windows.Forms.Padding(2);
-            this.groupBox1.Size = new System.Drawing.Size(449, 71);
+            this.groupBox1.Size = new System.Drawing.Size(572, 84);
             this.groupBox1.TabIndex = 20;
             this.groupBox1.TabStop = false;
             this.groupBox1.Text = "LeftTopPoint";
             // 
-            // btnwrite1
+            // tB_LTPointWD
             // 
-            this.btnwrite1.Location = new System.Drawing.Point(365, 32);
-            this.btnwrite1.Name = "btnwrite1";
-            this.btnwrite1.Size = new System.Drawing.Size(65, 19);
-            this.btnwrite1.TabIndex = 7;
-            this.btnwrite1.Text = "Write";
-            this.btnwrite1.UseVisualStyleBackColor = true;
-            this.btnwrite1.Click += new System.EventHandler(this.button1_Click);
+            this.tB_LTPointWD.Location = new System.Drawing.Point(291, 30);
+            this.tB_LTPointWD.Margin = new System.Windows.Forms.Padding(2);
+            this.tB_LTPointWD.Name = "tB_LTPointWD";
+            this.tB_LTPointWD.ReadOnly = true;
+            this.tB_LTPointWD.Size = new System.Drawing.Size(83, 21);
+            this.tB_LTPointWD.TabIndex = 10;
+            // 
+            // label8
+            // 
+            this.label8.AutoSize = true;
+            this.label8.Location = new System.Drawing.Point(263, 33);
+            this.label8.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+            this.label8.Name = "label8";
+            this.label8.Size = new System.Drawing.Size(23, 12);
+            this.label8.TabIndex = 9;
+            this.label8.Text = "WD:";
+            // 
+            // btn_gtLTPoint
+            // 
+            this.btn_gtLTPoint.Location = new System.Drawing.Point(478, 30);
+            this.btn_gtLTPoint.Name = "btn_gtLTPoint";
+            this.btn_gtLTPoint.Size = new System.Drawing.Size(65, 19);
+            this.btn_gtLTPoint.TabIndex = 7;
+            this.btn_gtLTPoint.Text = "Goto";
+            this.btn_gtLTPoint.UseVisualStyleBackColor = true;
+            this.btn_gtLTPoint.Click += new System.EventHandler(this.button1_Click);
             // 
             // bn_FirstPoint
             // 
-            this.bn_FirstPoint.Location = new System.Drawing.Point(281, 32);
+            this.bn_FirstPoint.Location = new System.Drawing.Point(394, 30);
             this.bn_FirstPoint.Margin = new System.Windows.Forms.Padding(2);
             this.bn_FirstPoint.Name = "bn_FirstPoint";
             this.bn_FirstPoint.Size = new System.Drawing.Size(72, 20);
@@ -124,30 +166,51 @@
             // 
             // groupBox2
             // 
-            this.groupBox2.Controls.Add(this.btnwrite2);
+            this.groupBox2.Controls.Add(this.tBx_RBPointWD);
+            this.groupBox2.Controls.Add(this.label7);
+            this.groupBox2.Controls.Add(this.btn_gtRBPoint);
             this.groupBox2.Controls.Add(this.tB_RBPointY);
             this.groupBox2.Controls.Add(this.label5);
             this.groupBox2.Controls.Add(this.tB_RBPointX);
             this.groupBox2.Controls.Add(this.label4);
             this.groupBox2.Controls.Add(this.bn_SecondPoint);
-            this.groupBox2.Location = new System.Drawing.Point(36, 164);
+            this.groupBox2.Location = new System.Drawing.Point(13, 123);
             this.groupBox2.Margin = new System.Windows.Forms.Padding(2);
             this.groupBox2.Name = "groupBox2";
             this.groupBox2.Padding = new System.Windows.Forms.Padding(2);
-            this.groupBox2.Size = new System.Drawing.Size(449, 76);
+            this.groupBox2.Size = new System.Drawing.Size(572, 76);
             this.groupBox2.TabIndex = 21;
             this.groupBox2.TabStop = false;
             this.groupBox2.Text = "RightBottomPoint";
             // 
-            // btnwrite2
+            // tBx_RBPointWD
+            // 
+            this.tBx_RBPointWD.Location = new System.Drawing.Point(291, 31);
+            this.tBx_RBPointWD.Margin = new System.Windows.Forms.Padding(2);
+            this.tBx_RBPointWD.Name = "tBx_RBPointWD";
+            this.tBx_RBPointWD.ReadOnly = true;
+            this.tBx_RBPointWD.Size = new System.Drawing.Size(83, 21);
+            this.tBx_RBPointWD.TabIndex = 15;
             // 
-            this.btnwrite2.Location = new System.Drawing.Point(362, 31);
-            this.btnwrite2.Name = "btnwrite2";
-            this.btnwrite2.Size = new System.Drawing.Size(67, 19);
-            this.btnwrite2.TabIndex = 13;
-            this.btnwrite2.Text = "Write";
-            this.btnwrite2.UseVisualStyleBackColor = true;
-            this.btnwrite2.Click += new System.EventHandler(this.button2_Click);
+            // label7
+            // 
+            this.label7.AutoSize = true;
+            this.label7.Location = new System.Drawing.Point(263, 34);
+            this.label7.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+            this.label7.Name = "label7";
+            this.label7.Size = new System.Drawing.Size(23, 12);
+            this.label7.TabIndex = 14;
+            this.label7.Text = "WD:";
+            // 
+            // btn_gtRBPoint
+            // 
+            this.btn_gtRBPoint.Location = new System.Drawing.Point(478, 34);
+            this.btn_gtRBPoint.Name = "btn_gtRBPoint";
+            this.btn_gtRBPoint.Size = new System.Drawing.Size(67, 19);
+            this.btn_gtRBPoint.TabIndex = 13;
+            this.btn_gtRBPoint.Text = "Goto";
+            this.btn_gtRBPoint.UseVisualStyleBackColor = true;
+            this.btn_gtRBPoint.Click += new System.EventHandler(this.button2_Click);
             // 
             // tB_RBPointY
             // 
@@ -187,7 +250,7 @@
             // 
             // bn_SecondPoint
             // 
-            this.bn_SecondPoint.Location = new System.Drawing.Point(281, 29);
+            this.bn_SecondPoint.Location = new System.Drawing.Point(397, 32);
             this.bn_SecondPoint.Margin = new System.Windows.Forms.Padding(2);
             this.bn_SecondPoint.Name = "bn_SecondPoint";
             this.bn_SecondPoint.Size = new System.Drawing.Size(72, 20);
@@ -199,7 +262,7 @@
             // bn_Cancel
             // 
             this.bn_Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
-            this.bn_Cancel.Location = new System.Drawing.Point(255, 281);
+            this.bn_Cancel.Location = new System.Drawing.Point(517, 595);
             this.bn_Cancel.Margin = new System.Windows.Forms.Padding(2);
             this.bn_Cancel.Name = "bn_Cancel";
             this.bn_Cancel.Size = new System.Drawing.Size(68, 26);
@@ -211,7 +274,7 @@
             // bn_OK
             // 
             this.bn_OK.DialogResult = System.Windows.Forms.DialogResult.OK;
-            this.bn_OK.Location = new System.Drawing.Point(158, 281);
+            this.bn_OK.Location = new System.Drawing.Point(420, 595);
             this.bn_OK.Margin = new System.Windows.Forms.Padding(2);
             this.bn_OK.Name = "bn_OK";
             this.bn_OK.Size = new System.Drawing.Size(73, 26);
@@ -220,16 +283,172 @@
             this.bn_OK.UseVisualStyleBackColor = true;
             this.bn_OK.Click += new System.EventHandler(this.bn_OK_Click);
             // 
+            // panel1
+            // 
+            this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+            this.panel1.Location = new System.Drawing.Point(13, 11);
+            this.panel1.Name = "panel1";
+            this.panel1.Size = new System.Drawing.Size(461, 475);
+            this.panel1.TabIndex = 24;
+            // 
+            // panel2
+            // 
+            this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+            this.panel2.Location = new System.Drawing.Point(12, 483);
+            this.panel2.Name = "panel2";
+            this.panel2.Size = new System.Drawing.Size(462, 165);
+            this.panel2.TabIndex = 25;
+            // 
+            // panel3
+            // 
+            this.panel3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+            this.panel3.Controls.Add(this.tBx_Magnification);
+            this.panel3.Controls.Add(this.label10);
+            this.panel3.Controls.Add(this.cB_Inclinedplanefocus);
+            this.panel3.Controls.Add(this.bn_Cancel);
+            this.panel3.Controls.Add(this.bn_OK);
+            this.panel3.Controls.Add(this.groupBox3);
+            this.panel3.Controls.Add(this.groupBox2);
+            this.panel3.Controls.Add(this.groupBox1);
+            this.panel3.Location = new System.Drawing.Point(481, 11);
+            this.panel3.Name = "panel3";
+            this.panel3.Size = new System.Drawing.Size(598, 637);
+            this.panel3.TabIndex = 26;
+            // 
+            // tBx_Magnification
+            // 
+            this.tBx_Magnification.Location = new System.Drawing.Point(108, 386);
+            this.tBx_Magnification.Name = "tBx_Magnification";
+            this.tBx_Magnification.Size = new System.Drawing.Size(100, 21);
+            this.tBx_Magnification.TabIndex = 26;
+            // 
+            // label10
+            // 
+            this.label10.AutoSize = true;
+            this.label10.Location = new System.Drawing.Point(13, 389);
+            this.label10.Name = "label10";
+            this.label10.Size = new System.Drawing.Size(89, 12);
+            this.label10.TabIndex = 25;
+            this.label10.Text = "Magnification:";
+            // 
+            // cB_Inclinedplanefocus
+            // 
+            this.cB_Inclinedplanefocus.AutoSize = true;
+            this.cB_Inclinedplanefocus.Location = new System.Drawing.Point(13, 341);
+            this.cB_Inclinedplanefocus.Name = "cB_Inclinedplanefocus";
+            this.cB_Inclinedplanefocus.Size = new System.Drawing.Size(144, 16);
+            this.cB_Inclinedplanefocus.TabIndex = 24;
+            this.cB_Inclinedplanefocus.Text = "Inclined plane focus";
+            this.cB_Inclinedplanefocus.UseVisualStyleBackColor = true;
+            this.cB_Inclinedplanefocus.CheckedChanged += new System.EventHandler(this.cB_Inclinedplanefocus_CheckedChanged);
+            // 
+            // groupBox3
+            // 
+            this.groupBox3.Controls.Add(this.tBx_TheThirdPointWD);
+            this.groupBox3.Controls.Add(this.label9);
+            this.groupBox3.Controls.Add(this.btn_gtTheThirdPoint);
+            this.groupBox3.Controls.Add(this.bn_TheThirdPoint);
+            this.groupBox3.Controls.Add(this.label1);
+            this.groupBox3.Controls.Add(this.tBx_TheThirdPointX);
+            this.groupBox3.Controls.Add(this.label6);
+            this.groupBox3.Controls.Add(this.tBx_TheThirdPointY);
+            this.groupBox3.Location = new System.Drawing.Point(13, 228);
+            this.groupBox3.Margin = new System.Windows.Forms.Padding(2);
+            this.groupBox3.Name = "groupBox3";
+            this.groupBox3.Padding = new System.Windows.Forms.Padding(2);
+            this.groupBox3.Size = new System.Drawing.Size(572, 84);
+            this.groupBox3.TabIndex = 22;
+            this.groupBox3.TabStop = false;
+            this.groupBox3.Text = "LeftTopPoint";
+            // 
+            // tBx_TheThirdPointWD
+            // 
+            this.tBx_TheThirdPointWD.Location = new System.Drawing.Point(291, 30);
+            this.tBx_TheThirdPointWD.Margin = new System.Windows.Forms.Padding(2);
+            this.tBx_TheThirdPointWD.Name = "tBx_TheThirdPointWD";
+            this.tBx_TheThirdPointWD.ReadOnly = true;
+            this.tBx_TheThirdPointWD.Size = new System.Drawing.Size(83, 21);
+            this.tBx_TheThirdPointWD.TabIndex = 17;
+            // 
+            // label9
+            // 
+            this.label9.AutoSize = true;
+            this.label9.Location = new System.Drawing.Point(263, 33);
+            this.label9.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+            this.label9.Name = "label9";
+            this.label9.Size = new System.Drawing.Size(23, 12);
+            this.label9.TabIndex = 16;
+            this.label9.Text = "WD:";
+            // 
+            // btn_gtTheThirdPoint
+            // 
+            this.btn_gtTheThirdPoint.Location = new System.Drawing.Point(478, 29);
+            this.btn_gtTheThirdPoint.Name = "btn_gtTheThirdPoint";
+            this.btn_gtTheThirdPoint.Size = new System.Drawing.Size(65, 19);
+            this.btn_gtTheThirdPoint.TabIndex = 7;
+            this.btn_gtTheThirdPoint.Text = "Goto";
+            this.btn_gtTheThirdPoint.UseVisualStyleBackColor = true;
+            this.btn_gtTheThirdPoint.Click += new System.EventHandler(this.btn_gtTheThirdPoint_Click);
+            // 
+            // bn_TheThirdPoint
+            // 
+            this.bn_TheThirdPoint.Location = new System.Drawing.Point(394, 29);
+            this.bn_TheThirdPoint.Margin = new System.Windows.Forms.Padding(2);
+            this.bn_TheThirdPoint.Name = "bn_TheThirdPoint";
+            this.bn_TheThirdPoint.Size = new System.Drawing.Size(72, 20);
+            this.bn_TheThirdPoint.TabIndex = 6;
+            this.bn_TheThirdPoint.Text = "Obtain";
+            this.bn_TheThirdPoint.UseVisualStyleBackColor = true;
+            this.bn_TheThirdPoint.Click += new System.EventHandler(this.bn_TheThirdPoint_Click_1);
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Location = new System.Drawing.Point(24, 32);
+            this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(17, 12);
+            this.label1.TabIndex = 2;
+            this.label1.Text = "X:";
+            // 
+            // tBx_TheThirdPointX
+            // 
+            this.tBx_TheThirdPointX.Location = new System.Drawing.Point(51, 30);
+            this.tBx_TheThirdPointX.Margin = new System.Windows.Forms.Padding(2);
+            this.tBx_TheThirdPointX.Name = "tBx_TheThirdPointX";
+            this.tBx_TheThirdPointX.Size = new System.Drawing.Size(76, 21);
+            this.tBx_TheThirdPointX.TabIndex = 3;
+            // 
+            // label6
+            // 
+            this.label6.AutoSize = true;
+            this.label6.Location = new System.Drawing.Point(147, 32);
+            this.label6.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+            this.label6.Name = "label6";
+            this.label6.Size = new System.Drawing.Size(17, 12);
+            this.label6.TabIndex = 4;
+            this.label6.Text = "Y:";
+            // 
+            // tBx_TheThirdPointY
+            // 
+            this.tBx_TheThirdPointY.Location = new System.Drawing.Point(174, 30);
+            this.tBx_TheThirdPointY.Margin = new System.Windows.Forms.Padding(2);
+            this.tBx_TheThirdPointY.Name = "tBx_TheThirdPointY";
+            this.tBx_TheThirdPointY.Size = new System.Drawing.Size(76, 21);
+            this.tBx_TheThirdPointY.TabIndex = 5;
+            // 
             // frmInitializeTwoPointRectangle
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(500, 341);
-            this.Controls.Add(this.bn_Cancel);
-            this.Controls.Add(this.bn_OK);
-            this.Controls.Add(this.groupBox2);
-            this.Controls.Add(this.groupBox1);
+            this.ClientSize = new System.Drawing.Size(1091, 656);
+            this.Controls.Add(this.panel3);
+            this.Controls.Add(this.panel2);
+            this.Controls.Add(this.panel1);
+            this.MaximumSize = new System.Drawing.Size(1107, 695);
+            this.MinimumSize = new System.Drawing.Size(1107, 695);
             this.Name = "frmInitializeTwoPointRectangle";
+            this.ShowIcon = false;
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
             this.Text = "TwoPointRectangle";
             this.Load += new System.EventHandler(this.frmInitializeTwoPointRectangle_Load);
@@ -237,6 +456,10 @@
             this.groupBox1.PerformLayout();
             this.groupBox2.ResumeLayout(false);
             this.groupBox2.PerformLayout();
+            this.panel3.ResumeLayout(false);
+            this.panel3.PerformLayout();
+            this.groupBox3.ResumeLayout(false);
+            this.groupBox3.PerformLayout();
             this.ResumeLayout(false);
 
         }
@@ -257,7 +480,26 @@
         private System.Windows.Forms.Button bn_SecondPoint;
         private System.Windows.Forms.Button bn_Cancel;
         private System.Windows.Forms.Button bn_OK;
-        private System.Windows.Forms.Button btnwrite1;
-        private System.Windows.Forms.Button btnwrite2;
+        private System.Windows.Forms.Button btn_gtLTPoint;
+        private System.Windows.Forms.Button btn_gtRBPoint;
+        private System.Windows.Forms.Panel panel1;
+        private System.Windows.Forms.Panel panel2;
+        private System.Windows.Forms.Panel panel3;
+        private System.Windows.Forms.GroupBox groupBox3;
+        private System.Windows.Forms.Button btn_gtTheThirdPoint;
+        private System.Windows.Forms.Button bn_TheThirdPoint;
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.TextBox tBx_TheThirdPointX;
+        private System.Windows.Forms.Label label6;
+        private System.Windows.Forms.TextBox tBx_TheThirdPointY;
+        private System.Windows.Forms.TextBox tB_LTPointWD;
+        private System.Windows.Forms.Label label8;
+        private System.Windows.Forms.TextBox tBx_RBPointWD;
+        private System.Windows.Forms.Label label7;
+        private System.Windows.Forms.TextBox tBx_TheThirdPointWD;
+        private System.Windows.Forms.Label label9;
+        private System.Windows.Forms.CheckBox cB_Inclinedplanefocus;
+        private System.Windows.Forms.TextBox tBx_Magnification;
+        private System.Windows.Forms.Label label10;
     }
 }

+ 132 - 24
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/frmInitializeTwoPointRectangle.cs

@@ -1,13 +1,8 @@
-using OTSModelSharp.ServiceCenter;
+using OTSMeasureApp._0_OTSModel.OTSDataType;
+using OTSModelSharp.ServiceCenter;
 using System;
 using System.Collections;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
 using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 using System.Windows.Forms;
 
 namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
@@ -17,17 +12,23 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         ISemController cfun;
         public PointF LTPoint;
         public PointF RBPoint;
+        public PointF TheThirdPoint;
         public bool IsOK = false;
+        public bool IsInclinedPlaneFocus = false;
+
 
         OTSCommon.Language lan;
         Hashtable table;
+
+        CSlopFocusParam slopFocusParam;
+
+
         public frmInitializeTwoPointRectangle()
         {
             InitializeComponent();
             lan = new OTSCommon.Language(this);
             table = lan.GetNameTable(this.Name);
         }
-
         private void bn_FirstPoint_Click(object sender, EventArgs e)
         {
             double Px = 0;
@@ -37,56 +38,163 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             {
                 tB_LTPointX.Text = Px.ToString();
                 tB_LTPointY.Text = Py.ToString();
-
-
                 LTPoint = new PointF((float)Px, (float)Py);
             }
+            double WD = 0;
+            if (cfun.GetWorkingDistance(ref WD))
+            {
+                tB_LTPointWD.Text = WD.ToString();
+            }
         }
-
         private void bn_SecondPoint_Click(object sender, EventArgs e)
         {
             double Px = 0;
             double Py = 0;
             double Pr = 0;
-
             if (cfun.GetSemPositionXY(ref Px, ref Py, ref Pr))
             {
                 tB_RBPointX.Text = Px.ToString();
                 tB_RBPointY.Text = Py.ToString();
                 RBPoint = new PointF((float)Px, (float)Py);
             }
+            double WD = 0;
+            if (cfun.GetWorkingDistance(ref WD))
+            {
+                tB_RBPointX.Text = WD.ToString();
+            }
         }
-
         private void frmInitializeTwoPointRectangle_Load(object sender, EventArgs e)
         {
-            if (cfun == null)
+            if (cfun == null){cfun = SemController.GetSEMController();}
+            cB_Inclinedplanefocus.Checked=true;double val=0;
+            if(cfun.GetMagnification(ref val)) tBx_Magnification.Text=val.ToString();
+        }
+        private void button1_Click(object sender, EventArgs e)
+        {
+            if (tB_LTPointWD.Text == "")
             {
-                cfun = SemController.GetSEMController();
+                MessageBox.Show("Please  read first!");
+                return;
             }
+            double Px = Convert.ToDouble(tB_LTPointX.Text);
+            double Py = Convert.ToDouble(tB_LTPointY.Text);
+            double wd = Convert.ToDouble(tB_LTPointWD.Text);
+            if (cfun.MoveSEMToPoint(Px, Py)) cfun.SetWorkingDistance(wd);
         }
 
+
+
+
+
+        private void button2_Click(object sender, EventArgs e)
+        {
+            if (tBx_RBPointWD.Text == "")
+            {
+                MessageBox.Show("Please  read first!");
+                return;
+            }
+            double Px = Convert.ToDouble(tB_RBPointX.Text);
+            double Py = Convert.ToDouble(tB_RBPointY.Text);
+            double wd = Convert.ToDouble(tBx_RBPointWD.Text);
+            if (cfun.MoveSEMToPoint(Px, Py))
+            {
+                cfun.SetWorkingDistance(wd);
+            }
+        }
+        private void bn_TheThirdPoint_Click_1(object sender, EventArgs e)
+        {
+            double Px = 0;
+            double Py = 0;
+            double Pr = 0;
+            if (cfun.GetSemPositionXY(ref Px, ref Py, ref Pr))
+            {
+                tBx_TheThirdPointX.Text = Px.ToString();
+                tBx_TheThirdPointY.Text = Py.ToString();
+                TheThirdPoint = new PointF((float)Px, (float)Py);
+            }
+            double WD = 0;
+            if (cfun.GetWorkingDistance(ref WD))
+            {
+                tBx_TheThirdPointWD.Text = WD.ToString();
+            }
+        }
+        private void btn_gtTheThirdPoint_Click(object sender, EventArgs e)
+        {
+            if (tBx_TheThirdPointWD.Text == "")
+            {
+                MessageBox.Show("Please  read first!");
+                return;
+            }
+            double Px = Convert.ToDouble(tBx_TheThirdPointX.Text);
+            double Py = Convert.ToDouble(tBx_TheThirdPointY.Text);
+            double wd = Convert.ToDouble(tBx_TheThirdPointWD.Text);
+            if (cfun.MoveSEMToPoint(Px, Py))
+            {
+                cfun.SetWorkingDistance(wd);
+            }
+        }
         private void bn_OK_Click(object sender, EventArgs e)
         {
+            
             IsOK = true;
+            double iPX1, iPY1, iPX2, iPY2, iPX3, iPY3;
+            iPX1 = iPY1 = iPX2 = iPY2 = iPX3 = iPY3 = 0;
+            double dPW1, dPW2, dPW3;
+            dPW1 = dPW2 = dPW3 = 0;
+            if (!double.TryParse(tB_LTPointX.Text, out iPX1) || !double.TryParse(tB_LTPointY.Text, out iPY1) || !double.TryParse(tB_RBPointX.Text, out iPX2) || !double.TryParse(tB_RBPointY.Text, out iPY2) ||  !double.TryParse(tB_LTPointWD.Text, out dPW1) || !double.TryParse(tBx_RBPointWD.Text, out dPW2) )
+            {
+                MessageBox.Show("Please check Params!");
+                return;
+            }
+            if (tB_LTPointX.Text == tB_RBPointX.Text && tB_LTPointY.Text == tB_RBPointY.Text)
+            {
+                MessageBox.Show("Please select different points!");
+                return;
+            }
+            if(cB_Inclinedplanefocus.Checked)
+            {
+                
+                if(!double.TryParse(tBx_TheThirdPointX.Text, out iPX3) || !double.TryParse(tBx_TheThirdPointY.Text, out iPY3) || !double.TryParse(tBx_TheThirdPointWD.Text, out dPW3))
+                {
+                    MessageBox.Show("Please check Params!");
+                    return;
+                }
+                if((tB_LTPointX.Text == tBx_TheThirdPointX.Text && tB_LTPointX.Text ==tBx_TheThirdPointY.Text) || (tB_LTPointX.Text == tBx_TheThirdPointY.Text && tB_RBPointY.Text == tBx_TheThirdPointY.Text))
+                {
+                    MessageBox.Show("Please check Params!");
+                    return;
+                }
+            }
+            if (slopFocusParam == null)
+            {
+                slopFocusParam = new CSlopFocusParam();
+            }
+            slopFocusParam.IsUsingSlopParam = cB_Inclinedplanefocus.Checked;
+            slopFocusParam.FirstPoint = new Point((int)iPX1, (int)iPY1);
+            slopFocusParam.FirstWD = dPW1;
+            slopFocusParam.SecondPoint = new Point((int)iPX2, (int)iPY2);
+            slopFocusParam.SecondWD = dPW2;
+            slopFocusParam.ThirdPoint = new Point((int)iPX3, (int)iPY3);
+            slopFocusParam.ThirdWD = dPW3;
             this.Close();
         }
-
         private void bn_Cancel_Click(object sender, EventArgs e)
         {
             this.Close();
         }
 
-        private void button1_Click(object sender, EventArgs e)
+
+        
+        
+        
+        private void cB_Inclinedplanefocus_CheckedChanged(object sender, EventArgs e)
         {
-            LTPoint = new PointF(Convert.ToSingle(tB_LTPointX.Text), Convert.ToSingle(tB_LTPointY.Text));
-          
+            if(cB_Inclinedplanefocus.Checked)IsInclinedPlaneFocus = true;
+            else IsInclinedPlaneFocus = false;
         }
-
-        private void button2_Click(object sender, EventArgs e)
+        public CSlopFocusParam GetCSlopFocusParam()
         {
-            RBPoint = new PointF(Convert.ToSingle(tB_RBPointX.Text), Convert.ToSingle(tB_RBPointY.Text));
+            return slopFocusParam;
         }
-
-       
     }
 }