示例#1
0
        protected override void OnDoubleClick()
        {
            base.OnDoubleClick();

            if (isDrawing && Editor.ActiveLayer != null)
            {
                IPoint startCoor = Raster.ScreenCoor2MapCoor(Control.MousePosition.X, Control.MousePosition.Y);
                newLineFeedback.AddPoint(startCoor);

                IPointCollection pointCollection = (IPointCollection)newLineFeedback.Stop();
                List <Position>  pointList       = new List <Position>();
                for (int i = 0; i < pointCollection.PointCount - 1; i++)
                {
                    Position startPos = Raster.MapCoor2RasterCoor(pointCollection.get_Point(i), Painter.ActiveLayer);
                    Position endPos   = Raster.MapCoor2RasterCoor(pointCollection.get_Point(i + 1), Painter.ActiveLayer);

                    pointList.AddRange(Display.GetPolyline(startPos, endPos, layerExetent));
                }



                isDrawing = false;
            }
        }
示例#2
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 = Raster.ScreenCoor2RasterCoor(arg.X, arg.Y, activeLayer);
                        brCorner = tlCorner;
                    }
                    else
                    {
                        tlCorner = Raster.MapCoor2RasterCoor(envelop.UpperLeft, activeLayer);
                        brCorner = Raster.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++)
                        {
                            Position pos = new Position(col, row);
                            if (!Editor.Selections.Exists(pos))
                            {
                                Pixel pixel = new Pixel(pos);
                                pixel.GraphicElement = Display.DrawBox(pixel.Position, Editor.GetSelectionSymbol(), ArcMapApp.GetRasterLayer());
                                Editor.Selections.Add(pixel);
                            }
                        }
                    }

                    Display.Refresh();

                    double[,] values = Raster.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");
                }
            }
        }
示例#3
0
        protected override void OnMouseUp(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            base.OnMouseDown(arg);

            if (Editor.ActiveLayer != null)
            {
                try
                {
                    UID uid = new UIDClass();
                    uid.Value = ThisAddIn.IDs.EditForm;
                    IDockableWindow dockWin  = ArcMap.DockableWindowManager.GetDockableWindow(uid);
                    EditForm        editForm = AddIn.FromID <EditForm.AddinImpl>(ThisAddIn.IDs.EditForm).UI;

                    IEnvelope envelop = newEnvelopeFeedback.Stop();

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

                    if (!IsIntersect(tlCorner, brCorner, maxIndex))
                    {
                        editForm.ClearValues();
                        return;
                    }

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

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

                    Display.Refresh();

                    IRasterLayer rasterLayer = (IRasterLayer)Editor.ActiveLayer;
                    double[,] values = Raster.GetValues(tlCorner, brCorner, rasterLayer.Raster);
                    editForm.SetValues(tlCorner, brCorner, values);

                    // If there is only one value, select that.
                    if (values.Length == 1)
                    {
                        editForm.RasterGridView[0, 0].Selected = false;
                        editForm.RasterGridView[1, 0].Selected = true;
                    }

                    if (!dockWin.IsVisible())
                    {
                        dockWin.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");
                }
            }
        }