Exemplo n.º 1
0
        /// <summary>
        /// Create a CIMPointGaphic which can be added to the MapView overlay.
        /// </summary>
        /// <param name="point">The location for the point (as a CIM point)</param>
        /// <returns></returns>
        public CIMPointGraphic MakeCIMPointGraphic(PointN point)
        {
            CIMMarker marker = SymbolFactory.Instance.ConstructMarker(Red, 10, SimpleMarkerStyle.Star);

            CIMSymbolLayer[] layers = new CIMSymbolLayer[1];
            layers[0] = marker;

            CIMPointSymbol pointSymbol = new CIMPointSymbol()
            {
                SymbolLayers = layers,
                ScaleX       = 1
            };
            CIMSymbolReference symbolRef = new CIMSymbolReference()
            {
                Symbol = pointSymbol
            };
            CIMPointGraphic pointGraphic = new CIMPointGraphic();

            ArcGIS.Core.Geometry.SpatialReference spatialRef = SpatialReferenceBuilder.CreateSpatialReference(point.SpatialReference.WKID);
            MapPoint mapPoint = MapPointBuilder.CreateMapPoint(point.X, point.Y, spatialRef);

            pointGraphic.Location = mapPoint;
            pointGraphic.Symbol   = symbolRef;

            return(pointGraphic);
        }
Exemplo n.º 2
0
        public void CreateGraphicElementUsingCIMGraphic()
        {
            #region Graphic Element using CIMGraphic
            var graphicsLayer = MapView.Active.Map.GetLayersAsFlattenedList()
                                .OfType <ArcGIS.Desktop.Mapping.GraphicsLayer>().FirstOrDefault();
            if (graphicsLayer == null)
            {
                return;
            }
            QueuedTask.Run(() =>
            {
                //Place symbol in the center of the map
                var extent   = MapView.Active.Extent;
                var location = extent.Center;

                //specify a symbol
                var pt_symbol = SymbolFactory.Instance.ConstructPointSymbol(
                    ColorFactory.Instance.GreenRGB);

                //create a CIMGraphic
                var graphic = new CIMPointGraphic()
                {
                    Symbol   = pt_symbol.MakeSymbolReference(),
                    Location = location //center of map
                };
                graphicsLayer.AddElement(graphic);
            });
            #endregion
        }
Exemplo n.º 3
0
        protected override Task HandleMouseDownAsync(MapViewMouseButtonEventArgs e)
        {
            return(QueuedTask.Run(() =>
            {
                // Get the mouse click point
                MapPoint location = MapView.Active.ClientToMap(e.ClientPoint);

                // Create a symbol based on the mouse button.
                CIMPointSymbol pointSymbol = null;
                if (e.ChangedButton == MouseButton.Left)
                {
                    // Specify a symbol
                    pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.CreateRGBColor(150, 0, 0, 60), 80, SimpleMarkerStyle.Circle);
                }
                else if (e.ChangedButton == MouseButton.Right)
                {
                    // Specify a symbol
                    pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.CreateRGBColor(0, 0, 150, 60), 80, SimpleMarkerStyle.Cross);
                }

                // Create a CIMGraphic to show the symbol on the map in the grapicslayer.
                var graphic = new CIMPointGraphic()
                {
                    Symbol = pointSymbol?.MakeSymbolReference(),
                    Location = location
                };

                // Add the graphic to the grapicslayer.
                FieldOfJoy.AddElement(graphic);

                // By default all items are selected, deselect all items
                FieldOfJoy.UnSelectElements();
            }));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create a CIMPointGaphic which can be added to the MapView overlay.
        /// </summary>
        /// <param name="point">The location for the point (as a CIM point)</param>
        /// <returns></returns>
        public CIMPointGraphic MakeCIMPointGraphic(PointN point)
        {
            ////CIMMarker marker = SymbolHelper.ConstructMarker(Red, 10, SimpleMarkerStyle.Circle);

            CIMMarker marker = SymbolHelper.ConstructMarker(Red, 10, SimpleMarkerStyle.Star);

            CIMSymbolLayer[] layers = new CIMSymbolLayer[1];
            layers[0] = marker;

            CIMPointSymbol pointSymbol = new CIMPointSymbol();

            pointSymbol.SymbolLayers = layers;
            pointSymbol.ScaleX       = 1;

            CIMSymbolReference symbolRef = new CIMSymbolReference();

            symbolRef.Symbol = pointSymbol;

            CIMPointGraphic pointGraphic = new CIMPointGraphic();

            pointGraphic.Location = point;
            pointGraphic.Symbol   = symbolRef;

            return(pointGraphic);
        }
