protected override Task <bool> OnSketchCompleteAsync(Geometry geometry)
        {
            if (ActiveElementContainer == null)
            {
                Task.FromResult(true);
            }

            QueuedTask.Run(() =>
            {
                var sketch = geometry as Polygon;
                var marker = SymbolFactory.Instance.ConstructMarker(
                    CIMColor.CreateRGBColor(0, 0, 255), 20, SimpleMarkerStyle.Cloud) as CIMVectorMarker;

                var cloud      = marker.MarkerGraphics[0].Geometry;
                var polySymbol = marker.MarkerGraphics[0].Symbol;

                //Add the cloud to the layout elem factory
                //which converts it to page or map (this is the _key_)
                var ge = ElementFactory.Instance.CreateGraphicElement(
                    this.ActiveElementContainer, cloud, Module1.SelectedSymbol);

                //scale it to fill the extent of the sketch, then move
                ge.SetLockedAspectRatio(true);
                ge.SetHeight(sketch.Extent.Height);                   //scale
                ge.SetAnchor(Anchor.CenterPoint);
                ge.SetAnchorPoint(sketch.Extent.Center.Coordinate2D); //move
            });
            return(base.OnSketchCompleteAsync(geometry));
        }
        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);
        }
        /// <summary>
        /// Renders a feature layer using graduated symbols and natural breaks to draw quantities.
        /// ![cb-symbols.png](http://Esri.github.io/arcgis-pro-sdk/images/Renderers/cb-symbols.png "Graduated symbols with natural breaks renderer.")
        /// </summary>
        /// <returns>
        /// </returns>
        internal static Task CBRendererGraduatedSymbols()
        {
            //Check feature layer name
            //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data
            var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType <FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics");

            if (featureLayer == null)
            {
                MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing");
                return(Task.FromResult(0));
            }
            return(QueuedTask.Run(() =>
            {
                GraduatedSymbolsRendererDefinition gsDef = new GraduatedSymbolsRendererDefinition()
                {
                    ClassificationField = SDKHelpers.GetNumericField(featureLayer), //getting the first numeric field
                    ClassificationMethod = ClassificationMethod.NaturalBreaks,
                    SymbolTemplate = SymbolFactory.Instance.ConstructPointSymbol(CIMColor.CreateRGBColor(76, 230, 0)).MakeSymbolReference(),
                    MinimumSymbolSize = 4,
                    MaximumSymbolSize = 50,
                    BreakCount = 5,
                    ColorRamp = SDKHelpers.GetColorRamp(), //getting a color ramp
                };
                CIMClassBreaksRenderer renderer = (CIMClassBreaksRenderer)featureLayer.CreateRenderer(gsDef);
                featureLayer?.SetRenderer(renderer);
            }));
        }
        /// <summary>
        /// Create a polygon symbol with a gradient color fill. <br/>
        /// ![PolygonSymbolGradientColor](http://Esri.github.io/arcgis-pro-sdk/images/Symbology/polygon-gradient-color.png)
        /// </summary>
        /// <remarks>
        /// 1. Create a solid colored stroke with 50% transparency
        /// 1. Create a fill using gradient colors red through green
        /// 1. Apply both the stroke and fill as a symbol layer array to the new PolygonSymbol
        /// </remarks>
        /// <returns></returns>
        public static async Task <CIMPolygonSymbol> CreateGradientFill()
        {
            var polyGradientFill = await QueuedTask.Run(() =>
            {
                var trans         = 50.0;//semi transparent
                CIMStroke outline = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(0, 0, 0, trans), 2.0, SimpleLineStyle.Solid);
                //Mimic cross hatch
                CIMFill solidColorHatch =
                    new CIMGradientFill()
                {
                    ColorRamp = ColorFactory.Instance.ConstructColorRamp(ColorRampAlgorithm.LinearContinuous,
                                                                         ColorFactory.Instance.RedRGB, ColorFactory.Instance.GreenRGB)
                };
                List <CIMSymbolLayer> symbolLayers = new List <CIMSymbolLayer>();
                symbolLayers.Add(outline);
                symbolLayers.Add(solidColorHatch);

                return(new CIMPolygonSymbol()
                {
                    SymbolLayers = symbolLayers.ToArray()
                });
            });

            return(polyGradientFill);
        }
