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 (_calloutTextSymbol == null)
            {
                return(Task.FromResult(true));
            }
            var textGraphic = new CIMTextGraphic
            {
                Symbol = _calloutTextSymbol.MakeSymbolReference(),
                Shape  = geometry as MapPoint,
                Text   = "Some Text"
            };

            return(QueuedTask.Run(() =>
            {
                Module1.Current.SelectedGraphicsLayerTOC.AddElement(textGraphic);

                return true;
            }));
        }
Пример #2
0
        private void SetXmlText(CIMTextGraphic textGraphic)
        {
            var xml = textGraphic?.ToXml() ?? "";

            this.AvalonTextEditor.Text = FormatXml(xml);
            this._xmlFolding.UpdateFoldings(this._foldingManager, this.AvalonTextEditor.Document);
        }
        protected override Task <bool> OnSketchCompleteAsync(Geometry geometry)
        {
            if (ActiveElementContainer == null)
            {
                Task.FromResult(true);
            }

            if (Module1.SelectedSymbol == null)
            {
                return(Task.FromResult(true));
            }

            return(QueuedTask.Run(() =>
            {
                var cimGraphicElement = new CIMTextGraphic
                {
                    Shape = geometry as MapPoint,
                    Text = "Text",
                    Symbol = Module1.SelectedSymbol.MakeSymbolReference()
                };
                LayoutElementFactory.Instance.CreateGraphicElement(this.ActiveElementContainer, cimGraphicElement);
                //The new text graphic element has been created
                //We now switch to Pro's out of box "esri_layouts_inlineEditTool"
                //This will allow inline editing of the text
                //This tool will work on graphics on both map view and layouts
                FrameworkApplication.SetCurrentToolAsync("esri_layouts_inlineEditTool");
                return true;
            }));
        }
Пример #4
0
            protected override async Task <bool> OnSketchCompleteAsync(Geometry geometry)
            {
                //Add an overlay graphic to the map view
                _graphic = await this.AddOverlayAsync(geometry, _lineSymbol.MakeSymbolReference());

                //define the text symbol
                var textSymbol = new CIMTextSymbol();
                //define the text graphic
                var textGraphic = new CIMTextGraphic();

                await QueuedTask.Run(() =>
                {
                    //Create a simple text symbol
                    textSymbol = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.BlackRGB, 8.5, "Corbel", "Regular");
                    //Sets the geometry of the text graphic
                    textGraphic.Shape = geometry;
                    //Sets the text string to use in the text graphic
                    textGraphic.Text = "This is my line";
                    //Sets symbol to use to draw the text graphic
                    textGraphic.Symbol = textSymbol.MakeSymbolReference();
                    //Draw the overlay text graphic
                    _graphic = this.ActiveMapView.AddOverlay(textGraphic);
                });

                return(true);
            }
        public Task <bool> ChangeAnnotationTextGraphicAsync(string xmlGraphic)
        {
            _lasterror = "";//reset
            if (string.IsNullOrEmpty(xmlGraphic))
            {
                return(Task.FromResult(false));
            }
            if (this.AnnotationLayer == null)
            {
                return(Task.FromResult(false));
            }

            return(QueuedTask.Run(() =>
            {
                if (!((AnnotationFeatureClass)AnnotationLayer.GetFeatureClass()).GetDefinition().AreSymbolOverridesAllowed())
                {
                    _lasterror = $"Overrides are not allowed on '{AnnotationLayer.GetFeatureClass().GetName()}'";
                    return false;//overrides are not allowed
                }

                EditOperation op = new EditOperation();
                op.Name = $"Change annotation graphic [{count++}]";
                op.SelectModifiedFeatures = true;

                var oid = this.AnnotationLayer.GetSelection().GetObjectIDs().First();

                //At 2.1 we must use an edit operation Callback...
                op.Callback(context => {
                    QueryFilter qf = new QueryFilter()
                    {
                        WhereClause = $"OBJECTID = {oid}"
                    };
                    //Cursor must be non-recycling. Use the table ~not~ the layer..i.e. "GetTable().Search()"
                    //annoLayer is ~your~ Annotation layer
                    var rowCursor = this.AnnotationLayer.GetTable().Search(qf, false);
                    rowCursor.MoveNext();
                    var annoFeature = rowCursor.Current as ArcGIS.Core.Data.Mapping.AnnotationFeature;

                    // update the graphic
                    CIMTextGraphic textGraphic = GraphicFromXml(xmlGraphic);
                    annoFeature.SetGraphic(textGraphic);
                    // store is required
                    annoFeature.Store();
                    //refresh layer cache
                    context.Invalidate(annoFeature);
                }, this.AnnotationLayer.GetTable());
                var ok = op.Execute();
                if (!ok)
                {
                    _lasterror = op.ErrorMessage;
                }
                return ok;
            }));
        }
        public CIMTextGraphic GraphicFromXml(string xmlGraphic)
        {
            //Will throw if not called on a QueuedTask!
            CIMTextGraphic textGraphic = new CIMTextGraphic();
            StringReader   sr          = new StringReader(xmlGraphic);

            if (!string.IsNullOrEmpty(xmlGraphic))
            {
                using (XmlReader reader = new XmlTextReader(sr)) {
                    textGraphic.ReadXml(reader);
                }
            }
            return(textGraphic);
        }
