public PickerViewModel(List <IPickableItem> pickingCandidates,
                               bool isSingleMode)
        {
            FlashItemCmd = new RelayCommand(FlashItem, () => true, false);

            CloseCommand = new RelayCommand(Close, () => true, false);

            PickableItems =
                new ObservableCollection <IPickableItem>(pickingCandidates);

            _isSingleMode = isSingleMode;

            CIMColor magenta = ColorFactory.Instance.CreateRGBColor(255, 0, 255);

            CIMStroke outline =
                SymbolFactory.Instance.ConstructStroke(
                    magenta, 4, SimpleLineStyle.Solid);

            _highlightLineSymbol =
                SymbolFactory.Instance.ConstructLineSymbol(magenta, 4);

            _highlightPolygonSymbol =
                SymbolFactory.Instance.ConstructPolygonSymbol(
                    magenta, SimpleFillStyle.Null, outline);

            _highlightPointSymbol =
                SymbolFactory.Instance.ConstructPointSymbol(magenta, 6);
        }
        public RemoveOverlapsFeedback()
        {
            _overlapLineSymbol =
                SymbolUtils.CreateLineSymbol(255, 0, 0, 2);

            _overlapPolygonSymbol = SymbolUtils.CreateHatchFillSymbol(255, 0, 0);
        }
Exemple #3
0
        private Task <CIMSymbolReference> OverlaySymbolX(GeometryType gt)
        {
            return(QueuedTask.Run(() =>
            {
                CIMSymbolReference retval = null;

                switch (gt)
                {
                case GeometryType.Polygon:
                case GeometryType.Envelope:
                    CIMStroke outline = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.RedRGB, 2.0, SimpleLineStyle.Solid);
                    CIMPolygonSymbol fillWithOutline =
                        SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.Null, outline);
                    retval = fillWithOutline.MakeSymbolReference();
                    break;

                case GeometryType.Point:
                case GeometryType.Multipoint:
                    CIMPointSymbol ps = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.RedRGB, 5.0, SimpleMarkerStyle.Circle);
                    retval = ps.MakeSymbolReference();
                    break;

                case GeometryType.Polyline:
                    CIMLineSymbol ls = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.RedRGB, 2.0, SimpleLineStyle.Solid);
                    retval = ls.MakeSymbolReference();
                    break;

                default:
                    break;
                }

                return retval;
            }));
        }
        public ChangeAlongFeedback()
        {
            var red = ColorFactory.Instance.CreateRGBColor(248, 0, 0);

            _noReshapeLineSymbol = SymbolFactory.Instance.ConstructLineSymbol(red, _lineWidth);

            var green = ColorFactory.Instance.CreateRGBColor(0, 248, 0);

            _reshapeLineSymbol = SymbolFactory.Instance.ConstructLineSymbol(green, _lineWidth);

            var yellow = ColorFactory.Instance.CreateRGBColor(255, 255, 0);

            _candidateReshapeLineSymbol =
                SymbolFactory.Instance.ConstructLineSymbol(yellow, _lineWidth);

            var grey = ColorFactory.Instance.CreateRGBColor(100, 100, 100);

            _filteredReshapeLineSymbol =
                SymbolFactory.Instance.ConstructLineSymbol(grey, _lineWidth);

            _noReshapeLineEnd = CreateMarkerSymbol(red);
            _reshapeLineEnd   = CreateMarkerSymbol(green);
            _candidateLineEnd = CreateMarkerSymbol(yellow);
            _filteredLineEnd  = CreateMarkerSymbol(grey);
        }
 /// <summary>
 /// Occurs when the tool is activated.
 /// </summary>
 /// <param name="hasMapViewChanged">A value indicating if the active <see cref="T:ArcGIS.Desktop.Mapping.MapView"/> has changed.</param>
 /// <returns>
 /// A Task that represents a tool activation event.
 /// </returns>
 protected async override Task OnToolActivateAsync(bool hasMapViewChanged)
 {
     if (_lineSymbol == null)
     {
         _lineSymbol = await Module1.CreateLineSymbolAsync();
     }
     this.SketchSymbol = _lineSymbol.MakeSymbolReference();
 }
        //construct line symbol
        public void ContructLineSymbol_1()
        {
            #region How to construct a line symbol of specific color, size and line style

            CIMLineSymbol lineSymbol = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlueRGB, 4.0, SimpleLineStyle.Solid);

            #endregion
        }
 /// <summary>
 /// Occurs when the tool is activated.
 /// </summary>
 /// <param name="hasMapViewChanged">A value indicating if the active <see cref="T:ArcGIS.Desktop.Mapping.MapView"/> has changed.</param>
 /// <returns>
 /// A Task that represents a tool activation event.
 /// </returns>
 protected async override Task OnToolActivateAsync(bool hasMapViewChanged) {
     if (_lineSymbol == null) {
         _lineSymbol = await Module1.CreateLineSymbolAsync();
     }
     this.SketchSymbol = _lineSymbol.MakeSymbolReference();
     //configure snapping
     await Module1.ConfigureSnappingAsync();
 }
Exemple #8
0
        public static void MakeLinesLayer(Map mapView)
        {
            try
            {
                // Create the "Sewer Lines" object.
                var lines = mapView.GetLayersAsFlattenedList().OfType <FeatureLayer>().FirstOrDefault(s => s.Name == "Sewer Lines");

                //Get the selected features from the map.
                var linesOIDList = lines.GetSelection().GetObjectIDs();                 // Gets a list of Object IDs
                var linesOID     = lines.GetTable().GetDefinition().GetObjectIDField(); // Gets the OBJECTID field name for the def query

                // Check to see if there are sewer lines features selected inthe map.
                if (linesOIDList.Count() == 0)
                {
                    MessageBox.Show("There are no sewer lines selected.");
                }

                else
                {
                    //Create the defenition query
                    string defQuery = $"{linesOID} in ({string.Join(",", linesOIDList)})";
                    string url      = @"O:\SHARE\405 - INFORMATION SERVICES\GIS_Layers\[email protected]\SDE.SEWERMAN.SEWERS_VIEW";

                    // Create the Uri object create the feature layer.
                    Uri uri            = new Uri(url);
                    var selectionLayer = LayerFactory.Instance.CreateFeatureLayer(uri, mapView, 0, "Sewer Lines SELECTION");

                    // Apply the definition query
                    selectionLayer.SetDefinitionQuery(defQuery);

                    // Create the line symbol renderer.
                    CIMLineSymbol lineSymbol = SymbolFactory.Instance.ConstructLineSymbol(
                        ColorFactory.Instance.RedRGB,
                        3.0,
                        SimpleLineStyle.Solid
                        );
                    CIMSimpleRenderer renderer = selectionLayer.GetRenderer() as CIMSimpleRenderer;

                    // Reference the existing renderer
                    renderer.Symbol = lineSymbol.MakeSymbolReference();
                    // Apply the new renderer
                    selectionLayer.SetRenderer(renderer);
                }
            }

            catch (Exception ex)
            {
                SysModule.LogError(ex.Message, ex.StackTrace);

                string caption = "Error Occurred";
                string message = "Process failed. \nSave and restart ArcGIS Pro and try process again.\n" +
                                 "If problem persist, contact your GIS Admin.";

                //Using the ArcGIS Pro SDK MessageBox class
                MessageBox.Show(message, caption);
            }
        }
        public void ContructLineSymbol_2()
        {
            #region How to construct a line symbol from a stroke

            CIMStroke     stroke = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 2.0);
            CIMLineSymbol lineSymbolFromStroke = SymbolFactory.Instance.ConstructLineSymbol(stroke);

            #endregion
        }
 private void AddReshapeLines(IEnumerable <CutSubcurve> subcurves,
                              Predicate <CutSubcurve> predicate, CIMLineSymbol symbol)
 {
     foreach (var cutSubcurve in subcurves)
     {
         if (predicate == null || predicate(cutSubcurve))
         {
             AddOverlay(cutSubcurve.Path, symbol);
         }
     }
 }
