Ejemplo n.º 1
0
        private void Events_MapMouseDown(Map map, MouseButtonEventArgs args)
        {
            if (map.DragMode == Map.DragBehavior.Draw)
            {
                _CurrentMousePoint = map.CoordHelper.PixelToGeo(args.GetPosition(map));

                // Drawing Event Arguments to be pass out of silverlight application
                DrawingEventArgs drawing_args = new DrawingEventArgs();

                switch (DrawMode)
                {
                    case GeometryMode.FreeDraw:
                        _FreeDrawLine = new DrawLineString { LineColor = DrawLineColor, LineThickness = DrawLineThickness, Opacity = DrawOpacity };
                        _FreeDrawLine.Points.Add(_CurrentMousePoint);
                        DrawLayer.Add(_FreeDrawLine);
                        break;

                    case GeometryMode.StringLine:
                        if (!_IsDoubleClick)
                        {
                            if (!_IsDrawing)
                            {
                                _StringLine = new DrawLineString { LineColor = DrawLineColor, LineThickness = DrawLineThickness, Opacity = DrawOpacity };
                                _StringLine.Points.Add(_CurrentMousePoint);

                                DrawLayer.Add(_StringLine);

                                LinesPointsLayer.Add(new DrawPoint { Point = _CurrentMousePoint, LineString = _StringLine, Index = _StringLine.Points.Count - 1 });
                                _IsDrawing = true;
                            }
                            else
                            {
                                _StringLine.Points.Add(_CurrentMousePoint);
                                LinesPointsLayer.Add(new DrawPoint { Point = _CurrentMousePoint, LineString = _StringLine, Index = _StringLine.Points.Count - 1 });
                                // Orginal    _DrawLayer.Add(new DrawPoint { Point = _CurrentMousePoint });
                            }
                        }
                        else
                        {
                            //var linepin = new DrawDevPin
                            //{
                            //    Point = _CurrentMousePoint
                            //    ,
                            //    Style = (Application.Current.Resources["DrawDevPinStyle"] as Style)
                            //};
                            //_DrawLayer.Add(linepin);
                            _IsDoubleClick = false;
                        }
                        break;

                    case GeometryMode.Polygon:
                        if (!_IsDoubleClick)
                        {
                            if (!_IsDrawing)
                            {
                                _Polygon = new DrawPolygon { LineColor = DrawLineColor, LineThickness = DrawLineThickness, Opacity = DrawOpacity, FillColor = DrawFillColor };
                                _Polygon.Points.Add(_CurrentMousePoint);
                                DrawLayer.Add(_Polygon);
                                PolygonsPointsLayer.Add(new DrawPoint { Point = _CurrentMousePoint, Polygon = _Polygon, Index = _Polygon.Points.Count - 1 });
                                _IsDrawing = true;
                            }
                            else
                            {
                                _Polygon.Points.Add(_CurrentMousePoint);
                                PolygonsPointsLayer.Add(new DrawPoint { Point = _CurrentMousePoint, Polygon = _Polygon, Index = _Polygon.Points.Count - 1 });
                            }
                        }
                        else
                        {
                            _IsDoubleClick = false;
                        }
                        break;

                    case GeometryMode.PointPin:
                        if (!_IsDoubleClick)
                        {
                            if (!_IsDrawing)
                            {
                                _LeaderPoint = new DrawPoint();
                                _LeaderPoint.Point = _CurrentMousePoint;
                                _LeaderPoint.Style = Application.Current.Resources["DrawPointStyle"] as Style;
                                DrawLayer.Clear();
                                DrawLayer.Add(_LeaderPoint);
                            }
                        }
                        else
                        {
                            _IsDoubleClick = false;
                        }
                        break;

                    case GeometryMode.Eraser:
                        break;
                }



                //if (DrawMapMouseDown != null)
                //{
                //    DrawMapMouseDown(map, drawing_args);
                //}
            }
        }
Ejemplo n.º 2
0
        private void Events_MapDoubleClick(Map map, MouseButtonEventArgs args)
        {
            
            if (map.DragMode == Map.DragBehavior.Draw)
            {
                _CurrentMousePoint = map.CoordHelper.PixelToGeo(args.GetPosition(map));

                string arg = string.Empty;
                // Drawing Event Arguments to be pass out of silverlight application
                DrawingEventArgs drawing_args = new DrawingEventArgs();

                switch (DrawMode)
                {
                    case GeometryMode.FreeDraw:
                        break;

                    case GeometryMode.StringLine:
                        //_StringLine = null;

                        arg = string.Empty;
                        for (int i = 0; i < _StringLine.Points.Count; i++)
                        {

                            arg += _StringLine.Points[i].X.ToString() + " ";
                            arg += _StringLine.Points[i].Y.ToString() + ",";
                        }
                        arg = arg.Substring(0, arg.Length - 1);
                        // setting the properties of the drawing argument
                        drawing_args.Positions = arg;
                        drawing_args.Color = _StringLine.LineColor.ToString();
                        drawing_args.Opacity = _StringLine.Opacity.ToString();
                        drawing_args.Thickness = _StringLine.LineThickness.ToString();



                        //HtmlWindow hwe = HtmlPage.Window;
                       // ScriptObject soe = (ScriptObject)hwe.GetProperty("external");

                      //  soe.Invoke("SetP");

                        //HtmlPage.Document.Invoke("SetP");
                        _LeaderPolygon = null;

                        ClearDrawLeader();
                        break;

                    case GeometryMode.Polygon:
                        //_Polygon = null;

                        arg = string.Empty;
                         for (int i = 0; i < _Polygon.Points.Count; i++)
                        {

                            arg += _Polygon.Points[i].X.ToString() + " ";
                            arg += _Polygon.Points[i].Y.ToString() + ",";
                        }
                         arg += _Polygon.Points[0].X.ToString() + " ";
                         arg += _Polygon.Points[0].Y.ToString();
                         // setting the properties of the drawing argument
                         drawing_args.Positions = arg;
                         drawing_args.Color = _Polygon.LineColor.ToString();
                         drawing_args.Opacity = _Polygon.Opacity.ToString();
                         drawing_args.Thickness = _Polygon.LineThickness.ToString();

                        //HtmlPage.Window.Invoke("SetPosition", new object[] { arg });
                        _LeaderPolygon = null;
                        ClearDrawLeader();
                        break;

                    case GeometryMode.PointPin:
                        var submitedpin = new DrawPoint();
                        submitedpin.Point = _CurrentMousePoint;
                        submitedpin.Style = Application.Current.Resources["DrawPointStyle"] as Style;
                        submitedpin.TempID = "default";
                        //DrawPointLayer.Add(submitedpin);

                        // setting the properties of the drawing argument
                        drawing_args.Positions = _CurrentMousePoint.X + "," + _CurrentMousePoint.Y;
                        drawing_args.Color = "";
                        drawing_args.Opacity = "";
                        drawing_args.Thickness = "";
                        break;

                    case GeometryMode.Eraser:
                        break;
                }
                _IsDrawing = false;
                _IsDoubleClick = true;

                if (DrawMapDoubleClick != null)
                {
                    DrawMapDoubleClick(map, drawing_args);
                }
            }
        }
Ejemplo n.º 3
0
 void GeometryTools_DrawMapDoubleClick(BIT.AVL.Silver.Map.Map map, DrawingEventArgs args)
 {
     _drawArgs.AfterDrawMethod(args.Positions);
     _drawArgs = null;
     map.DragMode = BIT.AVL.Silver.Map.Map.DragBehavior.Pan;
     map.CaptureMouse();
 }