Пример #7
0
 public static async Task UpdateMapElementsAsync(Layout layout, string titleText, BA_Objects.MapDefinition mapDefinition)
 {
     if (layout != null)
     {
         if (!String.IsNullOrEmpty(titleText))
         {
             if (titleText != null)
             {
                 GraphicElement textBox = layout.FindElement(Constants.MAPS_TITLE) as GraphicElement;
                 if (textBox != null)
                 {
                     await QueuedTask.Run(() =>
                     {
                         CIMTextGraphic graphic = (CIMTextGraphic )textBox.Graphic;
                         graphic.Text           = titleText;
                         textBox.SetGraphic(graphic);
                     });
                 }
             }
             if (mapDefinition.SubTitle != null)
             {
                 GraphicElement textBox = layout.FindElement(Constants.MAPS_SUBTITLE) as GraphicElement;
                 if (textBox != null)
                 {
                     await QueuedTask.Run(() =>
                     {
                         CIMTextGraphic graphic = (CIMTextGraphic)textBox.Graphic;
                         graphic.Text           = mapDefinition.SubTitle;
                         textBox.SetGraphic(graphic);
                     });
                 }
             }
             if (mapDefinition.UnitsText != null)
             {
                 GraphicElement textBox = layout.FindElement(Constants.MAPS_TEXTBOX1) as GraphicElement;
                 if (textBox != null)
                 {
                     await QueuedTask.Run(() =>
                     {
                         CIMTextGraphic graphic = (CIMTextGraphic)textBox.Graphic;
                         graphic.Text           = mapDefinition.UnitsText;
                         textBox.SetGraphic(graphic);
                     });
                 }
             }
         }
     }
 }
        private void InsertAnnotation(AnnotationFeature annofeat)
        {
            var selectedFeatures = MapView.Active.Map.GetSelection().Where(kvp => kvp.Key is AnnotationLayer).ToDictionary(kvp => (AnnotationLayer)kvp.Key, kvp => kvp.Value);
            var layer            = selectedFeatures.Keys.FirstOrDefault();

            // コピーするアノテーション用に行を作成
            AnnotationFeatureClass annotationFeatureClass = layer.GetFeatureClass() as AnnotationFeatureClass;
            RowBuffer rowBuffer = annotationFeatureClass.CreateRowBuffer();
            Feature   feature   = annotationFeatureClass.CreateRow(rowBuffer) as Feature;

            // コピーするアノテーションを作成
            AnnotationFeature copyAnnoFeat = feature as AnnotationFeature;

            copyAnnoFeat.SetStatus(AnnotationStatus.Placed);
            copyAnnoFeat.SetAnnotationClassID(0);

            // コピー元のアノテーションの重心にポイントを作成
            Envelope shape           = annofeat.GetShape().Extent;
            var      x               = shape.Center.X;
            var      y               = shape.Center.Y;
            var      mapPointBuilder = new MapPointBuilder(layer.GetSpatialReference());

            mapPointBuilder.X = x;
            mapPointBuilder.Y = y;
            MapPoint mapPoint = mapPointBuilder.ToGeometry();

            // コピー元のアノテーションのテキストを作成
            var annoGraphich = annofeat.GetGraphic() as CIMTextGraphic;

            // 作成したポイントとアノテーションをコピー先のアノテーションにコピー
            CIMTextGraphic cimTextGraphic = new CIMTextGraphic();

            cimTextGraphic.Text  = annoGraphich.Text;
            cimTextGraphic.Shape = mapPoint;

            // シンボル設定
            var symbolRef = new CIMSymbolReference();

            symbolRef.SymbolName  = annoGraphich.Symbol.SymbolName;
            symbolRef.Symbol      = annoGraphich.Symbol.Symbol;
            cimTextGraphic.Symbol = symbolRef;

            // コピー
            copyAnnoFeat.SetGraphic(cimTextGraphic);
            copyAnnoFeat.Store();
        }