Exemple #11
0
        public async Task RedrawObservationAsync()
        {
            await QueuedTask.Run(() =>
            {
                _disposeInnerLine?.Dispose();
                _disposeOuterLine?.Dispose();

                if (_measurementPoint?.IsObservationVisible() ?? false)
                {
                    MapView thisView   = MapView.Active;
                    MapPoint measPoint = _measurementPoint?.Point;
                    MapPoint mapPointObsLine;

                    if ((measPoint != null) && (!double.IsNaN(measPoint.X)) && (!double.IsNaN(measPoint.Y)))
                    {
                        Point winMeasPoint = thisView.MapToScreen(measPoint);
                        Point winObsPoint  = thisView.MapToScreen(Point);

                        double xdir           = ((winMeasPoint.X - winObsPoint.X) * 3) / 2;
                        double ydir           = ((winMeasPoint.Y - winObsPoint.Y) * 3) / 2;
                        Point winPointObsLine = new Point(winObsPoint.X + xdir, winObsPoint.Y + ydir);
                        mapPointObsLine       = thisView.ScreenToMap(winPointObsLine);
                    }
                    else
                    {
                        mapPointObsLine = MapPointBuilder.CreateMapPoint((Point.X + (XDir * DistLine)), (Point.Y + (YDir * DistLine)));
                    }

                    IList <MapPoint> linePointList = new List <MapPoint>();
                    linePointList.Add(mapPointObsLine);
                    linePointList.Add(Point);
                    Polyline polyline = PolylineBuilder.CreatePolyline(linePointList);

                    Color outerColorLine             = Viewer?.Color ?? Color.DarkGray;
                    CIMColor cimOuterColorLine       = ColorFactory.Instance.CreateColor(Color.FromArgb(255, outerColorLine));
                    CIMLineSymbol cimOuterLineSymbol = SymbolFactory.Instance.DefaultLineSymbol;
                    cimOuterLineSymbol.SetColor(cimOuterColorLine);
                    cimOuterLineSymbol.SetSize(OuterLineSize);
                    CIMSymbolReference cimOuterLineSymbolRef = cimOuterLineSymbol.MakeSymbolReference();
                    _disposeOuterLine = thisView.AddOverlay(polyline, cimOuterLineSymbolRef);

                    Color innerColorLine             = Color.LightGray;
                    CIMColor cimInnerColorLine       = ColorFactory.Instance.CreateColor(innerColorLine);
                    CIMLineSymbol cimInnerLineSymbol = SymbolFactory.Instance.DefaultLineSymbol;
                    cimInnerLineSymbol.SetColor(cimInnerColorLine);
                    cimInnerLineSymbol.SetSize(InnerLineSize);
                    CIMSymbolReference cimInnerLineSymbolRef = cimInnerLineSymbol.MakeSymbolReference();
                    _disposeInnerLine = thisView.AddOverlay(polyline, cimInnerLineSymbolRef);
                }
            });
        }
Exemple #12
0
        private async void getData(Geometry geometry, GeometryDimension dimension)
        {
            properties = new NecessaryProperties();
            ArcGIS.Desktop.Mapping.MapView view = ArcGIS.Desktop.Mapping.MapView.Active;

            var          layersTOC    = ArcGIS.Desktop.Mapping.MapView.Active.Map.GetLayersAsFlattenedList();
            FeatureLayer parcelsLayer = (FeatureLayer)layersTOC.Where((layer) =>
            {
                return(layer.Name.Contains(config.getConfig("Działki", "parcelsLayer")));
            }).First();
            var parcels = ArcGIS.Desktop.Mapping.MapView.Active.Map.GetLayersAsFlattenedList();

            foreach (var f in parcels)
            {
                var feat = f.Name.Equals(config.getConfig("Działki", "parcelsLayer"));
                if (feat)
                {
                    this.parcellayer = (FeatureLayer)f;
                }
            }
            this.getParcel(parcelsLayer, geometry, dimension);
            CIMLineSymbol symbol = new CIMLineSymbol();

            symbol.SetColor(ColorFactory.Instance.CreateRGBColor(255, 255, 255, 0));
            foreach (ParcelModel parcelModel in properties.parcels)
            {
                object result          = null;
                var    pointsFromShape = parcelModel.parcel.TryGetValue("Shape", out result);
            }
            Polygon shp = null;

            foreach (Layer layer in layersTOC)
            {
                try
                {
                    FeatureLayer fLayer = (FeatureLayer)layer;
                    if (fLayer.Name.Contains(config.getConfig("MPZP", "MPZPlayer")))
                    {
                        this.getMPZP(fLayer, geometry, dimension);
                    }
                    else if (fLayer.Name.Contains(config.getConfig("Wydzielenia", "precintLayer")))
                    {
                        this.getResolution(fLayer, geometry, dimension);
                    }
                    else if (fLayer.Name.Contains(config.getConfig("Obręby", "areaLayer")))
                    {
                        this.getPrecints(fLayer, geometry, dimension);
                    }
                }catch (Exception) { }
            }
        }
        /// <summary>
        /// When the active map view changes, update the graphic overlay on the map control
        /// </summary>
        /// <param name="args"></param>
        private void OnMapViewCameraChanged(MapViewCameraChangedEventArgs args)
        {
            if (MapView.Active == null)
            {
                return;
            }
            if (MapView.Active.Extent == null)
            {
                return;
            }
            if (MapView.Active.ViewingMode != ArcGIS.Core.CIM.MapViewingMode.Map)
            {
                return;
            }

            //get the Map view's extent
            var viewExtent = MapView.Active.Extent.Clone() as Envelope;

            QueuedTask.Run(() =>
            {
                //Line symbol to be used to draw the overview rectangle.
                if (_lineSymbol == null)
                {
                    _lineSymbol =
                        SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.RedRGB, 2.0, SimpleLineStyle.Solid);
                }

                _graphic?.Dispose();            //Clear out the old overlay

                _overviewEnvelope = viewExtent; //overview envelope based on active map view

                if (_overviewEnvelope == null)
                {
                    return;
                }
                //Creating the overview rectangle
                IList <MapPoint> segments = new List <MapPoint>
                {
                    MapPointBuilder.CreateMapPoint(_overviewEnvelope.XMin, _overviewEnvelope.YMin, _overviewEnvelope.SpatialReference),
                    MapPointBuilder.CreateMapPoint(_overviewEnvelope.XMax, _overviewEnvelope.YMin, _overviewEnvelope.SpatialReference),
                    MapPointBuilder.CreateMapPoint(_overviewEnvelope.XMax, _overviewEnvelope.YMax, _overviewEnvelope.SpatialReference),
                    MapPointBuilder.CreateMapPoint(_overviewEnvelope.XMin, _overviewEnvelope.YMax, _overviewEnvelope.SpatialReference),
                    MapPointBuilder.CreateMapPoint(_overviewEnvelope.XMin, _overviewEnvelope.YMin, _overviewEnvelope.SpatialReference)
                };
                _polyLine = PolylineBuilder.CreatePolyline(segments, _overviewEnvelope.SpatialReference);

                _graphic = _mapControl.AddOverlay(_polyLine, _lineSymbol.MakeSymbolReference());
            });
        }
Exemple #14
0
        public static CIMLineSymbol CreateLineSymbol(float red, float green, float blue,
                                                     double lineWidth)
        {
            CIMColor color = ColorUtils.CreateRGB(red, green, blue);

            var solidStroke = new CIMSolidStroke
            {
                Color = color,
                Width = lineWidth
            };

            CIMLineSymbol lineSymbol = CreateLineSymbol(solidStroke);

            return(lineSymbol);
        }
Exemple #15
0
        /// <summary>
        /// Create a line symbol with a dash and two markers.<br/>
        /// </summary>
        /// <remarks>
        /// This line symbol comprises three symbol layers listed below:
        /// 1. A solid stroke that has dashes.
        /// 1. A circle marker.
        /// 1. A square marker.
        /// ![LineSymbolTwoMarkers](http://Esri.github.io/arcgis-pro-sdk/images/Symbology/line-dash-two-markers.png)
        /// </remarks>
        /// <returns></returns>
        internal static async Task <CIMLineSymbol> CreateLineDashTwoMarkers()
        {
            var lineSymbol = await QueuedTask.Run(() =>
            {
                var dash2MarkersLine = new CIMLineSymbol();

                var mySymbolLyrs = new CIMSymbolLayer[]
                {
                    new CIMSolidStroke()
                    {
                        Color       = ColorFactory.Instance.BlackRGB,
                        Enable      = true,
                        ColorLocked = true,
                        CapStyle    = LineCapStyle.Round,
                        JoinStyle   = LineJoinStyle.Round,
                        LineStyle3D = Simple3DLineStyle.Strip,
                        MiterLimit  = 10,
                        Width       = 1,
                        CloseCaps3D = false,
                        Effects     = new CIMGeometricEffect[]
                        {
                            new CIMGeometricEffectDashes()
                            {
                                CustomEndingOffset = 0,
                                DashTemplate       = new double[] { 20, 10, 20, 10 },
                                LineDashEnding     = LineDashEnding.HalfPattern,
                                OffsetAlongLine    = 0,
                                ControlPointEnding = LineDashEnding.NoConstraint
                            },
                            new CIMGeometricEffectOffset()
                            {
                                Method = GeometricEffectOffsetMethod.Bevelled,
                                Offset = 0,
                                Option = GeometricEffectOffsetOption.Fast
                            }
                        },
                    },
                    CreateCircleMarkerPerSpecs(),
                    CreateSquareMarkerPerSpecs()
                };
                dash2MarkersLine.SymbolLayers = mySymbolLyrs;
                return(dash2MarkersLine);
            });

            return(lineSymbol);
        }
