Example #1
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);
            }
        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;
            }));
        }
        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;
            }));
        }
Example #4
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;
            }));
        }