Exemple #5
0
        public static CIMGrayColor ToGray(this CIMColor color)
        {
            if (color == null)
            {
                return(null);
            }
            switch (color)
            {
            case CIMRGBColor rgb:
                return(rgb.ToGray());

            case CIMCMYKColor cmyk:
                return(cmyk.ToRGB().ToGray());

            case CIMGrayColor gray:
                return(gray);

            case CIMHSVColor hsv:
                return(hsv.ToRGB().ToGray());

            case CIMHSLColor hsl:
                return(hsl.ToRGB().ToGray());

            default:
                throw new NotSupportedException($"Cannot convert from {color.GetType().Name} to Gray");
            }
        }
Exemple #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;
            }));
        }
Exemple #7
0
        public static CIMMarker CreateMarker(CIMColor color, double size, MarkerStyle style)
        {
            var geometry = CreateMarkerGeometry(style);
            var symbol   = CreatePolygonSymbol(color);

            var graphic = new CIMMarkerGraphic {
                Geometry = geometry, Symbol = symbol
            };

            var marker = new CIMVectorMarker();

            marker.ColorLocked                = false;
            marker.Enable                     = true;
            marker.Size                       = size >= 0 ? size : DefaultMarkerSize;
            marker.AnchorPointUnits           = SymbolUnits.Relative;
            marker.BillboardMode3D            = BillboardMode.FaceNearPlane;
            marker.DominantSizeAxis3D         = DominantSizeAxis.Y;
            marker.ScaleSymbolsProportionally = true;
            marker.RespectFrame               = true;
            marker.MarkerGraphics             = new[] { graphic };
            marker.Frame                      = style == MarkerStyle.Circle
                                               ? GeometryFactory.CreateEnvelope(-5, -5, 5, 5)
                                               : graphic.Geometry.Extent;

            return(marker);
        }
        internal async Task AddGraphicToMap(Geometry geom, CIMColor color, bool IsTempGraphic = false, double size = 1.0, string text = "")
        {
            if (geom == null || MapView.Active == null)
            {
                return;
            }

            CIMSymbolReference symbol = null;

            if (!string.IsNullOrWhiteSpace(text) && geom.GeometryType == GeometryType.Point)
            {
                await QueuedTask.Run(() =>
                {
                    //var tg = new CIMTextGraphic() { Placement = Anchor.CenterPoint, Text = text};
                });
            }
            else if (geom.GeometryType == GeometryType.Point)
            {
                await QueuedTask.Run(() =>
                {
                    var s  = SymbolFactory.ConstructPointSymbol(color, size, SimpleMarkerStyle.Circle);
                    symbol = new CIMSymbolReference()
                    {
                        Symbol = s
                    };
                });
            }
            else if (geom.GeometryType == GeometryType.Polyline)
            {
                await QueuedTask.Run(() =>
                {
                    var s  = SymbolFactory.ConstructLineSymbol(color, size);
                    symbol = new CIMSymbolReference()
                    {
                        Symbol = s
                    };
                });
            }
            else if (geom.GeometryType == GeometryType.Polygon)
            {
                await QueuedTask.Run(() =>
                {
                    var outline = SymbolFactory.ConstructStroke(ColorFactory.Black, 1.0, SimpleLineStyle.Solid);
                    var s       = SymbolFactory.ConstructPolygonSymbol(color, SimpleFillStyle.Solid, outline);
                    symbol      = new CIMSymbolReference()
                    {
                        Symbol = s
                    };
                });
            }

            await QueuedTask.Run(() =>
            {
                var disposable = MapView.Active.AddOverlay(geom, symbol);
                overlayObjects.Add(disposable);

                GraphicsList.Add(new ProGraphic(disposable, geom, IsTempGraphic));
            });
        }
 protected override Task OnToolActivateAsync(bool active)
 {
     QueuedTask.Run(() =>
     {
         _pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(CIMColor.CreateRGBColor(100, 255, 40), 10, SimpleMarkerStyle.Circle);
     });
     return(base.OnToolActivateAsync(active));
 }
Exemple #10
0
        public static CIMFill CreateSolidFill(CIMColor color = null)
        {
            var solidFill = new CIMSolidFill();

            solidFill.Color       = color ?? DefaultFillColor;
            solidFill.ColorLocked = false;
            solidFill.Enable      = true;
            return(solidFill);
        }
Exemple #11
0
        public static CIMColor SetAlpha(this CIMColor color, float alpha)
        {
            if (color != null)
            {
                color.Alpha = Clip(alpha, 0, 100);
            }

            return(color);
        }