Exemple #16
0
        /// <summary>
        /// Create a tiktaktow play field, with 2 vertical en 2 horizontal lines.
        /// </summary>
        /// <param name="centre"></param>
        /// <param name="fieldOfJoy"></param>
        public void CreatePlayField(System.Windows.Point centre, GraphicsLayer fieldOfJoy)
        {
            MapPoint topLeft    = MapView.Active.ClientToMap(new System.Windows.Point(centre.X - 200, centre.Y + 600));
            MapPoint bottomLeft = MapView.Active.ClientToMap(new System.Windows.Point(centre.X - 200, centre.Y - 600));

            MapPoint topRight    = MapView.Active.ClientToMap(new System.Windows.Point(centre.X + 200, centre.Y + 600));
            MapPoint bottomRight = MapView.Active.ClientToMap(new System.Windows.Point(centre.X + 200, centre.Y - 600));

            MapPoint rightTop = MapView.Active.ClientToMap(new System.Windows.Point(centre.X + 600, centre.Y + 200));
            MapPoint leftTop  = MapView.Active.ClientToMap(new System.Windows.Point(centre.X - 600, centre.Y + 200));

            MapPoint rightBottom = MapView.Active.ClientToMap(new System.Windows.Point(centre.X + 600, centre.Y - 200));
            MapPoint leftButtom  = MapView.Active.ClientToMap(new System.Windows.Point(centre.X - 600, centre.Y - 200));

            CIMLineSymbol lineSymbol = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.CreateRGBColor(0, 0, 0), 5, SimpleLineStyle.Solid);

            CreateLine(fieldOfJoy, topLeft, bottomLeft, lineSymbol);
            CreateLine(fieldOfJoy, topRight, bottomRight, lineSymbol);
            CreateLine(fieldOfJoy, rightTop, leftTop, lineSymbol);
            CreateLine(fieldOfJoy, rightBottom, leftButtom, lineSymbol);
        }
Exemple #17
0
        /// <summary>
        /// This function builds the map topology graph of the current map view extent.
        /// </summary>
        /// <returns></returns>
        private async Task BuildGraphWithActiveView()
        {
            await QueuedTask.Run(() =>
            {
                ClearOverlay();

                //Build the map topology graph
                MapView.Active.BuildMapTopologyGraph <TopologyDefinition>(topologyGraph =>
                {
                    //Getting the nodes and edges present in the graph
                    topologyGraphNodes = topologyGraph.GetNodes();
                    topologyGraphEdges = topologyGraph.GetEdges();

                    if (_symbol == null)
                    {
                        //Construct point and line symbols
                        _symbol     = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.BlueRGB, 6.0, SimpleMarkerStyle.Circle);
                        _symbolLine = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlueRGB, 3.0);
                        //Get symbol references from the symbols
                        _symbolReference     = _symbol.MakeSymbolReference();
                        _symbolReferenceLine = _symbolLine.MakeSymbolReference();
                    }

                    //Draw the nodes and edges on the overlay to highlight them
                    foreach (var node in topologyGraphNodes)
                    {
                        _overlayObject = MapView.Active.AddOverlay(node.GetShape() as MapPoint, _symbolReference);
                        snapshot.Add(_overlayObject);
                    }
                    foreach (var edge in topologyGraphEdges)
                    {
                        _overlayObject = MapView.Active.AddOverlay(edge.GetShape() as Polyline, _symbolReferenceLine);
                        snapshot.Add(_overlayObject);
                    }

                    MessageBox.Show($"Number of topo graph nodes are:  {topologyGraphNodes.Count}.\n Number of topo graph edges are {topologyGraphEdges.Count}.", "Map Topology Info");
                });
            });
        }
        //multilayer symbols
        public void ContructMultilayerLineSymbol_1()
        {
            #region How to construct a multilayer line symbol with circle markers on the line ends

            //These methods must be called within the lambda passed to QueuedTask.Run
            var lineStrokeRed = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.RedRGB, 4.0);
            var markerCircle  = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.RedRGB, 12, SimpleMarkerStyle.Circle);
            markerCircle.MarkerPlacement = new CIMMarkerPlacementOnVertices()
            {
                AngleToLine      = true,
                PlaceOnEndPoints = true,
                Offset           = 0
            };
            var lineSymbolWithCircles = new CIMLineSymbol()
            {
                SymbolLayers = new CIMSymbolLayer[2] {
                    markerCircle, lineStrokeRed
                }
            };

            #endregion
        }
        public void ContructMultilayerLineSymbol_2()
        {
            #region How to construct a multilayer line symbol with an arrow head on the end

            //These methods must be called within the lambda passed to QueuedTask.Run
            var markerTriangle = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.RedRGB, 12, SimpleMarkerStyle.Triangle);
            markerTriangle.Rotation        = -90; // or -90
            markerTriangle.MarkerPlacement = new CIMMarkerPlacementOnLine()
            {
                AngleToLine = true, RelativeTo = PlacementOnLineRelativeTo.LineEnd
            };

            var lineSymbolWithArrow = new CIMLineSymbol()
            {
                SymbolLayers = new CIMSymbolLayer[2] {
                    markerTriangle,
                    SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.RedRGB, 2)
                }
            };

            #endregion
        }
Exemple #20
0
        public RemoveOverlapsFeedback()
        {
            CIMColor color = ColorFactory.Instance.CreateRGBColor(255, 0, 0);

            _overlapLineSymbol = SymbolFactory.Instance.ConstructLineSymbol(color, 2);

            var hatchFill = new CIMHatchFill
            {
                Enable     = true,
                Rotation   = 0.0,
                Separation = 2.5,
                LineSymbol = _overlapLineSymbol
            };

            var symbolLayers = new List <CIMSymbolLayer>();

            symbolLayers.AddRange(_overlapLineSymbol.SymbolLayers);
            symbolLayers.Add(hatchFill);

            _overlapPolygonSymbol = new CIMPolygonSymbol {
                SymbolLayers = symbolLayers.ToArray()
            };
        }
Exemple #21
0
        public static CIMPolygonSymbol CreateHatchFillSymbol(float red, float green, float blue,
                                                             double rotation       = 0,
                                                             double lineWidth      = 2,
                                                             double lineSeparation = 5)
        {
            CIMLineSymbol lineSymbol = CreateLineSymbol(red, green, blue, lineWidth);

            var hatchFill = new CIMHatchFill
            {
                Enable     = true,
                Rotation   = rotation,
                Separation = lineSeparation,
                LineSymbol = lineSymbol
            };

            var symbolLayers = new List <CIMSymbolLayer>();

            symbolLayers.AddRange(lineSymbol.SymbolLayers);
            symbolLayers.Add(hatchFill);

            return(new CIMPolygonSymbol {
                SymbolLayers = symbolLayers.ToArray()
            });
        }
Exemple #22
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 (_lineSymbol == 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 Line?
                if (selectedElements.Count() == 1)
                {
                    if (selectedElements.FirstOrDefault().GetGraphic() is CIMLineGraphic) //It is a line
                    {
                        //So we use it
                        var lineSymbol = selectedElements.FirstOrDefault().GetGraphic() as CIMLineGraphic;
                        _lineSymbol = lineSymbol.Symbol.Symbol as CIMLineSymbol;
                    }
                }
                var cimGraphicElement = new CIMLineGraphic
                {
                    Line = geometry as Polyline,
                    Symbol = _lineSymbol.MakeSymbolReference()
                };
                Module1.Current.SelectedGraphicsLayerTOC.AddElement(cimGraphicElement);
                return true;
            }));
        }
Exemple #23
0
        protected override async void OnClick()
        {
            SharedFunctions.Log("Starting To Create 3D Visualization");
            DateTime startTime = DateTime.Now;

            CIMLineSymbol      symbol          = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.GreyRGB, 5.0, SimpleLineStyle.Solid);
            CIMSymbolReference symbolReference = symbol.MakeSymbolReference();

            try
            {
                await QueuedTask.Run(async() =>
                {
                    if (!SharedFunctions.LayerExists("DamCandidates") || !SharedFunctions.LayerExists("ReservoirSurfaces"))
                    {
                        return;
                    }
                    var damCandidatesLayer     = MapView.Active.Map.FindLayers("DamCandidates").FirstOrDefault();
                    var reservoirSurfacesLayer = MapView.Active.Map.FindLayers("ReservoirSurfaces").FirstOrDefault();

                    SpatialReference      = damCandidatesLayer.GetSpatialReference();
                    var damVisLayer       = await CreateMultiPatchFeatureClass("DamVisualization");
                    var reservoirVisLayer = await CreatePolygonFeatureClass("ReservoirVisualization");

                    Visualize(damVisLayer, reservoirVisLayer, reservoirSurfacesLayer as BasicFeatureLayer, damCandidatesLayer as BasicFeatureLayer);
                });
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                DateTime endTime = DateTime.Now;
                SharedFunctions.Log("Visualized in " + (endTime - startTime).TotalSeconds.ToString() + " seconds");
            }
        }
