Exemple #1
0
        public Form()
        {
            InitializeComponent();

            Line OX = new Line();

            OX.BeginPoint = new GEOPoint(-this.Width / 2, 0);
            OX.EndPoint   = new GEOPoint(this.Width / 2, 0);

            Line OY = new Line();

            OY.BeginPoint = new GEOPoint(0, this.Height / 2);
            OY.EndPoint   = new GEOPoint(0, -this.Height / 2);

            var pointX = new Point();

            pointX.Style    = new PointStyle("Arial", Convert.ToByte('X'), 14, System.Drawing.Color.Black);
            pointX.Position = new GEOPoint(this.Width / 2 - 40, pointX.Style.SymbolSize);

            var pointY = new Point();

            pointY.Style    = new PointStyle("Arial", Convert.ToByte('Y'), 14, System.Drawing.Color.Black);
            pointY.Position = new GEOPoint(pointX.Style.SymbolSize, this.Height / 2 - 60);

            var polyLine = new PolyLine();

            polyLine.AddNode(new GEOPoint(300, 200));
            polyLine.AddNode(new GEOPoint(700, 100));
            polyLine.AddNode(new GEOPoint(200, -500));
            polyLine.AddNode(new GEOPoint(-800, 75));

            var polygon = new Polygon();

            polygon.AddNode(new GEOPoint(50, 0));
            polygon.AddNode(new GEOPoint(200, 0));
            polygon.AddNode(new GEOPoint(200, 100));
            polygon.AddNode(new GEOPoint(50, 100));

            var layer1 = new Layer();

            layer1.AddMapObject(OX);
            layer1.AddMapObject(OY);
            layer1.AddMapObject(pointX);
            layer1.AddMapObject(pointY);
            layer1.AddMapObject(polyLine);
            layer1.AddMapObject(polygon);
            mapControl.AddLayer(layer1);

            mapControl.CurrentTool = Tool.Select;
            CurrentToolBtn         = selectBtn;
            CurrentToolBtn.Checked = true;
        }
Exemple #2
0
        private void Map_MouseMove(object sender, MouseEventArgs e)
        {
            switch (CurrentTool)
            {
            case Tool.Select:
                break;

            case Tool.Pan:
                if (IsMouseDown)
                {
                    double dx, dy;
                    dx = MouseDownPosition.X - e.X;
                    dy = MouseDownPosition.Y - e.Y;

                    MapCenter.X += dx / MapScale;
                    MapCenter.Y -= dy / MapScale;

                    MouseDownPosition = e.Location;

                    Refresh();
                }
                break;

            case Tool.ZoomIn:
                if (IsMouseDown)
                {
                    Refresh();
                    var g = CreateGraphics();

                    var frame = new PolyLine();
                    frame.AddNode(ScreenToMap(new System.Drawing.Point(MouseDownPosition.X, MouseDownPosition.Y)));
                    frame.AddNode(ScreenToMap(new System.Drawing.Point(e.X, MouseDownPosition.Y)));
                    frame.AddNode(ScreenToMap(new System.Drawing.Point(e.X, e.Y)));
                    frame.AddNode(ScreenToMap(new System.Drawing.Point(MouseDownPosition.X, e.Y)));
                    frame.AddNode(ScreenToMap(new System.Drawing.Point(MouseDownPosition.X, MouseDownPosition.Y)));

                    cosmeticLayer.Clear();
                    cosmeticLayer.AddMapObject(frame);
                }
                break;

            case Tool.ZoomOut:
                break;
            }
        }