Exemple #12
0
        internal async Task AddGraphicToMap(Geometry geom, CIMColor color, ProGraphicAttributes p = null, bool IsTempGraphic = false, double size = 1.0)
        {
            if (geom == null || MapView.Active == null)
            {
                return;
            }

            CIMSymbolReference symbol = null;

            if (geom.GeometryType == GeometryType.Point)
            {
                await QueuedTask.Run(() =>
                {
                    var s  = SymbolFactory.Instance.ConstructPointSymbol(color, size, SimpleMarkerStyle.Circle);
                    symbol = new CIMSymbolReference()
                    {
                        Symbol = s
                    };
                });
            }
            else if (geom.GeometryType == GeometryType.Polyline)
            {
                await QueuedTask.Run(() =>
                {
                    var s  = SymbolFactory.Instance.ConstructLineSymbol(color, size);
                    symbol = new CIMSymbolReference()
                    {
                        Symbol = s
                    };
                });
            }
            else if (geom.GeometryType == GeometryType.Polygon)
            {
                await QueuedTask.Run(() =>
                {
                    var outline = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.RedRGB, 1.0, SimpleLineStyle.Solid);
                    var s       = SymbolFactory.Instance.ConstructPolygonSymbol(color, SimpleFillStyle.Null, outline);
                    symbol      = new CIMSymbolReference()
                    {
                        Symbol = s
                    };
                });
            }

            await QueuedTask.Run(() =>
            {
                var disposable = MapView.Active.AddOverlay(geom, symbol);
                overlayObjects.Add(disposable);

                var gt = GetGraphicType();

                GraphicsList.Add(new Graphic(gt, disposable, geom, this, p, IsTempGraphic));

                RaisePropertyChanged(() => HasMapGraphics);
            });
        }
Exemple #13
0
        protected override Task OnToolActivateAsync(bool active)
        {
            QueuedTask.Run(() =>
            {
                _pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(CIMColor.CreateRGBColor(255, 255, 0, 40), 10, SimpleMarkerStyle.Circle);
                _textSymbol  = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.BlackRGB, 9.5, "Corbel", "Bold");
            });

            return(base.OnToolActivateAsync(active));
        }
        static public bool IsWhiteColor(CIMColor color)
        {
            CIMRGBColor rgb = color as CIMRGBColor;

            if (rgb == null)
            {
                return(false);
            }
            return(rgb.R == 255 && rgb.G == 255 && rgb.B == 255 && rgb.Alpha == 100);
        }
