示例#1
0
 private void Dg_recipe_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (ParameterInstance.Instance.dxfParameter.Data.Count < 1)
     {
         return;
     }
     selectRecIndex = dg_recipe.SelectedIndex;
     if (selectRecIndex < 0)
     {
         return;
     }
     selectRceItem = ParameterInstance.Instance.dxfParameter.Data[selectRecIndex];
     dxfWind.PaintingPath(selectRceItem.RecipePath);
 }
示例#2
0
        private void Btn_AddRecipe_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            if (openFileDialog1.ShowDialog().Value)
            {
                //读取dxf,获取路径和文件名
                string   path = openFileDialog1.FileName;
                string[] arr  = openFileDialog1.SafeFileName.Split('.');
                string   name = arr[0];
                DxfReader.Instance.Read(path);
                if (DxfReader.Instance.PathList.Count < 0)
                {
                    MessageBox.Show("dxf文件读取失败");
                    return;
                }
                List <PATH> rotateLs  = new List <PATH>(); //旋转后路径
                List <PATH> OneQuadLs = new List <PATH>(); //第一象限路径

                DxfReader.Instance.TransformToOneQuadrant(DxfReader.Instance.PathList, OneQuadLs, ref max_x, ref max_y);
                DxfReader.Instance.PathRotateAng(OneQuadLs, rotateLs, 180);
                DxfReader.Instance.TransformToOneQuadrant(rotateLs, OneQuadLs, ref max_x, ref max_y);
                //获取时间
                string tim = DateTime.Now.ToString("yyMMdd HH:mm");
                //保存参数
                DxfItem item = new DxfItem();
                item.RecipeName = name;
                item.RecipeDate = tim;
                item.RecipePath = OneQuadLs;

                item.Max_x = max_x;
                item.Max_y = max_y;
                ParameterInstance.Instance.dxfParameter.Add(item);
                //绘图
                int index = selectRecIndex;
                if (index < dg_recipe.Items.Count - 1)
                {
                    index = dg_recipe.Items.Count - 1;
                }
                //PaintingPath(ls, max_x, max_y);
                dg_recipe.ItemsSource   = null;
                dg_recipe.ItemsSource   = ParameterInstance.Instance.dxfParameter.Data;
                dg_recipe.SelectedIndex = index + 1;
            }
        }