private void Bt_enter_Click(object sender, RoutedEventArgs e)
        {
            CDM_SD.IsEnabled = true;
            CDM_HD.IsEnabled = true;
            CDM_VD.IsEnabled = true ;
            

            string odbcConnStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + AppDomain.CurrentDomain.BaseDirectory + "\\TSISData.accdb";
            if (CDM_SD.Text.Trim() != "" && CDM_HD.Text.Trim() != "" && CDM_VD.Text.Trim() != "")
            {
                OleDbConnection conn = new OleDbConnection(odbcConnStr);
                conn.Open();
                string sql = "select * from Convention_DistanceMeasure whereCDM_SD='" + CDM_SD.Text.Trim() + "'";
                OleDbCommand cmd = new OleDbCommand(sql, conn);

                sql = "insert into Convention_DistanceMeasure (CDM_SD,CDM_HD,CDM_VD) values ('"
                    + CDM_SD.Text.Trim() + "','" + CDM_HD.Text.Trim() + "','" + CDM_VD.Text.Trim() + "')";

                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();
                myMessageBox my = new myMessageBox();
                my.show("放样值加成功!");

                conn.Close();
            }
            else
            {
                myMessageBox my = new myMessageBox();
                my.show("输入距离放样值均不能为空!");
               // MessageBox.Show("输入距离放样值均不能为空!", "提示");
            }
        }
        public static myMessageBox CallMessageBox(string s, update form2)
        {
            myMessageBox myMessageBox = new myMessageBox(s, form2);

            myMessageBox.Show();
            return(myMessageBox);
        }
        public static myMessageBox CallMessageBox(string s, play form3)
        {
            myMessageBox myMessageBox = new myMessageBox(s, form3);

            myMessageBox.Show();
            return(myMessageBox);
        }
        public static myMessageBox CallMessageBox(string s, settings form4)
        {
            myMessageBox myMessageBox = new myMessageBox(s, form4);

            myMessageBox.Show();
            return(myMessageBox);
        }
        public static myMessageBox CallMessageBox(string s, mainform form1)
        {
            myMessageBox myMessageBox = new myMessageBox(s, form1);

            myMessageBox.Show();
            return(myMessageBox);
        }
        private void keyboard_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            key.keyboard_click(sender, e);
            string type = key.ReturnType;
            string value = key.ReturnValue;
            if (type == "function" && value == "Power")
            {
                Window_Start start = new Window_Start();
                start.Show();
                this.Close();

                //  跳转至播放介绍视频界面
                //  Window_intro_Video intro = new Window_intro_Video();
                //  intro.Show();
                //  this.Close();//关闭当前窗口

                if (IsPower)
                {
                    


                    //Window_Start window_Start1 = new Window_Start();
                    //window_Start1.Show();
                    //this.Close();//关闭当前窗口
                    IsPower = false;
                }
                else
                {
                    myMessageBox my = new myMessageBox();
                    my.show("开机界面退出!");

                }
            }
        }
        private void Bt_enter_Click(object sender, RoutedEventArgs e)
        {
            string odbcConnStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + AppDomain.CurrentDomain.BaseDirectory + "\\TSISData.accdb";
            if (CCM_仪器高.Text.Trim() != "")
            {
                OleDbConnection conn = new OleDbConnection(odbcConnStr);
                conn.Open();
                string sql = "select  CCM_仪器高 from Convention_CoordinatesMeasure where CCM_仪器高='" + CCM_仪器高.Text.Trim() + "'";
                OleDbCommand cmd = new OleDbCommand(sql, conn);
                sql = "update Convention_CoordinatesMeasure set CCM_仪器高 = ('" + CCM_仪器高.Text.Trim() + "') where CCM_ID=1";

                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();
                myMessageBox my = new myMessageBox();
                my.show("仪器高添加成功!");
                //MessageBox.Show("仪器高添加成功!");
                conn.Close();
            }
            else
            {
                myMessageBox my = new myMessageBox();
                my.show("输入仪器高不能为空!");
               // MessageBox.Show("输入仪器高不能为空!", "提示");
            }
        }
 private void ENT_Click(object sender, RoutedEventArgs e)
 {
     myMessageBox my = new myMessageBox();
     my.show("HL保持");
     //MessageBox.Show("HL保持");
     Window_convention01 window_convention01 = new Window_convention01();
     window_convention01.Show();
     this.Close();//关闭当前窗口
 }
 private void Bt_exit_Click(object sender, RoutedEventArgs e)
 {
     if (MessageBox.Show("确定退出吗?", "系统提示", MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.OK)
     {
         myMessageBox my = new myMessageBox();
         my.show("开机界面退出!");
         Application.Current.Shutdown();
     }
 }
 private void ENT_Click(object sender, RoutedEventArgs e)
 {
     myMessageBox my = new myMessageBox();
     my.show("设置成功!");
    // MessageBox.Show("设置成功!");
     Window_convention01 window_convention01 = new Window_convention01();
     window_convention01.Show();
     window_convention01.tabControl1.SelectedIndex = 2;
     this.Close();//关闭当前窗口
 }
        private void poweroff_Click(object sender, RoutedEventArgs e)
        {

            //if (MessageBox.Show("确定关机吗?", "系统提示", MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.OK)
            //{             
            //    Application.Current.Shutdown();
            //}

            myMessageBox my = new myMessageBox();
            my.show("开机界面退出!");
          //  Application.Current.Shutdown();
        }
        private void Bt_enter_Click(object sender, RoutedEventArgs e)
        {
            string odbcConnStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + AppDomain.CurrentDomain.BaseDirectory + "\\TSISData.accdb";
            if (CCM_N.Text.Trim() != "" && CCM_E.Text.Trim() != "" && CCM_Z.Text.Trim() != "")
            {
                OleDbConnection conn = new OleDbConnection(odbcConnStr);
                conn.Open();
                string sql1 = "select CCM_N from Convention_CoordinatesMeasure where CCM_N='" + CCM_N.Text.Trim() + "'";
                OleDbCommand cmd1 = new OleDbCommand(sql1, conn);
             
                    sql1 = "update Convention_CoordinatesMeasure set CCM_N = ('"
                        + CCM_N.Text.Trim() +  "') where CCM_ID=1" ;

                    cmd1.CommandText = sql1;
                    cmd1.ExecuteNonQuery();

                    string sql2 = "select CCM_E from Convention_CoordinatesMeasure where CCM_E='" + CCM_E.Text.Trim() + "'";
                    OleDbCommand cmd2 = new OleDbCommand(sql2, conn);

                    sql2 = "update Convention_CoordinatesMeasure set CCM_E = ('"
                        + CCM_E.Text.Trim() +  "') where CCM_ID=1";

                    cmd2.CommandText = sql2;
                    cmd2.ExecuteNonQuery();

                    string sql3 = "select CCM_Z from Convention_CoordinatesMeasure where CCM_Z='" + CCM_Z.Text.Trim() + "'";
                    OleDbCommand cmd3 = new OleDbCommand(sql3, conn);

                    sql3 = "update Convention_CoordinatesMeasure set CCM_Z = ('"
                        + CCM_Z.Text.Trim() + "') where CCM_ID=1";

                    cmd3.CommandText = sql3;
                    cmd3.ExecuteNonQuery();
                    myMessageBox my = new myMessageBox();
                    my.show("测站添加成功!");
                 conn.Close();
            }
            else
            {
                MessageBox.Show("测站坐标名称不能为空!", "提示!");
            }
        }
        private void ENT_Click()
        {
            if (CAM_HL.Text.Trim() != "")
            {
                OleDbConnection conn = new OleDbConnection(odbcConnStr);
                conn.Open();
                //double CAM_HL.Text.Trim()
                double m = Convert.ToDouble( CAM_HL.Text.Trim());
                int A = Convert.ToInt32(m);
                double B = m - A ;
                int C = Convert.ToInt32(B * 100);                
                int D =Convert.ToInt32((B*100 - C)*100);
                string EF = A.ToString() + "°" + C.ToString() + "′" + D.ToString() + "″";
                myMessageBox my = new myMessageBox();
                my.show(EF);
                //MessageBox.Show(EF);
                string sql = "select CAM_HL from Convention_AngleMeasure where CAM_ID = 1 ";
                OleDbCommand cmd = new OleDbCommand(sql, conn);

                sql = "Update Convention_AngleMeasure Set CAM_HL = '" + EF + "' Where CAM_ID = 1";
                //sql = "Insert into Convention_AngleMeasure (CAM_HL) values ('" + EF + "') ";
                    cmd.CommandText = sql;
                    cmd.ExecuteNonQuery();
                   // myMessageBox my = new myMessageBox();
                    my.show("角度置盘成功!"); 
                   // MessageBox.Show("角度置盘成功!");                    
                   conn.Close();
            }
            else
            {
                myMessageBox my = new myMessageBox();
                my.show("输入角度不能为空!");
                //MessageBox.Show("输入角度不能为空!", "提示");
            }


            Window_convention01 window_convention01 = new Window_convention01();
            window_convention01.Show();
            window_convention01.tabControl1.SelectedIndex = 3;
            this.Close();//关闭当前窗口
        }
        private void ENT_Click(object sender, RoutedEventArgs e)
        {
            string odbcConnStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + AppDomain.CurrentDomain.BaseDirectory + "\\TSISData.accdb";
            OleDbConnection conn = new OleDbConnection(odbcConnStr);

            conn.Open();
            string sql = "select CAM_V from Convention_AngleMeasure where CAM_ID=1";
            OleDbCommand cmd = new OleDbCommand(sql, conn);

            sql = "update Convention_AngleMeasure set CAM_HL= '0°0′0″' where CAM_ID=1 ";
            cmd.CommandText = sql;
            cmd.ExecuteNonQuery();
            myMessageBox my = new myMessageBox();
            my.show("置零成功!");
            //MessageBox.Show("置零成功!");
            conn.Close();
           // Lab_HL.Content = "0";

            conn.Open();
            OleDbCommand cmd1 = conn.CreateCommand();
            cmd1.CommandText = "select CAM_V ,CAM_HL from Convention_AngleMeasure where CAM_ID=1";
            OleDbDataReader reader = cmd1.ExecuteReader();
            if (reader.Read())
            {
                j1.v1 = reader["CAM_V"].ToString().Trim();
                j1.v2 = reader["CAM_HL"].ToString().Trim();
            }

            //Lab_V.DataContext = j1;
            //Lab_HL.DataContext = j1;
            reader.Close();
            conn.Close();

            Window_convention01 window_convention = new Window_convention01();
            window_convention.Show();
            this.Close();//关闭当前窗口
        }
        private void BTSave_Click(object sender, RoutedEventArgs e)
        {
            string SQL = null;
            Draw_ylj(EX_Point.X, EX_Point.Y, StationPoint.X, StationPoint.Y);
            //添加数据库

            SQL = "INSERT INTO NEZCoord (PName,PCode,N,E,Z) values ('" + TbPname.Text + "','" + CBcode.SelectionBoxItem.ToString() + "','" + EX_Point.X.ToString("f03") + "','" + EX_Point.Y.ToString("f03") + "','" + EX_Point.Z.ToString("f03") + "')";
            //  MessageBox.Show(SQL);
            DBClass.Manipulation_CMD(SQL);
            TbPname.Text = ToolCase.PointNumberAdd1(TbPname.Text);
            myMessageBox my = new myMessageBox();
            my.show("存储一个点,并画图");
           
           // MessageBox.Show("存储一个点,并画图");
        }
        private void BTSur3_Click(object sender, RoutedEventArgs e)
        {
            //求延长线上点坐标
            //直线方程:y=kx+b
            //
            double S;
            double k, b;
            double x1, y1, x2, y2;
            double x, y;
            double HA, VA;
            double VD, HD, SD;
            //一元二次方程系数
            double a1, b1, c1;
            if (TBEXDis.Text == "")
            {
                myMessageBox my = new myMessageBox();
                my.show("延长距离值为空,请核实!");
              
                // MessageBox.Show("延长距离值为空,请核实!");

            }
            else
            {
                S = Convert.ToDouble(TBEXDis.Text);
                x1 = FirstP.X;
                y1 = FirstP.Y;
                x2 = SeconP.X;
                y2 = SeconP.Y;
                k = (y2 - y1) / (x2 - x1);
                b = y1 - x1 * (y2 - y1) / (x2 - x1);
                a1 = 1 + k * k;
                b1 = 2 * k * (b - y2) - 2 * x2;
                c1 = x2 * x2 + (b - y2) * (b - y2) - S * S;
                x = (b1 - Math.Sqrt(b1 * b1 - 4 * a1 * c1)) / (-2 * a1);
                y = k * x + b;
                EX_Point.X = x;
                EX_Point.Y = y;
                EX_Point.Z = 0;
            }
            HA = ToolCase.IIPointFW(EX_Point, StationPoint);
            VA = Math.Atan(EX_Point.Y / StationPoint.Y);
            HD = ToolCase.IIPointHD(EX_Point, StationPoint);
            VD = ToolCase.IIPointVD(EX_Point, StationPoint);
            SD = ToolCase.IIPointSD(EX_Point, StationPoint);
            
            //数据显示
            PD.N = EX_Point.X.ToString("f3");
            PD.E = EX_Point.Y.ToString("f03");
            PD.Z = (10.87).ToString("f03");
            PD.HA = ToolCase.huduTojiaodu(HA);
            PD.VA = ToolCase.huduTojiaodu(VA);
            PD.HD = HD.ToString("f03");
            PD.VD = VD.ToString("f03");
            PD.SD = SD.ToString("f03");

            Point_N.DataContext = PD;
            Point_E.DataContext = PD;
            Point_Z.DataContext = PD;
            Point_HA.DataContext = PD;
            Point_VA.DataContext = PD;
            Point_HD.DataContext = PD;
            Point_VD.DataContext = PD;
            Point_SD.DataContext = PD;


        }
        private void BTSave_Click(object sender, RoutedEventArgs e)
        {
            string SQL = null;
            double Dis_YX = 0;
            double Vhudu = 0;//核实
            arfa = (Hhudu_B - Hhudu_A) / 2;
            if (Distance > 0 && arfa > 0)
            {
                Point_ylj Point_Center = new Point_ylj();
                //圆心距离
                Dis_YX = Distance * (1 / (1 - Math.Tan(arfa)));
                //圆心方位角
                Hhudu_YX = Hhudu_A + arfa;

                //圆心坐标
                Point_Center = ToolCase.CalculationOfCoordinatePoints(StationPoint, Dis_YX, Hhudu_YX, 0);
                //画图
                Draw_ylj(Point_Center.X, Point_Center.Y, StationPoint.X, StationPoint.Y);
                //显示数据

                //数据显示
                PD.N = Point_Center.X.ToString("f3");
                PD.E = Point_Center.Y.ToString("f03");
                PD.Z = (10.87).ToString("f03");
                PD.HA = ToolCase.huduTojiaodu(Hhudu_YX);
                PD.VA = ToolCase.huduTojiaodu(Vhudu);
                PD.HD = (Dis_YX * Math.Cos(Vhudu)).ToString("f03");
                PD.VD = (Dis_YX * Math.Sin(Vhudu)).ToString("f03");
                PD.SD = Dis_YX.ToString("f03");

                Point_N.DataContext = PD;
                Point_E.DataContext = PD;
                Point_Z.DataContext = PD;
                Point_HA.DataContext = PD;
                Point_VA.DataContext = PD;
                Point_HD.DataContext = PD;
                Point_VD.DataContext = PD;
                Point_SD.DataContext = PD;
                //添加数据库
                SQL = "INSERT INTO NEZCoord (PName,PCode,N,E,Z) values ('" + TbPname.Text + "','" + CBcode.SelectionBoxItem.ToString() + "','" + Point_Center.X.ToString("f03") + "','" + Point_Center.Y.ToString("f03") + "','" + Point_Center.Z.ToString("f03") + "')";
                //  MessageBox.Show(SQL);
                DBClass.Manipulation_CMD(SQL);
                TbPname.Text = ToolCase.PointNumberAdd1(TbPname.Text);
            }
            else
            {
                myMessageBox my = new myMessageBox();
                my.show("没有测角或者测距");
              
               // MessageBox.Show("没有测角或者测距");
            }
        }
        private void LayoutRoot_Click(object sender, RoutedEventArgs e)
        {
            Button bt = e.OriginalSource as Button;
            if (bt != null)
            {

                string keyName = bt.Name.ToString();
                switch (keyName)
                {
                    case "Arfakey":
                        #region case "Arfakey":
                        if (isupper)
                        {
                            isupper = false;
                            myMessageBox my = new myMessageBox();
                            my.show("小写字母");
                            //MessageBox.Show("小写字母");
                        }
                        else
                        {
                            isupper = true;
                            myMessageBox my = new myMessageBox();
                            my.show("大写字母");
                            //MessageBox.Show("大写字母");
                        }
                        break;
                        #endregion
                    case "Softkey":
                        //   MessageBox.Show("显示软件盘");
                        break;
                    case "Starkey":
                        //  MessageBox.Show("快捷键");
                        break;
                    case "Powerkey":
                        #region
                         Window_Shutdown_PowerOff Shutdown_PowerOff = new Window_Shutdown_PowerOff();
                         Shutdown_PowerOff.Show();
                         this.Close();//关闭当前窗口 
                        break;
                        #endregion
                    case "Funckey":
                        // MessageBox.Show("Func");
                        break;
                    case "Ctrlkey":
                        break;
                    case "Altkey":
                        break;
                    case "Delkey":
                        #region case "Delkey":
                        if (istbwulengjingchangshuFocused) tbstringfun(TBwulengjingchangshu, 3, "*");
                        if (istbTByoulengjingchangshuFocused) tbstringfun(TByoulengjingchangshu, 3, "*");                        
                        break;
                        #endregion
                    case "Tabkey":
                        #region
 /*                       switch (txtfocus)
                        {
                            case 0:
                                txtfocus = txtfocus + 1;
                                TByoulengjingchangshu.Focus();

                                break;
                            case 1:
                                txtfocus = txtfocus + 1;
                                istbTByoulengjingchangshuFocused.Focus();

                                break;
                            default:
                                txtfocus = 0;
                                tbItemName.Focus();
                                break;
                        }*/
                        break;
                        #endregion
                    case "BSkey":
                        #region case "BSkey":
                        if (istbwulengjingchangshuFocused) tbstringfun(TBwulengjingchangshu, 2, "*");
                        if (istbTByoulengjingchangshuFocused) tbstringfun(TByoulengjingchangshu, 2, "*");
                      
                        break;
                        #endregion
                    case "Shiftkey":
                        #region case "Shiftkey":
                        if (isnumber)
                        {

                            isnumber = false;

                            //                      MessageBox.Show("字母键盘");
                            Bt0key.Content = "#$%";
                            Btptkey.Content = "!&@";
                            Bt_key.Content = "+*/";
                            Bt1key.Content = "STU";
                            Bt2key.Content = "VWX";
                            Bt3key.Content = "YZ";
                            Bt4key.Content = "JKL";
                            Bt5key.Content = "MNO";
                            Bt6key.Content = "PQR";
                            Bt7key.Content = "ABC";
                            Bt8key.Content = "DEF";
                            Bt9key.Content = "GHI";
                        }
                        else
                        {
                            isnumber = true;
                            timer.IsEnabled = false;
                            //                           MessageBox.Show("数字键盘");
                            Bt0key.Content = "0";
                            Btptkey.Content = ".";
                            Bt_key.Content = "-";
                            Bt1key.Content = "1";
                            Bt2key.Content = "2";
                            Bt3key.Content = "3";
                            Bt4key.Content = "4";
                            Bt5key.Content = "5";
                            Bt6key.Content = "6";
                            Bt7key.Content = "7";
                            Bt8key.Content = "8";
                            Bt9key.Content = "9";
                        }
                        if (istbwulengjingchangshuFocused) TBwulengjingchangshu.Focus();
                        if (istbTByoulengjingchangshuFocused) TByoulengjingchangshu.Focus();
                        break;
                        #endregion
                    case "SPkey":
                        #region
                        if (istbwulengjingchangshuFocused) tbstringfun(TBwulengjingchangshu, 0, bt.Content.ToString());
                        if (istbTByoulengjingchangshuFocused) tbstringfun(TByoulengjingchangshu, 0, bt.Content.ToString());
 
                        break;
                        #endregion
                    case "ESCkey":
                        #region
                        ESC_Click(sender, e);
                        break;
                        #endregion
                    case "ENTkey":
                        #region case "ENTkey":

                        break;
                        #endregion

                    case "BtDnkey":
                        #region
                        switch (txtfocus)
                        {
                            case 0:
                                txtfocus = txtfocus + 1;
                                TByoulengjingchangshu.Focus();
                                break;
;
                            default:
                                txtfocus = 0;
                                TBwulengjingchangshu.Focus();
                                break;
                        }
                        break;
                        #endregion
                    case "BtUpkey":
                        #region case "BtUpkey"
                        switch (txtfocus)
                        {
                            case 1:
                                txtfocus = txtfocus - 1;
                                TBwulengjingchangshu.Focus();
                                break;
                            default:
                                txtfocus = 1;
                                TByoulengjingchangshu.Focus();
                                break;
                        }
                        break;
                        #endregion
                    case "BtLtkey":
                        #region
                        if (istbwulengjingchangshuFocused)
                        {
                            selectPos = this.TBwulengjingchangshu.SelectionStart;
                            TBwulengjingchangshu.Focus();
                            if (selectPos >= 1)
                            {

                                TBwulengjingchangshu.Select(selectPos - 1, 0);
                            }
                        }
                        if (istbTByoulengjingchangshuFocused)
                        {
                            selectPos = this.TByoulengjingchangshu.SelectionStart;
                            TByoulengjingchangshu.Focus();
                            if (selectPos >= 1)
                            {
                                TByoulengjingchangshu.Select(selectPos - 1, 0);
                            }
                        }
                        break;
                        #endregion
                    case "BtRtkey":
                        #region
                        istimeout = true;
                        lastkey = null;
                        if (istbTByoulengjingchangshuFocused) 
                        {
                            selectPos = this.TByoulengjingchangshu.SelectionStart;
                            TByoulengjingchangshu.Focus();
                            if (selectPos < this.TByoulengjingchangshu.Text.Length)
                            {
                                TByoulengjingchangshu.Select(selectPos + 1, 0);
                            }
                        }
                        if (istbwulengjingchangshuFocused)
                        {
                            selectPos = this.TBwulengjingchangshu.SelectionStart;
                            TBwulengjingchangshu.Focus();
                            if (selectPos < TBwulengjingchangshu.Text.Length)
                            {
                                TBwulengjingchangshu.Select(selectPos + 1, 0);
                            }
                        }
                        break;
                        #endregion
                    default:
                        #region default:
                        if (isnumber)
                        {
                            if (istbwulengjingchangshuFocused) tbstringfun(TBwulengjingchangshu, 0, bt.Content.ToString());
                            if (istbTByoulengjingchangshuFocused) tbstringfun(TByoulengjingchangshu, 0, bt.Content.ToString());                          
                        }
                        else
                        {

                            string press = bt.Name.ToString();
                            timer.Stop();
                            timer.Start();
                            if (press != lastkey)
                            {
                                lastkey = press;
                                istimeout = true;
                                keyNumber = 1;
                            }
                            else
                            {
                                keyNumber++;
                            }
                            if (istbwulengjingchangshuFocused)
                            {
                                switch (keyNumber % 3)
                                {
                                    case 0:
                                        if (istimeout)
                                        {
                                            tbstringfun(TBwulengjingchangshu, 0, bt.Content.ToString().Substring(2, 1));
                                        }
                                        else
                                        {
                                            tbstringfun(TBwulengjingchangshu, 1, bt.Content.ToString().Substring(2, 1));
                                        }
                                        break;
                                    case 1:
                                        if (istimeout)
                                        {
                                            tbstringfun(TBwulengjingchangshu, 0, bt.Content.ToString().Substring(0, 1));
                                        }
                                        else
                                        {
                                            tbstringfun(TBwulengjingchangshu, 1, bt.Content.ToString().Substring(0, 1));
                                        }
                                        break;
                                    case 2:
                                        if (istimeout)
                                        {
                                            tbstringfun(TBwulengjingchangshu, 0, bt.Content.ToString().Substring(1, 1));
                                        }
                                        else
                                        {
                                            tbstringfun(TBwulengjingchangshu, 1, bt.Content.ToString().Substring(1, 1));
                                        }
                                        break;
                                }
                            }
#region
                            if (istbTByoulengjingchangshuFocused)
                            {
                                switch (keyNumber % 3)
                                {
                                    case 0:
                                        if (istimeout)
                                        {
                                            tbstringfun(TByoulengjingchangshu, 0, bt.Content.ToString().Substring(2, 1));
                                        }
                                        else
                                        {
                                            tbstringfun(TByoulengjingchangshu, 1, bt.Content.ToString().Substring(2, 1));
                                        }
                                        break;
                                    case 1:
                                        if (istimeout)
                                        {
                                            tbstringfun(TByoulengjingchangshu, 0, bt.Content.ToString().Substring(0, 1));
                                        }
                                        else
                                        {
                                            tbstringfun(TByoulengjingchangshu, 1, bt.Content.ToString().Substring(0, 1));
                                        }
                                        break;
                                    case 2:
                                        if (istimeout)
                                        {
                                            tbstringfun(TByoulengjingchangshu, 0, bt.Content.ToString().Substring(1, 1));
                                        }
                                        else
                                        {
                                            tbstringfun(TByoulengjingchangshu, 1, bt.Content.ToString().Substring(1, 1));
                                        }
                                        break;
                                 }
#endregion
                               }                           
                            }
                            istimeout = false;
                            break;
                        }
                        #endregion
                }
        }
 private void BTView2_Click(object sender, RoutedEventArgs e)
 {
     myMessageBox my = new myMessageBox();
     my.show(SeconP.X.ToString("f03") + ";" + SeconP.Y.ToString("f03") + ";" + SeconP.Z.ToString("f03"));
    
     //MessageBox.Show(SeconP.X.ToString("f03") + ";" + SeconP.Y.ToString("f03") + ";" + SeconP.Z.ToString("f03"));
 }
        private void BTSave_Click(object sender, RoutedEventArgs e)
        {
            //计算平面方程
            /* 
               A(x - x1) + B(y - y1) + C(z - z1) = 0 (点法式)
               A = (y3 - y1)*(z3 - z1) - (z2 -z1)*(y3 - y1);
               B = (x3 - x1)*(z2 - z1) - (x2 - x1)*(z3 - z1);
               C = (x2 - x1)*(y3 - y1) - (x3 - x1)*(y2 - y1);
             直线方程:
             * m = Lx2 - Lx1;
             * n = Ly2 - Ly1;
             * p = Lz2 - Lz1;
             
             */
            double A, B, C, D;//平面方程参数
            double m, n, p;//直线方程参数
            double ZX_X, ZX_Y, ZX_Z;//重心坐标
            double Hhudu, Vhudu, Dis;
            //           double denrtaX = 0, denrtaY = 0, denrtaZ = 0;
            string SQL = null;
            Point_ylj Point_P = new Point_ylj();
            Point_ylj Point_jiao = new Point_ylj();
            double t = 0;
            //平面方程
            A = (Point_C.Y - Point_A.Y) * (Point_C.Z - Point_A.Z) - (Point_B.Z - Point_A.Z) * (Point_C.Y - Point_A.Y);
            B = (Point_C.X - Point_A.X) * (Point_B.Z - Point_A.Z) - (Point_B.X - Point_A.X) * (Point_C.Z - Point_A.Z);
            C = (Point_B.X - Point_A.X) * (Point_C.Y - Point_A.Y) - (Point_C.X - Point_A.X) * (Point_B.Y - Point_A.Y);
            D = -A * Point_A.X - B * Point_A.Y - C * Point_A.Z;
            //三个点重心坐标
            ZX_X = Point_A.X + Point_B.X + Point_C.X;
            ZX_Y = Point_A.Y + Point_B.Y + Point_C.Y;
            ZX_Z = Point_A.Z + Point_B.Z + Point_C.Z;

            Hhudu = ToolCase.HARadom;
            Vhudu = ToolCase.VARadom;
            Dis = ToolCase.DistanceRadom;
            //坐标
            Point_P = ToolCase.CalculationOfCoordinatePoints(StationPoint, Dis, Hhudu, Vhudu);
            //已知两点建直线方程
            m = Point_P.X - StationPoint.X;
            n = Point_P.Y - StationPoint.Y;
            p = Point_P.Z - StationPoint.Z;
            //直线与平面的焦点
            if (A * m + B * n + C * p == 0)  //判断直线是否与平面平行   
            {
                myMessageBox my = new myMessageBox();
                my.show("直线与平面平行,无法确定交点");
            
                //MessageBox.Show("直线与平面平行,无法确定交点");
            }
            else
            {
                t = -(StationPoint.X * A + StationPoint.Y * B + StationPoint.Z * C + D) / (A * m + B * n + C * p);
                Point_jiao.X = StationPoint.X + m * t;
                Point_jiao.Y = StationPoint.Y + n * t;
                Point_jiao.Z = StationPoint.Z + p * t;
            }
            LBHA.Content = ToolCase.huduTojiaodu(Hhudu);
            LbVA.Content = ToolCase.huduTojiaodu(Vhudu);
            //显示坐标信息
            //数据显示
            PD.N = Point_jiao.X.ToString("f3");
            PD.E = Point_jiao.Y.ToString("f03");
            PD.Z = (10.87).ToString("f03");
            PD.HA = ToolCase.huduTojiaodu(Hhudu);
            PD.VA = ToolCase.huduTojiaodu(Vhudu);
            PD.HD = (Dis * Math.Cos(Vhudu)).ToString("f03");
            PD.VD = (Dis * Math.Sin(Vhudu)).ToString("f03");
            PD.SD = Dis.ToString("f03");

            Point_N.DataContext = PD;
            Point_E.DataContext = PD;
            Point_Z.DataContext = PD;
            Point_HA.DataContext = PD;
            Point_VA.DataContext = PD;
            Point_HD.DataContext = PD;
            Point_VD.DataContext = PD;
            Point_SD.DataContext = PD;
            //画图
            int caseSwitch = -1;
            caseSwitch = CBProj.SelectedIndex;
            switch (caseSwitch)
            {
                case 1:
                    //NE投影Z=0
                    Draw_ylj(Point_jiao.X, Point_jiao.Y, ZX_X, ZX_Y);
                    break;
                case 2:
                    //NZ投影Y=0
                    Draw_ylj(Point_jiao.X, Point_jiao.Z, ZX_X, ZX_Z);
                    break;
                default:
                    //EZ投影X=0
                    Draw_ylj(Point_jiao.Y, Point_jiao.Z, ZX_Y, ZX_Z);
                    break;
            }
            //获取的点加入数据库
            SQL = "INSERT INTO NEZCoord (PName,PCode,N,E,Z) values ('" + TbPname.Text + "','" + CBcode.SelectionBoxItem.ToString() + "','" + Point_jiao.X.ToString("f03") + "','" + Point_jiao.Y.ToString("f03") + "','" + Point_jiao.Z.ToString("f03") + "')";
            //  MessageBox.Show(SQL);
            DBClass.Manipulation_CMD(SQL);
            TbPname.Text = ToolCase.PointNumberAdd1(TbPname.Text);
        }
        private void UC_select_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            UC_select.btn_Click(sender,e);
            
            string result = UC_select.getBtn_result();
            if (result == "OK")
            {
                if(lastPointChange != null)
                {
                    CurrentLine1[CurrentPoints.IndexOf(lastPointChange)].Stroke = new SolidColorBrush(Colors.Red);
                    CurrentLine2[CurrentPoints.IndexOf(lastPointChange)].Stroke = new SolidColorBrush(Colors.Red);

                }
                
                string pointchange = UC_select.text.Text;
                if (CurrentPoints.IndexOf(pointchange) > -1)
                {

                    CurrentLine1[CurrentPoints.IndexOf(pointchange)].Stroke = new SolidColorBrush(Colors.Black);
                    CurrentLine2[CurrentPoints.IndexOf(pointchange)].Stroke = new SolidColorBrush(Colors.Black);
                    lastPointChange = UC_select.text.Text;
                    UC_select.Visibility = Visibility.Collapsed;
                }
                else
                {
                    myMessageBox my = new myMessageBox();
                    my.show("没有这个点!");
                }
            }
            else if(result == "Cancel")
            {
                this.UC_select.Visibility = Visibility.Collapsed;
            }
        }