public bool CanDisplayObject(ESRI.ArcGIS.Catalog.IGxObject obj) { //Check objects can be displayed try { //Check objects can be displayed if (m_pBasicFilter.CanDisplayObject(obj)) { return(true); } else if (obj is IGxFile) { string sExt = null; sExt = GetExtension(obj.Name); if (sExt.ToLower() == ".py") { return(true); } } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); } return(false); }
private void LoadViewer(IGxObject gxObject) { Cursor = Cursors.WaitCursor; string[] items = new string[2]; ClearViewer(); if (gxObject is IGxObjectContainer) { if (gxObject is IGxDatabase) { if (!(gxObject as IGxDatabase).IsConnected) { (gxObject as IGxDatabase).Connect(); } if (!(gxObject as IGxDatabase).IsConnected) { return; } } else if (gxObject is IGxAGSConnection) { if (!(gxObject as IGxAGSConnection).IsConnected) { (gxObject as IGxAGSConnection).Connect(); } if (!(gxObject as IGxAGSConnection).IsConnected) { return; } } IEnumGxObject children = (gxObject as IGxObjectContainer).Children; children.Reset(); IGxObject subObj = children.Next(); bool canDisplay = true; while (subObj != null) { if (subObj is IGxNewDatabase) { canDisplay = true; } else if (_gxObjectFilter != null) { canDisplay = _gxObjectFilter.CanDisplayObject(subObj); } else { for (int i = 0; i < _filterArray.Count; i++) { IGxObjectFilter filter = _filterArray.Element[i] as IGxObjectFilter; if (canDisplay = filter.CanDisplayObject(subObj)) { break; } } } if (canDisplay) { items[0] = subObj.Name; items[1] = subObj.Category; ListViewItem item = new ListViewItem(items, GetImageIndex(subObj)) { Tag = subObj }; listView1.Items.Add(item); } subObj = children.Next(); } } Cursor = Cursors.Default; }
private void method_10(IGxObject igxObject_1) { System.Windows.Forms.Cursor.Current = Cursors.WaitCursor; string[] items = new string[2]; this.method_8(); if (igxObject_1 is IGxObjectContainer) { if (igxObject_1 is IGxDatabase) { if (!(igxObject_1 as IGxDatabase).IsConnected) { (igxObject_1 as IGxDatabase).Connect(); } if (!(igxObject_1 as IGxDatabase).IsConnected) { return; } } else if (igxObject_1 is IGxAGSConnection) { if (!(igxObject_1 as IGxAGSConnection).IsConnected) { (igxObject_1 as IGxAGSConnection).Connect(); } if (!(igxObject_1 as IGxAGSConnection).IsConnected) { return; } } IEnumGxObject children = (igxObject_1 as IGxObjectContainer).Children; children.Reset(); IGxObject obj3 = children.Next(); bool flag = true; IGxObjectFilter filter = null; while (obj3 != null) { if (obj3 is IGxNewDatabase) { flag = true; } else if (this.igxObjectFilter_0 != null) { flag = this.igxObjectFilter_0.CanDisplayObject(obj3); } else { for (int i = 0; i < this.iarray_0.Count; i++) { filter = this.iarray_0.get_Element(i) as IGxObjectFilter; if (flag = filter.CanDisplayObject(obj3)) { break; } } } if (flag) { items[0] = obj3.Name; items[1] = obj3.Category; ListViewItem item = new ListViewItem(items, this.method_2(obj3)) { Tag = obj3 }; this.listView1.Items.Add(item); } obj3 = children.Next(); } } System.Windows.Forms.Cursor.Current = Cursors.Default; }
public void DoFilter() { try { IFilterValue filter = pGxObjectFilter as IFilterValue; filter.Filter = ""; filteredObjects.Clear(); Debug.WriteLine(string.Format("DoFilter: {0}", this.Value)); string filterString = this.Value; Debug.WriteLine(filterString); IGxObject pGxObj; IEnumGxObject pEnumGxObject; IGxSelection pGxSelection = _pGxApp.Selection; if (pGxSelection == null) { return; } IEnumGxObject pSelectedGxObjects = pGxSelection.SelectedObjects; IGxObject pGxObject_Current = pGxSelection.Location; IGxObjectContainer pGxObjectContainer = null; if (pGxObject_Current is IGxObjectContainer) { pGxObjectContainer = pGxObject_Current as IGxObjectContainer; } if (!pGxObjectContainer.HasChildren) { return; } pEnumGxObject = pGxObjectContainer.Children; if (pEnumGxObject == null) { return; } filter = pGxObjectFilter as IFilterValue; filter.Filter = filterString; pGxObj = pEnumGxObject.Next(); while (pGxObj != null) { bool canDisplay = pGxObjectFilter.CanDisplayObject(pGxObj); if (canDisplay == false) { //* if the object is not going to be displayed (due to being filtered out) we will track it so we can unselect it later (if it was selected) filteredObjects.Add(pGxObj); } pGxObj = pEnumGxObject.Next(); } //* Since selected objects stay selected after filtering, we need to manually unselect hidden items due to the filter IGxObject pGxObjSelected = pSelectedGxObjects.Next(); while (pGxObjSelected != null) { if (filteredObjects.Contains(pGxObjSelected)) { Debug.WriteLine("Selected Object that is hidden: " + pGxObjSelected.FullName); pGxSelection.Unselect(pGxObjSelected, null); } pGxObjSelected = pSelectedGxObjects.Next(); } pGxContentsView.ObjectFilter = pGxObjectFilter; } catch (Exception ex) { ArcCatalog.Application.StatusBar.set_Message(0, ex.Message); } finally { _pGxView.Refresh(); } //UpdateItems(filterString); }