Esempio n. 1
0
        private void PassListItem()
        {
            foreach (ListViewItem item in this.listView1.SelectedItems)
            {
                IGxObject tag = item.Tag as IGxObject;
                if (tag != null)
                {
                    this._array2.Add(tag);
                    this._gxObjects.Add(tag);
                }
            }
            base.DialogResult = DialogResult.OK;
            GISDataComboItem selectedItem = this.gisDataComboBox1.SelectedItem as GISDataComboItem;

            this._gxObject  = selectedItem.Tag as IGxObject;
            _pStartLocation = this._gxObject.FullName;
            if (_pStartLocation != null)
            {
                StreamWriter writer = null;
                try
                {
                    writer = File.CreateText(this._pStartFilePath);
                    writer.WriteLine(_pStartLocation.ToString());
                    writer.Close();
                }
                catch (Exception)
                {
                }
            }
            base.Close();
        }
Esempio n. 2
0
        private void LoadGISDataCombo(IGxObject gxObject)
        {
            GISDataComboItem ex;

            this.LoadViewer(gxObject);
            this._isFree = false;
            if (gxObject.Parent is IGxCatalog)
            {
                for (int i = 0; i < this.gisDataComboBox1.Items.Count; i++)
                {
                    ex = this.gisDataComboBox1.Items[i] as GISDataComboItem;
                    if (ex.Tag == gxObject)
                    {
                        this.gisDataComboBox1.SelectedIndex = i;
                        break;
                    }
                }
            }
            else
            {
                ex = this.gisDataComboBox1.Items[this.gisDataComboBox1.SelectedIndex] as GISDataComboItem;
                int degree = ex.Level;
                ex = new GISDataComboItem(gxObject.Name, gxObject.FullName, this.GetImageIndex(gxObject), degree + 1)
                {
                    Tag = gxObject
                };
                this.gisDataComboBox1.AddChildNode(ex);
                this.gisDataComboBox1.SelectedIndex++;
            }
            this._isFree = true;
        }
Esempio n. 3
0
 private void EndLocation()
 {
     if (this.listView1.SelectedItems.Count > 0)
     {
         ListViewItem item = this.listView1.SelectedItems[0];
         IGxObject    tag  = item.Tag as IGxObject;
         if ((tag != null) && (this._gxObjectFilter != null))
         {
             MyDoubleClickResult myDCRDefault = MyDoubleClickResult.myDCRDefault;
             this._gxObjectFilter.CanChooseObject(tag, ref myDCRDefault);
             if (myDCRDefault == MyDoubleClickResult.myDCRChooseAndDismiss)
             {
                 this._array2.RemoveAll();
                 this._array2.Add(tag);
                 this._gxObjects.Clear();
                 this._gxObjects.Add(tag);
                 base.DialogResult = DialogResult.OK;
                 GISDataComboItem selectedItem = this.gisDataComboBox1.SelectedItem as GISDataComboItem;
                 if (selectedItem.Tag != null)
                 {
                     _pStartLocation = (selectedItem.Tag as IGxObject).FullName;
                 }
                 base.Close();
             }
         }
     }
 }
Esempio n. 4
0
        private bool CheckObject(IGxObject gxObject)
        {
            GISDataComboItem    ex;
            MyDoubleClickResult myDCRDefault = MyDoubleClickResult.myDCRDefault;

            if (this._gxObjectFilter != null)
            {
                this._gxObjectFilter.CanChooseObject(gxObject, ref myDCRDefault);
                if (myDCRDefault == MyDoubleClickResult.myDCRChooseAndDismiss)
                {
                    return(false);
                }
            }
            else
            {
                for (int i = 0; i < this._filterArray.Count; i++)
                {
                    (this._filterArray.Element[i] as IGxObjectFilter).CanChooseObject(gxObject, ref myDCRDefault);
                    if (myDCRDefault == MyDoubleClickResult.myDCRChooseAndDismiss)
                    {
                        return(false);
                    }
                }
            }
            if (!(gxObject is IGxObjectContainer))
            {
                return(false);
            }
            this.LoadViewer(gxObject);
            this._isFree = false;
            if (gxObject.Parent is IGxCatalog)
            {
                for (int j = 0; j < this.gisDataComboBox1.Items.Count; j++)
                {
                    ex = this.gisDataComboBox1.Items[j] as GISDataComboItem;
                    if (ex.Tag == gxObject)
                    {
                        this.gisDataComboBox1.SelectedIndex = j;
                        break;
                    }
                }
            }
            else
            {
                ex = this.gisDataComboBox1.Items[this.gisDataComboBox1.SelectedIndex] as GISDataComboItem;
                int degree = ex.Level;
                ex = new GISDataComboItem(gxObject.Name, gxObject.FullName, this.GetImageIndex(gxObject), degree + 1)
                {
                    Tag = gxObject
                };
                this.gisDataComboBox1.AddChildNode(ex);
                this.gisDataComboBox1.SelectedIndex++;
            }
            this._isFree = true;
            return(true);
        }
