private Task AddStyleItemToStyle(StyleProjectItem styleProjectItem, CIMPolygonSymbol cimPolygonSymbol) { return(QueuedTask.Run(() => { if (styleProjectItem == null || cimPolygonSymbol == null) { throw new System.ArgumentNullException(); } SymbolStyleItem symbolStyleItem = new SymbolStyleItem()//define the symbol { Symbol = cimPolygonSymbol, ItemType = StyleItemType.PolygonSymbol, Category = "BuildingFacade", Name = SelectedRulePackage.Name, Key = SelectedRulePackage.Name, Tags = $"BuildingStyle, {SelectedRulePackage.Title}" }; //Does style already contain the styleItem? SymbolStyleItem item = (SymbolStyleItem)_styleProjectItem?.LookupItem(symbolStyleItem.ItemType, symbolStyleItem.Key); if (item == null) { styleProjectItem.AddItem(symbolStyleItem); } })); }
/// <summary> /// Adds a styleitem to a style. /// </summary> /// <param name="styleProjectItem"></param> /// <param name="cimSymbolStyleItem"></param> /// <returns></returns> private Task AddStyleItemToStyle(StyleProjectItem styleProjectItem, SymbolStyleItem cimSymbolStyleItem) { return(QueuedTask.Run(() => { if (styleProjectItem == null || cimSymbolStyleItem == null) { return; } styleProjectItem.AddItem(cimSymbolStyleItem); })); }
public Task AddStyleItemAsync(StyleProjectItem style, StyleItem itemToAdd) { return(QueuedTask.Run(() => { if (style == null || itemToAdd == null) { throw new System.ArgumentNullException(); } //Add the item to style style.AddItem(itemToAdd); })); }
/// <summary> /// Adds a styleitem to a style. /// </summary> /// <param name="styleProjectItem"></param> /// <param name="cimSymbolStyleItem"></param> /// <returns></returns> private Task AddStyleItemToStyle(StyleProjectItem styleProjectItem, SymbolStyleItem cimSymbolStyleItem) { return(QueuedTask.Run(() => { if (styleProjectItem == null || cimSymbolStyleItem == null) { return; } try { styleProjectItem.AddItem(cimSymbolStyleItem); } catch (Exception ex) { } })); }
/// <summary> /// Adds a styleitem to a style. /// </summary> /// <param name="styleProjectItem"></param> /// <param name="cimSymbolStyleItem"></param> /// <returns></returns> private Task AddStyleItemToStyle(StyleProjectItem styleProjectItem, SymbolStyleItem cimSymbolStyleItem) { return(QueuedTask.Run(() => { if (styleProjectItem == null || cimSymbolStyleItem == null || styleProjectItem.IsReadOnly) { return; } try { styleProjectItem.AddItem(cimSymbolStyleItem); } catch (Exception ex) { MessageBox.Show($"{ex.Message}. Unable to add {cimSymbolStyleItem.Name}. Key is {cimSymbolStyleItem.Key}"); } })); }
/// <summary> /// Adds a styleitem to a style. /// </summary> /// <param name="styleProjectItem"></param> /// <param name="cimSymbolStyleItem"></param> /// <returns></returns> private Task AddStyleItemToStyle(StyleProjectItem styleProjectItem, SymbolStyleItem cimSymbolStyleItem) { return(QueuedTask.Run(() => { if (styleProjectItem == null || cimSymbolStyleItem == null) { return; } try { styleProjectItem.AddItem(cimSymbolStyleItem); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($@"Error in AddStyleItemToStyle: {ex.ToString()}"); } })); }
private Task AddStyleItemToStyle(StyleProjectItem styleProjectItem, CIMPointSymbol cimPointSymbol) { return(QueuedTask.Run(() => { if (styleProjectItem == null || cimPointSymbol == null) { throw new System.ArgumentNullException(); } SymbolStyleItem symbolStyleItem = new SymbolStyleItem() //define the symbol { Symbol = cimPointSymbol, ItemType = StyleItemType.PointSymbol, Category = $"{SelectedFontFamily}", Name = $"{SelectedCharacter.Character.ToString()}", Key = $"{SelectedCharacter.Character.ToString()}_{SelectedFontFamily}_3", Tags = $"{SelectedFontFamily};{SelectedCharacter.Character.ToString()};point" }; styleProjectItem.AddItem(symbolStyleItem); })); }
public void Merge(StyleProjectItem styleToMerge, bool replaceKeys) { _numSymbolsAdded = 0; _numSymbolsNotAdded = 0; // point symbols IList <SymbolStyleItem> sourcePointSymbols = styleToMerge.SearchSymbols(StyleItemType.PointSymbol, string.Empty); foreach (var styleItem in sourcePointSymbols) { try { if (replaceKeys) { var item = _style.LookupItem(StyleItemType.PointSymbol, styleItem.Key); if (item != null) { _style.RemoveItem(item); } } _style.AddItem(styleItem); //System.Diagnostics.Debug.WriteLine("Merging item: " + styleItem.Name); _numSymbolsAdded++; } catch (Exception) { if (_report != null) { _report("Could not add key " + styleItem.Key); } _numSymbolsNotAdded++; } } // point symbols IList <SymbolStyleItem> sourceLineSymbols = styleToMerge.SearchSymbols(StyleItemType.LineSymbol, string.Empty); foreach (var styleItem in sourceLineSymbols) { try { if (replaceKeys) { var item = _style.LookupItem(StyleItemType.LineSymbol, styleItem.Key); if (item != null) { _style.RemoveItem(item); } } _style.AddItem(styleItem); //System.Diagnostics.Debug.WriteLine("Merging item: " + styleItem.Name); _numSymbolsAdded++; } catch (Exception) { if (_report != null) { _report("Could not add key " + styleItem.Key); } _numSymbolsNotAdded++; } } // point symbols IList <SymbolStyleItem> sourcePolygonSymbols = styleToMerge.SearchSymbols(StyleItemType.PolygonSymbol, string.Empty); foreach (var styleItem in sourcePolygonSymbols) { try { if (replaceKeys) { var item = _style.LookupItem(StyleItemType.PolygonSymbol, styleItem.Key); if (item != null) { _style.RemoveItem(item); } } _style.AddItem(styleItem); //System.Diagnostics.Debug.WriteLine("Merging item: " + styleItem.Name); _numSymbolsAdded++; } catch (Exception) { if (_report != null) { _report("Could not add key " + styleItem.Key); } _numSymbolsNotAdded++; } } }