示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            GISShapefile sf = new GISShapefile();

            layer = sf.ReadShapefile(@"D:\课程\大三上\地理信息系统底层开发\data\china_cities_gdf_prj.shp");
            layer.DrawAttributeOrNot = false;
            MessageBox.Show("read " + layer.FeatureCount() + " point objects");
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter           = "Shapefile文件|*.shp";
            openFileDialog.RestoreDirectory = true;
            openFileDialog.FilterIndex      = 1;
            openFileDialog.Multiselect      = false;
            if (openFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            layer = GISShapefile.ReadShapefile(openFileDialog.FileName);
            layer.DrawAttributeOrNot = false;
            MessageBox.Show("read " + layer.FeatureCount() + "objects");
            view.UpdateExtent(layer.Extent);
            UpdateMap();
        }
示例#3
0
 private void toolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (sender.Equals(toolStripMenuItem8))
     {
         if (layerDialog == null)
         {
             layerDialog = new Form3(document, this);
         }
         layerDialog.Show();
         if (layerDialog.WindowState == FormWindowState.Minimized)
         {
             layerDialog.WindowState = FormWindowState.Normal;
         }
         layerDialog.BringToFront();
     }
     else if (sender.Equals(toolStripMenuItem6))
     {
         OpenFileDialog openFileDialog = new OpenFileDialog();
         openFileDialog.Filter           = "Shapefile文件|*.shp";
         openFileDialog.RestoreDirectory = false;
         openFileDialog.FilterIndex      = 1;
         openFileDialog.Multiselect      = false;
         if (openFileDialog.ShowDialog() != DialogResult.OK)
         {
             return;
         }
         document.AddLayer(GISShapefile.ReadShapeFile(openFileDialog.FileName));
         if (document.layers.Count == 1)
         {
             view.CurrentMapExtent.CopyFrom(document.extent);
         }
         updateview();
         if (layerDialog != null)
         {
             layerDialog.UpdateLayer();
         }
     }
     else if (sender.Equals(toolStripMenuItem7))
     {
         toolStripComboBox1.Items.Clear();
         for (int i = 0; i < document.layers.Count; i++)
         {
             toolStripComboBox1.Items.Add(document.layers[i].Name);
         }
     }
     else if (sender.Equals(toolStripMenuItem5))
     {
         view.CurrentMapExtent.CopyFrom(document.extent);
         if (delaunayToolStripMenuItem1.Checked || 泰森多边形ToolStripMenuItem.Checked)
         {
             updateview2();
         }
         else
         {
             updateview();
         }
     }
     else
     {
         toolStripMenuItem1.Checked          = false;
         toolStripMenuItem2.Checked          = false;
         toolStripMenuItem3.Checked          = false;
         toolStripMenuItem4.Checked          = false;
         toolStripMenuItem9.Checked          = false;
         ((ToolStripMenuItem)sender).Checked = true;
         if (sender.Equals(toolStripMenuItem1))
         {
             MouseCommand = MOUSECOMMAND.Select;
         }
         else if (sender.Equals(toolStripMenuItem2))
         {
             MouseCommand = MOUSECOMMAND.ZoomIn;
         }
         else if (sender.Equals(toolStripMenuItem3))
         {
             MouseCommand = MOUSECOMMAND.ZoomOut;
         }
         else if (sender.Equals(toolStripMenuItem4))
         {
             MouseCommand = MOUSECOMMAND.Pan;
         }
         else if (sender.Equals(toolStripMenuItem9))
         {
             MouseCommand = MOUSECOMMAND.MY;
         }
     }
 }
示例#4
0
        private void ToolStrimButton_Click(object sender, EventArgs e)
        {
            //if (sender.Equals(Properties))
            //{
            //    if (layerDialog == null)
            //    layerDialog.Show();
            //    if (layerDialog.WindowState == FormWindowState.Minimized)
            //        layerDialog.WindowState = FormWindowState.Normal;
            //    layerDialog.BringToFront();
            //}
            if (sender.Equals(Clear))
            {
                Tyson.Checked    = false;
                Delaunay.Checked = false;
                updateview();
            }
            if (sender.Equals(AddLayer))
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Filter           = "Shapefile文件|*.shp";
                openFileDialog.RestoreDirectory = false;
                openFileDialog.FilterIndex      = 1;
                openFileDialog.Multiselect      = false;
                if (openFileDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                document.AddLayer(GISShapefile.ReadShapeFile(openFileDialog.FileName));
                // MessageBox.Show(Path.GetFileNameWithoutExtension(openFileDialog.FileName));
                {
                    tcs                += 1;
                    tcgl[tcs]           = tcs;
                    radiob[tcs].Visible = true;
                    radiob[tcs].Checked = true;
                    radiob[tcs].Text    = Path.GetFileNameWithoutExtension(openFileDialog.FileName);
                }
                FillValue(document.layers[document.layers.Count - 1]);
                if (document.layers.Count == 1)
                {
                    view.CurrentMapExtent.CopyFrom(document.extent);
                }
                updateview();
                if (layerDialog != null)
                {
                    layerDialog.UpdateLayer();
                }
            }
            //else if (sender.Equals(RemoveLayer))
            //{
            //    //toolStripComboBox1.Items.Clear();
            //    //for (int i = 0; i < document.layers.Count; i++)
            //    //    toolStripComboBox1.Items.Add(document.layers[i].Name);
            //}
            else if (sender.Equals(FullExtent))
            {
                view.CurrentMapExtent.CopyFrom(document.extent);
                if (Delaunay.Checked || Tyson.Checked)
                {
                    updateview2();
                }
                else
                {
                    updateview();
                }
            }
            else
            {
                ZoomIn.Checked   = false;
                ZoomOut.Checked  = false;
                Select.Checked   = false;
                Pan.Checked      = false;
                Distance.Checked = false;
                if ((ToolStripButton)sender != MY && (ToolStripButton)sender != Clear && (ToolStripButton)sender != psc)
                {
                    ((ToolStripButton)sender).Checked = true;
                }
                if (sender.Equals(Select))
                {
                    MouseCommand = MOUSECOMMAND.Select;
                }
                else if (sender.Equals(ZoomIn))
                {
                    MouseCommand = MOUSECOMMAND.ZoomIn;
                }
                else if (sender.Equals(ZoomOut))
                {
                    MouseCommand = MOUSECOMMAND.ZoomOut;
                }
                else if (sender.Equals(Pan))
                {
                    MouseCommand = MOUSECOMMAND.Pan;
                }
                else if (sender.Equals(Distance))
                {
                    MouseCommand = MOUSECOMMAND.Dis;
                }
                else if (sender.Equals(MY))
                {
                    if (MY.Checked == false)
                    {
                        MouseCommand = MOUSECOMMAND.MY;
                        MY.Checked   = true;
                    }
                    else
                    {
                        MouseCommand = MOUSECOMMAND.Unused;
                        MY.Checked   = false;
                    }
                }
                else if (sender.Equals(Delaunay))
                {
                    DrawDelaunay();
                }
                else if (sender.Equals(Tyson))
                {
                    DrawTyson();
                }
                else if (sender.Equals(psc))
                {
                    PrintScreen();
                }
            }
        }