Exemplo n.º 5
0
        //Create the element from the sketch geometry and the CIM symbol
        protected override Task <bool> OnSketchCompleteAsync(Geometry geometry)
        {
            if (ActiveElementContainer == null)
            {
                Task.FromResult(true);
            }

            if (Module1.SelectedSymbol == null)
            {
                return(Task.FromResult(true));
            }
            return(QueuedTask.Run(() =>
            {
                var cimGraphic = new CIMPointGraphic()
                {
                    Location = geometry as MapPoint,
                    Symbol = Module1.SelectedSymbol.MakeSymbolReference()
                };

                ElementFactory.Instance.CreateGraphicElement(
                    this.ActiveElementContainer, cimGraphic, Module1.SelectedSymbolName);
                //Graphics Layer OR Layout
                return true;
            }));
        }
Exemplo n.º 6
0
        protected override Task <bool> OnSketchCompleteAsync(Geometry geometry)
        {
            if (ActiveElementContainer == null)
            {
                Task.FromResult(true);
            }
            return(QueuedTask.Run(() =>
            {
                var marker = SymbolFactory.Instance.ConstructMarker(CIMColor.CreateRGBColor(0, 0, 255), 20, SimpleMarkerStyle.Cloud);
                //cast CIMMarker to CIMVectorMarker
                var cimVectorMarker = marker as CIMVectorMarker;

                if (cimVectorMarker == null)
                {
                    return true;
                }

                //Create a PointSymbol using the CIMVector marker
                var newPointSymbol = SymbolFactory.Instance.ConstructPointSymbol(cimVectorMarker);

                //Create CIMPointGraphic - using the point Symbol.
                var cimGraphic = new CIMPointGraphic
                {
                    Symbol = newPointSymbol.MakeSymbolReference(),
                    Location = geometry as MapPoint
                };
                //Create GraphicsElement using the CIMPointGraphic.
                var ge = LayoutElementFactory.Instance.CreateGraphicElement(this.ActiveElementContainer, cimGraphic);
                return true;
            }));
        }
Exemplo n.º 7
0
 private void Dispose(bool disposing)
 {
     if (disposing && !_isDisposed)
     {
         if (_graphic != null)
         {
             ((CIMPointSymbol)_graphic.Symbol.Symbol).SymbolLayers = null;
             _graphic.Symbol.Symbol = null;
             _graphic.Symbol        = null;
             _graphic.Location      = null;
             _graphic = null;
         }
     }
     System.Diagnostics.Debug.WriteLine("CIMPointGraphic disposed {0}", disposing.ToString());
     _isDisposed = true;
 }