Пример #9
0
        private Tuple <IDisposable, IDisposable, Envelope> AddOverlay(MapView mapView, MapPoint location, ValuePointCluster value, SpatialReference spatialRef)
        {
            var text        = value.Count.ToString();
            var textGraphic = new CIMTextGraphic()
            {
                Text = text, Symbol = _textSymbolRef, Shape = location
            };

            var baseSize   = _pointSize * 2;                // smallest size (slightly bigger than for single points)
            var multiplier = 1 + ((text.Length - 1) * 0.5); // increase size by 0.5 for every text digit
            var size       = baseSize * multiplier;

            _pointSymbol.SetSize(size);

            var pointElem = mapView.AddOverlay(location, _pointSymbol.MakeSymbolReference());
            var textElem  = mapView.AddOverlay(textGraphic);
            var hitbox    = CreateHitBox(mapView, location, size / 2, spatialRef);

            return(new Tuple <IDisposable, IDisposable, Envelope>(pointElem, textElem, hitbox));
        }
        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 (_textSymbol == 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 Text?
                if (selectedElements.Count() == 1)
                {
                    if (selectedElements.FirstOrDefault().GetGraphic() is CIMTextGraphic) //It is a Text
                    {
                        //So we use it
                        var textSymbol = selectedElements.FirstOrDefault().GetGraphic() as CIMTextGraphic;
                        _textSymbol = textSymbol.Symbol.Symbol as CIMTextSymbol;
                    }
                }
                var textGraphic = new CIMTextGraphic
                {
                    Symbol = _textSymbol.MakeSymbolReference(),
                    Shape = geometry as MapPoint,
                    Text = "Some Text"
                };
                Module1.Current.SelectedGraphicsLayerTOC.AddElement(textGraphic);

                return true;
            }));
        }
Пример #11
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));
            }

            return(QueuedTask.Run(() =>
            {
                var textSymbol = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.BlackRGB, 8.5, "Corbel", "Regular");
                var textGraphic = new CIMTextGraphic
                {
                    Symbol = textSymbol.MakeSymbolReference(),
                    Shape = geometry as Polyline,
                    Text = "Some Text"
                };
                Module1.Current.SelectedGraphicsLayerTOC.AddElement(textGraphic);

                return true;
            }));
        }
Пример #12
0
        protected override Task <bool> OnSketchCompleteAsync(Geometry geometry)
        {
            if (Module1.Current.SelectedGraphicsLayerTOC == null)
            {
                MessageBox.Show("Select a graphics layer in the TOC", "No graphics layer selected",
                                System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Exclamation);
                return(Task.FromResult(true));
            }

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

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

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

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

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

                return true;
            }));
        }
 public SelectedGraphicChangedEventArgs(AnnotationLayer annoLayer, CIMTextGraphic graphic)
 {
     AnnotationLayer = annoLayer;
     SelectedGraphic = graphic;
 }