Esempio n. 5
0
 private void gisDataComboBox1_SelectedItemChanged(GISDataComboItem item)
 {
     if (this._isFree)
     {
         Cursor = Cursors.WaitCursor;
         GISDataComboItem ex =
             this.gisDataComboBox1.Items[this.gisDataComboBox1.SelectedIndex] as GISDataComboItem;
         IGxObject tag = ex.Tag as IGxObject;
         this.LoadViewer(tag);
         this.LoadByCombo();
         Cursor = Cursors.Default;
     }
 }
Esempio n. 6
0
        private void frmExplorerData_Load(object sender, EventArgs e)
        {
            if (_gxCatalog == null)
            {
                _gxCatalog = new GxCatalog();
            }
            GISDataComboItem item = new GISDataComboItem((_gxCatalog as IGxObject).Name, (_gxCatalog as IGxObject).Name,
                                                         this.GetImageIndex(this._gxCatalog as IGxObject), 0)
            {
                Tag = _gxCatalog
            };

            gisDataComboBox1.Items.Add(item);
            IEnumGxObject children = (this._gxCatalog as IGxObjectContainer).Children;

            children.Reset();
            for (IGxObject subObj = children.Next(); subObj != null; subObj = children.Next())
            {
                item = new GISDataComboItem(subObj.Name, subObj.FullName, this.GetImageIndex(subObj), 1)
                {
                    Tag = subObj
                };
                this.gisDataComboBox1.AddChildNode(item);
            }
            gisDataComboBox1.SelectedIndex = 0;
            this._array2.RemoveAll();
            this._gxObjects.Clear();
            this.cboShowType.Items.Clear();
            for (int i = 0; i < this._filterArray.Count; i++)
            {
                IGxObjectFilter filter = this._filterArray.Element[i] as IGxObjectFilter;
                this.cboShowType.Items.Add(filter.Description);
                if (filter == this._gxObjectFilter)
                {
                    this.cboShowType.SelectedIndex = i;
                }
            }
            if ((this._modalType == 0) && (this._filterArray.Count > 1))
            {
                this.cboShowType.Items.Add("已列出的所有过滤条件");
            }
            if (this.cboShowType.SelectedIndex == -1)
            {
                this.cboShowType.SelectedIndex = this.cboShowType.Items.Count - 1;
            }
            if ((_pStartLocation != null) && (_pStartLocation is string))
            {
                this.LoadViewer(_pStartLocation as string);
            }
        }
Esempio n. 7
0
        private void LoadByCombo()
        {
            GISDataComboItem ex  = this.gisDataComboBox1.Items[this.gisDataComboBox1.SelectedIndex] as GISDataComboItem;
            IGxObject        tag = ex.Tag as IGxObject;

            for (int i = this.gisDataComboBox1.Items.Count - 1; i > 0; i--)
            {
                ex = this.gisDataComboBox1.Items[i] as GISDataComboItem;
                IGxObject obj3 = ex.Tag as IGxObject;
                if ((!(obj3 is IGxCatalog) && !(obj3.Parent is IGxCatalog)) &&
                    ((obj3 != tag) && !this.IsParent(obj3, tag)))
                {
                    this.gisDataComboBox1.Items.RemoveAt(i);
                }
            }
        }
Esempio n. 8
0
        private void cboShowType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.cboShowType.SelectedIndex == _filterArray.Count)
            {
                this._gxObjectFilter = null;
            }
            else
            {
                this._gxObjectFilter = _filterArray.Element[this.cboShowType.SelectedIndex] as IGxObjectFilter;
            }
            ClearViewer();
            GISDataComboItem item    = gisDataComboBox1.Items[gisDataComboBox1.SelectedIndex] as GISDataComboItem;
            IGxObject        linkTag = item.Tag as IGxObject;

            LoadViewer(linkTag);
        }