Exemple #15
0
        public static CIMFill CreateHatchFill(double angleDegrees, double separation,
                                              CIMColor color = null)
        {
            var hatchFill = new CIMHatchFill();

            hatchFill.Enable     = true;
            hatchFill.Rotation   = angleDegrees;
            hatchFill.Separation = separation;
            hatchFill.LineSymbol = CreateLineSymbol(color);
            return(hatchFill);
        }
        public void setFootprintSymbol()
        {
            CIMColor  outlineColor = ColorFactory.Instance.CreateRGBColor(0, 157, 165, 100);
            CIMColor  fillColor    = ColorFactory.Instance.CreateRGBColor(0, 157, 165, 25);
            CIMStroke outline      = SymbolFactory.Instance.ConstructStroke(
                outlineColor, 2.0, SimpleLineStyle.Solid);
            CIMPolygonSymbol polygonSymbol = SymbolFactory.Instance.ConstructPolygonSymbol(
                fillColor, SimpleFillStyle.Solid, outline);

            footprintSymbol = polygonSymbol.MakeSymbolReference();
        }
        static public bool IsBlackColor(CIMColor color, bool close = true)
        {
            CIMRGBColor rgb = color as CIMRGBColor;

            if (rgb == null)
            {
                return(false);
            }
            int max = close ? 45 : 0;

            return(rgb.R <= max && rgb.G <= max && rgb.B <= max && rgb.Alpha == 100);
        }
        private Task <bool> CheckSelection(Dictionary <MapMember, List <long> > sel)
        {
            //work around for possible bug where pane can become detached when changing maps
            if (EditingModuleInternal.TemplateManager.CurrentTemplate == null)
            {
                return(Task.FromResult(false));
            }

            //Enable only if we have one selected polyline Z feature
            if (sel == null || sel.Values.Sum(List => List.Count) != 1)
            {
                return(Task.FromResult(false));
            }

            var selMember = sel.Keys.FirstOrDefault();
            var selOID    = sel[selMember].First();

            var flayer = selMember as FeatureLayer;

            if (flayer == null)
            {
                return(Task.FromResult(false));
            }
            if (flayer.ShapeType != esriGeometryType.esriGeometryPolyline)
            {
                return(Task.FromResult(false));
            }

            return(QueuedTask.Run(() =>
            {
                var insp = new Inspector();
                insp.Load(selMember, selOID);
                _selLineGeom = insp.Shape as Polyline;

                //draw the line direction
                if (MapView.Active.Map.MapType == MapType.Map)
                {
                    var symbol = SymbolFactory.Instance.ConstructPointSymbol(CIMColor.CreateRGBColor(155, 75, 75), 12, SimpleMarkerStyle.Triangle);
                    _mapOverlay = MapView.Active.AddOverlay(_selLineGeom, symbol.MakeSymbolReference());
                }

                //draw the line direction in 3D. Not fully supported
                //if (MapView.Active.Map.MapType == MapType.Scene)
                //{
                //  string symbolXml = Settings1.Default.lineSymbol3D;
                //  var symbol = CIMSymbolReference.FromXml(symbolXml);
                //  _mapOverlay = MapView.Active.AddOverlay(_selLineGeom, symbol);
                //}

                return (!_selLineGeom.HasCurves & _selLineGeom.HasZ);
            }));
        }
        /// <summary>
        /// Create a polygon symbol with a cross hatch fill. <br/>
        /// ![PolygonSymbolCrossHatch](http://Esri.github.io/arcgis-pro-sdk/images/Symbology/polygon-crosshatch.png)
        /// </summary>
        /// <returns></returns>
        public static async Task <CIMPolygonSymbol> CreateCrossHatchPolygon()
        {
            var polyCrossHatch = await QueuedTask.Run(() =>
            {
                var trans         = 50.0;//semi transparent
                CIMStroke outline = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(0, 0, 0, trans), 2.0, SimpleLineStyle.Solid);

                //Stroke for the hatch fill
                var dash = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(255, 170, 0, trans), 1.0, SimpleLineStyle.Dash);

                //Mimic cross hatch
                CIMFill[] crossHatch =
                {
                    new CIMHatchFill()
                    {
                        Enable     = true,
                        Rotation   = 0.0,
                        Separation = 5.0,
                        LineSymbol = new CIMLineSymbol()
                        {
                            SymbolLayers = new CIMSymbolLayer[1]{
                                dash
                            }
                        }
                    },
                    new CIMHatchFill()
                    {
                        Enable     = true,
                        Rotation   = 90.0,
                        Separation = 5.0,
                        LineSymbol = new CIMLineSymbol()
                        {
                            SymbolLayers = new CIMSymbolLayer[1]{
                                dash
                            }
                        }
                    }
                };
                List <CIMSymbolLayer> symbolLayers = new List <CIMSymbolLayer>();
                symbolLayers.Add(outline);
                foreach (var fill in crossHatch)
                {
                    symbolLayers.Add(fill);
                }
                return(new CIMPolygonSymbol()
                {
                    SymbolLayers = symbolLayers.ToArray()
                });
            });

            return(polyCrossHatch);
        }
Exemple #20
0
        /// <summary>
        /// Additive color mixing: (1-f)*a + f*b.
        /// Requires RGB colors (including HLS and HSV) or gray level colors.
        /// Not supported for other color spaces.
        /// </summary>
        public static CIMRGBColor Blend(CIMColor x, CIMColor y, float f = 0.5f)
        {
            var xx = x.ToRGB();
            var yy = y.ToRGB();

            float cf = 1 - f;

            float r = cf * xx.R + f * yy.R;
            float g = cf * xx.G + f * yy.G;
            float b = cf * xx.B + f * yy.B;

            return(CreateRGB(r, g, b));
        }
Exemple #21
0
        private CIMPolygonSymbol CreatePolygonSymbol()
        {
            CIMColor magenta = ColorFactory.Instance.CreateRGBColor(255, 0, 255);

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

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

            return(highlightPolygonSymbol);
        }