Пример #14
0
        //Using Inspector...
        internal async void UpdateAnnotation()
        {
            BasicFeatureLayer annoLayer = MapView.Active.Map.GetLayersAsFlattenedList().First() as BasicFeatureLayer;
            var oid = 1;

            #region Update Annotation Text

            await QueuedTask.Run(() =>
            {
                //annoLayer is ~your~ Annotation layer...

                // use the inspector methodology
                var insp = new Inspector(true);
                insp.Load(annoLayer, oid);

                // get the annotation properties
                AnnotationProperties annoProperties = insp.GetAnnotationProperties();
                // set the attribute
                annoProperties.TextString = "Hello World";
                // assign the annotation proeprties back to the inspector
                insp.SetAnnotationProperties(annoProperties);

                //create and execute the edit operation
                EditOperation op = new EditOperation();
                op.Name          = "Update annotation";
                op.Modify(insp);
                op.Execute();
            });

            #endregion

            #region Modify Annotation Shape

            await QueuedTask.Run(() =>
            {
                //Don't use 'Shape'....Shape is the bounding box of the annotation text. This is NOT what you want...
                //
                //var insp = new Inspector();
                //insp.Load(annoLayer, oid);
                //var shape = insp["SHAPE"] as Polygon;
                //...wrong shape...

                //Instead, we must use the AnnotationProperties

                //annoLayer is ~your~ Annotation layer
                var insp = new Inspector(true);
                insp.Load(annoLayer, oid);

                AnnotationProperties annoProperties = insp.GetAnnotationProperties();
                var shape = annoProperties.Shape;
                if (shape.GeometryType != GeometryType.GeometryBag)
                {
                    var newGeometry      = GeometryEngine.Instance.Move(shape, 10, 10);
                    annoProperties.Shape = newGeometry;
                    insp.SetAnnotationProperties(annoProperties);

                    EditOperation op = new EditOperation();
                    op.Name          = "Change annotation angle";
                    op.Modify(insp);
                    op.Execute();
                }
            });

            #endregion

            #region Modify Annotation Text Graphic

            await QueuedTask.Run(() =>
            {
                var selection = annoLayer.GetSelection();
                if (selection.GetCount() == 0)
                {
                    return;
                }

                // use the first selelcted feature
                var insp = new Inspector(true);
                insp.Load(annoLayer, selection.GetObjectIDs().FirstOrDefault());

                // getAnnoProperties should return null if not an annotation feature
                AnnotationProperties annoProperties = insp.GetAnnotationProperties();
                // get the textGraphic
                CIMTextGraphic textGraphic = annoProperties.TextGraphic;

                // change text
                textGraphic.Text = "Hello world";

                // set x,y offset via the symbol
                var symbol         = textGraphic.Symbol.Symbol;
                var textSymbol     = symbol as CIMTextSymbol;
                textSymbol.OffsetX = 2;
                textSymbol.OffsetY = 3;

                textSymbol.HorizontalAlignment = HorizontalAlignment.Center;

                // load the updated textGraphic
                annoProperties.LoadFromTextGraphic(textGraphic);
                // assign the annotation properties back
                insp.SetAnnotationProperties(annoProperties);

                EditOperation op = new EditOperation();
                op.Name          = "modify symbol";
                op.Modify(insp);
                bool result = op.Execute();
            });

            #endregion
        }