Esempio n. 9
0
        private void btnUpper_Click(object sender, EventArgs e)
        {
            GISDataComboItem comboItem = gisDataComboBox1.SelectedItem as GISDataComboItem;

            if (comboItem == null)
            {
                return;
            }
            if (comboItem.Level != 0)
            {
                if (comboItem.Level == 1)
                {
                    gisDataComboBox1.SelectedIndex = 0;
                }
                else
                {
                    int num = gisDataComboBox1.SelectedIndex - 1;
                    gisDataComboBox1.SelectedIndex = num;
                }
            }
        }
Esempio n. 10
0
        private void listView1_DoubleClick(object sender, EventArgs e)
        {
            if (this.listView1.SelectedItems.Count != 0)
            {
                MyDoubleClickResult myDCRShowChildren;
                IGxObject           tag = this.listView1.SelectedItems[0].Tag as IGxObject;
                if ((this._gxObjectFilter != null) && (tag is IGxDatabase))
                {
                    myDCRShowChildren = MyDoubleClickResult.myDCRShowChildren;
                    this._gxObjectFilter.CanChooseObject(tag, ref myDCRShowChildren);
                    if (myDCRShowChildren == MyDoubleClickResult.myDCRChooseAndDismiss)
                    {
                        this.PassListItem();
                        return;
                    }
                }
                if (!(tag is IGxObjectContainer))
                {
                    if (tag is IGxNewDatabase)
                    {
                        IWorkspaceName name;
                        IGxObject      obj3;
                        ListViewItem   item;
                        if (tag.FullName == "添加OLE DB连接")
                        {
                            try
                            {
                                string path = Environment.SystemDirectory.Substring(0, 2) +
                                              @"\Documents and Settings\Administrator\Application Data\ESRI\ArcCatalog\";
                                string str2 = path + "OLE DB Connection.odc";
                                if (Directory.Exists(path))
                                {
                                    str2 = this.ChangeODCExtension(str2);
                                    IWorkspaceFactory factory = new OLEDBWorkspaceFactory() as IWorkspaceFactory;
                                    name = factory.Create(path, System.IO.Path.GetFileName(str2), null, 0);
                                    IGxObject gxDatabase = new GxDatabase() as IGxObject;
                                    (gxDatabase as IGxDatabase).WorkspaceName = name;
                                    gxDatabase.Attach(tag.Parent, this._gxCatalog);
                                    item = new ListViewItem(new string[] { gxDatabase.Name, gxDatabase.Category },
                                                            this.GetImageIndex(gxDatabase))
                                    {
                                        Tag = gxDatabase
                                    };
                                    this.listView1.Items.Add(item);
                                }
                            }
                            catch (Exception exception)
                            {
                                exception.ToString();
                            }
                        }
                        else if (tag.FullName == "添加空间数据库连接")
                        {
                            frmCreateGDBConnection connection = new frmCreateGDBConnection
                            {
                                TopMost = true
                            };
                            if (connection.ShowDialog() == DialogResult.OK)
                            {
                                IGxObject      oneObj = new GxDatabase() as IGxObject;
                                IWorkspaceName name2  = new WorkspaceName() as IWorkspaceName;
                                name2.WorkspaceFactoryProgID = "esriDataSourcesGDB.SdeWorkspaceFactory";
                                name2.PathName = connection.ConnectionPath;

                                (oneObj as IGxDatabase).WorkspaceName = name2;
                                oneObj.Attach(tag.Parent, this._gxCatalog);
                                item = new ListViewItem(new string[] { oneObj.Name, oneObj.Category },
                                                        this.GetImageIndex(oneObj))
                                {
                                    Tag = oneObj
                                };
                                this.listView1.Items.Add(item);
                            }
                        }
                    }
                    else
                    {
                        this.PassListItem();
                    }
                }
                else
                {
                    GISDataComboItem ex;
                    if (tag is IGxDataset)
                    {
                        esriDatasetType type = (tag as IGxDataset).Type;
                        myDCRShowChildren = MyDoubleClickResult.myDCRShowChildren;
                        this._gxObjectFilter.CanChooseObject(tag, ref myDCRShowChildren);
                        if ((((type != esriDatasetType.esriDTFeatureDataset) &&
                              (type != esriDatasetType.esriDTContainer)) &&
                             ((type != esriDatasetType.esriDTRasterCatalog) &&
                              (type != esriDatasetType.esriDTCadDrawing))) &&
                            (type != esriDatasetType.esriDTRasterDataset))
                        {
                            this.PassListItem();
                            return;
                        }
                    }
                    this.LoadViewer(tag);
                    this._isFree = false;
                    if (tag.Parent is IGxCatalog)
                    {
                        for (int i = 0; i < this.gisDataComboBox1.Items.Count; i++)
                        {
                            ex = this.gisDataComboBox1.Items[i] as GISDataComboItem;
                            if (ex.Tag == tag)
                            {
                                this.gisDataComboBox1.SelectedIndex = i;
                                break;
                            }
                        }
                    }
                    else
                    {
                        ex = this.gisDataComboBox1.Items[this.gisDataComboBox1.SelectedIndex] as GISDataComboItem;
                        int degree = ex.Level;
                        ex = new GISDataComboItem(tag.Name, tag.FullName, this.GetImageIndex(tag), degree + 1)
                        {
                            Tag = tag
                        };
                        int selectedIndex = this.gisDataComboBox1.SelectedIndex;
                        this.gisDataComboBox1.AddChildNode(ex);
                        this.gisDataComboBox1.SelectedIndex = selectedIndex + 1;
                    }
                    this._isFree = true;
                }
            }
        }