Exemple #22
0
        public static CIMStroke CreateSolidStroke(CIMColor color, double width = -1)
        {
            var solidStroke = new CIMSolidStroke();

            solidStroke.Color       = color ?? DefaultStrokeColor;
            solidStroke.ColorLocked = false;
            solidStroke.CapStyle    = LineCapStyle.Round;
            solidStroke.JoinStyle   = LineJoinStyle.Round;
            solidStroke.MiterLimit  = 10.0;
            solidStroke.Width       = width >= 0 ? width : DefaultStrokeWidth;
            solidStroke.Enable      = true;
            return(solidStroke);
        }
Exemple #23
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 #24
0
        public static CIMPolygonSymbol CreatePolygonSymbol(
            CIMColor color = null, FillStyle fillStyle = FillStyle.Solid, CIMStroke outline = null)
        {
            var symbolLayers = new List <CIMSymbolLayer>();

            if (outline != null)
            {
                symbolLayers.Add(outline);
            }

            switch (fillStyle)
            {
            case FillStyle.Null:
                break;

            case FillStyle.Solid:
                symbolLayers.Add(CreateSolidFill(color));
                break;

            case FillStyle.BackwardDiagonal:
                symbolLayers.Add(CreateHatchFill(-45.0, 5.3, color));
                break;

            case FillStyle.ForwardDiagonal:
                symbolLayers.Add(CreateHatchFill(45.0, 5.3, color));
                break;

            case FillStyle.DiagonalCross:
                symbolLayers.Add(CreateHatchFill(45.0, 5.3, color));
                symbolLayers.Add(CreateHatchFill(-45.0, 5.3, color));
                break;

            case FillStyle.Horizontal:
                symbolLayers.Add(CreateHatchFill(0.0, 7.5, color));
                break;

            case FillStyle.Vertical:
                symbolLayers.Add(CreateHatchFill(90.0, 7.5, color));
                break;

            case FillStyle.Cross:
                symbolLayers.Add(CreateHatchFill(0.0, 7.5, color));
                symbolLayers.Add(CreateHatchFill(90.0, 7.5, color));
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(fillStyle));
            }

            return(CreatePolygonSymbol(symbolLayers.ToArray()));
        }
Exemple #25
0
        /// <summary>
        /// Create a polygon symbol with a diagonal cross hatch fill. <br/>
        /// ![PolygonSymbolDiagonalCrossHatch](http://Esri.github.io/arcgis-pro-sdk/images/Symbology/polygon-diagonal-crosshatch.png)
        /// </summary>
        /// <returns></returns>
        public static Task <CIMPolygonSymbol> CreateDiagonalCrossPolygonAsync()
        {
            return(QueuedTask.Run <CIMPolygonSymbol>(() =>
            {
                var trans = 50.0;//semi transparent
                CIMStroke outline = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(0, 0, 0, trans), 2.0, SimpleLineStyle.Solid);

                //Stroke for the fill
                var solid = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(255, 0, 0, trans), 1.0, SimpleLineStyle.Solid);

                //Mimic cross hatch
                CIMFill[] diagonalCross =
                {
                    new CIMHatchFill()
                    {
                        Enable = true,
                        Rotation = 45.0,
                        Separation = 5.0,
                        LineSymbol = new CIMLineSymbol()
                        {
                            SymbolLayers = new CIMSymbolLayer[1]{
                                solid
                            }
                        }
                    },
                    new CIMHatchFill()
                    {
                        Enable = true,
                        Rotation = -45.0,
                        Separation = 5.0,
                        LineSymbol = new CIMLineSymbol()
                        {
                            SymbolLayers = new CIMSymbolLayer[1]{
                                solid
                            }
                        }
                    }
                };
                List <CIMSymbolLayer> symbolLayers = new List <CIMSymbolLayer>();
                symbolLayers.Add(outline);
                foreach (var fill in diagonalCross)
                {
                    symbolLayers.Add(fill);
                }
                return new CIMPolygonSymbol()
                {
                    SymbolLayers = symbolLayers.ToArray()
                };
            }));
        }
