public static void ShowProjectExplorer(bool bVisible)
        {
            // Note that the IsVisible property on the dockable window does not
            // seem to track the state of the window properly. Especially if the user
            // clicks the "Pin" icon to close the dockable window. This seems to be a reliable
            // method for re-opening the dockable window when this happens.
            // http://forums.arcgis.com/threads/11692-ArcGIS10-Add-Ins-and-Dockable-Window
            //
            ESRI.ArcGIS.esriSystem.IUID pUI = new ESRI.ArcGIS.esriSystem.UID();
            pUI.Value = ThisAddIn.IDs.GCDAddIn_ucProjectManager;

            ESRI.ArcGIS.Framework.IDockableWindow docWin = ArcMap.DockableWindowManager.GetDockableWindow((ESRI.ArcGIS.esriSystem.UID)pUI);
            if (docWin is ESRI.ArcGIS.Framework.IDockableWindow)
            {
                docWin.Show(bVisible);

                if (bVisible)
                {
                    try
                    {
                        // Try and refresh the project window.
                        ucProjectManager.AddinImpl winImpl = ESRI.ArcGIS.Desktop.AddIns.AddIn.FromID <ucProjectManager.AddinImpl>(ThisAddIn.IDs.GCDAddIn_ucProjectManager);
                        winImpl.UI.LoadTree();
                    }
                    catch (Exception ex)
                    {
                        naru.error.ExceptionUI.HandleException(ex, "Error Opening Project Explorer", GCDCore.Properties.Resources.NewIssueURL);
                    }
                }
            }
        }
        protected override void OnClick()
        {
            try
            {
                if (MessageBox.Show("Are you sure that you want to close all riverscapes projects? This will also remove the layers related to these projects from your current map document.",
                                    "Close All Riverscapes Projects?",
                                    MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question,
                                    MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    ESRI.ArcGIS.esriSystem.IUID pUI = new ESRI.ArcGIS.esriSystem.UID();
                    pUI.Value = ThisAddIn.IDs.ucProjectExplorer;

                    ESRI.ArcGIS.Framework.IDockableWindow docWin = ArcMap.DockableWindowManager.GetDockableWindow((ESRI.ArcGIS.esriSystem.UID)pUI);
                    if (docWin is ESRI.ArcGIS.Framework.IDockableWindow)
                    {
                        // Try and refresh the project window.
                        ucProjectExplorer.AddinImpl winImpl = ESRI.ArcGIS.Desktop.AddIns.AddIn.FromID <ucProjectExplorer.AddinImpl>(ThisAddIn.IDs.ucProjectExplorer);
                        winImpl.UI.CloseAllProjects();
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandling.frmException.HandleException(ex, "Error Closing RAVE Projects", string.Empty);
            }

            ArcMap.Application.CurrentTool = null;
        }
Exemple #3
0
        protected override void OnClick()
        {
            try
            {
                frmOptions frm = new frmOptions();
                if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    ESRI.ArcGIS.esriSystem.IUID pUI = new ESRI.ArcGIS.esriSystem.UID();
                    pUI.Value = ThisAddIn.IDs.ucProjectExplorer;

                    ESRI.ArcGIS.Framework.IDockableWindow docWin = ArcMap.DockableWindowManager.GetDockableWindow((ESRI.ArcGIS.esriSystem.UID)pUI);
                    if (docWin is ESRI.ArcGIS.Framework.IDockableWindow)
                    {
                        try
                        {
                            // Try and refresh the project window.
                            ucProjectExplorer.AddinImpl winImpl = ESRI.ArcGIS.Desktop.AddIns.AddIn.FromID <ucProjectExplorer.AddinImpl>(ThisAddIn.IDs.ucProjectExplorer);
                            winImpl.UI.RefreshBaseMaps();
                        }
                        catch (Exception ex)
                        {
                            ErrorHandling.frmException.HandleException(ex, "Error showing project explorer.", string.Empty);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandling.frmException.HandleException(ex, "Error Showing RAVE Options Form", string.Empty);
            }

            ArcMap.Application.CurrentTool = null;
        }
Exemple #4
0
        protected override void OnClick()
        {
            try
            {
                OpenFileDialog f = new OpenFileDialog();
                f.DefaultExt      = "xml";
                f.Filter          = "Riverscapes Project Files (*.rs.xml)|*.rs.xml";
                f.Title           = "Open Existing Riverscapes Project";
                f.CheckFileExists = true;

                if (!string.IsNullOrEmpty(RaveAddIn.Properties.Settings.Default.LastUsedProjectFolder) && System.IO.Directory.Exists(RaveAddIn.Properties.Settings.Default.LastUsedProjectFolder))
                {
                    f.InitialDirectory = RaveAddIn.Properties.Settings.Default.LastUsedProjectFolder;

                    // Try and find the last used project in the folder
                    string[] fis = System.IO.Directory.GetFiles(RaveAddIn.Properties.Settings.Default.LastUsedProjectFolder, "*.rs.xml", System.IO.SearchOption.TopDirectoryOnly);
                    if (fis.Length > 0)
                    {
                        f.FileName = System.IO.Path.GetFileName(fis[0]);
                    }
                }

                if (f.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        ESRI.ArcGIS.esriSystem.IUID pUI = new ESRI.ArcGIS.esriSystem.UID();
                        pUI.Value = ThisAddIn.IDs.ucProjectExplorer;

                        ESRI.ArcGIS.Framework.IDockableWindow docWin = ArcMap.DockableWindowManager.GetDockableWindow((ESRI.ArcGIS.esriSystem.UID)pUI);
                        if (docWin is ESRI.ArcGIS.Framework.IDockableWindow)
                        {
                            // Try and refresh the project window.
                            ucProjectExplorer.AddinImpl winImpl = ESRI.ArcGIS.Desktop.AddIns.AddIn.FromID <ucProjectExplorer.AddinImpl>(ThisAddIn.IDs.ucProjectExplorer);
                            winImpl.UI.LoadProject(new System.IO.FileInfo(f.FileName));
                        }

                        //ProjectManager.OpenProject(new System.IO.FileInfo(f.FileName));
                        Properties.Settings.Default.LastUsedProjectFolder = System.IO.Path.GetDirectoryName(f.FileName);
                        Properties.Settings.Default.Save();

                        // This will cause the project tree to reload all open projects
                        btnProjectExplorer.ShowProjectExplorer(true);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(string.Format("Error reading the project file '{0}'. Ensure that the file is a valid project file with valid and complete XML contents.\n\n{1}", f.FileName, ex.Message), Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandling.frmException.HandleException(ex, "Error Opening Project", string.Empty);
            }

            ArcMap.Application.CurrentTool = null;
        }
        private void OnActiveViewEventsAfterDraw(ESRI.ArcGIS.Display.IDisplay display, ESRI.ArcGIS.Carto.esriViewDrawPhase phase)
        {
            ESRI.ArcGIS.Carto.esriViewDrawPhase m_phase = phase;

            //if the drawing pahse geography, find all feature layer and selected feature and draw them on screen if they are polygons. Please note don't call   display::StartDrawing as it is already started by the system.
            if (m_phase == ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeography)
            {
                IMap m_Map = m_MxDoc.FocusMap;
                ESRI.ArcGIS.esriSystem.UID m_UID = new ESRI.ArcGIS.esriSystem.UID();
                m_UID.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}";
                IEnumLayer m_EnumLayer = m_Map.Layers[m_UID];
                ILayer     m_Layer     = m_EnumLayer.Next();

                //if you want to change the selection color you can change it here.
                ISimpleFillSymbol m_FillSymbol = new SimpleFillSymbol();
                m_Rgb              = new RgbColor();
                m_Rgb.Red          = 255;
                m_FillSymbol.Color = m_Rgb;
                display.SetSymbol(m_FillSymbol as ISymbol);

                do
                {
                    if (m_Layer is IFeatureLayer)
                    {
                        if (m_Layer != null)
                        {
                            IFeatureSelection m_FeatureSelection = (IFeatureSelection)m_Layer;
                            ISelectionSet     m_SelSet           = m_FeatureSelection.SelectionSet;
                            IFeatureCursor    m_FeatCur;
                            ICursor           m_Cursor;
                            m_SelSet.Search(null, false, out m_Cursor);

                            m_FeatCur = (IFeatureCursor)m_Cursor;
                            IFeature m_Feature;

                            m_Feature = m_FeatCur.NextFeature();

                            do
                            {
                                if (m_Feature != null)
                                {
                                    if (m_Feature.Shape is IPolygon)
                                    {
                                        display.DrawPolygon(m_Feature.Shape);
                                    }
                                }
                                m_Feature = m_FeatCur.NextFeature();
                            } while (m_Feature != null);
                        }
                    }
                    m_Layer = m_EnumLayer.Next();
                } while (m_Layer != null);
            }
            #endregion
        }
        void activeViewEvents_SelectionChanged()
        {
            ///loop through all feature layer and do a partial refresh if the layer is polygon
            ///This important as selection change only does a partial refresh at geoselection level and since we are drawing polygon at geography phase, this step is essential.
            IMap m_Map = m_MxDoc.FocusMap;

            ESRI.ArcGIS.esriSystem.UID m_UID = new ESRI.ArcGIS.esriSystem.UID();
            m_UID.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}";
            IEnumLayer m_EnumLayer = m_Map.Layers[m_UID];
            ILayer     m_Layer     = m_EnumLayer.Next();


            IActiveView m_activeview = (IActiveView)m_MxDoc.ActivatedView;

            do
            {
                if (m_Layer is IFeatureLayer)
                {
                    if (m_Layer != null)
                    {
                        if (m_Layer.Visible == true)
                        {
                            IFeatureSelection m_FeatureSelection = (IFeatureSelection)m_Layer;
                            ISelectionSet     m_SelSet           = m_FeatureSelection.SelectionSet;



                            if (m_SelSet.Count > 0)
                            {
                                IEnumGeometry     m_EnumGeo;
                                IEnumGeometryBind m_EnumGeoBind;

                                m_EnumGeo     = new EnumFeatureGeometry();
                                m_EnumGeoBind = (IEnumGeometryBind)m_EnumGeo;
                                m_EnumGeoBind.BindGeometrySource(null, m_SelSet);

                                IGeometryFactory m_GeoFactory = new GeometryEnvironmentClass();
                                IGeometry        m_GeoEnvelop = m_GeoFactory.CreateGeometryFromEnumerator(m_EnumGeo);
                                m_activeview.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, m_GeoEnvelop.Envelope);
                            }
                            else
                            {
                                m_activeview.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                            }
                        }
                    }
                }
                m_Layer = m_EnumLayer.Next();
            } while (m_Layer != null);
        }
Exemple #7
0
        public ESRI.ArcGIS.Geodatabase.IFeatureClass CreateFeatureClass(string name, ESRI.ArcGIS.Geometry.ISpatialReference spatialReference, string workspacename)
        {
            ESRI.ArcGIS.Geodatabase.IWorkspace w = WorkSpace.CreateInMemoryWorkspace(workspacename);

            ESRI.ArcGIS.Geodatabase.IFeatureWorkspace fw = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)w;


            ESRI.ArcGIS.Geodatabase.IFields2 fields = CreateFields(spatialReference);
            ESRI.ArcGIS.esriSystem.UID       uid    = new ESRI.ArcGIS.esriSystem.UID();
            ESRI.ArcGIS.Geodatabase.IFeatureClassDescription fcDesc = new ESRI.ArcGIS.Geodatabase.FeatureClassDescriptionClass();
            ESRI.ArcGIS.Geodatabase.IObjectClassDescription  ocDesc = (ESRI.ArcGIS.Geodatabase.IObjectClassDescription)fcDesc;

            ESRI.ArcGIS.Geodatabase.IFeatureClass fc = fw.CreateFeatureClass(name, fields, ocDesc.InstanceCLSID, ocDesc.ClassExtensionCLSID, ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimple, "Shape", "");

            return(fc);
        }
        private void CreateSettingsTable(IFeatureWorkspace fwspc)
        {
            if (MessageBox.Show(String.Format("There is no settings table in this workspace.{0}Would you like to create one?", Environment.NewLine), "Settings Table", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                try
                {
                    IFields     flds     = new FieldsClass();
                    IFieldsEdit fldsEdit = (IFieldsEdit)flds;
                    fldsEdit.FieldCount_2 = 3;

                    IField     oidfld     = new FieldClass();
                    IFieldEdit oidfldEdit = (IFieldEdit)oidfld;
                    oidfldEdit.Name_2      = "OBJECTID";
                    oidfldEdit.AliasName_2 = "ObjectID";
                    oidfldEdit.Type_2      = esriFieldType.esriFieldTypeOID;

                    IField     keyfld     = new FieldClass();
                    IFieldEdit keyfldEdit = (IFieldEdit)keyfld;
                    keyfldEdit.AliasName_2 = "AKEY";
                    keyfldEdit.Name_2      = "AKEY";
                    keyfldEdit.Type_2      = esriFieldType.esriFieldTypeString;
                    keyfldEdit.Length_2    = 255;

                    IField     valuefld     = new FieldClass();
                    IFieldEdit valuefldEdit = (IFieldEdit)valuefld;
                    valuefldEdit.AliasName_2 = "AVALUE";
                    valuefldEdit.Name_2      = "AVALUE";
                    valuefldEdit.Type_2      = esriFieldType.esriFieldTypeString;
                    valuefldEdit.Length_2    = 255;

                    fldsEdit.set_Field(0, oidfld);
                    fldsEdit.set_Field(1, keyfld);
                    fldsEdit.set_Field(2, valuefld);

                    ESRI.ArcGIS.esriSystem.UID AddressingSettingsUID = new ESRI.ArcGIS.esriSystem.UID();
                    AddressingSettingsUID.Value = AddressingSettingsGUID;

                    ESRI.ArcGIS.esriSystem.UID extclsid = new ESRI.ArcGIS.esriSystem.UID();
                    extclsid.Value = "esriGeoDatabase.Object";

                    IFeatureClassDescription fcDesc = new FeatureClassDescriptionClass();
                    IObjectClassDescription  ocDesc = (IObjectClassDescription)fcDesc;

                    SettingsTable = fwspc.CreateTable("AddressingSettings", flds, AddressingSettingsUID, null, null);
                }
                catch (Exception ex)
                {
                    throw (ex);
                }



                Globals.SettingsTable = SettingsTable;

                ICursor cursor = SettingsTable.Search(null, false);
                try
                {
                    IRow row = cursor.NextRow();
                    System.Collections.Generic.Dictionary <string, string> settings = new System.Collections.Generic.Dictionary <string, string>();
                    while (row != null)
                    {
                        settings[row.get_Value(1).ToString()] = row.get_Value(2).ToString();
                        row = cursor.NextRow();
                    }

                    Globals.Settings = settings;
                }
                catch
                {
                    cursor = null;
                }
            }
            else
            {
                UseExtension = false;
            }
        }
        void activeViewEvents_SelectionChanged()
        {

            ///loop through all feature layer and do a partial refresh if the layer is polygon
            ///This important as selection change only does a partial refresh at geoselection level and since we are drawing polygon at geography phase, this step is essential.
                IMap m_Map = m_MxDoc.FocusMap;
                ESRI.ArcGIS.esriSystem.UID m_UID = new ESRI.ArcGIS.esriSystem.UID();
                m_UID.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}";
                IEnumLayer m_EnumLayer = m_Map.Layers[m_UID];
                ILayer m_Layer = m_EnumLayer.Next();

           
                IActiveView m_activeview = (IActiveView)m_MxDoc.ActivatedView;  

                do
                {
                    if (m_Layer is IFeatureLayer)
                    {
                         if (m_Layer != null)
                         {
                             if (m_Layer.Visible == true)
                             {
                                 IFeatureSelection m_FeatureSelection = (IFeatureSelection)m_Layer;
                                 ISelectionSet m_SelSet = m_FeatureSelection.SelectionSet;



                                 if (m_SelSet.Count > 0)
                                 {
                                     IEnumGeometry m_EnumGeo;
                                     IEnumGeometryBind m_EnumGeoBind;

                                     m_EnumGeo = new EnumFeatureGeometry();
                                     m_EnumGeoBind = (IEnumGeometryBind)m_EnumGeo;
                                     m_EnumGeoBind.BindGeometrySource(null, m_SelSet);

                                     IGeometryFactory m_GeoFactory = new GeometryEnvironmentClass();
                                     IGeometry m_GeoEnvelop = m_GeoFactory.CreateGeometryFromEnumerator(m_EnumGeo);
                                     m_activeview.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, m_GeoEnvelop.Envelope);

                                 }
                                 else
                                 {
                                     m_activeview.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                                 }

                             }
                    }
                    }
                   m_Layer = m_EnumLayer.Next();
                } while (m_Layer != null);


            
        }
        private void OnActiveViewEventsAfterDraw(ESRI.ArcGIS.Display.IDisplay display, ESRI.ArcGIS.Carto.esriViewDrawPhase phase)
        {

            ESRI.ArcGIS.Carto.esriViewDrawPhase m_phase = phase;

            //if the drawing pahse geography, find all feature layer and selected feature and draw them on screen if they are polygons. Please note don't call   display::StartDrawing as it is already started by the system.
            if (m_phase == ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeography)
            {
               
                IMap m_Map = m_MxDoc.FocusMap;
                ESRI.ArcGIS.esriSystem.UID m_UID = new ESRI.ArcGIS.esriSystem.UID();
                m_UID.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}";
                IEnumLayer m_EnumLayer = m_Map.Layers[m_UID];
                ILayer m_Layer = m_EnumLayer.Next();

                //if you want to change the selection color you can change it here.
                ISimpleFillSymbol m_FillSymbol = new SimpleFillSymbol();
                m_Rgb = new RgbColor();
                m_Rgb.Red = 255;
                m_FillSymbol.Color = m_Rgb;
                display.SetSymbol(m_FillSymbol as ISymbol);

                do
                {
                    if (m_Layer is IFeatureLayer)
                    {
                         if (m_Layer != null)
                         {
                        IFeatureSelection m_FeatureSelection = (IFeatureSelection)m_Layer;
                        ISelectionSet m_SelSet = m_FeatureSelection.SelectionSet;
                        IFeatureCursor m_FeatCur;
                        ICursor m_Cursor;
                        m_SelSet.Search(null, false, out m_Cursor);

                        m_FeatCur = (IFeatureCursor) m_Cursor;
                        IFeature m_Feature;

                        m_Feature = m_FeatCur.NextFeature();

                        do
                        {
                            if (m_Feature != null)
                            {
                                if (m_Feature.Shape is IPolygon)
                                {
                                    display.DrawPolygon(m_Feature.Shape);
                                }
                            }
                            m_Feature = m_FeatCur.NextFeature();
                        } while (m_Feature != null);



                    }
                    }
                   m_Layer = m_EnumLayer.Next();
                } while (m_Layer != null);


            }
        #endregion
        }