Esempio n. 1
0
        /// <summary>
        /// Remove all selection if there is no layer loaded
        /// </summary>
        protected override void OnUpdate()
        {
            Enabled = ArcMap.Application != null;

            try
            {
                if (ArcMap.Document.FocusMap.LayerCount == 0)
                {
                    Display.ClearElement(Editor.Selections.GetAllGraphicElements());
                    Editor.Selections.Clear();

                    UID dockWinID = new UIDClass();
                    dockWinID.Value = ThisAddIn.IDs.IdentifyForm;
                    IDockableWindow dockWindow = ArcMap.DockableWindowManager.GetDockableWindow(dockWinID);
                    if (dockWindow.IsVisible())
                    {
                        IdentifyForm identifyForm = AddIn.FromID <IdentifyForm.AddinImpl>(ThisAddIn.IDs.IdentifyForm).UI;
                        identifyForm.ClearValues();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Unfortunately, the application meets an error.\n\nSource: {0}\nSite: {1}\nMessage: {2}", ex.Source, ex.TargetSite, ex.Message), "Error");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Remove all selecion and close the select window once the tool is disabled.
        /// </summary>
        /// <returns></returns>
        protected override bool OnDeactivate()
        {
            try
            {
                Display.ClearElement(Editor.Selections.GetAllGraphicElements());
                Editor.Selections.Clear();

                UID dockWinID = new UIDClass();
                dockWinID.Value = ThisAddIn.IDs.IdentifyForm;
                IDockableWindow dockWindow = ArcMap.DockableWindowManager.GetDockableWindow(dockWinID);
                if (dockWindow.IsVisible())
                {
                    dockWindow.Show(false);
                    IdentifyForm identifyForm = AddIn.FromID <IdentifyForm.AddinImpl>(ThisAddIn.IDs.IdentifyForm).UI;
                    identifyForm.ClearValues();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Unfortunately, the application meets an error.\n\nSource: {0}\nSite: {1}\nMessage: {2}", ex.Source, ex.TargetSite, ex.Message), "Error");
            }

            return(base.OnDeactivate());
        }
Esempio n. 3
0
 protected override IntPtr OnCreateChild()
 {
     m_windowUI = new IdentifyForm(this.Hook);
     return(m_windowUI.Handle);
 }
Esempio n. 4
0
        /// <summary>
        /// Select the pixels when mouse up.
        /// </summary>
        /// <param name="arg"></param>
        protected override void OnMouseUp(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            base.OnMouseUp(arg);

            if (activeLayer != null)
            {
                try
                {
                    IEnvelope envelop = newEnvelopeFeedback.Stop();

                    UID dockWinID = new UIDClass();
                    dockWinID.Value = ThisAddIn.IDs.IdentifyForm;

                    // Use GetDockableWindow directly as we want the client IDockableWindow not the internal class
                    IDockableWindow dockWindow   = ArcMap.DockableWindowManager.GetDockableWindow(dockWinID);
                    IdentifyForm    identifyForm = AddIn.FromID <IdentifyForm.AddinImpl>(ThisAddIn.IDs.IdentifyForm).UI;

                    Position tlCorner, brCorner;
                    if (envelop.UpperLeft.IsEmpty)
                    {
                        tlCorner = Editor.ScreenCoor2RasterCoor(arg.X, arg.Y, activeLayer);
                        brCorner = tlCorner;
                    }
                    else
                    {
                        tlCorner = Editor.MapCoor2RasterCoor(envelop.UpperLeft, activeLayer);
                        brCorner = Editor.MapCoor2RasterCoor(envelop.LowerRight, activeLayer);
                    }

                    if (!IsIntersect(tlCorner, brCorner, maxExtent))
                    {
                        identifyForm.ClearValues();
                        return;
                    }

                    tlCorner.Adjust(0, 0, maxExtent.Column, maxExtent.Row);
                    brCorner.Adjust(0, 0, maxExtent.Column, maxExtent.Row);

                    // Show symbols of selected pixels
                    for (int row = tlCorner.Row; row <= brCorner.Row; row++)
                    {
                        for (int col = tlCorner.Column; col <= brCorner.Column; col++)
                        {
                            Pixel pixel = new Pixel(new Position(col, row));
                            pixel.GraphicElement = Display.DrawBox(pixel.Position, Editor.GetSelectionSymbol(), ArcMapApp.GetRasterLayer());
                            Editor.Selections.Add(pixel);
                        }
                    }

                    double[,] values = Editor.GetValues(tlCorner, brCorner, activeLayer.Raster);

                    identifyForm.SetValues(tlCorner, brCorner, values);
                    identifyForm.SetLayerName(activeLayer.Name);
                    if (!dockWindow.IsVisible())
                    {
                        dockWindow.Show(true);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format("Unfortunately, the application meets an error.\n\nSource: {0}\nSite: {1}\nMessage: {2}", ex.Source, ex.TargetSite, ex.Message), "Error");
                }
            }
        }
Esempio n. 5
0
 protected override IntPtr OnCreateChild()
 {
     m_windowUI = new IdentifyForm(this.Hook);
     return m_windowUI.Handle;
 }