Exemple #24
0
        // Methods to create the selection layers.
        public static void MakeSewersLayers(Map mapView)
        {
            try
            {
                var mh    = mapView.GetLayersAsFlattenedList().OfType <FeatureLayer>().FirstOrDefault(s => s.Name == "Manholes");
                var lines = mapView.GetLayersAsFlattenedList().OfType <FeatureLayer>().FirstOrDefault(s => s.Name == "Sewer Lines");

                //Get the selected features from the map.
                var mhOIDList    = mh.GetSelection().GetObjectIDs();                 // Gets a list of Object IDs
                var mhOID        = mh.GetTable().GetDefinition().GetObjectIDField(); // Gets the OBJECTID field name for the def query
                var linesOIDList = lines.GetSelection().GetObjectIDs();
                var linesOID     = lines.GetTable().GetDefinition().GetObjectIDField();

                //Check to see if there are mmanhole or sewer line features selected in map.
                if (mhOIDList.Count() == 0 && linesOIDList.Count() == 0)
                {
                    MessageBox.Show("Manholes & Sewers contain no selected features.", "Warning");
                }

                else if (mhOIDList.Count() == 0 && linesOIDList.Count() > 0)
                {
                    MessageBox.Show("Manholes layer contains no selected features.", "Warning");
                }

                else if (mhOIDList.Count() > 0 && linesOIDList.Count() == 0)
                {
                    MessageBox.Show("Sewer Lines layer contains no selected features.", "Warning");
                }

                else
                {
                    // CREATE THE SEWER LINES SELECTION LAYER
                    // Create the defenition query
                    string linesDefQuery = $"{linesOID} in ({string.Join(",", linesOIDList)})";
                    string linesURL      = @"O:\SHARE\405 - INFORMATION SERVICES\GIS_Layers\[email protected]\SDE.SEWERMAN.SEWERS_VIEW";

                    // Create the Uri object create the feature layer.
                    Uri linesURI      = new Uri(linesURL);
                    var linesSelLayer = LayerFactory.Instance.CreateFeatureLayer(linesURI, mapView, 0, "Sewer Lines SELECTION");

                    // Apply the definition query
                    linesSelLayer.SetDefinitionQuery(linesDefQuery);

                    // Create the line symbol renderer.
                    CIMLineSymbol lineSymbol = SymbolFactory.Instance.ConstructLineSymbol(
                        ColorFactory.Instance.RedRGB,
                        3.0,
                        SimpleLineStyle.Solid
                        );
                    CIMSimpleRenderer lineRenderer = linesSelLayer.GetRenderer() as CIMSimpleRenderer;

                    // Renference the existing renderer
                    lineRenderer.Symbol = lineSymbol.MakeSymbolReference();
                    // Apply the new renderer
                    linesSelLayer.SetRenderer(lineRenderer);


                    // CREATE THE MANHOLES SELECTION LAYER
                    // Create the defenition query
                    string mhDefQuery = $"{mhOID} in ({string.Join(",", mhOIDList)})";
                    string mhURL      = @"O:\SHARE\405 - INFORMATION SERVICES\GIS_Layers\[email protected]\SDE.SEWERMAN.MANHOLES_VIEW";

                    // Create the Uri object create the feature layer.
                    Uri mhURI      = new Uri(mhURL);
                    var mhSelLayer = LayerFactory.Instance.CreateFeatureLayer(mhURI, mapView, 0, "Manholes SELECTION");

                    // Apply the definition query
                    mhSelLayer.SetDefinitionQuery(mhDefQuery);

                    // Create the point symbol renderer.
                    CIMPointSymbol pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(
                        ColorFactory.Instance.GreenRGB,
                        8.0,
                        SimpleMarkerStyle.Circle
                        );
                    CIMSimpleRenderer pointRenderer = mhSelLayer.GetRenderer() as CIMSimpleRenderer;

                    // Renference the existing renderer
                    pointRenderer.Symbol = pointSymbol.MakeSymbolReference();
                    // Apply the new renderer
                    mhSelLayer.SetRenderer(pointRenderer);
                }
            }

            catch (Exception ex)
            {
                string caption = "Module1.MakeSewersLayers method failed!";
                string message = "Process failed. \n\nSave and restart ArcGIS Pro and try process again.\n\n" +
                                 $"If problem persist, contact your local GIS nerd.\n\n{ex}";

                //Using the ArcGIS Pro SDK MessageBox class
                MessageBox.Show(message, caption);
            }
        }
Exemple #25
0
        /// <summary>
        /// Called after the feature selection changed.
        /// Method for retrieving map items in the project.
        /// </summary>
        private async void FindLinkedFeatures(MapSelectionChangedEventArgs args)
        {
            await QueuedTask.Run(() =>
            {
                //Clear the collections
                _listOfLinkedFeatures.Clear();

                //Clearing the currently drawn overlay on the map
                foreach (var graphic in snapshot)
                {
                    graphic.Dispose();
                }
                snapshot.Clear();

                Feature selectedFeature = null;
                //Gets the feature that is currently selected in the map
                var selectedFeat = MapView.Active.Map.GetSelection().ToDictionary().Where(kvp => layerNames.Contains(kvp.Key.ToString())).FirstOrDefault();
                if (selectedFeat.Value == null)
                {
                    return;
                }
                var layer = pLayers.Where(l => l.Name.Equals(selectedFeat.Key.ToString(), StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

                QueryFilter queryFilter = new QueryFilter()
                {
                    ObjectIDs = selectedFeat.Value
                };

                using (RowCursor cursor = layer.Search(queryFilter))
                {
                    System.Diagnostics.Debug.Assert(cursor.MoveNext());
                    selectedFeature = (Feature)cursor.Current;
                }

                if (selectedFeature != null)
                {
                    //Add Overlay showing all the connected topology nodes and for that selected feature
                    if (_symbol == null)
                    {
                        //Construct point and line symbols
                        _symbol     = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.RedRGB, 10.0, SimpleMarkerStyle.Circle);
                        _symbolLine = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.RedRGB, 5.0);
                        //Get symbol reference from the symbol
                        _symbolReference     = _symbol.MakeSymbolReference();
                        _symbolReferenceLine = _symbolLine.MakeSymbolReference();
                    }

                    MapView.Active.BuildMapTopologyGraph <TopologyDefinition>(topologyGraph =>
                    {
                        var nodes = topologyGraph.GetNodes(selectedFeature); //Topology nodes via that feature

                        foreach (TopologyNode node in nodes)
                        {
                            var edges = node.GetEdges();

                            var parent = node.GetParentFeatures();
                            foreach (var p in parent)
                            {
                                //Skipping the currently selected feature so as not to list it in the pane
                                if (p.FeatureClassName.Equals(selectedFeat.Key.ToString()) && p.ObjectID.Equals(selectedFeature.GetObjectID()))
                                {
                                    continue;
                                }
                                if (!_listOfLinkedFeatures.Contains(p))
                                {
                                    _listOfLinkedFeatures.Add(p);
                                }
                            }

                            foreach (TopologyEdge edge in edges)
                            {
                                var shape      = edge.GetShape();
                                _overlayObject = MapView.Active.AddOverlay(edge.GetShape() as Polyline, _symbolReferenceLine);
                                snapshot.Add(_overlayObject);
                            }
                            var nodeShape  = node.GetShape();
                            _overlayObject = MapView.Active.AddOverlay(node.GetShape() as MapPoint, _symbolReference);
                            snapshot.Add(_overlayObject);
                        }
                    });
                    System.Diagnostics.Debug.WriteLine($"Number of topologically connected features are:  {_listOfLinkedFeatures.Count}.");
                }
            });
        }
        /// <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;
                    }
                }
            }
        }
Exemple #27
0
 /// <summary>
 /// Create a line graphic.
 /// </summary>
 /// <param name="fieldOfJoy"></param>
 /// <param name="a"></param>
 /// <param name="b"></param>
 /// <param name="lineSymbol"></param>
 private static void CreateLine(GraphicsLayer fieldOfJoy, MapPoint a, MapPoint b, CIMLineSymbol lineSymbol)
 {
     fieldOfJoy.AddElement(new CIMLineGraphic()
     {
         Symbol = lineSymbol.MakeSymbolReference(),
         Line   = PolylineBuilder.CreatePolyline(new List <MapPoint>()
         {
             a, b
         }, fieldOfJoy.GetSpatialReference())
     });
 }
