Example #1
0
        private void myimage_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (ready_parse == true)
            {
                ready_parse = false;
                this.Cursor = Cursors.Arrow;
                if (e.ChangedButton == MouseButton.Left)
                {
                    //int b = 0;
                    // 添加地桩
                    if (e.GetPosition(Imageborder).X >= 0 && e.GetPosition(Imageborder).X < Imageborder.Width && e.GetPosition(Imageborder).Y >= 0 && e.GetPosition(Imageborder).Y <= Imageborder.Height)
                    {
                        //int a = 0;
                        // 加入地桩
                        DiZhuang_Item item = new DiZhuang_Item();
                        maingrid.Children.Add(item);
                        item.Margin = new Thickness(e.GetPosition(Imageborder).X + Imageborder.Margin.Left, e.GetPosition(Imageborder).Y + Imageborder.Margin.Top, 0, 0);

                        double pos_x = e.GetPosition(Imageborder).X;
                        double pos_y = e.GetPosition(Imageborder).Y;

                        item.pos_x = (pos_x - myimage.Margin.Left - Imageborder.Margin.Left + item.Width / 2) / suofang;
                        item.pos_y = (pos_y - myimage.Margin.Top - Imageborder.Margin.Top + item.Height / 2) / suofang;

                        all_dizhuang_list.Add(item);

                        // 在配置文件中加入地桩


                        Point_Set_View view  = new Point_Set_View();
                        bool?          ok_is = view.ShowDialog();
                        if (ok_is == true)
                        {
                            MainWindow.Point_ini.IniWriteValue(Point_Set_View.myname, "enable", "true");
                            MainWindow.Point_ini.IniWriteValue(Point_Set_View.myname, "rukou", Point_Set_View.rukou.ToString());
                            MainWindow.Point_ini.IniWriteValue(Point_Set_View.myname, "chukou", Point_Set_View.chukou.ToString());
                            MainWindow.Point_ini.IniWriteValue(Point_Set_View.myname, "X", item.pos_x.ToString());
                            MainWindow.Point_ini.IniWriteValue(Point_Set_View.myname, "Y", item.pos_y.ToString());
                            item.Set_Left(Point_Set_View.rukou);
                            item.Set_Right(Point_Set_View.chukou);
                            item.Set_Center(Point_Set_View.myname);
                        }
                    }
                    //DiZhuang_Item item = new DiZhuang_Item();



                    //maingrid.Children.Add(item);
                }
            }
            else
            {
                move_enable = true;
                pre_pos_x   = e.GetPosition(Imageborder).X;
                pre_pos_y   = e.GetPosition(Imageborder).Y;
            }
        }
