Beispiel #1
0
        /// <summary>
        /// 根据ID显示指定的DockWindow
        /// </summary>
        /// <param name="uid_value">UID.Value,一般为“ThisAddIn.IDs.xxxx”格式,其中“xxxx”为DockableWindow的ID</param>
        internal static void ShowDockAbleWindow(string uid_value)
        {
            if (DateTime.Now > new DateTime(2019, 8, 31))
            {
                ShowDialogInfo("插件已过期");
                return;
            }

            IDockableWindowManager pDocWinMgr = ArcMap.DockableWindowManager;
            UID uid = new UIDClass()
            {
                Value = uid_value
            };
            IDockableWindow pWindow = pDocWinMgr.GetDockableWindow(uid);


            if (!pWindow.IsVisible())
            {
                pWindow.Dock(esriDockFlags.esriDockShow);
            }
            else
            {
                pWindow.Dock(esriDockFlags.esriDockUnPinned);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            //This command is designed to be on a context menu displayed when the
            //logging window is right-clicked. Get the context item of the application
            IDocument doc         = m_application.Document;
            object    contextItem = null;

            if (doc is IBasicDocument)
            {
                contextItem = ((IBasicDocument)doc).ContextItem;
            }

            IDockableWindow dockWin     = null;
            UID             logWindowID = new UIDClass();

            logWindowID.Value = "{600cb3c8-e9d8-4c20-b2c7-f97082b10f92}";

            if (contextItem != null && contextItem is IDockableWindow)
            {
                dockWin = (IDockableWindow)contextItem;
            }
            else //In the case of ArcCatalog or the command has been placed outside the designated context menu
            {
                //Get the dockable window directly
                IDockableWindowManager dockWindowManager = (IDockableWindowManager)m_application;
                dockWin = dockWindowManager.GetDockableWindow(logWindowID);
            }

            //Clear list items in the dockable window
            if (dockWin != null && dockWin.ID.Compare(logWindowID))
            {
                System.Windows.Forms.ListBox containedBox = dockWin.UserData as System.Windows.Forms.ListBox;
                containedBox.Items.Clear();
            }
        }
Beispiel #3
0
        public IDockableWindow GetDockableWindow(IApplication app, string winName)
        {
            IDockableWindowManager dWinManager = app as IDockableWindowManager;
            UID winID = new UIDClass();

            winID.Value = winName;
            return(dWinManager.GetDockableWindow(winID));
        }
        private void lstPendingMessage_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right && lstPendingMessage.ContextMenuStrip == null)
            {
                //Before showing the context menu, set ContextItem to be the actual dockable window
                //which represents this definition class in the framework
                IDocument doc = m_application.Document;
                IDockableWindowManager windowManager = m_application as IDockableWindowManager;
                UID dockwinID = new UIDClass();
                dockwinID.Value = this.GetType().GUID.ToString("B");
                IDockableWindow frameworkWindow = windowManager.GetDockableWindow(dockwinID);
                if (doc is IBasicDocument) //ArcMap, ArcScene and ArcGlobe
                {
                    ((IBasicDocument)doc).ContextItem = frameworkWindow;
                }

                //Get the context menu to show
                ICommandBars documentBars = m_application.Document.CommandBars;
                ICommandBar  ctxMenu      = null;
                if (radDynamic.Checked) //Create context menu dynamically
                {
                    //Disadvantage(s):
                    //1. ICommandBars.Create will set document to dirty
                    //2. Cannot insert separator
                    ctxMenu = documentBars.Create("DockableWindowCtxTemp", esriCmdBarType.esriCmdBarTypeShortcutMenu); //This sets document flag to dirty :(

                    //Add commands to context menu
                    UID    cmdID = new UIDClass();
                    object idx   = Type.Missing;

                    cmdID.Value = "{b5820a63-e3d4-42a1-91c5-d90eacc3985b}"; //ClearLoggingCommand
                    ctxMenu.Add(cmdID, ref idx);

                    cmdID.Value = "{21532172-bc21-43eb-a2ad-bb6c333eff5e}"; //LogLineMultiItemCmd
                    ctxMenu.Add(cmdID, ref idx);
                }
                else    //Use predefined context menu
                {
                    UID menuID = new UIDClass();
                    menuID.Value = "{c6238198-5a2a-4fe8-bff0-e2f574f6a6cf}"; //LoggingWindowCtxMnu
                    ICommandItem locateMenu = documentBars.Find(menuID, false, false);
                    if (locateMenu != null)
                    {
                        ctxMenu = locateMenu as ICommandBar;
                    }
                }

                //Pop up context menu at screen location
                Point scrnPoint = lstPendingMessage.PointToScreen(e.Location);
                if (ctxMenu != null)
                {
                    ctxMenu.Popup(scrnPoint.X, scrnPoint.Y);
                }
            }
        }
        protected override void OnClick()
        {
            UID uid = new UID();

            uid.Value = ThisAddIn.IDs._DocWindowSami; // ThisAddin.IDs returns all the class IDs under this Add-in project
            IDockableWindowManager dockWindowManager = ArcMap.Application as IDockableWindowManager;
            IDockableWindow        dockableWindow    = dockWindowManager.GetDockableWindow(uid);

            //IDockableWindow dockableWindow = GetDockableWindow(ArcMap.Application, "esriGeoprocessingUI.GPCommandWindow"); // Open a System dockable window
            dockableWindow.Show(true); // use False to hide the dockable window
        }