Exemplo n.º 8
0
 private void BulkGraphicsCreation()
 {
     #region Bulk Graphics creation
     //Point Feature layer to convert into graphics
     var lyr = MapView.Active?.Map?.GetLayersAsFlattenedList().OfType <FeatureLayer>().FirstOrDefault();
     //Graphics layer to store the graphics to
     var gl = MapView.Active.Map.GetLayersAsFlattenedList().OfType <ArcGIS.Desktop.Mapping.GraphicsLayer>().FirstOrDefault();
     if (lyr == null)
     {
         return;
     }
     QueuedTask.Run(() =>
     {
         //Point symbol for graphics
         var pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(CIMColor.CreateRGBColor(100, 255, 40), 10, SimpleMarkerStyle.Circle);
         //Collection to hold the point graphics
         var listGraphicElements = new List <CIMGraphic>();
         //Iterate through each point feature in the feature layer
         using (RowCursor rows = lyr.Search()) //execute
         {
             int i = 0;
             while (rows.MoveNext())
             {
                 using (var feature = rows.Current as Feature)
                 {
                     //Create a point graphic for the feature
                     var crimePt = feature.GetShape() as MapPoint;
                     if (crimePt != null)
                     {
                         var cimGraphicElement = new CIMPointGraphic
                         {
                             Location = crimePt, //MapPoint
                             Symbol   = pointSymbol.MakeSymbolReference()
                         };
                         //Add the point feature to the collection
                         listGraphicElements.Add(cimGraphicElement);
                         i++;
                     }
                 }
             }
         }
         //Magic happens...Add all the features to the Graphics layer
         gl.AddElements(listGraphicElements);
     });
     #endregion
 }
        protected override Task <bool> OnSketchCompleteAsync(Geometry geometry)
        {
            if (Module1.Current.SelectedGraphicsLayerTOC == null)
            {
                MessageBox.Show("Select a graphics layer in the TOC", "No graphics layer selected",
                                System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Exclamation);
                return(Task.FromResult(true));
            }

            if (_pointSymbol == null)
            {
                return(Task.FromResult(true));
            }
            return(QueuedTask.Run(() =>
            {
                var selectedElements = Module1.Current.SelectedGraphicsLayerTOC.GetSelectedElements().
                                       OfType <GraphicElement>();

                //If only one element is selected, is it of type Point?
                if (selectedElements.Count() == 1)
                {
                    if (selectedElements.FirstOrDefault().GetGraphic() is CIMPointGraphic) //It is a Point
                    {
                        //So we use it
                        var polySymbol = selectedElements.FirstOrDefault().GetGraphic() as CIMPointGraphic;
                        _pointSymbol = polySymbol.Symbol.Symbol as CIMPointSymbol;
                    }
                }
                var cimGraphicElement = new CIMPointGraphic
                {
                    Location = geometry as MapPoint,
                    Symbol = _pointSymbol.MakeSymbolReference()
                };
                Module1.Current.SelectedGraphicsLayerTOC.AddElement(cimGraphicElement);
                return true;
            }));
        }
Exemplo n.º 10
0
        protected override Task <bool> OnSketchCompleteAsync(Geometry geometry)
        {
            if (Module1.Current.SelectedGraphicsLayerTOC == null)
            {
                MessageBox.Show("Select a graphics layer in the TOC", "No graphics layer selected",
                                System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Exclamation);
                return(Task.FromResult(true));
            }

            if (_pointSymbol == null)
            {
                return(Task.FromResult(true));
            }
            return(QueuedTask.Run(() =>
            {
                var selectedElements = Module1.Current.SelectedGraphicsLayerTOC.GetSelectedElements().
                                       OfType <GraphicElement>();

                //If only one element is selected, is it of type Point?
                if (selectedElements.Count() == 1)
                {
                    if (selectedElements.FirstOrDefault().GetGraphic() is CIMPointGraphic) //It is a Point
                    {
                        //So we use it
                        var polySymbol = selectedElements.FirstOrDefault().GetGraphic() as CIMPointGraphic;
                        _pointSymbol = polySymbol.Symbol.Symbol as CIMPointSymbol;
                    }
                }
                var cimGraphicElement = new CIMPointGraphic
                {
                    Location = geometry as MapPoint,
                    Symbol = _pointSymbol.MakeSymbolReference()
                };
                Module1.Current.SelectedGraphicsLayerTOC.AddElement(cimGraphicElement);

                //  Add a text label graphic next to the point graphic:
                if (selectedElements.Count() == 1)
                {
                    if (selectedElements.FirstOrDefault().GetGraphic() is CIMTextGraphic) //It is a Text
                    {
                        var textSymbol = selectedElements.FirstOrDefault().GetGraphic() as CIMTextGraphic;
                        _textSymbol = textSymbol.Symbol.Symbol as CIMTextSymbol;
                    }
                }

                // Get the ribbon or the dockpane text values
                string txtBoxString = null;
                string queryTxtBoxString = null;
                if (Module1.Current.blnDockpaneOpenStatus == false)
                {
                    // Use value in the edit box
                    txtBoxString = Module1.Current.TextValueEditBox.Text;
                    queryTxtBoxString = Module1.Current.QueryValueEditBox.Text;
                    if (txtBoxString == null || txtBoxString == "")
                    {
                        txtBoxString = "    Default Text";
                    }
                    else
                    {
                        txtBoxString = "   " + txtBoxString;
                    }
                    if (queryTxtBoxString != null && queryTxtBoxString != "")
                    {
                        txtBoxString = txtBoxString + "\r\n    " + queryTxtBoxString;
                    }
                }
                if (Module1.Current.blnDockpaneOpenStatus == true)
                {
                    _dockpane = FrameworkApplication.DockPaneManager.Find("GraphicTools_TextPane") as TextPaneViewModel;
                    txtBoxString = _dockpane.TxtBoxDoc;
                    queryTxtBoxString = _dockpane.QueryTxtBoxDoc;
                    if (txtBoxString == null || txtBoxString == "")
                    {
                        txtBoxString = "    Default Text";
                    }
                    else
                    {
                        txtBoxString = "   " + txtBoxString;
                    }
                    if (queryTxtBoxString != null && queryTxtBoxString != "")
                    {
                        txtBoxString = txtBoxString + "\r\n    " + queryTxtBoxString;
                    }
                }

                var textGraphic = new CIMTextGraphic
                {
                    Symbol = _textSymbol.MakeSymbolReference(),
                    Shape = geometry as MapPoint,
                    Text = txtBoxString
                };
                Module1.Current.SelectedGraphicsLayerTOC.AddElement(textGraphic);
                Module1.Current.SelectedGraphicsLayerTOC.ClearSelection();

                return true;
            }));
        }
