/// <summary> /// Recursively parses a d8list and determines in any of the features /// are in the extent. Intended for use with an ATE. /// </summary> /// <param name="IRO">Bounding Extent</param> /// <param name="List">Designer List Object</param> /// <returns></returns> private static bool HasD8ChildInExtent(IRelationalOperator IRO, ID8List List) { bool allchildrenoutofextent = true; #region Check the current list item if (List is ID8GeoAssoc) { IFeature GuFeat = ((ID8GeoAssoc)List).AssociatedGeoRow as IFeature; if (GuFeat != null && GuFeat.Shape != null) { if (!IRO.Disjoint(GuFeat.Shape)) { allchildrenoutofextent = false; } } } #endregion List.Reset(); ID8ListItem Child = List.Next(false); while (Child != null && allchildrenoutofextent) { #region Process children until we find a child inside the extent if (Child is ID8GeoAssoc) { IFeature GuFeat = ((ID8GeoAssoc)Child).AssociatedGeoRow as IFeature; if (GuFeat != null && GuFeat.Shape != null) { if (!IRO.Disjoint(GuFeat.Shape)) { allchildrenoutofextent = false; } } } if (Child is ID8List) { allchildrenoutofextent = !HasD8ChildInExtent(IRO, (ID8List)Child); } Child = List.Next(false); #endregion } return(!allchildrenoutofextent); }
public void TreeViewSelectionEnumerator_Next_IsTrue() { IFeatureClass testClass = base.Workspace.GetFeatureClass("TRANSFORMER", true); Assert.IsNotNull(testClass); IQueryFilter filter = new QueryFilterClass(); filter.WhereClause = "OBJECTID < 10"; var list = testClass.Fetch(filter); var enumerator = new TreeViewSelection(list); ID8ListItem item = enumerator.Next; Assert.IsTrue(item is ID8Feature); }
/// <summary> /// Gets the parent that matches the specified predicate /// </summary> /// <typeparam name="TValue">The type of the value.</typeparam> /// <param name="source">The source.</param> /// <param name="predicate">The predicate used to determine if the value should be used.</param> /// <returns> /// Returns a a type of the representing the parent. /// </returns> /// <exception cref="System.ArgumentNullException">predicate</exception> public static TValue GetParent <TValue>(this ID8ListItem source, Predicate <TValue> predicate) where TValue : class { if (source == null) { return(null); } if (predicate == null) { throw new ArgumentNullException("predicate"); } for (var i = source.ContainedBy as ID8ListItem; i != null; i = i.ContainedBy as ID8ListItem) { var value = i as TValue; if (value != null && predicate(value)) { return(value); } } return(null); }
/// <summary> /// Updates the node with the specified <paramref name="vData" />. /// </summary> /// <param name="vData">The data.</param> /// <param name="pListItem">The list item.</param> /// <remarks> /// Allows the user to update the list in the tree based on changes made to the node(s). /// For example, if a user changes ownership or the state of a node, this method can update the list accordingly. /// </remarks> public virtual void UpdateNode(ref object vData, ID8ListItem pListItem) { }
/// <summary> /// /// </summary> /// <param name="PxApp"></param> /// <param name="TopList"></param> /// <param name="FilterExtent">Optional, if not null it will be used to filter the notes to the current extent</param> /// <param name="UseLookupTable">Whether to perform a search / replace of the CUNames in the Design before outputting them</param> /// <returns></returns> public static string GetConstructionNotes(IMMPxApplication PxApp, IMMPersistentXML ListItem, IEnvelope FilterExtent) { if (PxApp == null) { throw new Exception("No Px Application found"); } if (ListItem == null) { throw new Exception("No item given to generate notes for"); } string XslPath = ""; try { XslPath = DesignerUtility.GetPxConfig(PxApp, Constants.PxConfig_ContstructionNotesXslPath); if (string.IsNullOrEmpty(XslPath)) { throw new Exception("Obtained an empty reference to the Construction Notes Stylesheet. Ask your administrator to verify the Px Configuration."); } } catch (Exception ex) { throw new Exception("Unable to find a Px Configuration for the Construction Notes Stylesheet. Ask your administrator to verify the Px Configuration.", ex); } //Our resulting XML must have Work Locations / Gis Units in order to filter it System.Xml.XmlDocument modernDocument = null; string labelXmlType = DesignerUtility.GetPxConfig(PxApp, Constants.PxConfig_ContstructionNotesXmlSource); switch (labelXmlType) { case "DesignTree": modernDocument = GetReportingXml(PxApp, ListItem, LabelXmlType.DesignTree); break; default: case "DesignerXml": modernDocument = GetReportingXml(PxApp, ListItem, LabelXmlType.DesignerXml); break; case "PxXml": modernDocument = GetReportingXml(PxApp, ListItem, LabelXmlType.PxXml); break; case "CostEngine": modernDocument = GetReportingXml(PxApp, ListItem, LabelXmlType.CostEngine); break; case "Custom": modernDocument = GetReportingXml(PxApp, ListItem, LabelXmlType.Custom); break; } if (FilterExtent != null) { #region Fitler the Design Xml IRelationalOperator IRO = FilterExtent as IRelationalOperator; //Build up a list of Work Locations in the current extent List <string> BadWls = new List <string>(); List <string> BadGus = new List <string>(); ID8ListItem WlOrCu = null; ID8ListItem GivenItem = ListItem as ID8ListItem; if (GivenItem == null) { throw new ApplicationException("Selected item is not a valid list item"); } if (GivenItem.ItemType == mmd8ItemType.mmd8itWorkRequest) { ((ID8List)GivenItem).Reset(); ID8List Design = ((ID8List)GivenItem).Next(false) as ID8List; GivenItem = Design as ID8ListItem; ((ID8List)GivenItem).Reset(); WlOrCu = ((ID8List)GivenItem).Next(false); } else if (GivenItem.ItemType == mmd8ItemType.mmd8itDesign) { ((ID8List)GivenItem).Reset(); WlOrCu = ((ID8List)GivenItem).Next(false); } else if (GivenItem.ItemType == mmd8ItemType.mmd8itWorkLocation) { WlOrCu = (ID8ListItem)GivenItem; } else { throw new ApplicationException("Construction notes are not supported on the selected item"); } while (WlOrCu != null) { if (WlOrCu.ItemType == mmd8ItemType.mmd8itWorkLocation) { if (!HasD8ChildInExtent(IRO, WlOrCu as ID8List)) { BadWls.Add(((ID8WorkLocation)WlOrCu).ID); } } else { if (WlOrCu.ItemType == mmd8ItemType.mmitMMGisUnit) { if (!HasD8ChildInExtent(IRO, WlOrCu as ID8List)) { BadGus.Add(((IMMGisUnit)WlOrCu).GisUnitID.ToString()); } } } WlOrCu = ((ID8List)GivenItem).Next(false); } string wlquery = ""; foreach (string wlid in BadWls) { if (!string.IsNullOrEmpty(wlid)) { wlquery += "//WORKLOCATION[ID='" + wlid + "']|"; } } wlquery = wlquery.TrimEnd("|".ToCharArray()); string guquery = ""; foreach (string guid in BadGus) { if (!string.IsNullOrEmpty(guid)) { guquery += "//GISUNIT[DESIGNER_ID='" + guid + "']|"; } } guquery = guquery.TrimEnd("|".ToCharArray()); string query = wlquery + "|" + guquery; query = query.Trim("|".ToCharArray()); //Filter the xml document to remove the bad wls if (!string.IsNullOrEmpty(query)) { foreach (System.Xml.XmlNode BadNode in modernDocument.SelectNodes(query)) { BadNode.ParentNode.RemoveChild(BadNode); } } #endregion } return(TransformXml(modernDocument, XslPath)); }
/// <summary> /// Selects the item in the attribute editor when specified tab is visible. /// </summary> /// <param name="source">The source.</param> /// <param name="tabIndex">Index of the tab.</param> /// <param name="item">The item.</param> /// <returns> /// Returns <see cref="bool" /> representing <c>true</c> when the item was selected. /// </returns> public static bool SelectItem(this IMMAttributeEditor source, mmAETabIndex tabIndex, ID8ListItem item) { if (source == null) { return(false); } if (source.Show(tabIndex)) { var ui = source.UI as IMMAttributeEditorUI2; if (ui == null) { return(false); } ui.SelectItem((int)tabIndex, item); return(true); } return(false); }
/// <summary> /// Gets the parent that matches the specified predicate /// </summary> /// <typeparam name="TValue">The type of the value.</typeparam> /// <param name="source">The source.</param> /// <returns> /// Returns a type of the representing the parent. /// </returns> public static TValue GetParent <TValue>(this ID8ListItem source) where TValue : class { return(source.GetParent <TValue>(value => true)); }