Beispiel #6
0
        /// <summary>
        /// Shows the dockable window (common progIDs: esriEditor.AttributionCommand for Feature inspector, esriEditor.CreateFeatureDockWin for create features window)
        /// </summary>
        /// <param name="progID">The prog ID.</param>
        public static void ShowDockableWindow(string progID)
        {
            //show the create feature template window:
            IDockableWindowManager dockableWindowManager = (IDockableWindowManager)ArcMap.Application;
            UID nuid = new UIDClass()
            {
                Value = progID
            };
            IDockableWindow window = dockableWindowManager.GetDockableWindow(nuid);

            window.Show(true);
        }
Beispiel #7
0
 private void SetupDockableWindow()
 {
     if (m_dockableWindow == null)
     {
         IDockableWindowManager dockWindowManager = m_application as IDockableWindowManager;
         if (dockWindowManager != null)
         {
             UID windowID = new UIDClass();
             windowID.Value   = DockableWindowGuid;
             m_dockableWindow = dockWindowManager.GetDockableWindow(windowID);
         }
     }
 }
Beispiel #8
0
        public int OnPopup(object hook)
        {
            IApplication app = hook as IApplication;

            //This command is designed to be on a context menu displayed when the
            //logging window is right-clicked. Get the context item of the application
            IDocument doc         = app.Document;
            object    contextItem = null;

            if (doc is IBasicDocument)
            {
                contextItem = ((IBasicDocument)doc).ContextItem;
            }

            IDockableWindow dockWin     = null;
            UID             logWindowID = new UIDClass();

            logWindowID.Value = "{600cb3c8-e9d8-4c20-b2c7-f97082b10f92}";

            if (contextItem != null && contextItem is IDockableWindow)
            {
                dockWin = (IDockableWindow)contextItem;
            }
            else //In the case of ArcCatalog or the command has been placed outside the designated context menu
            {
                //Get the dockable window directly
                IDockableWindowManager dockWindowManager = (IDockableWindowManager)app;
                dockWin = dockWindowManager.GetDockableWindow(logWindowID);
            }

            //Get list item count in the dockable window
            if (dockWin != null && dockWin.ID.Compare(logWindowID))
            {
                m_targetListBox = dockWin.UserData as System.Windows.Forms.ListBox;
                return(m_targetListBox.Items.Count);
            }

            return(0); //failed or not applicable
        }
        public void Startup(ref object initializationData)
        {
            m_application = initializationData as IApplication;
            if (m_application == null)
            {
                return;
            }

            m_doc = m_application.Document as IMxDocument;

            //Get dockable window.
            IDockableWindowManager dockableWindowManager = m_application as IDockableWindowManager;
            UID dockWinID = new UIDClass();

            dockWinID.Value = @"SelectionCOMSample.SelectionCountDockWin";
            s_dockWindow    = dockableWindowManager.GetDockableWindow(dockWinID);

            //Wire up events.
            IDocumentEvents_Event docEvents = m_doc as IDocumentEvents_Event;

            docEvents.NewDocument  += new ESRI.ArcGIS.ArcMapUI.IDocumentEvents_NewDocumentEventHandler(ArcMap_NewOpenDocument);
            docEvents.OpenDocument += new ESRI.ArcGIS.ArcMapUI.IDocumentEvents_OpenDocumentEventHandler(ArcMap_NewOpenDocument);
        }
        protected override void OnClick()
        {
            ICadastralEditor            pCadEd         = (ICadastralEditor)ArcMap.Application.FindExtensionByName("esriCadastralUI.CadastralEditorExtension");
            ICadastralFabric            pCadFabric     = pCadEd.CadastralFabric;
            ICadastralExtensionManager2 pCadExtMan     = (ICadastralExtensionManager2)pCadEd;
            IParcelEditManager          pParcEditorMan = (IParcelEditManager)pCadEd;
            IParcelConstruction         pTrav          = pParcEditorMan.ParcelConstruction;

            //Test for the visibility of the parcel details window
            IDockableWindowManager pDocWinMgr = (IDockableWindowManager)ArcMap.Application;
            UID pUID = new UIDClass();

            pUID.Value = "{28531B78-7C42-4785-805D-2A7EC8879EA1}";//ArcID.ParcelDetails
            IDockableWindow pParcelDet = pDocWinMgr.GetDockableWindow(pUID);

            if (!pParcelDet.IsVisible())
            {
                MessageBox.Show("The Parcel Details window is not visible. \r\nThere is no data to save.");
                return;
            }

            //Make sure the lines grid is selected
            Utilities UTILS = new Utilities();

            UTILS.SelectCadastralPropertyPage((ICadastralExtensionManager)pCadExtMan, "lines");

            //test to make sure there is data there to be saved
            IParcelConstruction3 pConstr = (IParcelConstruction3)pTrav;
            IGSParcel            pParcel = null;

            //
            try
            {
                pParcel = pTrav.Parcel;
            }
            catch (COMException err)
            {
                MessageBox.Show(err.Message + Environment.NewLine + "ERROR: Select a parcel or add lines to the grid. \r\nThere is no data to save. ");
                return;
            }
            //define the file that needs to be saved
            // Display .Net dialog for File saving.
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            // Set File Filter
            saveFileDialog.Filter           = "Comma-delimited(*.csv)|*.csv|All Files|*.*";
            saveFileDialog.FilterIndex      = 1;
            saveFileDialog.RestoreDirectory = true;
            // Warn on overwrite
            saveFileDialog.OverwritePrompt = true;
            // Don't need to Show Help
            saveFileDialog.ShowHelp = false;
            // Set Dialog Title
            saveFileDialog.Title = "Save file";

            // Display Open File Dialog
            if (saveFileDialog.ShowDialog() != DialogResult.OK)
            {
                saveFileDialog = null;
                return;
            }
            TextWriter tw = null;

            try
            {
                tw = new StreamWriter(saveFileDialog.FileName);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            try
            {
                IGSPlan pPlan = pTrav.Parcel.Plan;
                int     iDF   = (int)pPlan.DirectionFormat;
                switch (iDF)
                {
                case (int)esriDirectionType.esriDTNorthAzimuth:
                    tw.WriteLine("DT,NA");
                    break;

                case (int)esriDirectionType.esriDTPolar:
                    tw.WriteLine("DT,P");
                    break;

                case (int)esriDirectionType.esriDTQuadrantBearing:
                    tw.WriteLine("DT,QB");
                    break;

                case (int)esriDirectionType.esriDTSouthAzimuth:
                    tw.WriteLine("DT,SA");
                    break;

                default:
                    tw.WriteLine("DT,NA");
                    break;
                }

                int iAU = (int)pPlan.AngleUnits;
                switch (iAU)
                {
                case (int)esriDirectionUnits.esriDUDecimalDegrees:
                    tw.WriteLine("DU,DD");
                    break;

                case (int)esriDirectionUnits.esriDUDegreesMinutesSeconds:
                    tw.WriteLine("DU,DMS");
                    break;

                case (int)esriDirectionUnits.esriDUGons:
                case (int)esriDirectionUnits.esriDUGradians:
                    tw.WriteLine("DU,G");
                    break;

                case (int)esriDirectionUnits.esriDURadians:
                    tw.WriteLine("DU,R");
                    break;

                default:
                    tw.WriteLine("DU,R");
                    break;
                }

                ICadastralUnitConversion pUnitConv = new CadastralUnitConversionClass();
                double dMetricConversion           = pUnitConv.ConvertDouble(1, pPlan.DistanceUnits, esriCadastralDistanceUnits.esriCDUMeter);
                string sLU = Convert.ToString(dMetricConversion);

                tw.WriteLine("ToMetricFactor," + sLU);

                IEnumGSLines pGSLines = pTrav.GetLines();
                pGSLines.Reset();
                IGSLine   pGSLine   = null;
                IGSParcel pGSParcel = null;
                pGSLines.Next(ref pGSParcel, ref pGSLine);
                while (pGSLine != null)
                {
                    int iFromPt  = pGSLine.FromPoint;     //from point
                    int iToPt    = pGSLine.ToPoint;       //to point
                    int iLineCat = (int)pGSLine.Category; //line category
                    if (iLineCat == 4)
                    {
                        pGSLines.Next(ref pGSParcel, ref pGSLine);
                        continue;                            //ignore radial lines
                    }
                    int    iLineUserType = pGSLine.LineType; //line user type
                    int    iAccCat       = pGSLine.Accuracy; //accuracy
                    double dDistance     = pGSLine.Distance; //distance
                    double dChord        = pGSLine.Distance; //chord
                    double dRadius       = pGSLine.Radius;   //radius

                    string sLineCat      = Convert.ToString(iLineCat);
                    string sLineUserType = Convert.ToString(iLineUserType);

                    if (iLineUserType > 2140000000)
                    {
                        sLineUserType = "";
                    }

                    string sAccCat = Convert.ToString(iAccCat);
                    string sFromPt = Convert.ToString(iFromPt);//from point

                    //following need conversion
                    string sDirection = NorthAzRadians_2_DirectionString(pGSLine.Bearing, pPlan.DirectionFormat, pPlan.AngleUnits); //direction
                    string sDistance  = Convert.ToString(dDistance / dMetricConversion);                                            //distance
                    string sRadius    = "";
                    string sChord     = "";

                    if (dRadius != 123456789)
                    {                                                                //circular curve
                        sRadius   = Convert.ToString(dRadius / dMetricConversion);   //radius
                        sChord    = Convert.ToString(dDistance / dMetricConversion); //chord
                        sDistance = "";                                              //distance is replaced with the chord distance
                    }

                    string sToPt = Convert.ToString(iToPt);//to point
                    //write the line
                    tw.WriteLine(sFromPt + "," + sDirection + "," + sDistance + "," + sRadius + "," + sChord + "," + sToPt + ","
                                 + sLineCat + "," + sLineUserType + "," + sAccCat);

                    pGSLines.Next(ref pGSParcel, ref pGSLine);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                tw.Close();
                saveFileDialog = null;
            }
        }