Пример #15
0
        public static void ShowPatchLabels(Patch patch)
        {
            foreach (var cg in CimGraphics)
            {
                cg.Dispose();
            }
            CimGraphics.Clear();
            int nodeNumber    = 0;
            int maxCoordCount = patch.Coords.Count;
            int coordCount    = 0;

            foreach (var coord in patch.Coords)
            {
                //MapView.Active.AddOverlay()
                var textGraphic = new CIMTextGraphic
                {
                    Symbol = SymbolFactory.Instance.ConstructTextSymbol(
                        ColorFactory.Instance.BlackRGB, 12, "Times New Roman", "Regular").MakeSymbolReference()
                };

                //make the callout for the circle
                var callOut = new CIMPointSymbolCallout
                {
                    PointSymbol = new CIMPointSymbol()
                };
                //Circle outline - 40
                var circle_outline = SymbolFactory.Instance.ConstructMarker(40, "ESRI Default Marker") as CIMCharacterMarker;
                //Square - 41
                //Triangle - 42
                //Pentagon - 43
                //Hexagon - 44
                //Octagon - 45
                circle_outline.Size = 40;
                //eliminate the outline
                foreach (var layer in circle_outline.Symbol.SymbolLayers)
                {
                    if (layer is CIMSolidStroke)
                    {
                        ((CIMSolidStroke)layer).Width = 0;
                    }
                }

                //Circle fill - 33
                var circle_fill = SymbolFactory.Instance.ConstructMarker(33, "ESRI Default Marker") as CIMCharacterMarker;
                //Square - 34
                //Triangle - 35
                //Pentagon - 36
                //Hexagon - 37
                //Octagon - 38
                circle_fill.Size = 40;
                //eliminate the outline, make sure the fill is white
                foreach (var layer in circle_fill.Symbol.SymbolLayers)
                {
                    if (layer is CIMSolidFill)
                    {
                        ((CIMSolidFill)layer).Color = ColorFactory.Instance.WhiteRGB;
                    }
                    else if (layer is CIMSolidStroke)
                    {
                        ((CIMSolidStroke)layer).Width = 0;
                    }
                }

                var calloutLayers = new List <CIMSymbolLayer>
                {
                    circle_outline,
                    circle_fill
                };
                //set the layers on the callout
                callOut.PointSymbol.SymbolLayers = calloutLayers.ToArray();

                //set the callout on the text symbol
                var textSym = textGraphic.Symbol.Symbol as CIMTextSymbol;
                textSym.Callout = callOut;
                textSym.Height  = 12;//adjust as needed

                //now set the text
                textGraphic.Text = $@"{nodeNumber++}";
                // reposition the last two labels
                // 2 meters up
                System.Diagnostics.Debug.WriteLine($@"Pnt: {coordCount} {coord.X} {coord.Y} {coord.Z} ");
                var labelPnt = MapPointBuilder.CreateMapPoint(new Coordinate3D(coord.X, coord.Y, coord.Z + 4 * coordCount++));
                textGraphic.Shape = labelPnt;

                CimGraphics.Add(MapView.Active.AddOverlay(textGraphic));
            }
        }
        protected override async Task <bool> OnSketchCompleteAsync(ArcGIS.Core.Geometry.Geometry geometry)
        {
            try
            {
                if (_graphic != null)
                {
                    _graphic.Dispose();
                }
                //Polygon polygon;
                //await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
                //{
                //    List<Coordinate2D> coordinates2 = new List<Coordinate2D>()
                //{
                //  //new Coordinate2D(-159.20168702818188, 21.876487211082708),
                //  //new Coordinate2D(-159.42653907783114, 21.838951660451173),
                //  //new Coordinate2D(-159.44077880308507, 21.94718691051718),
                //  //new Coordinate2D(-159.21630329750306, 21.94718691051718),
                //  //new Coordinate2D(-159.21413990271841, 21.9365008022738),
                //  //new Coordinate2D(-159.21383956606297, 21.93655454291286),
                //  //new Coordinate2D(-159.20168702818188, 21.876487211082708),
                //  new Coordinate2D(-17773406.8675, 2478583.7239999995),
                //  new Coordinate2D(-17773406.8675, 2578583.7239999995),
                //  new Coordinate2D(-16773406.8675, 2578583.7239999995),
                //  new Coordinate2D(-17773406.8675, 2478583.7239999995)
                //};
                //    CIMPolygonSymbol _polygonSymbol = null;
                //    _polygonSymbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.BlackRGB, SimpleFillStyle.Null, SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 2.0, SimpleLineStyle.Solid));
                //    using (PolygonBuilder polygonBuilder = new PolygonBuilder(coordinates2, MapView.Active.Extent.SpatialReference))
                //    {
                //        polygonBuilder.SpatialReference = MapView.Active.Extent.SpatialReference;
                //        polygon = polygonBuilder.ToGeometry();
                //        geometry = polygonBuilder.ToGeometry();
                //        //Geometry geometry2 = GeometryEngine.Instance.ProjectEx(geometry, projTransFromSRs);
                //        _graphic = MapView.Active.AddOverlayAsync(geometry, _polygonSymbol.MakeSymbolReference());
                //    }
                //});

                //return true;
                //DockPane pane = FrameworkApplication.DockPaneManager.Find("test_docing_Panel_PlanetDocPane");
                DockPane pane = FrameworkApplication.DockPaneManager.Find("test_docing_Panel_Demo");
                //PlanetDocPaneViewModel planetDocPaneViewModel = (PlanetDocPaneViewModel)pane;
                //planetDocPaneViewModel.Users = "New collection"
                pane.Enabled = true;
                //Add an overlay graphic to the map view
                _graphic = await this.AddOverlayAsync(geometry, _lineSymbol.MakeSymbolReference());

                //define the text symbol
                var textSymbol = new CIMTextSymbol();
                //define the text graphic
                var textGraphic = new CIMTextGraphic();

                //await QueuedTask.Run(() =>
                //{
                //    //Create a simple text symbol
                //    textSymbol = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.BlackRGB, 8.5, "Corbel", "Regular");
                //    //Sets the geometry of the text graphic
                //    textGraphic.Shape = geometry;
                //    //Sets the text string to use in the text graphic
                //    //textGraphic.Text = "This is my line";
                //    //Sets symbol to use to draw the text graphic
                //    textGraphic.Symbol = textSymbol.MakeSymbolReference();
                //    //Draw the overlay text graphic
                //    _graphic = this.ActiveMapView.AddOverlay(textGraphic);

                //});
                string  ejson = geometry.ToJson();
                Polygon poly  = (Polygon)geometry;
                IReadOnlyList <Coordinate2D> coordinates = poly.Copy2DCoordinatesToList();
                ToGeoCoordinateParameter     ddParam     = new ToGeoCoordinateParameter(GeoCoordinateType.DD);
                List <string> geocoords = new List <string>();
                List <Tuple <double, double> > AllPts = new List <Tuple <double, double> >();
                double x;
                double y;
                foreach (Coordinate2D item in coordinates)
                {
                    MapPoint mapPoint = MapPointBuilder.CreateMapPoint(item, MapView.Active.Extent.SpatialReference);
                    List <Tuple <string, string> > pts = new List <Tuple <string, string> >();
                    string dd1 = mapPoint.ToGeoCoordinateString(ddParam).Split(' ')[0];
                    pts.Add(new Tuple <string, string>(mapPoint.ToGeoCoordinateString(ddParam).Split(' ')[1], mapPoint.ToGeoCoordinateString(ddParam).Split(' ')[0]));
                    if (pts[0].Item1.Contains("W"))
                    {
                        x = double.Parse("-" + pts[0].Item1.Substring(0, pts[0].Item1.Length - 1));
                        y = double.Parse(pts[0].Item2.Substring(0, pts[0].Item2.Length - 1));
                        //AllPts.Add(new Tuple<int, int>(int.Parse("-" + pts[0].Item1.Substring(0, pts[0].Item1.Length - 1)), int.Parse(pts[0].Item2.Substring(0, pts[0].Item2.Length -1))));
                    }
                    else if (pts[1].Item2.Contains("S"))
                    {
                        x = double.Parse(pts[0].Item1.Substring(0, pts[0].Item1.Length - 1));
                        y = double.Parse("-" + pts[0].Item2.Substring(0, pts[1].Item2.Length - 1));
                        //AllPts.Add(new Tuple<int, int>(int.Parse(pts[0].Item1.Substring(0, pts[0].Item1.Length - 1)), int.Parse("-" + pts[0].Item2.Substring(0, pts[1].Item2.Length - 1))));
                    }
                    else
                    {
                        x = double.Parse(pts[0].Item1.Substring(0, pts[0].Item1.Length - 1));
                        y = double.Parse(pts[0].Item2.Substring(0, pts[0].Item2.Length - 1));
                        //AllPts.Add(new Tuple<int, int>(int.Parse(pts[0].Item1.Substring(0, pts[0].Item1.Length - 1)), int.Parse(pts[0].Item2.Substring(0, pts[1].Item2.Length - 1))));
                    }
                    AllPts.Add(new Tuple <double, double>(x, y));
                    geocoords.Add(mapPoint.ToGeoCoordinateString(ddParam));
                }

                double[,] sd = new double[AllPts.Count, 2];
                for (int i = 0; i < AllPts.Count; i++)
                {
                    sd[i, 0] = AllPts[i].Item1; //+ "," + AllPts[i].Item2;
                    sd[i, 1] = AllPts[i].Item2;
                }
                List <double[, ]> ss = new List <double[, ]>();
                ss.Add(sd);
                Config configPoints = new Config
                {
                    type        = "Polygon",
                    coordinates = ss.ToArray()
                };
                Config configGeom = new Config
                {
                    type       = "GeometryFilter",
                    field_name = "geometry",
                    config     = configPoints
                };



                //DateFilter
                Config dateconfigconfig2 = new Config
                {
                    gte = "2019-05-19T16:51:19.926Z",
                    lte = "2019-08-19T16:51:19.926Z"
                };

                Config dateconfigconfig = new Config
                {
                    type       = "DateRangeFilter",
                    field_name = "acquired",
                    config     = dateconfigconfig2
                };
                Config dateconfig = new Config
                {
                    type   = "OrFilter",
                    config = new[] { dateconfigconfig }
                };

                SearchFilter  searchFilter = new SearchFilter();
                List <string> typoes       = new List <string>();
                typoes.Add("PSScene4Band");
                typoes.Add("SkySatCollect");
                typoes.Add("REOrthoTile");


                List <Config> mainconfigs = new List <Config>();
                mainconfigs.Add(dateconfig);
                mainconfigs.Add(configGeom);
                searchFilter.item_types = typoes.ToArray();
                Filter topfilter = new Filter();
                topfilter.type      = "AndFilter";
                searchFilter.filter = topfilter;
                Config mainConfig = new Config();
                searchFilter.filter.config = mainconfigs.ToArray();


                //string json = JsonConvert.SerializeObject(searchFilter);
                string json = JsonConvert.SerializeObject(searchFilter, new JsonSerializerSettings()
                {
                    NullValueHandling = NullValueHandling.Ignore
                });
                string asas = "{\"filter\":{\"type\":\"AndFilter\",\"config\":[{\"type\":\"GeometryFilter\",\"field_name\":\"geometry\",\"config\":{\"type\":\"Polygon\",\"coordinates\":[[[-159.44149017333984,21.877787931279187],[-159.44998741149902,21.87679231243837],[-159.45372104644778,21.872769941600623],[-159.45217609405518,21.866835742000745],[-159.44372177124023,21.864207091531895],[-159.43561077117923,21.86930503623256],[-159.44149017333984,21.877787931279187]]]}},{\"type\":\"OrFilter\",\"config\":[{\"type\":\"DateRangeFilter\",\"field_name\":\"acquired\",\"config\":{\"gte\":\"2019-05-22T16:36:32.254Z\",\"lte\":\"2019-08-22T16:36:32.254Z\"}}]}]},\"item_types\":[\"PSScene4Band\",\"REOrthoTile\",\"SkySatCollect\"]}";
                //var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://api.somewhere.com/v2/cases");
                HttpClientHandler handler = new HttpClientHandler()
                {
                    AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
                };
                HttpClient client = new HttpClient(handler)
                {
                    BaseAddress = new Uri("https://api.planet.com")
                };
                HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "data/v1/quick-search");
                request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                request.Headers.CacheControl = new CacheControlHeaderValue();

                request.Headers.CacheControl.NoCache = true;
                request.Headers.Host = "api.planet.com";
                request.Headers.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip"));
                //request.Headers.Remove("Content-Type");
                //request.Headers.Add("Content-Type", "application/json");
                var content = new StringContent(json, Encoding.UTF8, "application/json");
                request.Content = content;
                var byteArray = Encoding.ASCII.GetBytes("1fe575980e78467f9c28b552294ea410:hgvhgv");
                client.DefaultRequestHeaders.Host = "api.planet.com";
                //_client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                content.Headers.Remove("Content-Type");
                content.Headers.Add("Content-Type", "application/json");
                //client.DefaultRequestHeaders.AcceptEncoding.Add(StringWithQualityHeaderValue.Parse("gzip"));
                client.DefaultRequestHeaders.Add("Connection", "keep-alive");
                client.DefaultRequestHeaders.Add("User-Agent", "ArcGISProC#");
                //content.Headers.TryAddWithoutValidation("Authorization", "Basic " + Convert.ToBase64String(byteArray));
                //client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", "MWZlNTc1OTgwZTc4NDY3ZjljMjhiNTUyMjk0ZWE0MTA6");//Convert.ToBase64String(byteArray));
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
                using (HttpResponseMessage httpResponse = client.SendAsync(request).Result)
                {
                    using (HttpContent content2 = httpResponse.Content)
                    {
                        var json2 = content2.ReadAsStringAsync().Result;
                        QuickSearchResult quickSearchResult = JsonConvert.DeserializeObject <QuickSearchResult>(json2);
                        //Geometry geometry2 = GeometryEngine.Instance.ImportFromJSON(JSONImportFlags.jsonImportDefaults, JsonConvert.SerializeObject( quickSearchResult.features[5].geometry));
                    }
                }



                pane.Activate();
                return(true);
            }
            catch (Exception exe)
            {
                if (_graphic != null)
                {
                    _graphic.Dispose();
                }
                return(false);
            }
        }
        protected override Task <bool> OnSketchCompleteAsync(Geometry geometry)
        {
            return(QueuedTask.Run(() =>
            {
                //MapView.Active.AddOverlay()
                var textGraphic = new CIMTextGraphic();
                textGraphic.Symbol = SymbolFactory.Instance.ConstructTextSymbol(
                    ColorFactory.Instance.BlackRGB, 12, "Times New Roman", "Regular").MakeSymbolReference();

                //make the callout for the circle
                var callOut = new CIMPointSymbolCallout();
                callOut.PointSymbol = new CIMPointSymbol();
                //Circle outline - 40
                var circle_outline = SymbolFactory.Instance.ConstructMarker(40, "ESRI Default Marker") as CIMCharacterMarker;
                //Square - 41
                //Triangle - 42
                //Pentagon - 43
                //Hexagon - 44
                //Octagon - 45
                circle_outline.Size = 40;
                //eliminate the outline
                foreach (var layer in circle_outline.Symbol.SymbolLayers)
                {
                    if (layer is CIMSolidStroke)
                    {
                        ((CIMSolidStroke)layer).Width = 0;
                    }
                }

                //Circle fill - 33
                var circle_fill = SymbolFactory.Instance.ConstructMarker(33, "ESRI Default Marker") as CIMCharacterMarker;
                //Square - 34
                //Triangle - 35
                //Pentagon - 36
                //Hexagon - 37
                //Octagon - 38
                circle_fill.Size = 40;
                //eliminate the outline, make sure the fill is white
                foreach (var layer in circle_fill.Symbol.SymbolLayers)
                {
                    if (layer is CIMSolidFill)
                    {
                        ((CIMSolidFill)layer).Color = ColorFactory.Instance.WhiteRGB;
                    }
                    else if (layer is CIMSolidStroke)
                    {
                        ((CIMSolidStroke)layer).Width = 0;
                    }
                }

                var calloutLayers = new List <CIMSymbolLayer>();
                calloutLayers.Add(circle_outline);
                calloutLayers.Add(circle_fill);
                //set the layers on the callout
                callOut.PointSymbol.SymbolLayers = calloutLayers.ToArray();

                //set the callout on the text symbol
                var textSym = textGraphic.Symbol.Symbol as CIMTextSymbol;
                textSym.Callout = callOut;
                textSym.Height = 12;//adjust as needed

                //now set the text
                textGraphic.Text = "12 <SUP><UND>00</UND></SUP>";
                textGraphic.Shape = geometry;

                var graphic = MapView.Active.AddOverlay(textGraphic);
                Module1.Current.Graphics.Add(graphic);
                return true;
            }));
        }
 public void SetSelectedGraphic(AnnotationLayer annoLayer, CIMTextGraphic graphic)
 {
     _annoLayer       = annoLayer;
     _selectedGraphic = graphic;
     SelectedGraphicChangedEvent.Publish(new SelectedGraphicChangedEventArgs(_annoLayer, _selectedGraphic));
 }