Example #2
0
        public void Read_All_Point()
        {
            // 读取所有的点
            ArrayList list = MainWindow.Point_ini.ReadSections();



            // 去掉点
            foreach (DiZhuang_Item item in all_dizhuang_list)
            {
                maingrid.Children.Remove(item);
            }
            all_dizhuang_list.Clear();

            foreach (myline item in all_line_list)
            {
                maingrid.Children.Remove(item);
            }
            all_line_list.Clear();

            foreach (putong item in all_putong_point)
            {
                maingrid.Children.Remove(item);
            }

            all_putong_point.Clear();

            foreach (string name in list)
            {
                //  加入点



                // 加入普通图片
                if (string_caozuo.Get_Xiahuaxian_String(name, 2) == "putong")
                {
                    try
                    {
                        double width  = double.Parse(MainWindow.Point_ini.IniReadValue(name, "width"));    // 图片宽度
                        double height = double.Parse(MainWindow.Point_ini.IniReadValue(name, "height"));   // 图片高度

                        double pos_x = double.Parse(MainWindow.Point_ini.IniReadValue(name, "pos_x"));     // 图片X位置
                        double pos_y = double.Parse(MainWindow.Point_ini.IniReadValue(name, "pos_y"));     // 图片Y位置

                        int      count = int.Parse(MainWindow.Point_ini.IniReadValue(name, "count"));      // 的数量
                        double[] x_arr = new double[count];
                        double[] y_arr = new double[count];

                        for (int i = 1; i <= count; i++)
                        {
                            x_arr[i - 1] = double.Parse(MainWindow.Point_ini.IniReadValue(name, "X" + i.ToString()));
                            y_arr[i - 1] = double.Parse(MainWindow.Point_ini.IniReadValue(name, "Y" + i.ToString()));
                        }

                        putong myputong = new putong(x_arr, y_arr);
                        myputong.Width  = width;
                        myputong.Height = height;

                        myputong.Margin = new Thickness(pos_x - width / 2, pos_y - height / 2, 0, 0);

                        maingrid.Children.Add(myputong);
                    }
                    catch { }
                }

                // 加入线
                #region
                if (string_caozuo.Get_Xiahuaxian_String(name, 2) == "line")
                {
                    //double x1 = double.Parse(MainWindow.Point_ini.IniReadValue(name, "X1"));
                    //double y1 = double.Parse(MainWindow.Point_ini.IniReadValue(name, "Y1"));
                    //double x2 = double.Parse(MainWindow.Point_ini.IniReadValue(name, "X2"));
                    //double y2 = double.Parse(MainWindow.Point_ini.IniReadValue(name, "Y2"));

                    //double
                    try
                    {
                        double width  = double.Parse(MainWindow.Point_ini.IniReadValue(name, "width"));    // 图片宽度
                        double height = double.Parse(MainWindow.Point_ini.IniReadValue(name, "height"));   // 图片高度

                        double pos_x = double.Parse(MainWindow.Point_ini.IniReadValue(name, "pos_x"));     // 图片X位置
                        double pos_y = double.Parse(MainWindow.Point_ini.IniReadValue(name, "pos_y"));     // 图片Y位置

                        int      count = int.Parse(MainWindow.Point_ini.IniReadValue(name, "count"));      // 的数量
                        double[] x_arr = new double[count];
                        double[] y_arr = new double[count];

                        for (int i = 1; i <= count; i++)
                        {
                            x_arr[i - 1] = double.Parse(MainWindow.Point_ini.IniReadValue(name, "X" + i.ToString()));
                            y_arr[i - 1] = double.Parse(MainWindow.Point_ini.IniReadValue(name, "Y" + i.ToString()));
                        }


                        myline item = new myline(x_arr, y_arr);
                        item.Key = name;



                        item.mywidth  = item.Width;
                        item.myheight = item.Height;

                        //item.Margin = new Thickness(x * suofang + myimage.Margin.Left + Imageborder.Margin.Left - item.Width / 2, y * suofang + myimage.Margin.Top + Imageborder.Margin.Top - item.Height / 2, 0, 0);

                        item.Width  = width;
                        item.Height = height;

                        item.Margin = new Thickness(pos_x - width / 2, pos_y - height / 2, 0, 0);
                        //maingrid.Children.Add(myputong);


                        maingrid.Children.Add(item);
                        all_line_list.Add(item);
                    }
                    catch { }
                }
                #endregion

                // 加入点
                #region
                if (string_caozuo.Get_Xiahuaxian_String(name, 2) == null)
                {
                    DiZhuang_Item item = new DiZhuang_Item();

                    item.edit_able = false;
                    double x = double.Parse(MainWindow.Point_ini.IniReadValue(name, "X"));
                    double y = double.Parse(MainWindow.Point_ini.IniReadValue(name, "Y"));
                    try
                    {
                        item.Set_Center(name);
                        item.Set_Left(int.Parse(MainWindow.Point_ini.IniReadValue(name, "rukou")));
                        item.Set_Right(int.Parse(MainWindow.Point_ini.IniReadValue(name, "chukou")));
                        item.pos_x = double.Parse(MainWindow.Point_ini.IniReadValue(name, "X"));
                        item.pos_y = double.Parse(MainWindow.Point_ini.IniReadValue(name, "Y"));
                    }
                    catch { }
                    item.Margin = new Thickness(x * suofang + myimage.Margin.Left + Imageborder.Margin.Left - item.Width / 2, y * suofang + myimage.Margin.Top + Imageborder.Margin.Top - item.Height / 2, 0, 0);

                    maingrid.Children.Add(item);
                    all_dizhuang_list.Add(item);
                }
                #endregion

                // 加入群点

                #region
                if (string_caozuo.Get_Xiahuaxian_String(name, 2) == "points")
                {
                    int    points_count = 0;
                    int    my_count     = 0;
                    double rukou        = double.Parse(MainWindow.Point_ini.IniReadValue(name, "rukou"));
                    double chukou       = double.Parse(MainWindow.Point_ini.IniReadValue(name, "chukou"));
                    double X1           = double.Parse(MainWindow.Point_ini.IniReadValue(name, "X1"));
                    double X2           = double.Parse(MainWindow.Point_ini.IniReadValue(name, "X2"));
                    double Y1           = double.Parse(MainWindow.Point_ini.IniReadValue(name, "Y1"));
                    double Y2           = double.Parse(MainWindow.Point_ini.IniReadValue(name, "Y2"));
                    points_count = (int)(Math.Abs(chukou - rukou) * 5);
                    foreach (DataList.Data_Struct item in MainWindow.Real_Data_List)
                    {
                        if (item.位置 >= rukou && item.位置 <= chukou)
                        {
                            try
                            {
                                my_count++;
                                double x = (X2 - X1) / points_count * my_count + X1;
                                double y = (Y2 - Y1) / points_count * my_count + Y1;

                                putongpoint point = new putongpoint(x, y);
                                point.key    = item.位置.ToString();
                                point.Width  = 2;
                                point.Height = 2;
                                point.Margin = new Thickness(x * suofang + myimage.Margin.Left + Imageborder.Margin.Left - point.Width / 2, y * suofang + myimage.Margin.Top + Imageborder.Margin.Top - point.Height / 2, 0, 0);
                                maingrid.Children.Add(point);
                                all_putong_point.Add(point);
                            }
                            catch { }
                        }
                    }
                }

                #endregion
            }
        }