Exemplo n.º 11
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public CIMPointGraphicHelper(PointN point)
 {
     _cimHelper = new CIMHelpers();
     _graphic   = _cimHelper.MakeCIMPointGraphic(point);
     GraphicID  = -1;
 }
 private void Dispose(bool disposing) {
     if (disposing && !_isDisposed) {
         if (_graphic != null) {
             ((CIMPointSymbol)_graphic.Symbol.Symbol).SymbolLayers = null;
             _graphic.Symbol.Symbol = null ;
             _graphic.Symbol = null ;
             _graphic.Location = null;
             _graphic = null;
         }
     }
     System.Diagnostics.Debug.WriteLine("CIMPointGraphic disposed {0}", disposing.ToString());
     _isDisposed = true;
 }
 /// <summary>
 /// Default constructor
 /// </summary>
 public CIMPointGraphicHelper(PointN point) {
     _cimHelper = new CIMHelpers();
     _graphic = _cimHelper.MakeCIMPointGraphic(point);
     graphicID = -1;
 }
        /// <summary>
        /// Create a CIMPointGaphic which can be added to the MapView overlay.
        /// </summary>
        /// <param name="point">The location for the point (as a CIM point)</param>
        /// <returns></returns>
        public  CIMPointGraphic MakeCIMPointGraphic(PointN point)
        {

            ////CIMMarker marker = SymbolHelper.ConstructMarker(Red, 10, SimpleMarkerStyle.Circle);
            
            CIMMarker marker = SymbolHelper.ConstructMarker(Red, 10, SimpleMarkerStyle.Star);

            CIMSymbolLayer[] layers = new CIMSymbolLayer[1];
            layers[0] = marker;

            CIMPointSymbol pointSymbol = new CIMPointSymbol();
            pointSymbol.SymbolLayers = layers;
            pointSymbol.ScaleX = 1;

            CIMSymbolReference symbolRef = new CIMSymbolReference();
            symbolRef.Symbol = pointSymbol;

            CIMPointGraphic pointGraphic = new CIMPointGraphic();
            pointGraphic.Location = point;
            pointGraphic.Symbol = symbolRef;

            return pointGraphic;
        }
        /// <summary>
        /// グラフィックの作成
        /// </summary>
        private void CreateGraphic(FeatureClass featureClass, QueryFilter queryFilter)
        {
            var mapView = MapView.Active;

            using (RowCursor rowCursor = featureClass.Search(queryFilter, true))
            {
                rowCursor.MoveNext();

                //レコードを取得
                using (Row row = rowCursor.Current)
                {
                    Feature  feature = row as Feature;
                    Geometry shape   = feature.GetShape();

                    RemoveFromMapOverlay(); // 既存のグラフィックを削除

                    switch (shape.GeometryType)
                    {
                    // ポイントの場合(マルチには対応していません)
                    case GeometryType.Point:
                        // ポイント作成
                        var      point    = shape as MapPoint;
                        MapPoint mapPoint = MapPointBuilder.CreateMapPoint(point.X, point.Y, shape.SpatialReference);

                        // グラフィック作成
                        var pointGraphic = new CIMPointGraphic();
                        pointGraphic.Location = mapPoint;

                        // シンボル作成
                        CIMPointSymbol pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.RedRGB, 5);
                        pointGraphic.Symbol = pointSymbol.MakeSymbolReference();

                        // グラフィックをマップビューに追加
                        _overlayObject = mapView.AddOverlay(pointGraphic);

                        break;

                    case GeometryType.Polygon:

                        // アノテーションの場合
                        if (feature.GetType().Name == "AnnotationFeature")
                        {
                            // グラフィック作成
                            var annoGraphic = new CIMPolygonGraphic();
                            annoGraphic.Polygon = shape as Polygon;

                            // シンボル作成
                            CIMStroke        outline       = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.RedRGB, 2, SimpleLineStyle.Solid);
                            CIMPolygonSymbol polygonSymbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.BlueRGB, SimpleFillStyle.Null, outline);
                            annoGraphic.Symbol = polygonSymbol.MakeSymbolReference();

                            // グラフィックをマップビューに追加
                            _overlayObject = mapView.AddOverlay(annoGraphic);
                        }
                        else
                        {
                            // グラフィック作成
                            var polygonGraphic = new CIMPolygonGraphic();
                            polygonGraphic.Polygon = shape as Polygon;

                            // シンボル作成
                            CIMPolygonSymbol polygonSymbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB);
                            polygonGraphic.Symbol = polygonSymbol.MakeSymbolReference();

                            // グラフィックをマップビューに追加
                            _overlayObject = mapView.AddOverlay(polygonGraphic);
                        }

                        break;

                    case GeometryType.Polyline:

                        // グラフィック作成
                        var lineGraphic = new CIMLineGraphic();
                        lineGraphic.Line = shape as Polyline;

                        // シンボル作成
                        CIMLineSymbol lineSymbol = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.RedRGB, 5);
                        lineGraphic.Symbol = lineSymbol.MakeSymbolReference();

                        // グラフィックをマップビューに追加
                        _overlayObject = mapView.AddOverlay(lineGraphic);

                        break;

                    default:
                        break;
                    }
                }
            }
        }
        /// <summary>
        /// Create a CIMPointGaphic which can be added to the MapView overlay.
        /// </summary>
        /// <param name="point">The location for the point (as a CIM point)</param>
        /// <returns></returns>
        public CIMPointGraphic MakeCIMPointGraphic(PointN point)
        {
            CIMMarker marker = SymbolFactory.ConstructMarker(Red, 10, SimpleMarkerStyle.Star);

            CIMSymbolLayer[] layers = new CIMSymbolLayer[1];
            layers[0] = marker;

            CIMPointSymbol pointSymbol = new CIMPointSymbol();
            pointSymbol.SymbolLayers = layers;
            pointSymbol.ScaleX = 1;

            CIMSymbolReference symbolRef = new CIMSymbolReference();
            symbolRef.Symbol = pointSymbol;

            CIMPointGraphic pointGraphic = new CIMPointGraphic();
            ArcGIS.Core.Geometry.SpatialReference spatialRef = SpatialReferenceBuilder.CreateSpatialReference(point.SpatialReference.WKID);
            MapPoint mapPoint = MapPointBuilder.CreateMapPoint(point.X, point.Y, spatialRef);
            pointGraphic.Location = mapPoint;
            pointGraphic.Symbol = symbolRef;

            return pointGraphic;
        }