Example #1
0
        private void drawButton_Click(object sender, EventArgs e)
        {
            // if there is already a element on the screen remove it.
            if (this.drawnElement != null)
            {
                ArcUtility.DeleteElementFromGraphicContainer(ArcMap.Document.ActiveView, this.drawnElement);
            }

            this.drawnPolygon = null;
            this.drawnElement = null;

            // Unsubscribe to pre-existing events if any then subscibe so only one
            // subscription is active.
            AnswerFactoryRelay.Instance.AoiHasBeenDrawn -= this.Instance_AoiHasBeenDrawn;
            AnswerFactoryRelay.Instance.AoiHasBeenDrawn += this.Instance_AoiHasBeenDrawn;

            var commandBars = ArcMap.Application.Document.CommandBars;
            var commandId   = new UIDClass {
                Value = ThisAddIn.IDs.Gbdx_Answer_Factory_AnswerFactorySelector
            };
            var commandItem = commandBars.Find(commandId, false, false);

            if (commandItem != null)
            {
                this.PreviouslySelectedItem    = ArcMap.Application.CurrentTool;
                ArcMap.Application.CurrentTool = commandItem;
            }
        }
        /// <summary>
        ///     Event handler for when the select area button is clicked.
        /// </summary>
        /// <param name="sender">
        ///     the button that is clicked
        /// </param>
        /// <param name="e">
        ///     event arguments that get sent by the button
        /// </param>
        private void EventHandlerSelectAreaButtonClick(object sender, EventArgs e)
        {
            // Draw Rectangle option
            if (this.aoiTypeComboBox.SelectedIndex == 0)
            {
                // Reset this variable to allow the user to differentiate between normal and query search.
                this.usingQuerySource     = false;
                this.treeView1.CheckBoxes = true;

                if (ArcMap.Application.CurrentTool.Name != "DigitalGlobe_Inc_sma_VectorIndex")
                {
                    // Unsubscribe from any previous events.  Prevents awesome mode
                    VectorIndexRelay.Instance.PolygonHasBeenSet -= this.InstancePolygonHasBeenSet;

                    // Subscribe to the event
                    VectorIndexRelay.Instance.PolygonHasBeenSet += this.InstancePolygonHasBeenSet;

                    // Clear any current drawn images
                    if (this.boundingBoxGraphicElement != null)
                    {
                        ArcUtility.DeleteElementFromGraphicContainer(
                            ArcMap.Document.ActivatedView,
                            this.boundingBoxGraphicElement);
                        this.boundingBoxGraphicElement = null;
                    }

                    // Clear the treeview
                    this.treeView1.Nodes.Clear();
                    this.textBoxSearch.Clear();

                    this.currentApplicationState = this.applicationStateGenerator.Next();
                    var commandBars = ArcMap.Application.Document.CommandBars;
                    var commandId   = new UIDClass {
                        Value = "DigitalGlobe_Inc_sma_VectorIndex"
                    };

                    var commandItem = commandBars.Find(commandId, false, false);
                    if (commandItem != null)
                    {
                        this.originallySelectedItem    = ArcMap.Application.CurrentTool;
                        ArcMap.Application.CurrentTool = commandItem;
                    }
                }
            }

            // Use selected AOI
            else if (this.aoiTypeComboBox.SelectedIndex == 1)
            {
                // Clear any current drawn images
                if (this.boundingBoxGraphicElement != null)
                {
                    ArcUtility.DeleteElementFromGraphicContainer(
                        ArcMap.Document.ActivatedView,
                        this.boundingBoxGraphicElement);
                    this.boundingBoxGraphicElement = null;
                }

                this.ShapeAoi();
            }
        }
Example #3
0
        private void resetButton_Click(object sender, EventArgs e)
        {
            this.projectNameTextbox.Clear();
            this.availableRecipesCombobox.SelectedIndex = -1;

            // if there is already a element on the screen remove it.
            if (this.drawnElement != null)
            {
                ArcUtility.DeleteElementFromGraphicContainer(ArcMap.Document.ActiveView, this.drawnElement);
            }
            this.drawnPolygon = null;
            this.drawnElement = null;
        }
        /// <summary>
        ///     Resets the vector index.  Deletes the element from the graphic container, clears the the treeview and search
        ///     textbox
        ///     and changes the current applications tate.
        /// </summary>
        private void ResetVectorServices()
        {
            this.treeView1.Nodes.Clear();
            this.textBoxSearch.Clear();

            // Clear any current drawn images
            if (this.boundingBoxGraphicElement != null)
            {
                ArcUtility.DeleteElementFromGraphicContainer(
                    ArcMap.Document.ActivatedView,
                    this.boundingBoxGraphicElement);
                this.boundingBoxGraphicElement = null;
            }

            this.currentApplicationState = this.applicationStateGenerator.Next();
        }
        /// <summary>
        ///     Event handler for when the clear button is clicked.
        /// </summary>
        /// <param name="sender">
        ///     the button that is clicked
        /// </param>
        /// <param name="e">
        ///     event arguments that get sent by the button
        /// </param>
        private void EventHandlerClearButtonClick(object sender, EventArgs e)
        {
            // Clear any current drawn images
            if (this.boundingBoxGraphicElement != null)
            {
                ArcUtility.DeleteElementFromGraphicContainer(
                    ArcMap.Document.ActivatedView,
                    this.boundingBoxGraphicElement);
                this.boundingBoxGraphicElement = null;
            }

            // Clear Treeview
            this.treeView1.Nodes.Clear();
            this.textBoxSearch.Clear();
            this.currentApplicationState = this.applicationStateGenerator.Next();
        }
        /// <summary>
        ///     The event handler for when the key up event for the search textbox is triggered.
        /// </summary>
        /// <param name="sender">
        ///     textbox listening for the key up event.
        /// </param>
        /// <param name="e">
        ///     Event arguments
        /// </param>
        private void EventHandlerTextBoxSearchKeyUp(object sender, KeyEventArgs e)
        {
            // Only care about the enter key
            if (e.KeyCode != Keys.Enter)
            {
                return;
            }

            this.currentApplicationState = this.applicationStateGenerator.Next();
            this.treeView1.Nodes.Clear();
            this.checkedNodes.Clear();
            this.treeView1.CheckBoxes = true;
            this.usingQuerySource     = false;

            if (this.aoiTypeComboBox.SelectedIndex == 0)
            {
                // if the boundingbox graphic element hasn't been pressed then
                // lets assume that we use the curren't active views extent as the envelope.
                if (this.boundingBoxGraphicElement == null)
                {
                    var poly = VectorIndexHelper.DisplayRectangle(
                        ArcMap.Document.ActiveView,
                        out this.boundingBoxGraphicElement);

                    // Kick off vector index functionality
                    this.ShapeAoi(poly);
                    return;
                }

                // We already have a bounding box drawn so lets re-use that without redrawing the aoi.
                var tempPolygon = (IPolygon)this.boundingBoxGraphicElement.Geometry;
                this.ShapeAoi(tempPolygon);
            }
            else
            {
                // Clear any current drawn images
                if (this.boundingBoxGraphicElement != null)
                {
                    ArcUtility.DeleteElementFromGraphicContainer(
                        ArcMap.Document.ActivatedView,
                        this.boundingBoxGraphicElement);
                    this.boundingBoxGraphicElement = null;
                }

                this.ShapeAoi();
            }
        }