/// <summary> /// Creates a <see cref="StrictContextMenuItem"/> which is bound to the action of clearing illustration points for a /// collection of calculations in a failure mechanism. /// </summary> /// <param name="isContextItemEnabledFunc">The function to determine whether the context menu item should be enabled.</param> /// <param name="changeHandler">Object responsible for clearing the illustration point results.</param> /// <returns>The created <see cref="StrictContextMenuItem"/>.</returns> public static StrictContextMenuItem CreateClearIllustrationPointsOfCalculationsInFailureMechanismItem( Func <bool> isContextItemEnabledFunc, IClearIllustrationPointsOfCalculationCollectionChangeHandler changeHandler) { return(CreateClearIllustrationPointsOfCalculationsItem( isContextItemEnabledFunc, changeHandler, Resources.CreateClearIllustrationPointsOfCalculationsItem_Clear_IllustrationPoints_In_FailureMechanism)); }
private static StrictContextMenuItem CreateClearIllustrationPointsOfCalculationsItem( Func <bool> isContextItemEnabledFunc, IClearIllustrationPointsOfCalculationCollectionChangeHandler changeHandler, string toolTipEnabledText) { bool isEnabled = isContextItemEnabledFunc(); string toolTip = isEnabled ? toolTipEnabledText : Resources.CreateClearIllustrationPointsOfCalculationsItem_No_IllustrationPoints_to_clear; return(new StrictContextMenuItem( Resources.CreateClearIllustrationPointsOfCalculationsItem_ClearIllustrationPoints_DisplayName, toolTip, Resources.ClearIllustrationPointsIcon, (o, args) => { if (changeHandler.InquireConfirmation()) { ClearIllustrationPointResults(changeHandler); } }) { Enabled = isEnabled }); }
/// <summary> /// Adds an item to the <see cref="ContextMenuStrip"/> which is bound to the action /// of clearing illustration points from collections of calculations in a failure mechanism. /// </summary> /// <param name="isEnabledFunc">The function to determine whether this item should be enabled.</param> /// <param name="changeHandler">Object responsible for clearing the illustration point results.</param> /// <returns>The <see cref="RiskeerContextMenuBuilder"/> itself.</returns> public RiskeerContextMenuBuilder AddClearIllustrationPointsOfCalculationsInFailureMechanismItem( Func <bool> isEnabledFunc, IClearIllustrationPointsOfCalculationCollectionChangeHandler changeHandler) { contextMenuBuilder.AddCustomItem(RiskeerContextMenuItemFactory.CreateClearIllustrationPointsOfCalculationsInFailureMechanismItem(isEnabledFunc, changeHandler)); return(this); }
private static void ClearIllustrationPointResults(IClearIllustrationPointsOfCalculationCollectionChangeHandler changeHandler) { IEnumerable <IObservable> affectedObjects = changeHandler.ClearIllustrationPoints(); affectedObjects.ForEachElementDo(o => o.NotifyObservers()); }