Exemple #28
0
        public void snippets_CreateLayoutElements()
        {
            LayoutView layoutView = LayoutView.Active;
            Layout     layout     = layoutView.Layout;

            #region Create point graphic with symbology

            //Create a simple 2D point graphic and apply an existing point style item as the symbology.
            //An alternative simple symbol is also provided below.  This would completely elminate the 4 lines of code that reference a style.

            QueuedTask.Run(() =>
            {
                //Build 2D point geometry
                Coordinate2D coord2D = new Coordinate2D(2.0, 10.0);

                //Reference a point symbol in a style
                StyleProjectItem ptStylePrjItm = Project.Current.GetItems <StyleProjectItem>().FirstOrDefault(item => item.Name == "ArcGIS 2D");
                SymbolStyleItem ptSymStyleItm  = ptStylePrjItm.SearchSymbols(StyleItemType.PointSymbol, "City Hall")[0];
                CIMPointSymbol pointSym        = ptSymStyleItm.Symbol as CIMPointSymbol;
                pointSym.SetSize(50);

                //Set symbolology, create and add element to layout
                //CIMPointSymbol pointSym = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.RedRGB, 25.0, SimpleMarkerStyle.Star);  //Alternative simple symbol
                GraphicElement ptElm = LayoutElementFactory.Instance.CreatePointGraphicElement(layout, coord2D, pointSym);
                ptElm.SetName("New Point");
            });
            #endregion

            #region Create line graphic with symbology

            //Create a simple 2D line graphic and apply an existing line style item as the symbology.
            //An alternative simple symbol is also provided below.  This would completely elminate the 4 lines of code that reference a style.

            QueuedTask.Run(() =>
            {
                //Build 2d line geometry
                List <Coordinate2D> plCoords = new List <Coordinate2D>();
                plCoords.Add(new Coordinate2D(1, 8.5));
                plCoords.Add(new Coordinate2D(1.66, 9));
                plCoords.Add(new Coordinate2D(2.33, 8.1));
                plCoords.Add(new Coordinate2D(3, 8.5));
                Polyline linePl = PolylineBuilder.CreatePolyline(plCoords);

                //Reference a line symbol in a style
                StyleProjectItem lnStylePrjItm = Project.Current.GetItems <StyleProjectItem>().FirstOrDefault(item => item.Name == "ArcGIS 2D");
                SymbolStyleItem lnSymStyleItm  = lnStylePrjItm.SearchSymbols(StyleItemType.LineSymbol, "Line with 2 Markers")[0];
                CIMLineSymbol lineSym          = lnSymStyleItm.Symbol as CIMLineSymbol;
                lineSym.SetSize(20);

                //Set symbolology, create and add element to layout
                //CIMLineSymbol lineSym = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlueRGB, 4.0, SimpleLineStyle.Solid);  //Alternative simple symbol
                GraphicElement lineElm = LayoutElementFactory.Instance.CreateLineGraphicElement(layout, linePl, lineSym);
                lineElm.SetName("New Line");
            });
            #endregion

            #region Create rectangle graphic with simple symbology

            //Create a simple 2D rectangle graphic and apply simple fill and outline symbols.

            QueuedTask.Run(() =>
            {
                //Build 2D envelope geometry
                Coordinate2D rec_ll = new Coordinate2D(1.0, 4.75);
                Coordinate2D rec_ur = new Coordinate2D(3.0, 5.75);
                Envelope rec_env    = EnvelopeBuilder.CreateEnvelope(rec_ll, rec_ur);

                //Set symbolology, create and add element to layout
                CIMStroke outline        = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 5.0, SimpleLineStyle.Solid);
                CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.GreenRGB, SimpleFillStyle.DiagonalCross, outline);
                GraphicElement recElm    = LayoutElementFactory.Instance.CreateRectangleGraphicElement(layout, rec_env, polySym);
                recElm.SetName("New Rectangle");
            });
            #endregion

            #region Create text element with basic font properties

            //Create a simple point text element and assign basic symbology as well as basic text settings.

            QueuedTask.Run(() =>
            {
                //Build 2D point geometry
                Coordinate2D coord2D = new Coordinate2D(3.5, 10);

                //Set symbolology, create and add element to layout
                CIMTextSymbol sym       = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.RedRGB, 32, "Arial", "Regular");
                string textString       = "Point text";
                GraphicElement ptTxtElm = LayoutElementFactory.Instance.CreatePointTextGraphicElement(layout, coord2D, textString, sym);
                ptTxtElm.SetName("New Point Text");

                //Change additional text properties
                ptTxtElm.SetAnchor(Anchor.CenterPoint);
                ptTxtElm.SetX(4.5);
                ptTxtElm.SetY(9.5);
                ptTxtElm.SetRotation(45);
            });
            #endregion

            #region Create rectangle text with more advanced symbol settings

            //Create rectangle text with background and border symbology.  Also notice how formatting tags are using within the text string.

            QueuedTask.Run(() =>
            {
                //Build 2D polygon geometry
                List <Coordinate2D> plyCoords = new List <Coordinate2D>();
                plyCoords.Add(new Coordinate2D(3.5, 7));
                plyCoords.Add(new Coordinate2D(4.5, 7));
                plyCoords.Add(new Coordinate2D(4.5, 6.7));
                plyCoords.Add(new Coordinate2D(5.5, 6.7));
                plyCoords.Add(new Coordinate2D(5.5, 6.1));
                plyCoords.Add(new Coordinate2D(3.5, 6.1));
                Polygon poly = PolygonBuilder.CreatePolygon(plyCoords);

                //Set symbolology, create and add element to layout
                CIMTextSymbol sym         = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.GreyRGB, 10, "Arial", "Regular");
                string text               = "Some Text String that is really long and is <BOL>forced to wrap to other lines</BOL> so that we can see the effects." as String;
                GraphicElement polyTxtElm = LayoutElementFactory.Instance.CreatePolygonParagraphGraphicElement(layout, poly, text, sym);
                polyTxtElm.SetName("New Polygon Text");

                //(Optionally) Modify paragraph border
                CIMGraphic polyTxtGra = polyTxtElm.Graphic;
                CIMParagraphTextGraphic cimPolyTxtGra   = polyTxtGra as CIMParagraphTextGraphic;
                cimPolyTxtGra.Frame.BorderSymbol        = new CIMSymbolReference();
                cimPolyTxtGra.Frame.BorderSymbol.Symbol = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.GreyRGB, 1.0, SimpleLineStyle.Solid);
                polyTxtElm.SetGraphic(polyTxtGra);
            });
            #endregion

            #region Create a new picture element with advanced symbol settings

            //Create a picture element and also set background and border symbology.

            QueuedTask.Run(() =>
            {
                //Build 2D envelope geometry
                Coordinate2D pic_ll = new Coordinate2D(6, 1);
                Coordinate2D pic_ur = new Coordinate2D(8, 2);
                Envelope env        = EnvelopeBuilder.CreateEnvelope(pic_ll, pic_ur);

                //Create and add element to layout
                string picPath        = @"C:\Temp\WhitePass.jpg";
                GraphicElement picElm = LayoutElementFactory.Instance.CreatePictureGraphicElement(layout, env, picPath);
                picElm.SetName("New Picture");

                //(Optionally) Modify the border and shadow
                CIMGraphic picGra                   = picElm.Graphic;
                CIMPictureGraphic cimPicGra         = picGra as CIMPictureGraphic;
                cimPicGra.Frame.BorderSymbol        = new CIMSymbolReference();
                cimPicGra.Frame.BorderSymbol.Symbol = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlueRGB, 2.0, SimpleLineStyle.Solid);

                cimPicGra.Frame.ShadowSymbol        = new CIMSymbolReference();
                cimPicGra.Frame.ShadowSymbol.Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.BlackRGB, SimpleFillStyle.Solid);

                picElm.SetGraphic(picGra);
            });
            #endregion

            #region Create a map frame and zoom to a bookmark

            //Create a map frame and also sets its extent by zooming the the extent of an existing bookmark.

            QueuedTask.Run(() =>
            {
                //Build 2D envelope geometry
                Coordinate2D mf_ll = new Coordinate2D(6.0, 8.5);
                Coordinate2D mf_ur = new Coordinate2D(8.0, 10.5);
                Envelope mf_env    = EnvelopeBuilder.CreateEnvelope(mf_ll, mf_ur);

                //Reference map, create MF and add to layout
                MapProjectItem mapPrjItem = Project.Current.GetItems <MapProjectItem>().FirstOrDefault(item => item.Name.Equals("Map"));
                Map mfMap      = mapPrjItem.GetMap();
                MapFrame mfElm = LayoutElementFactory.Instance.CreateMapFrame(layout, mf_env, mfMap);
                mfElm.SetName("New Map Frame");

                //Zoom to bookmark
                Bookmark bookmark = mfElm.Map.GetBookmarks().FirstOrDefault(b => b.Name == "Great Lakes");
                mfElm.SetCamera(bookmark);
            });
            #endregion

            #region Create a legend for a specifc map frame

            //Create a legend for an associated map frame.

            QueuedTask.Run(() =>
            {
                //Build 2D envelope geometry
                Coordinate2D leg_ll = new Coordinate2D(6, 2.5);
                Coordinate2D leg_ur = new Coordinate2D(8, 4.5);
                Envelope leg_env    = EnvelopeBuilder.CreateEnvelope(leg_ll, leg_ur);

                //Reference MF, create legend and add to layout
                MapFrame mapFrame = layout.FindElement("New Map Frame") as MapFrame;
                if (mapFrame == null)
                {
                    ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Map frame not found", "WARNING");
                    return;
                }
                Legend legendElm = LayoutElementFactory.Instance.CreateLegend(layout, leg_env, mapFrame);
                legendElm.SetName("New Legend");
            });
            #endregion

            #region Creating group elements
            //Create an empty group element at the root level of the contents pane
            //Note: call within QueuedTask.Run()
            GroupElement grp1 = LayoutElementFactory.Instance.CreateGroupElement(layout);
            grp1.SetName("Group");

            //Create a group element inside another group element
            //Note: call within QueuedTask.Run()
            GroupElement grp2 = LayoutElementFactory.Instance.CreateGroupElement(grp1);
            grp2.SetName("Group in Group");
            #endregion Creating group elements

            {
                #region Create scale bar
                Coordinate2D llScalebar = new Coordinate2D(6, 2.5);
                MapFrame     mapframe   = layout.FindElement("New Map Frame") as MapFrame;
                //Note: call within QueuedTask.Run()
                LayoutElementFactory.Instance.CreateScaleBar(layout, llScalebar, mapframe);
                #endregion
            }
            #region How to search for scale bars in a style
            var arcgis_2d = Project.Current.GetItems <StyleProjectItem>().First(si => si.Name == "ArcGIS 2D");
            QueuedTask.Run(() => {
                var scaleBarItems = arcgis_2d.SearchScaleBars("Double Alternating Scale Bar");
            });

            #endregion

            #region How to add a scale bar from a style to a layout
            var arcgis_2dStyle = Project.Current.GetItems <StyleProjectItem>().First(si => si.Name == "ArcGIS 2D");
            QueuedTask.Run(() =>
            {
                //Imperial Double Alternating Scale Bar
                //Metric Double Alternating Scale Bar
                //or just use empty string to list them all...
                var scaleBarItem     = arcgis_2d.SearchScaleBars("Double Alternating Scale Bar").FirstOrDefault();
                Coordinate2D coord2D = new Coordinate2D(10.0, 7.0);
                MapFrame myMapFrame  = layout.FindElement("Map Frame") as MapFrame;
                LayoutElementFactory.Instance.CreateScaleBar(layout, coord2D, myMapFrame, scaleBarItem);
            });
            #endregion

            #region Create NorthArrow
            Coordinate2D llNorthArrow = new Coordinate2D(6, 2.5);
            MapFrame     mf           = layout.FindElement("New Map Frame") as MapFrame;
            //Note: call within QueuedTask.Run()
            var northArrow = LayoutElementFactory.Instance.CreateNorthArrow(layout, llNorthArrow, mf);
            #endregion

            #region How to search for North Arrows in a style
            var arcgis_2dStyles = Project.Current.GetItems <StyleProjectItem>().First(si => si.Name == "ArcGIS 2D");
            QueuedTask.Run(() => {
                var scaleBarItems = arcgis_2dStyles.SearchNorthArrows("ArcGIS North 13");
            });
            #endregion

            #region How to add a North Arrow from a style to a layout
            var arcgis2dStyles = Project.Current.GetItems <StyleProjectItem>().First(si => si.Name == "ArcGIS 2D");
            QueuedTask.Run(() => {
                var northArrowStyleItem = arcgis2dStyles.SearchNorthArrows("ArcGIS North 13").FirstOrDefault();
                Coordinate2D nArrow     = new Coordinate2D(6, 2.5);
                MapFrame newFrame       = layout.FindElement("New Map Frame") as MapFrame;
                //Note: call within QueuedTask.Run()
                var newNorthArrow = LayoutElementFactory.Instance.CreateNorthArrow(layout, nArrow, newFrame, northArrowStyleItem);
            });

            #endregion

            #region Create dynamic text
            var          title   = @"<dyn type = ""page"" property = ""name"" />";
            Coordinate2D llTitle = new Coordinate2D(6, 2.5);
            //Note: call within QueuedTask.Run()
            var titleGraphics = LayoutElementFactory.Instance.CreatePointTextGraphicElement(layout, llTitle, null) as TextElement;
            titleGraphics.SetTextProperties(new TextProperties(title, "Arial", 24, "Bold"));
            #endregion


            #region Create dynamic table

            QueuedTask.Run(() =>
            {
                //Build 2D envelope geometry
                Coordinate2D tab_ll = new Coordinate2D(6, 2.5);
                Coordinate2D tab_ur = new Coordinate2D(12, 6.5);
                Envelope tab_env    = EnvelopeBuilder.CreateEnvelope(tab_ll, tab_ur);
                MapFrame mapFrame   = layout.FindElement("New Map Frame") as MapFrame;
                // get the layer
                MapProjectItem mapPrjItem = Project.Current.GetItems <MapProjectItem>().FirstOrDefault(item => item.Name.Equals("Map"));
                Map theMap = mapPrjItem?.GetMap();
                var lyrs   = theMap?.FindLayers("Inspection Point Layer", true);
                if (lyrs?.Count > 0)
                {
                    Layer lyr  = lyrs[0];
                    var table1 = LayoutElementFactory.Instance.CreateTableFrame(layout, tab_env, mapFrame, lyr, new string[] { "No", "Type", "Description" });
                }
            });
            #endregion
        }
