public void RemoveWidgetSet(IWidgetSet set) { var wset = set as WidgetSetType; if (wset != null) { this.WidgetSet.Remove(wset); OnPropertyChanged(nameof(WidgetSet)); } }
public void RemoveWidgetSet(IWidgetSet set) { var wset = set as WidgetSetType; if (wset != null) { this.WidgetSet.Remove(wset); OnPropertyChanged("WidgetSet"); //NOXLATE } }
/// <summary> /// Gets the first widget set of this application definition. /// </summary> /// <param name="appDef"></param> /// <returns></returns> public static IWidgetSet GetFirstWidgetSet(this IApplicationDefinition appDef) { Check.NotNull(appDef, "appDef"); //NOXLATE IWidgetSet set = null; foreach (var wgt in appDef.WidgetSets) { if (set == null) { set = wgt; break; } } return(set); }
/// <summary> /// Removes the specified widget from this /// </summary> /// <param name="appDef">The app definition.</param> /// <param name="widgetName">Name of the widget to remove.</param> /// <param name="deleteReferences">if set to <c>true</c> [deletes any references to the widget to be deleted].</param> public static void RemoveWidget(this IApplicationDefinition appDef, string widgetName, bool deleteReferences) { Check.NotNull(appDef, "appDef"); //NOXLATE Check.NotEmpty(widgetName, "widgetName"); //NOXLATE IWidgetSet matchingSet = null; IWidget matchingWidget = null; foreach (var set in appDef.WidgetSets) { if (matchingSet == null) { foreach (var wgt in set.Widgets) { if (wgt.Name == widgetName) { matchingSet = set; matchingWidget = wgt; break; } } } } int removed = 0; if (matchingSet != null && matchingWidget != null) { matchingSet.RemoveWidget(matchingWidget); if (deleteReferences) { foreach (var set in appDef.WidgetSets) { foreach (var cnt in set.Containers) { var uicnt = cnt as IUIItemContainer; if (uicnt != null) { List <IWidgetItem> removeMe = new List <IWidgetItem>(); foreach (var uiitem in uicnt.Items) { IWidgetItem witem = uiitem as IWidgetItem; if (witem != null && witem.Widget == widgetName) { removeMe.Add(witem); System.Diagnostics.Trace.TraceInformation("Found widget reference in container: " + uicnt.Name); //NOXLATE } } if (removeMe.Count > 0) { foreach (var rm in removeMe) { uicnt.RemoveItem(rm); removed++; } } } } } } } if (deleteReferences) { System.Diagnostics.Trace.TraceInformation(removed + " widget references removed"); //NOXLATE } }