private void TreeView_AfterSelect(object sender, TreeViewEventArgs e)
 {
     try {
         if (e.Node is TreeNodeGeodatabase)
         {
             TreeNodeGeodatabase treeNodeGeodatabase = (TreeNodeGeodatabase)e.Node;
             EsriModel           model = treeNodeGeodatabase.Model;
             model.SelectElements(false);
         }
         else if (e.Node is TreeNodeTable)
         {
             TreeNodeTable treeNodeTable = (TreeNodeTable)e.Node;
             EsriTable     table         = treeNodeTable.Table;
             EsriModel     model         = (EsriModel)table.Container;
             model.SelectElements(false);
             table.Selected = true;
         }
         else if (e.Node is TreeNodeGroup)
         {
         }
     }
     catch (Exception ex) {
         ExceptionDialog.HandleException(ex);
     }
 }
Exemple #2
0
        public override List <Dataset> GetChildren()
        {
            // Create Dataset List
            List <Dataset> datasets = new List <Dataset>();

            // Get Model
            EsriModel model = (EsriModel)base.Container;

            // Create Navigation
            Navigate navigate = model.Navigate;

            navigate.Start = this;
            Elements elements = navigate.Children();

            // Export Children
            foreach (Element element in elements.Values)
            {
                if (element is Dataset)
                {
                    Dataset dataset = (Dataset)element;
                    if (dataset.GetType() == typeof(RasterBand))
                    {
                        datasets.Add(dataset);
                    }
                }
            }

            // Return List
            return(datasets);
        }
        public ObjectClass GetParent()
        {
            // Get Model
            if (base.Container == null)
            {
                return(null);
            }
            EsriModel model = (EsriModel)base.Container;

            // Get Parents
            Navigate navigate = model.Navigate;

            navigate.Start = this;
            Elements elementParents = navigate.Parents(1);

            // Objectclass to return
            ObjectClass objectClass = null;

            // Find Parent that are ObjectClasses
            foreach (Element elementParent in elementParents.Values)
            {
                if (elementParent is ObjectClass)
                {
                    objectClass = (ObjectClass)elementParent;
                    break;
                }
            }

            // Return parent objectclass
            return(objectClass);
        }
Exemple #4
0
        public override List <Dataset> GetChildren()
        {
            // Create Dataset List
            List <Dataset> datasets = new List <Dataset>();

            // Get Model
            EsriModel model = (EsriModel)base.Container;

            // Create Navigation
            Navigate navigate = model.Navigate;

            navigate.Start = this;
            Elements elements = navigate.Children();

            // Export Children
            foreach (Element element in elements.Values)
            {
                if (element is Dataset)
                {
                    Dataset dataset = (Dataset)element;
                    if (dataset.GetType() == typeof(FeatureClass) ||
                        dataset.GetType() == typeof(RelationshipClass) ||
                        dataset.GetType() == typeof(GeometricNetwork) ||
                        dataset.GetType() == typeof(Network) ||
                        dataset.GetType() == typeof(Topology) ||
                        dataset.GetType() == typeof(Terrain))
                    {
                    }
                    datasets.Add(dataset);
                }
            }

            // Return List
            return(datasets);
        }
        public List <Subtype> GetSubtypes()
        {
            // Create Subtype List
            List <Subtype> subtypes = new List <Subtype>();

            // Get Model
            if (base.Container == null)
            {
                return(subtypes);
            }
            EsriModel model = (EsriModel)base.Container;

            // Get Navigator
            Navigate navigate = model.Navigate;

            navigate.Start = this;

            // Get Child Subtypes
            Elements elements = navigate.Children(1);

            foreach (Element element in elements.Values)
            {
                if (element is Subtype)
                {
                    Subtype subtype = (Subtype)element;
                    subtypes.Add(subtype);
                }
            }

            // Return Subtypes
            return(subtypes);
        }