Exemple #29
0
        protected override void OnClick()
        {
            var project = Project.Current;

            if (project == null)
            {
                MessageBox.Show("There are no currently active projects.", "No active projects", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
                return;
            }

            double xmin = 541593.3869217434,
                   ymin = 75366.04199113384,
                   xmax = 2560080.6803334514,
                   ymax = 1383832.028539666;

            var sr         = SpatialReferenceBuilder.CreateSpatialReference(2927);
            var waEnvelope = EnvelopeBuilder.CreateEnvelope(xmin, ymin, xmax, ymax, sr);
            // Create polygon for clipping
            var waPolygon         = PolygonBuilder.CreatePolygon(waEnvelope);
            var lineSymbolForCrop = new CIMLineSymbol();


            var items = project.GetItems <MapProjectItem>();

            System.Windows.MessageBoxResult result = System.Windows.MessageBoxResult.Cancel;
            if (items.Any())
            {
                result = MessageBox.Show("Set all maps' extents to that of WA?", "Set all extents", System.Windows.MessageBoxButton.OKCancel, System.Windows.MessageBoxImage.Question);
            }

            if (result == System.Windows.MessageBoxResult.OK)
            {
                QueuedTask.Run(() =>
                {
                    var geometryEngine = GeometryEngine.Instance;
                    foreach (var item in items)
                    {
                        var map = item.GetMap();
                        // Get the current full extent of the map.
                        var currentFullExtent = map.CalculateFullExtent();
                        // Set the map's full extent to WA if WA is contained in the current full extent.
                        NotificationItem nItem;
                        bool extentWasChanged = false;
                        if (geometryEngine.Contains(currentFullExtent, waEnvelope))
                        {
                            map.SetCustomFullExtent(waEnvelope);
                            extentWasChanged = true;
                            nItem            = new NotificationItem($"{DateTime.Now.Ticks}", false, $"Extent of map \"{map.Name}\" set to WA.", NotificationType.Information);
                        }
                        else
                        {
                            nItem = new NotificationItem($"{DateTime.Now.Ticks}", false, $"Extent of map \"{map.Name}\" was not changed. Current full extent does not contain WA.", NotificationType.Information);
                        }
                        NotificationManager.AddNotification(nItem);

                        if (extentWasChanged)
                        {
                            var currentClipGeometry = map.GetClipGeometry();
                            if (currentClipGeometry == null)
                            {
                                map.SetClipGeometry(waPolygon, lineSymbolForCrop);
                            }
                        }
                    }
                });
            }
        }
        /// <summary>
        /// Create a line symbol with a dash and two markers. <br/>
        /// In this pattern of creating this symbol, a [CIMVectorMarker](http://pro.arcgis.com/en/pro-app/sdk/api-reference/#topic6176.html) object is created as a new [CIMSymbolLayer](http://prodev.arcgis.com/en/pro-app/sdk/api-reference/#topic5503.html).
        /// The circle and square markers created by [ContructMarker](http://pro.arcgis.com/en/pro-app/sdk/api-reference/#topic12350.html) method is then assigned to the [MarkerGraphics](http://prodev.arcgis.com/en/pro-app/sdk/api-reference/#topic6188.html) property of the CIMVectorMarker.
        /// When using this method, the CIMVectorMarker's [Frame](http://pro.arcgis.com/en/pro-app/sdk/api-reference/#topic6187.html) property needs to be set to the [CIMMarker](http://pro.arcgis.com/en/pro-app/sdk/api-reference/#topic3264.html) object's Frame.
        /// Similarly, the CIMVectorMarker's [Size](http://pro.arcgis.com/en/pro-app/sdk/api-reference/#topic3284.html) property needs to be set to the CIMMarker object's size.
        /// </summary>
        /// <remarks>
        /// This line symbol comprises three symbol layers listed below:
        /// 1. A solid stroke that has dashes.
        /// 1. A circle marker.
        /// 1. A square marker.
        /// ![LineSymbolTwoMarkers](http://Esri.github.io/arcgis-pro-sdk/images/Symbology/line-dash-two-markers.png)
        /// </remarks>
        /// <returns></returns>

        internal static Task <CIMLineSymbol> CreateLineDashTwoMarkers2Async()
        {
            return(QueuedTask.Run <CIMLineSymbol>(() =>
            {
                //default line symbol that will get modified.
                var dash2MarkersLine = new CIMLineSymbol();
                //circle marker to be used in our line symbol as a layer
                var circleMarker = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.BlackRGB, 5, SimpleMarkerStyle.Circle) as CIMVectorMarker;
                //circle marker to be used in our line symbol as a layer
                var squareMarker = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.BlueRGB, 5, SimpleMarkerStyle.Square) as CIMVectorMarker;
                //Create the array of layers that make the new line symbol
                CIMSymbolLayer[] mySymbolLyrs =
                {
                    new CIMSolidStroke() //dash line
                    {
                        Color = ColorFactory.Instance.BlackRGB,
                        Enable = true,
                        ColorLocked = true,
                        CapStyle = LineCapStyle.Round,
                        JoinStyle = LineJoinStyle.Round,
                        LineStyle3D = Simple3DLineStyle.Strip,
                        MiterLimit = 10,
                        Width = 1,
                        CloseCaps3D = false,
                        Effects = new CIMGeometricEffect[]
                        {
                            new CIMGeometricEffectDashes()
                            {
                                CustomEndingOffset = 0,
                                DashTemplate = new double[]{                                 20, 10, 20, 10 },
                                LineDashEnding = LineDashEnding.HalfPattern,
                                OffsetAlongLine = 0,
                                ControlPointEnding = LineDashEnding.NoConstraint
                            },
                            new CIMGeometricEffectOffset()
                            {
                                Method = GeometricEffectOffsetMethod.Bevelled,
                                Offset = 0,
                                Option = GeometricEffectOffsetOption.Fast
                            }
                        }
                    },
                    new CIMVectorMarker() //circle marker
                    {
                        MarkerGraphics = circleMarker.MarkerGraphics,
                        Frame = circleMarker.Frame, //need to match the CIMVector marker's frame to the circleMarker's frame.
                        Size = circleMarker.Size,   //need to match the CIMVector marker's size to the circleMarker's size.
                        MarkerPlacement = new CIMMarkerPlacementAlongLineSameSize()
                        {
                            AngleToLine = true,
                            Offset = 0,
                            ControlPointPlacement = PlacementEndings.WithMarkers,
                            Endings = PlacementEndings.Custom,
                            OffsetAlongLine = 15,
                            PlacementTemplate = new double[]{                               60 },
                        }
                    },
                    new CIMVectorMarker() //square marker
                    {
                        MarkerGraphics = squareMarker.MarkerGraphics,
                        Frame = squareMarker.Frame, //need to match the CIMVector marker's frame to the squareMarker frame.
                        Size = squareMarker.Size,   //need to match the CIMVector marker's size to the squareMarker size.
                        MarkerPlacement = new CIMMarkerPlacementAlongLineSameSize()
                        {
                            AngleToLine = true,
                            Endings = PlacementEndings.Custom,
                            OffsetAlongLine = 45,
                            PlacementTemplate = new double[]{                               60 },
                        }
                    }
                };
                dash2MarkersLine.SymbolLayers = mySymbolLyrs;
                return dash2MarkersLine;
            }));
        }
