Exemplo n.º 1
0
        private void save_image_Click(object sender, EventArgs e)               //保存图形
        {
            if (pictureBox1.BackgroundImage == null)
            {
                status_text("图形窗口无图形,保存(.dxf)失败", Color.Red); return;
            }
            SaveFileDialog svf = new SaveFileDialog();

            svf.Filter = "(*.dxf)|*.dxf";
            DialogResult ok_cancel = svf.ShowDialog();

            if (ok_cancel == DialogResult.OK)
            {
                string dxf_path = svf.FileName;
                if (File.Exists(dxf_path))   //若同文件名文件已经存在,则删除
                {
                    File.Delete(dxf_path);
                }
                DRAW draw = new DRAW();
                if (checked_status == 0)
                {
                    draw.save_dxf(dxf_path, all_rangeX, all_rangeY, shp1, shp2);
                }
                if (checked_status == 1)
                {
                    draw.save_dxf(dxf_path, all_rangeX, all_rangeY, shp1, new shpfile());
                }
                if (checked_status == 2)
                {
                    draw.save_dxf(dxf_path, all_rangeX, all_rangeY, new shpfile(), shp2);
                }
                status_text("图形保存(.dxf)成功", Color.Black);
            }
        }
Exemplo n.º 2
0
 private void 绘制图形_Click(object sender, EventArgs e)            //绘制两个.shp文件的信息
 {
     try
     {
         if (shp1.line.Count == 0 && shp2.line.Count == 0)
         {
             status_text("请确保有图层信息,否则无法进行绘制!", Color.Red);
         }
         DRAW   draw = new DRAW();
         Bitmap bmp;
         if (checked_status == 0)
         {
             bmp = draw.get_picture(all_rangeX, all_rangeY, shp1, shp2);  //得到画布
             pictureBox1.BackgroundImage = bmp;                           //得到图片
         }
         if (checked_status == 1)
         {
             bmp = draw.get_picture(all_rangeX, all_rangeY, shp1, new shpfile()); //得到画布
             pictureBox1.BackgroundImage = bmp;                                   //得到图片
         }
         if (checked_status == 2)
         {
             bmp = draw.get_picture(all_rangeX, all_rangeY, new shpfile(), shp2); //得到画布
             pictureBox1.BackgroundImage = bmp;                                   //得到图片
         }
         pictureBox1.BackgroundImageLayout = ImageLayout.Stretch;
         panel1.Controls.Add(pictureBox1);
         image_show.BringToFront();
         status_text("图形绘制成功并显示", Color.Black);
     }
     catch { status_text("请确保有图层信息,否则无法进行绘制!", Color.Red); }
 }