Exemple #26
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 #27
0
        public static async Task <BA_ReturnCode> AddPolygonLayerAsync(Uri uri, CIMColor fillColor, bool isVisible, string displayName = "")
        {
            // parse the uri for the folder and file
            string strFileName   = null;
            string strFolderPath = null;

            if (uri.IsFile)
            {
                strFileName   = System.IO.Path.GetFileName(uri.LocalPath);
                strFolderPath = System.IO.Path.GetDirectoryName(uri.LocalPath);
            }
            BA_ReturnCode success = BA_ReturnCode.UnknownError;
            await QueuedTask.Run(() =>
            {
                FeatureClass fClass = null;
                // Opens a file geodatabase. This will open the geodatabase if the folder exists and contains a valid geodatabase.
                using (Geodatabase geodatabase =
                           new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(strFolderPath))))
                {
                    // Use the geodatabase.
                    fClass = geodatabase.OpenDataset <FeatureClass>(strFileName);
                }
                if (String.IsNullOrEmpty(displayName))
                {
                    displayName = fClass.GetDefinition().GetAliasName();
                }
                // Create symbology for feature layer
                var flyrCreatnParam = new FeatureLayerCreationParams(fClass)
                {
                    Name               = displayName,
                    IsVisible          = true,
                    RendererDefinition = new SimpleRendererDefinition()
                    {
                        //SymbolTemplate = SymbolFactory.Instance.ConstructPolygonSymbol(fillColor).MakeSymbolReference()
                        SymbolTemplate = SymbolFactory.Instance.ConstructPolygonSymbol(
                            fillColor, SimpleFillStyle.Solid,
                            SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 0))
                                         .MakeSymbolReference()
                    }
                };

                FeatureLayer fLayer = LayerFactory.Instance.CreateLayer <FeatureLayer>(flyrCreatnParam, MapView.Active.Map);
                fLayer.SetVisibility(isVisible);
                success = BA_ReturnCode.Success;
            });

            return(success);
        }
        private async void OnMapPointToolActivated(object obj)
        {
            var addList    = new List <tempProGraphic>();
            var removeList = new List <ProGraphic>();

            foreach (var item in ProGraphicsList)
            {
                if (item.Disposable != null || item.IsTemp == false)
                {
                    continue;
                }

                // re-add graphic to map overlay
                SimpleMarkerStyle ms    = SimpleMarkerStyle.Circle;
                CIMColor          color = ColorFactory.BlueRGB;

                if (item.Tag == "target")
                {
                    ms    = SimpleMarkerStyle.Square;
                    color = ColorFactory.RedRGB;
                }
                addList.Add(new tempProGraphic()
                {
                    GUID        = item.GUID,
                    Geometry    = item.Geometry,
                    Color       = color,
                    IsTemp      = true,
                    Size        = 5.0,
                    MarkerStyle = ms
                });
            }

            foreach (var temp in addList)
            {
                var pgOLD = ProGraphicsList.FirstOrDefault(g => g.GUID == temp.GUID);

                var guid = await AddGraphicToMap(temp.Geometry, temp.Color, temp.IsTemp, temp.Size, markerStyle : temp.MarkerStyle, tag : pgOLD.Tag);

                var pgNew = ProGraphicsList.FirstOrDefault(g => g.GUID == guid);
                pgNew.GUID = pgOLD.GUID;
                removeList.Add(pgOLD);
            }

            foreach (var pg in removeList)
            {
                ProGraphicsList.Remove(pg);
            }
        }
Exemple #29
0
        private CIMRenderer CreateniqueValueRendererForUSStatesUsingDefinition(FeatureLayer featureLayer)
        {
            //All of these methods have to be called on the MCT
            if (Module1.OnUIThread)
            {
                throw new CalledOnWrongThreadException();
            }

            // color ramp
            CIMICCColorSpace colorSpace = new CIMICCColorSpace()
            {
                URL = "Default RGB"
            };

            CIMContinuousColorRamp continuousColorRamp = new CIMLinearContinuousColorRamp();

            continuousColorRamp.FromColor  = CIMColor.CreateRGBColor(255, 255, 100); // yellow
            continuousColorRamp.ToColor    = CIMColor.CreateRGBColor(255, 0, 0);     // red
            continuousColorRamp.ColorSpace = colorSpace;

            CIMRandomHSVColorRamp randomHSVColorRamp = new CIMRandomHSVColorRamp()
            {
                ColorSpace = colorSpace,
                MinAlpha   = 100,
                MaxAlpha   = 100,
                MinH       = 0,
                MaxH       = 360,
                MinS       = 15,
                MaxS       = 30,
                MinV       = 99,
                MaxV       = 100,
                Seed       = 0
            };

            UniqueValueRendererDefinition uvRendererDef = new UniqueValueRendererDefinition()
            {
                ColorRamp        = continuousColorRamp, // randomHSVColorRamp,
                UseDefaultSymbol = true,
                ValueFields      = new List <string> {
                    "TOTPOP2010"
                }
            };

            //Configure the Renderer using the layer and the contents of the STATENAM
            //field
            return(featureLayer.CreateRenderer(uvRendererDef));
        }