Exemple #31
0
        async public static void CreateElementSnippets()
        {
            //There are already many Create element snippets in the PRO snippets section.  This section will only contain examples that are NOT in the Pro snippets section
            //Pro snippets region names includes:
            //    Create point graphic with symbology
            //    Create line graphic with symbology
            //    Create rectangle graphic with simple symbology
            //    Create text element with basic font properties
            //    Create rectangle text with more advanced symbol settings
            //    Create a new picture element with advanced symbol settings
            //    Create a map frame and zoom to a bookmark
            //    Create a legend for a specifc map frame
            //    Creating group elements

            LayoutView lytView = LayoutView.Active;
            Layout     layout  = lytView.Layout;

            #region Create_BeizierCurve
            await QueuedTask.Run(() =>
            {
                //Build geometry
                Coordinate2D pt1          = new Coordinate2D(1, 7.5);
                Coordinate2D pt2          = new Coordinate2D(1.66, 8);
                Coordinate2D pt3          = new Coordinate2D(2.33, 7.1);
                Coordinate2D pt4          = new Coordinate2D(3, 7.5);
                CubicBezierBuilder bez    = new CubicBezierBuilder(pt1, pt2, pt3, pt4);
                CubicBezierSegment bezSeg = bez.ToSegment();
                Polyline bezPl            = PolylineBuilder.CreatePolyline(bezSeg);

                //Set symbology, create and add element to layout
                CIMLineSymbol lineSym = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.RedRGB, 4.0, SimpleLineStyle.DashDot);
                GraphicElement bezElm = LayoutElementFactory.Instance.CreateLineGraphicElement(layout, bezPl, lineSym);
                bezElm.SetName("New Bezier Curve");
            });

            #endregion Create_BeizierCurve

            #region Create_freehand
            await QueuedTask.Run(() =>
            {
                //Build geometry
                List <Coordinate2D> plCoords = new List <Coordinate2D>();
                plCoords.Add(new Coordinate2D(1.5, 10.5));
                plCoords.Add(new Coordinate2D(1.25, 9.5));
                plCoords.Add(new Coordinate2D(1, 10.5));
                plCoords.Add(new Coordinate2D(0.75, 9.5));
                plCoords.Add(new Coordinate2D(0.5, 10.5));
                plCoords.Add(new Coordinate2D(0.5, 1));
                plCoords.Add(new Coordinate2D(0.75, 2));
                plCoords.Add(new Coordinate2D(1, 1));
                Polyline linePl = PolylineBuilder.CreatePolyline(plCoords);

                //Set symbolology, create and add element to layout
                CIMLineSymbol lineSym  = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlackRGB, 2.0, SimpleLineStyle.Solid);
                GraphicElement lineElm = LayoutElementFactory.Instance.CreateLineGraphicElement(layout, linePl, lineSym);
                lineElm.SetName("New Freehand");
            });

            #endregion Create_freehand

            #region Create_polygon
            await QueuedTask.Run(() =>
            {
                //Build geometry
                List <Coordinate2D> plyCoords = new List <Coordinate2D>();
                plyCoords.Add(new Coordinate2D(1, 7));
                plyCoords.Add(new Coordinate2D(2, 7));
                plyCoords.Add(new Coordinate2D(2, 6.7));
                plyCoords.Add(new Coordinate2D(3, 6.7));
                plyCoords.Add(new Coordinate2D(3, 6.1));
                plyCoords.Add(new Coordinate2D(1, 6.1));
                Polygon poly = PolygonBuilder.CreatePolygon(plyCoords);

                //Set symbolology, create and add element to layout
                CIMStroke outline        = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlueRGB, 2.0, SimpleLineStyle.DashDotDot);
                CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.ForwardDiagonal, outline);
                GraphicElement polyElm   = LayoutElementFactory.Instance.CreatePolygonGraphicElement(layout, poly, polySym);
                polyElm.SetName("New Polygon");
            });

            #endregion Create_polygon

            #region Create_circle
            await QueuedTask.Run(() =>
            {
                //Build geometry
                Coordinate2D center       = new Coordinate2D(2, 4);
                EllipticArcBuilder eabCir = new EllipticArcBuilder(center, 0.5, esriArcOrientation.esriArcClockwise);
                EllipticArcSegment cir    = eabCir.ToSegment();

                //Set symbolology, create and add element to layout
                CIMStroke outline          = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 2.0, SimpleLineStyle.Dash);
                CIMPolygonSymbol circleSym = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.Solid, outline);
                GraphicElement cirElm      = LayoutElementFactory.Instance.CreateCircleGraphicElement(layout, cir, circleSym);
                cirElm.SetName("New Circle");
            });

            #endregion Create_circle

            #region Create_ellipse
            await QueuedTask.Run(() =>
            {
                //Build geometry
                Coordinate2D center        = new Coordinate2D(2, 2.75);
                EllipticArcBuilder eabElp  = new EllipticArcBuilder(center, 0, 1, 0.45, esriArcOrientation.esriArcClockwise);
                EllipticArcSegment ellipse = eabElp.ToSegment();

                //Set symbolology, create and add element to layout
                CIMStroke outline           = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.GreenRGB, 2.0, SimpleLineStyle.Dot);
                CIMPolygonSymbol ellipseSym = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.GreyRGB, SimpleFillStyle.Vertical, outline);
                GraphicElement elpElm       = LayoutElementFactory.Instance.CreateEllipseGraphicElement(layout, ellipse, ellipseSym);
                elpElm.SetName("New Ellipse");
            });

            #endregion Create_ellipse

            #region Create_lasso
            await QueuedTask.Run(() =>
            {
                //Build geometry
                List <Coordinate2D> plyCoords = new List <Coordinate2D>();
                plyCoords.Add(new Coordinate2D(1, 1));
                plyCoords.Add(new Coordinate2D(1.25, 2));
                plyCoords.Add(new Coordinate2D(1.5, 1.1));
                plyCoords.Add(new Coordinate2D(1.75, 2));
                plyCoords.Add(new Coordinate2D(2, 1.1));
                plyCoords.Add(new Coordinate2D(2.25, 2));
                plyCoords.Add(new Coordinate2D(2.5, 1.1));
                plyCoords.Add(new Coordinate2D(2.75, 2));
                plyCoords.Add(new Coordinate2D(3, 1));
                Polygon poly = PolygonBuilder.CreatePolygon(plyCoords);

                //Set symbolology, create and add element to layout
                CIMStroke outline        = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 2.0, SimpleLineStyle.Solid);
                CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.ForwardDiagonal, outline);
                GraphicElement polyElm   = LayoutElementFactory.Instance.CreatePolygonGraphicElement(layout, poly, polySym);
                polyElm.SetName("New Lasso");
            });

            #endregion Create_lasso

            #region Create_CurveText
            await QueuedTask.Run(() =>
            {
                //Build geometry
                Coordinate2D pt1          = new Coordinate2D(3.6, 7.5);
                Coordinate2D pt2          = new Coordinate2D(4.26, 8);
                Coordinate2D pt3          = new Coordinate2D(4.93, 7.1);
                Coordinate2D pt4          = new Coordinate2D(5.6, 7.5);
                CubicBezierBuilder bez    = new CubicBezierBuilder(pt1, pt2, pt3, pt4);
                CubicBezierSegment bezSeg = bez.ToSegment();
                Polyline bezPl            = PolylineBuilder.CreatePolyline(bezSeg);

                //Set symbolology, create and add element to layout
                CIMTextSymbol sym        = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.BlackRGB, 24, "Comic Sans MS", "Regular");
                GraphicElement bezTxtElm = LayoutElementFactory.Instance.CreateCurvedTextGraphicElement(layout, bezPl, "Curved Text", sym);
                bezTxtElm.SetName("New Splinned Text");
            });

            #endregion Create_CurveText

            #region Create_PolygonText
            await QueuedTask.Run(() =>
            {
                //Build geometry
                List <Coordinate2D> plyCoords = new List <Coordinate2D>();
                plyCoords.Add(new Coordinate2D(3.5, 7));
                plyCoords.Add(new Coordinate2D(4.5, 7));
                plyCoords.Add(new Coordinate2D(4.5, 6.7));
                plyCoords.Add(new Coordinate2D(5.5, 6.7));
                plyCoords.Add(new Coordinate2D(5.5, 6.1));
                plyCoords.Add(new Coordinate2D(3.5, 6.1));
                Polygon poly = PolygonBuilder.CreatePolygon(plyCoords);

                //Set symbolology, create and add element to layout
                CIMTextSymbol sym         = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.GreyRGB, 10, "Arial", "Regular");
                string text               = "Some Text String that is really long and is <BOL>forced to wrap to other lines</BOL> so that we can see the effects." as String;
                GraphicElement polyTxtElm = LayoutElementFactory.Instance.CreatePolygonParagraphGraphicElement(layout, poly, text, sym);
                polyTxtElm.SetName("New Polygon Text");

                //(Optionally) Modify paragraph border
                CIMGraphic polyTxtGra = polyTxtElm.Graphic;
                CIMParagraphTextGraphic cimPolyTxtGra   = polyTxtGra as CIMParagraphTextGraphic;
                cimPolyTxtGra.Frame.BorderSymbol        = new CIMSymbolReference();
                cimPolyTxtGra.Frame.BorderSymbol.Symbol = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.GreyRGB, 1.0, SimpleLineStyle.Solid);
                polyTxtElm.SetGraphic(polyTxtGra);
            });

            #endregion Create_PolygonText

            #region Create_CircleText
            await QueuedTask.Run(() =>
            {
                //Build geometry
                Coordinate2D center       = new Coordinate2D(4.5, 4);
                EllipticArcBuilder eabCir = new EllipticArcBuilder(center, 0.5, esriArcOrientation.esriArcClockwise);
                EllipticArcSegment cir    = eabCir.ToSegment();

                //Set symbolology, create and add element to layout
                CIMTextSymbol sym        = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.GreenRGB, 10, "Arial", "Regular");
                string text              = "Circle, circle, circle, circle, circle, circle, circle, circle, circle, circle, circle";
                GraphicElement cirTxtElm = LayoutElementFactory.Instance.CreateCircleParagraphGraphicElement(layout, cir, text, sym);
                cirTxtElm.SetName("New Circle Text");

                //(Optionally) Modify paragraph border
                CIMGraphic cirTxtGra = cirTxtElm.Graphic;
                CIMParagraphTextGraphic cimCirTxtGra   = cirTxtGra as CIMParagraphTextGraphic;
                cimCirTxtGra.Frame.BorderSymbol        = new CIMSymbolReference();
                cimCirTxtGra.Frame.BorderSymbol.Symbol = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.GreyRGB, 1.0, SimpleLineStyle.Solid);
                cirTxtElm.SetGraphic(cirTxtGra);
            });

            #endregion Create_CircleText

            #region Create_EllipseText
            await QueuedTask.Run(() =>
            {
                //Build geometry
                Coordinate2D center        = new Coordinate2D(4.5, 2.75);
                EllipticArcBuilder eabElp  = new EllipticArcBuilder(center, 0, 1, 0.45, esriArcOrientation.esriArcClockwise);
                EllipticArcSegment ellipse = eabElp.ToSegment();

                //Set symbolology, create and add element to layout
                CIMTextSymbol sym        = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.BlueRGB, 10, "Arial", "Regular");
                string text              = "Ellipse, ellipse, ellipse, ellipse, ellipse, ellipse, ellipse, ellipse, ellipse, ellipse, ellipse, ellipse";
                GraphicElement elpTxtElm = LayoutElementFactory.Instance.CreateEllipseParagraphGraphicElement(layout, ellipse, text, sym);
                elpTxtElm.SetName("New Ellipse Text");

                //(Optionally) Modify paragraph border
                CIMGraphic elpTxtGra = elpTxtElm.Graphic;
                CIMParagraphTextGraphic cimElpTxtGra   = elpTxtGra as CIMParagraphTextGraphic;
                cimElpTxtGra.Frame.BorderSymbol        = new CIMSymbolReference();
                cimElpTxtGra.Frame.BorderSymbol.Symbol = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.GreyRGB, 1.0, SimpleLineStyle.Solid);
                elpTxtElm.SetGraphic(elpTxtGra);
            });

            #endregion Create_EllipseText

            MapFrame mfElm = null;
            #region Create_MapFrame
            //This example creates a new map frame and changes the camera scale.
            await QueuedTask.Run(() =>
            {
                //Build geometry
                Coordinate2D ll = new Coordinate2D(6.0, 8.5);
                Coordinate2D ur = new Coordinate2D(8.0, 10.5);
                Envelope env    = EnvelopeBuilder.CreateEnvelope(ll, ur);

                //Reference map, create MF and add to layout
                MapProjectItem mapPrjItem = Project.Current.GetItems <MapProjectItem>().FirstOrDefault(item => item.Name.Equals("Map"));
                Map mfMap = mapPrjItem.GetMap();
                mfElm     = LayoutElementFactory.Instance.CreateMapFrame(layout, env, mfMap);
                mfElm.SetName("New Map Frame");

                //Set the camera
                Camera camera = mfElm.Camera;
                camera.Scale  = 24000;
                mfElm.SetCamera(camera);
            });

            #endregion Create_MapFrame


            #region Create_ScaleBar
            await QueuedTask.Run(() =>
            {
                //Reference a North Arrow in a style
                StyleProjectItem stylePrjItm = Project.Current.GetItems <StyleProjectItem>().FirstOrDefault(item => item.Name == "ArcGIS 2D");
                ScaleBarStyleItem sbStyleItm = stylePrjItm.SearchScaleBars("Double Alternating Scale Bar 1")[0];

                //Build geometry
                Coordinate2D center = new Coordinate2D(7, 8);

                //Reference MF, create north arrow and add to layout
                MapFrame mf = layout.FindElement("New Map Frame") as MapFrame;
                if (mf == null)
                {
                    ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Map frame not found", "WARNING");
                    return;
                }
                ScaleBar sbElm = LayoutElementFactory.Instance.CreateScaleBar(layout, center, mf, sbStyleItm);
                sbElm.SetName("New Scale Bar");
                sbElm.SetWidth(2);
                sbElm.SetX(6);
                sbElm.SetY(7.5);
            });

            #endregion Create_ScaleBar

            #region Create_NorthArrow
            await QueuedTask.Run(() =>
            {
                //Reference a North Arrow in a style
                StyleProjectItem stylePrjItm   = Project.Current.GetItems <StyleProjectItem>().FirstOrDefault(item => item.Name == "ArcGIS 2D");
                NorthArrowStyleItem naStyleItm = stylePrjItm.SearchNorthArrows("ArcGIS North 10")[0];

                //Build geometry
                Coordinate2D center = new Coordinate2D(7, 5.5);

                //Reference MF, create north arrow and add to layout
                MapFrame mf = layout.FindElement("New Map Frame") as MapFrame;
                if (mf == null)
                {
                    ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Map frame not found", "WARNING");
                    return;
                }
                NorthArrow arrowElm = LayoutElementFactory.Instance.CreateNorthArrow(layout, center, mf, naStyleItm);
                arrowElm.SetName("New North Arrow");
                arrowElm.SetHeight(1.75);
                arrowElm.SetX(7);
                arrowElm.SetY(6);
            });

            #endregion Create_NorthArrow
        }