Esempio n. 11
0
 private void EndSave()
 {
     if (this.txtName.Text.Trim().Length > 0)
     {
         GISDataComboItem selectedItem = this.gisDataComboBox1.SelectedItem as GISDataComboItem;
         IGxObject        tag          = selectedItem.Tag as IGxObject;
         if ((tag != null) && (this._gxObjectFilter != null))
         {
             bool   flag = false;
             string str  = this.txtName.Text.Trim();
             if (this._gxObjectFilter.CanSaveObject(tag, str, ref flag))
             {
                 this._gxObject = tag;
                 this._array2.RemoveAll();
                 this._gxObjects.Clear();
                 if (this._gxObjectFilter.Name == "GxFilterWorkspaces")
                 {
                     IWorkspaceName name = null;
                     IGxObject      unk  = null;
                     unk  = new GxDatabase() as IGxObject;
                     name = new WorkspaceName() as IWorkspaceName;
                     string path = (tag as IGxFile).Path + @"\" + str;
                     string str3 = System.IO.Path.GetExtension(path).ToLower();
                     if (str3 == ".mdb")
                     {
                         name.WorkspaceFactoryProgID = "esriDataSourcesGDB.AccessWorkspaceFactory";
                     }
                     else if ((str3 == ".sde") && flag)
                     {
                         name.WorkspaceFactoryProgID = "esriDataSourcesGDB.SdeWorkspaceFactory";
                     }
                     else
                     {
                         name.WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory";
                     }
                     if (!flag)
                     {
                         if (str3 == ".mdb")
                         {
                             IWorkspaceFactory factory = new AccessWorkspaceFactory() as IWorkspaceFactory;
                             try
                             {
                                 factory.Create(System.IO.Path.GetDirectoryName(path),
                                                System.IO.Path.GetFileNameWithoutExtension(path), null, 0);
                             }
                             catch (Exception exception)
                             {
                                 MessageBox.Show(this, exception.Message);
                             }
                         }
                         else
                         {
                             Directory.CreateDirectory(path);
                         }
                     }
                     name.PathName = path;
                     (unk as IGxDatabase).WorkspaceName = name;
                     this._array2.Add(unk);
                     this._gxObjects.Add(unk);
                 }
                 else
                 {
                     if (((tag is IGxFolder) || (tag is IGxDiskConnection)) || (tag is IGxDatabase))
                     {
                         this._array2.Add(tag);
                         this._gxObjects.Add(tag);
                     }
                     else
                     {
                         if (!(tag is IGxDataset))
                         {
                             return;
                         }
                         if ((tag as IGxDataset).Type == esriDatasetType.esriDTFeatureDataset)
                         {
                             this._array2.Add(tag);
                             this._gxObjects.Add(tag);
                         }
                     }
                     this._saveName = this.CheckExtension(str, this._gxObjectFilter);
                 }
                 base.DialogResult = DialogResult.OK;
                 if (selectedItem.Tag != null)
                 {
                     _pStartLocation = (selectedItem.Tag as IGxObject).FullName;
                 }
                 base.Close();
             }
         }
     }
 }