Exemple #30
0
        private void ShowInvalidOverlays(Polyline multipartLine)
        {
            var colorFactory = ColorFactory.Instance;
            var colors       = new CIMColor[4] {
                colorFactory.BlueRGB, colorFactory.RedRGB, colorFactory.GreenRGB, colorFactory.WhiteRGB
            };

            for (var i = 0; i < multipartLine.Parts.Count; i++)
            {
                var part        = multipartLine.Parts[i];
                var partBuilder = new PolylineBuilder(SpatialReferenceBuilder.CreateSpatialReference(26912));
                partBuilder.AddPart(part);
                var colorNum = 50 * i;
                var symbol   = SymbolFactory.Instance.ConstructLineSymbol(colors[i], 8).MakeSymbolReference();
                overlays.Add(MapView.Active.AddOverlay(partBuilder.ToGeometry(), symbol));
            }
        }
        internal async Task AddGraphicToMap(Geometry geom, CIMColor color, bool IsTempGraphic = false, double size = 1.0, string text = "")
        {
            if (geom == null || MapView.Active == null)
                return;

            CIMSymbolReference symbol = null;

            if(!string.IsNullOrWhiteSpace(text) && geom.GeometryType == GeometryType.Point)
            {
                await QueuedTask.Run(() =>
                    {
                        //var tg = new CIMTextGraphic() { Placement = Anchor.CenterPoint, Text = text};
                    });
            }
            else if (geom.GeometryType == GeometryType.Point)
            {
                await QueuedTask.Run(() =>
                {
                    var s = SymbolFactory.ConstructPointSymbol(color, size, SimpleMarkerStyle.Circle);
                    symbol = new CIMSymbolReference() { Symbol = s };
                });
            }
            else if (geom.GeometryType == GeometryType.Polyline)
            {
                await QueuedTask.Run(() =>
                {
                    var s = SymbolFactory.ConstructLineSymbol(color, size);
                    symbol = new CIMSymbolReference() { Symbol = s };
                });
            }
            else if (geom.GeometryType == GeometryType.Polygon)
            {
                await QueuedTask.Run(() =>
                {
                    var outline = SymbolFactory.ConstructStroke(ColorFactory.Black, 1.0, SimpleLineStyle.Solid);
                    var s = SymbolFactory.ConstructPolygonSymbol(color, SimpleFillStyle.Solid, outline);
                    symbol = new CIMSymbolReference() { Symbol = s };
                });
            }

            await QueuedTask.Run(() =>
            {
                var disposable = MapView.Active.AddOverlay(geom, symbol);
                overlayObjects.Add(disposable);

                GraphicsList.Add(new ProGraphic(disposable, geom, IsTempGraphic));
            });
        }
        internal async Task AddGraphicToMap(Geometry geom, CIMColor color, bool IsTempGraphic = false, double size = 1.0)
        {
            if (geom == null || MapView.Active == null)
                return;

            CIMSymbolReference symbol = null;

            if(geom.GeometryType == GeometryType.Point)
            {
                await QueuedTask.Run(() =>
                    {
                        var s = SymbolFactory.ConstructPointSymbol(color, size, SimpleMarkerStyle.Circle);
                        symbol = new CIMSymbolReference() { Symbol = s };
                    });
            }
            else if(geom.GeometryType == GeometryType.Polyline)
            {
                await QueuedTask.Run(() =>
                    {
                        var s = SymbolFactory.ConstructLineSymbol(color, size);
                        symbol = new CIMSymbolReference() { Symbol = s };
                    });
            }
            else if(geom.GeometryType == GeometryType.Polygon)
            {
                await QueuedTask.Run(() =>
                {
                    var outline = SymbolFactory.ConstructStroke(ColorFactory.Black, 1.0, SimpleLineStyle.Solid);
                    var s = SymbolFactory.ConstructPolygonSymbol(color, SimpleFillStyle.Solid, outline);
                    symbol = new CIMSymbolReference() { Symbol = s };
                });
            }

            await QueuedTask.Run(() =>
                {
                    var disposable = MapView.Active.AddOverlay(geom, symbol);
                    overlayObjects.Add(disposable);

                    var gt = GetGraphicType();
                    
                    GraphicsList.Add(new Graphic(gt, disposable, geom, IsTempGraphic));
                });
        }