Exemple #6
0
        public Dataset GetParent()
        {
            // Get Model
            EsriModel model = (EsriModel)base.Container;

            // Create Navigation
            Navigate navigate = model.Navigate;

            navigate.Start = this;

            // Get Parents
            Elements elements = navigate.Parents(1);

            if (elements.Count == 0)
            {
                return(null);
            }

            // Get First Parent
            IEnumerator enumerator = elements.Values.GetEnumerator();
            bool        ok         = enumerator.MoveNext();

            if (!ok)
            {
                return(null);
            }
            Element element = (Element)enumerator.Current;

            // Return Dataset
            if (!(element is Dataset))
            {
                return(null);
            }
            Dataset dataset = (Dataset)element;

            return(dataset);
        }
 public ModelEventArgs(EsriModel model) {
     this._model = model;
 }
 public ModelEventArgs(EsriModel model)
 {
     this._model = model;
 }
        private void MenuItem_Activate(object sender, EventArgs e)
        {
            try {
                //
                // Error List Context Menu
                //
                if (sender == this.menuButtonItemScroll)
                {
                    // Can only zoom to one item
                    if (this.listViewErrorList.SelectedItems.Count != 1)
                    {
                        return;
                    }

                    // Get EsriTable containing the error
                    ListViewItemError item  = (ListViewItemError)this.listViewErrorList.SelectedItems[0];
                    EsriTable         table = null;
                    if (item.Error is ErrorTable)
                    {
                        ErrorTable errorTable = (ErrorTable)item.Error;
                        table = errorTable.Table;
                    }
                    else if (item.Error is ErrorTableRow)
                    {
                        ErrorTableRow errorTableRow = (ErrorTableRow)item.Error;
                        EsriTableRow  esriTableRow  = (EsriTableRow)errorTableRow.TableRow;
                        table = (EsriTable)esriTableRow.Table;
                    }
                    else if (item.Error is ErrorObject)
                    {
                        ErrorObject errorObject = (ErrorObject)item.Error;
                        table = errorObject.Table;
                    }
                    if (table == null)
                    {
                        return;
                    }

                    // Get Containing Model
                    EsriModel model = (EsriModel)table.Container;

                    // Scroll to Table
                    model.ScrollToElement(table);

                    // Flash Table
                    table.Flash();
                }
                else if (sender == this.menuButtonItemSelect)
                {
                    // Can only zoom to one item
                    if (this.listViewErrorList.SelectedItems.Count == 0)
                    {
                        return;
                    }

                    foreach (ListViewItemError item in this.listViewErrorList.SelectedItems)
                    {
                        EsriModel model = null;
                        if (item.Error is ErrorTable)
                        {
                            ErrorTable errorTable = (ErrorTable)item.Error;
                            EsriTable  table      = errorTable.Table;
                            model = (EsriModel)table.Container;
                        }
                        else if (item.Error is ErrorTableRow)
                        {
                            ErrorTableRow errorTableRow = (ErrorTableRow)item.Error;
                            EsriTableRow  esriTableRow  = (EsriTableRow)errorTableRow.TableRow;
                            EsriTable     table         = (EsriTable)esriTableRow.Table;
                            model = (EsriModel)table.Container;
                        }
                        else if (item.Error is ErrorObject)
                        {
                            ErrorObject errorObject = (ErrorObject)item.Error;
                            EsriTable   table       = errorObject.Table;
                            model = (EsriModel)table.Container;
                        }
                        if (model == null)
                        {
                            continue;
                        }

                        // Clear Model Selection
                        model.SelectElements(false);
                    }
                    //
                    foreach (ListViewItemError item in this.listViewErrorList.SelectedItems)
                    {
                        // Get Table
                        EsriTable table = null;
                        if (item.Error is ErrorTable)
                        {
                            ErrorTable errorTable = (ErrorTable)item.Error;
                            table = errorTable.Table;
                        }
                        else if (item.Error is ErrorTableRow)
                        {
                            ErrorTableRow errorTableRow = (ErrorTableRow)item.Error;
                            EsriTableRow  esriTableRow  = (EsriTableRow)errorTableRow.TableRow;
                            table = (EsriTable)esriTableRow.Table;
                        }
                        else if (item.Error is ErrorObject)
                        {
                            ErrorObject errorObject = (ErrorObject)item.Error;
                            table = errorObject.Table;
                        }
                        if (table == null)
                        {
                            continue;
                        }

                        // Flash Table
                        table.Selected = true;
                    }
                }
                else if (sender == this.menuButtonItemFlashError)
                {
                    // Can only zoom to one item
                    if (this.listViewErrorList.SelectedItems.Count == 0)
                    {
                        return;
                    }

                    //
                    foreach (ListViewItemError item in this.listViewErrorList.SelectedItems)
                    {
                        // Get Table
                        EsriTable table = null;
                        if (item.Error is ErrorTable)
                        {
                            ErrorTable errorTable = (ErrorTable)item.Error;
                            table = errorTable.Table;
                        }
                        else if (item.Error is ErrorTableRow)
                        {
                            ErrorTableRow errorTableRow = (ErrorTableRow)item.Error;
                            EsriTableRow  esriTableRow  = (EsriTableRow)errorTableRow.TableRow;
                            table = (EsriTable)esriTableRow.Table;
                        }
                        else if (item.Error is ErrorObject)
                        {
                            ErrorObject errorObject = (ErrorObject)item.Error;
                            table = errorObject.Table;
                        }
                        if (table == null)
                        {
                            continue;
                        }

                        // Flash Table
                        table.Flash();
                    }
                }
                else if (sender == this.menuButtonItemClearError)
                {
                    // Remove Selected Items
                    foreach (ListViewItemError item in this.listViewErrorList.SelectedItems)
                    {
                        if (this.m_errors.Contains(item.Error))
                        {
                            this.m_errors.Remove(item.Error);
                        }
                    }

                    // Refresh Error List
                    this.RefreshErrorList();
                }
                else if (sender == menuButtonItemClearAllErrors)
                {
                    // Remove All Errors
                    this.m_errors.Clear();

                    // Refresh Error List
                    this.RefreshErrorList();
                }
                //
                // Validator Dropdown Menu
                //
                else if (sender == this.menuButtonItemPGdb)
                {
                    WorkspaceValidator.Default.Validator = new PersonalGeodatabaseValidator();
                }
                else if (sender == this.menuButtonItemFGdb)
                {
                    WorkspaceValidator.Default.Validator = new FileGeodatabaseValidator();
                }
                else if (sender == this.menuButtonItemSelectGeodatabase)
                {
                    // Create GxObjectFilter for GxDialog
                    IGxObjectFilter gxObjectFilter = new GxFilterWorkspacesClass();

                    // Create GxDialog
                    IGxDialog gxDialog = new GxDialogClass();
                    gxDialog.AllowMultiSelect = false;
                    gxDialog.ButtonCaption    = Resources.TEXT_SELECT;
                    gxDialog.ObjectFilter     = gxObjectFilter;
                    gxDialog.RememberLocation = true;
                    gxDialog.Title            = Resources.TEXT_SELECT_EXISTING_GEODATABASE;

                    // Declare Enumerator to hold selected objects
                    IEnumGxObject enumGxObject = null;

                    // Open Dialog
                    if (!gxDialog.DoModalOpen(0, out enumGxObject))
                    {
                        return;
                    }
                    if (enumGxObject == null)
                    {
                        return;
                    }

                    // Get Selected Object (if any)
                    IGxObject gxObject = enumGxObject.Next();
                    if (gxObject == null)
                    {
                        return;
                    }
                    if (!gxObject.IsValid)
                    {
                        return;
                    }

                    // Get GxDatabase
                    if (!(gxObject is IGxDatabase))
                    {
                        return;
                    }
                    IGxDatabase gxDatabase = (IGxDatabase)gxObject;

                    // Get Workspace
                    IWorkspace workspace = gxDatabase.Workspace;
                    if (workspace == null)
                    {
                        return;
                    }

                    // Get Workspace Factory
                    IWorkspaceFactory workspaceFactory = workspace.WorkspaceFactory;
                    if (workspaceFactory == null)
                    {
                        return;
                    }

                    // Get Workspace Factory ID
                    IUID   uid  = workspaceFactory.GetClassID();
                    string guid = uid.Value.ToString().ToUpper();

                    switch (guid)
                    {
                    case EsriRegistry.GEODATABASE_PERSONAL:
                        WorkspaceValidator.Default.Validator = new PersonalGeodatabaseValidator(workspace);
                        break;

                    case EsriRegistry.GEODATABASE_FILE:
                        WorkspaceValidator.Default.Validator = new FileGeodatabaseValidator(workspace);
                        break;

                    case EsriRegistry.GEODATABASE_SDE:
                        WorkspaceValidator.Default.Validator = new SdeValidator(workspace);
                        break;

                    default:
                        break;
                    }
                }
                else if ((sender is MenuButtonItem) && (((MenuButtonItem)sender).Parent == this.menuButtonItemSdeConnection))
                {
                    MenuButtonItem item = (MenuButtonItem)sender;
                    if (item.Tag == null)
                    {
                        return;
                    }
                    WorkspaceValidator.Default.Validator = new SdeValidator(item.Tag.ToString());
                }
            }
            catch (Exception ex) {
                ExceptionDialog.HandleException(ex);
            }
        }
 //
 // CONSTRUCTOR
 //
 public TreeNodeGeodatabase(EsriModel model) : base()
 {
     this.m_model = model;
 }
 //
 // CONSTRUCTOR
 //
 public TreeNodeGeodatabase(EsriModel model) : base() {
     this.m_model = model;
 }