Exemplo n.º 1
0
        private DateTime m_timeLastLeftButtonUp = DateTime.Now;//鼠标左键弹起的时间,判断双击用
        /// <summary>
        /// 鼠标在DataGrid弹起事件回调
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DataGrid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            DateTime b = DateTime.Now;
            long     c = CommFun.TimeDiff(b, m_timeLastLeftButtonUp);

            m_timeLastLeftButtonUp = b;
            if (c < 280)
            {//双击事件
                if (m_graphicsLayer != null && m_graphics != null)
                {
                    m_graphicsLayer.RemoveGraphics(m_graphics);
                    m_graphics = null;
                }
                DataGrid grid = sender as DataGrid;
                if (grid != null && grid.SelectedItem is BindClass && grid.Tag is TmpInfo && m_graphicsLayer != null)
                {
                    CGetObjByID getGeo = new CGetObjByID();
                    getGeo.MapDocIndex = 0;
                    getGeo.LayerIndex  = (grid.Tag as TmpInfo).LayerIndex;
                    getGeo.FeatureID   = Convert.ToInt32((grid.SelectedItem as BindClass).key0);
                    COpenMap openmap = new COpenMap();
                    openmap.MapName = new string[1] {
                        activeMapDoc.MapDocName
                    };
                    getGeo.MapName = openmap;
                    activeMapDoc.GetGeomByID(getGeo, new UploadStringCompletedEventHandler(FlashFeature));
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取某个图形关联的所有的连接线
        /// </summary>
        /// <param name="graphics">要获取的图形</param>
        /// <returns>该图形所关联的所有的连接线</returns>
        private List <GraphicsPolyline> GetAssociatedPolylines(GraphicsBase graphics)
        {
            if (graphics.Type == GraphicsType.Polyline)
            {
                return(null);
            }

            List <GraphicsPolyline> result;

            if (!this.graphicsPolylines.TryGetValue(graphics.ID, out result))
            {
                result = new List <GraphicsPolyline>();

                // 先找到所有折线图形
                IEnumerable <GraphicsPolyline> polylines = this.VisualList.Select(v => v.Graphics).OfType <GraphicsPolyline>();

                // 从折线图形里筛选
                foreach (GraphicsPolyline polyline in polylines)
                {
                    if (polyline.AssociatedGraphics1 == graphics.ID || polyline.AssociatedGraphics2 == graphics.ID)
                    {
                        result.Add(polyline);
                    }
                }
            }

            return(result);
        }
        /// <summary>
        /// 闪烁查询到要素
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void flashFeature(object sender, UploadStringCompletedEventArgs e)
        {
            geoObj = this.IMSCatalog.ActiveLayerObj.OnGetGeomByFID(e);
            if (geoObj == null)
            {
                return;
            }
            List <Point> pntArr = new List <Point>();

            for (int i = 0; i < geoObj.RegGeom[0].Rings.Length; i++)
            {
                for (int j = 0; j < geoObj.RegGeom[0].Rings[i].Arcs.Length; j++)
                {
                    for (int k = 0; k < geoObj.RegGeom[0].Rings[i].Arcs[j].Dots.Length; k++)
                    {
                        pntArr.Add(new Point(geoObj.RegGeom[0].Rings[i].Arcs[j].Dots[k].x, geoObj.RegGeom[0].Rings[i].Arcs[j].Dots[k].y));
                    }
                }
            }
            if (pntArr[0].X <this.IMSCatalog.ActiveLayerObj.MapContainer.WinViewBound.XMin || pntArr[0].X> this.IMSCatalog.ActiveLayerObj.MapContainer.WinViewBound.XMax ||
                pntArr[0].Y <this.IMSCatalog.ActiveLayerObj.MapContainer.WinViewBound.YMin || pntArr[0].Y> this.IMSCatalog.ActiveLayerObj.MapContainer.WinViewBound.YMax)
            {
                this.IMSCatalog.ActiveLayerObj.MapContainer.PanTo(pntArr[0].X, pntArr[0].Y);
            }
            m_graphics = new IMSPolygon(CoordinateType.Logic)
            {
                Points = pntArr
            };
            m_graphicsLayer.AddGraphics(m_graphics);
            m_graphics.FlickerOverCallback = new GraphicsFlickerOverDelegate(FlickerOverCallback);
            m_graphics.Draw();
            m_graphics.Flicker();
        }
Exemplo n.º 4
0
        private byte[] Capture()
        {
            try
            {
                Bitmap bitmap = new Bitmap(this.Canvas.Size.Width, this.Canvas.Size.Height);
                using (GraphicsBase g = GraphicsGDIPuls.FromImage(bitmap))
                {
                    this.Canvas.Draw(g);
                }
                BitmapData imageData = bitmap.LockBits(new Rectangle(0, 0, _width, _height), ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                byte[]     bs        = new byte[_width * _height * 3];
                Marshal.Copy(imageData.Scan0, bs, 0, bs.Length);
                bitmap.UnlockBits(imageData);
                bitmap.Dispose();
                var @out = _ffscale.Convert(bs);
                return(@out);
            }
            catch (Exception e)
            {
                //if (AppConfig._D)
                //    throw;

                return(null);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Delete objects again.
        /// </summary>
        public override void Redo(DrawingCanvas drawingCanvas)
        {
            // Delete from list all objects kept in cloneList.
            // Use object IDs for deleting, don't beleive to objects order.

            int n = drawingCanvas.GraphicsList.Count;

            for (int i = n - 1; i >= 0; i--)
            {
                bool         toDelete      = false;
                GraphicsBase currentObject = (GraphicsBase)drawingCanvas.GraphicsList[i];

                foreach (PropertiesGraphicsBase o in cloneList)
                {
                    if (o.ID == currentObject.Id)
                    {
                        toDelete = true;
                        break;
                    }
                }

                if (toDelete)
                {
                    drawingCanvas.GraphicsList.RemoveAt(i);
                }
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// 右键菜单点击事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void item_Click(object sender, RoutedEventArgs e)
 {
     if (this.shape != null)
     {
         this.shape.EnableEdit = false;
         this.shape            = null;
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// 闪烁完毕回调
 /// </summary>
 /// <param name="g"></param>
 private void FlickerOverCallback(GraphicsBase g)
 {
     if (m_graphicsLayer != null && m_graphics != null)
     {
         m_graphicsLayer.RemoveGraphics(m_graphics);
         m_graphics = null;
     }
 }
Exemplo n.º 8
0
 public DeleteGraphicsHistory(IGraphicsDraw drawer, GraphicsBase graphics)
 {
     this.Description = "删除图形";
     Graphics         = graphics;
     Drawer           = drawer;
     this.Revocation  = () => (Graphics as GraphicsBase).Redo(drawer, graphics);
     this.Redo        = () => (Graphics as GraphicsBase).Revocate(drawer);
 }
Exemplo n.º 9
0
 public MoveGraphicsHistory(IGraphicsDraw drawer, GraphicsBase graphics)
 {
     this.Description = "移动图形";
     Graphics         = graphics;
     Drawer           = drawer;
     this.Revocation  = () => OldBounds = (graphics as GraphicsRectSizeBase).Bounds;
     //this.Redo = () => (graphics as GraphicsRectSizeBase).Bounds = OldBounds;
 }
Exemplo n.º 10
0
 /// <summary>
 /// 右键菜单“取消选择”,监听事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void item_Click(object sender, RoutedEventArgs e)
 {
     //取消当前选择的对象
     if (this._polygonStyle != null)
     {
         this._polygonStyle.EnableEdit = false;
         this._polygonStyle            = null;
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// 关闭
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Close(object sender, RoutedEventArgs e)
 {
     if (GraphicsLayer != null && m_graphics != null)
     {
         GraphicsLayer.RemoveGraphics(m_graphics);
         m_graphics = null;
     }
     this.Close();
 }
Exemplo n.º 12
0
        /// <summary>
        /// Add new object to drawing canvas.
        /// Function is called when user left-clicks drawing canvas,
        /// and one of ToolObject-derived tools is active.
        /// </summary>
        protected static void AddNewObject(DrawingCanvas drawingCanvas, GraphicsBase o)
        {
            HelperFunctions.UnselectAll(drawingCanvas);

            o.IsSelected = true;
            //o.Clip = new RectangleGeometry(new Rect(0, 0, drawingCanvas.ActualWidth, drawingCanvas.ActualHeight));

            drawingCanvas.GraphicsList.Add(o);
            drawingCanvas.CaptureMouse();
        }
Exemplo n.º 13
0
        public void OnDrop(DropInfo dropInfo)
        {
            Point position = dropInfo.DropPosition;

            GraphicsVM gvm = dropInfo.Data as GraphicsVM;

            GraphicsBase graphics = GraphicsFactory.Create(position, gvm.Type);

            DrawableLayer.DrawVisual(graphics);
        }
Exemplo n.º 14
0
 /// <summary>
 /// 对象选择处理事件
 /// </summary>
 /// <param name="sender"></param>
 public void callback(GraphicsBase sender)
 {
     //清除上次选择的对象
     if (this._polygonStyle != null)
     {
         this._polygonStyle.EnableEdit = false;
     }
     //设置当前选择的对象
     this._polygonStyle            = sender;
     this._polygonStyle.EnableEdit = true;
 }
Exemplo n.º 15
0
        public VisualGraphics DrawVisual(GraphicsBase graphics)
        {
            VisualGraphics visual = VisualFactory.Create(graphics);

            this.VisualList.Add(visual);

            this.AddVisualChild(visual);    // 该函数只会把DrawableVisual和DrawableVisualLayer关联起来,在渲染的时候并不会真正渲染。关联的目的是为了做命中测试(HitTest)。

            visual.Render();

            return(visual);
        }
Exemplo n.º 16
0
 /// <summary>
 /// 多边形选择后回调事件
 /// </summary>
 /// <param name="sender"></param>
 public void callback(GraphicsBase sender)
 {
     //上次选择对象清除
     if (this.shape != null)
     {
         this.shape.EnableEdit = false;
     }
     if (_markers != null)
     {
         _markers.EnableEdit = false;
     }
     //设置当前选择的对象
     this.shape            = sender;
     this.shape.EnableEdit = true;
 }
Exemplo n.º 17
0
 /// <summary>
 /// 线对象选择回调事件
 /// </summary>
 /// <param name="sender"></param>
 void chossedCallBack(IMSPredefinedLineStyle sender)
 {
     //清除上次选择的对象
     if (this.shape != null)
     {
         this.shape.EnableEdit = false;
     }
     if (_markers != null)
     {
         _markers.EnableEdit = false;
     }
     //设置当前选择的对象
     this.shape            = sender;
     this.shape.EnableEdit = true;
 }
Exemplo n.º 18
0
 private void EditPoint(object sender, RoutedEventArgs e)
 {
     if (GraphicsLayer != null)
     {
         if (m_graphics != null)
         {
             GraphicsLayer.RemoveGraphics(m_graphics);
             m_graphics = null;
         }
         CLayerGetByID getGeo = new CLayerGetByID();
         getGeo.GdbIndex   = ActiveLayerObj.ActiveGdbIndex;
         getGeo.LayerIndex = ActiveLayerObj.ActiveLayerIndex;
         getGeo.FeatureID  = m_featureID;
         ActiveLayerObj.GetGeomByFID(getGeo, new UploadStringCompletedEventHandler(DrawFeature));
     }
 }
Exemplo n.º 19
0
        protected override Size MeasureOverride(Size constraint)
        {
            double bottomMost = 0d;
            double rightMost  = 0d;

            foreach (object obj in graphicsList)
            {
                GraphicsBase child = obj as GraphicsBase;

                if (child != null)
                {
                    bottomMost = Math.Max(bottomMost, child.Bottom);
                    rightMost  = Math.Max(rightMost, child.Right);
                }
            }
            return(new Size(rightMost, bottomMost));
        }
 /// <summary>
 /// 闪烁完毕回调
 /// </summary>
 /// <param name="g"></param>
 private void FlickerOverCallback(GraphicsBase g)
 {
     m_graphicsLayer.RemoveGraphics(m_graphics);
     m_graphics = null;
     if (MessageBox.Show("查询成功。是否添加该要素?", "查询并闪烁成功", MessageBoxButton.OKCancel) == MessageBoxResult.OK)//"提示",Alert.YES|Alert.NO , this , onAlert , null , Alert.NO);
     {
         if (set == 0)
         {
             this._firstFeature        = geoObj;
             this.radioButton1.Content = "获取第一个区要素(已获取)";
         }
         if (set == 1)
         {
             this._secondFeature       = geoObj;
             this.radioButton2.Content = "获取第二个区要素(已获取)";
         }
     }
 }
Exemplo n.º 21
0
        /// <summary>
        /// Handle mouse up.
        /// Return to normal state.
        /// </summary>
        public override void OnMouseUp(DrawingCanvas drawingCanvas, Point position)
        {
            if (!drawingCanvas.IsMouseCaptured)
            {
                drawingCanvas.Cursor = Cursors.Arrow;
                selectMode           = SelectionMode.None;
                return;
            }

            if (resizedObject != null)
            {
                // after resizing
                resizedObject.Normalize();

                resizedObject = null;
            }

            if (selectMode == SelectionMode.GroupSelection)
            {
                GraphicsSelectionRectangle r = (GraphicsSelectionRectangle)drawingCanvas[drawingCanvas.Count - 1];
                r.Normalize();
                Rect rect = r.Frame;

                drawingCanvas.GraphicsList.Remove(r);

                foreach (GraphicsBase g in drawingCanvas.GraphicsList)
                {
                    if (g.IntersectsWith(rect))
                    {
                        g.IsSelected = true;
                    }
                }
            }

            drawingCanvas.ReleaseMouseCapture();
            drawingCanvas.InvalidateMeasure();
            drawingCanvas.Cursor = Cursors.Arrow;

            selectMode = SelectionMode.None;

            AddChangeToHistory(drawingCanvas);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Delete added object
        /// </summary>
        public override void Undo(DrawingCanvas drawingCanvas)
        {
            // Find object to delete by its ID.
            // Don't use objects order in the list.
            GraphicsBase objectToDelete = null;

            // Remove object from the list
            foreach (GraphicsBase b in drawingCanvas.GraphicsList)
            {
                if (b.Id == newObjectClone.ID)
                {
                    objectToDelete = b;
                    break;
                }
            }

            if (objectToDelete != null)
            {
                drawingCanvas.GraphicsList.Remove(objectToDelete);
            }
        }
Exemplo n.º 23
0
 private void EditPoint(object sender, RoutedEventArgs e)
 {
     if (GraphicsLayer != null)
     {
         if (m_graphics != null)
         {
             GraphicsLayer.RemoveGraphics(m_graphics);
             m_graphics = null;
         }
         CGetObjByID getGeo = new CGetObjByID();
         getGeo.MapDocIndex = 0;
         getGeo.LayerIndex  = ActiveMapDoc.ActiveLayerIndex;
         getGeo.FeatureID   = m_featureID;
         COpenMap openmap = new COpenMap();
         openmap.MapName = new string[1] {
             ActiveMapDoc.MapDocName
         };
         getGeo.MapName = openmap;
         ActiveMapDoc.GetGeomByID(getGeo, new UploadStringCompletedEventHandler(DrawFeature));
     }
 }
Exemplo n.º 24
0
 private void Clear()
 {
     if (GraphicsLayer != null && m_graphics != null)
     {
         GraphicsLayer.RemoveGraphics(m_graphics);
         m_graphics = null;
     }
     this.grid1.RowDefinitions.Clear();
     this.grid1.Children.Clear();
     this.grid2.Children.Clear();
     this.grid3.ColumnDefinitions.Clear();
     this.grid3.Children.Clear();
     this.grid3.ColumnDefinitions.Add(new ColumnDefinition()
     {
         Width = new GridLength(75)
     });
     this.grid3.ColumnDefinitions.Add(new ColumnDefinition()
     {
         Width = new GridLength(75)
     });
     m_textBoxArr.Clear();
 }
Exemplo n.º 25
0
        /// <summary>
        /// Left mouse is released.
        /// New object is created and resized.
        /// </summary>
        public override void OnMouseUp(DrawingCanvas drawingCanvas, Point position)
        {
            if (drawingCanvas.Count > 0)
            {
                GraphicsBase o = drawingCanvas[drawingCanvas.Count - 1] as GraphicsBase;
                o.MoveMouse(position);

                if (!o.HasDelta())
                {
                    drawingCanvas.GraphicsList.Remove(o);
                }
            }

            if (drawingCanvas.Count > 0)
            {
                drawingCanvas[drawingCanvas.Count - 1].Normalize();
                drawingCanvas.AddCommandToHistory(new CommandAdd(drawingCanvas[drawingCanvas.Count - 1]));
            }

            drawingCanvas.Cursor = Cursors.Arrow;
            drawingCanvas.ReleaseMouseCapture();
            drawingCanvas.InvalidateMeasure();
        }
Exemplo n.º 26
0
        public static VisualGraphics Create(GraphicsBase graphics)
        {
            switch (graphics.Type)
            {
            case GraphicsType.Rectangle:
            {
                return(new VisualRectangle(graphics));
            }

            case GraphicsType.Ellipse:
            {
                return(new VisualEllipse(graphics));
            }

            case GraphicsType.Polyline:
            {
                return(new VisualPolyline(graphics));
            }

            default:
                throw new NotImplementedException();
            }
        }
        // 重点
        protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            if (IsSlideImageLoaded == false)
            {
                annotationCanvas.Tool = ToolType.None;
                return;
            }

            int index = MouseMoveOnAnnotation(_currentPositionOnTarget);

            if (index >= 0)
            {
                annotationCanvas.UnselectAll();
                GraphicsBase gb = (GraphicsBase)annotationCanvas.GraphicsList[index - 1];
                gb.IsSelected = true;
                annotationCanvas.IsHitTestVisible = true;
            }
            else
            {
                annotationCanvas.UnselectAll();
                annotationCanvas.IsHitTestVisible = false;
                imageCanvas.Focus();
            }
        }
Exemplo n.º 28
0
 public CreateGraphicsHistory(IGraphicsDraw drawer, GraphicsBase graphics)
 {
     this.Description = "创建图形";
     Graphics         = graphics;
     Drawer           = drawer;
     if (graphics is GraphicsLineModel)
     {
         this.Revocation = () =>
         {
             var glm = (Graphics as GraphicsLineModel);
             glm.Revocate(Drawer);
         };
         this.Redo = () =>
         {
             var glm = (Graphics as GraphicsLineModel);
             glm.Redo(Drawer, null);
         };
     }
     else
     {
         this.Revocation = () => (Graphics as GraphicsBase).Revocate(drawer);
         this.Redo       = () => (Graphics as GraphicsBase).Redo(drawer, graphics);
     }
 }
Exemplo n.º 29
0
        // Set selection order in graphicsList according to list of IDs
        private static void ChangeOrder(VisualCollection graphicsList, List <int> indexList)
        {
            List <GraphicsBase> tmpList = new List <GraphicsBase>();

            // Read indexList, find every element in graphicsList by ID
            // and move it to tmpList.

            foreach (int id in indexList)
            {
                GraphicsBase objectToMove = null;

                foreach (GraphicsBase g in graphicsList)
                {
                    if (g.Id == id)
                    {
                        objectToMove = g;
                        break;
                    }
                }

                if (objectToMove != null)
                {
                    // Move
                    tmpList.Add(objectToMove);
                    graphicsList.Remove(objectToMove);
                }
            }

            // Now tmpList contains objects in correct order.
            // Read tmpList and add all its elements back to graphicsList.

            foreach (GraphicsBase g in tmpList)
            {
                graphicsList.Add(g);
            }
        }
Exemplo n.º 30
0
 // Create this command with DrawObject instance added to the list
 public CommandAdd(GraphicsBase newObject)
     : base()
 {
     // Keep copy of added object
     this.newObjectClone = newObject.CreateSerializedObject();
 }