예제 #1
0
 /// <summary>
 /// 添加图层
 /// </summary>
 private void AddLayerToolStripMenuItem_Click(object sender, EventArgs e)
 {
     treeViewLayers.SelectedNode.ContextMenuStrip = null;
     if (opFileDlgLayers.ShowDialog() == DialogResult.OK)
     {
         myMap.AddLayer(new MyLayer(opFileDlgLayers.FileName));
         TreeNode layerNode = new TreeNode(Path.GetFileNameWithoutExtension(opFileDlgLayers.FileName), 2, 2);
         layerNode.Checked = true;
         treeViewLayers.Nodes[0].Nodes.Insert(0, layerNode);
         treeViewLayers.ExpandAll();
         UpdateMapImg();
     }
 }
예제 #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Core.Point point = new Core.Point(0, 0);
            Core.Line  line  = new Core.Line(1, 2, 500, 300);
            // line.Selected = true;
            Core.PolyLine polyLine = new Core.PolyLine();


            polyLine.AddNode(0, 0);
            polyLine.AddNode(-500, 300);
            polyLine.AddNode(-300, -500);
            polyLine.AddNode(500, 0);

            Random random = new Random();


            // polyLine.RemoveNode(1);
            Core.Polygon polygon = new Core.Polygon();
            polygon.AddNode(700, 0);
            polygon.AddNode(0, 400);
            polygon.AddNode(-100, 0);
            polygon.AddNode(0, -300);
            SolidBrush ownBrush = new SolidBrush(Color.Aquamarine);
            Pen        ownPen   = new Pen(Color.Green);

            polygon.OwnBrush = ownBrush;
            polygon.OwnPen   = ownPen;

            /*Core.Node node = polyLine.GetNode(0);
             * polyLine.Clear();*/
            /* for (int i=0; i<100; i++)
             * {
             *   polyLine.AddNode(i, -i);
             * }
             * //polyLine[0] = polyLine[2];
             */
            Core.Layer layer = new Layer();

            layer.AddObject(point);
            layer.AddObject(line);
            layer.AddObject(polyLine);
            layer.AddObject(polygon);
            int pointCount = 0, lineCount = 0, polyLineCount = 0, polygonCount = 0;

            foreach (MapObject obj in layer._objects)
            {
                switch (obj.Type)
                {
                case MapObjectType.Point:
                    pointCount++;
                    break;

                case MapObjectType.Line:
                    lineCount++;
                    break;

                case MapObjectType.PolyLine:
                    polyLineCount++;
                    break;

                case MapObjectType.Polygon:
                    polygonCount++;
                    break;
                }
            }



            MyMap.AddLayer(layer);
            MyMap.MapScale *= 2;
        }