Index: Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuItemFactory.cs =================================================================== diff -u -r4435a35be229b12da5859395985ad38c9c5d4729 -r09e76611c2a789b6f015368968a18ea5b9b138cc --- Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuItemFactory.cs (.../RingtoetsContextMenuItemFactory.cs) (revision 4435a35be229b12da5859395985ad38c9c5d4729) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuItemFactory.cs (.../RingtoetsContextMenuItemFactory.cs) (revision 09e76611c2a789b6f015368968a18ea5b9b138cc) @@ -183,24 +183,6 @@ } /// - /// Creates a which is bound to the action of changing the relevancy state of a disabled failure mechanism. - /// - /// The failure mechanism context belonging to the failure mechanism. - /// The created . - public static StrictContextMenuItem CreateDisabledChangeRelevancyItem(IFailureMechanismContext failureMechanismContext) - { - return new StrictContextMenuItem( - Resources.FailureMechanismContextMenuStrip_Is_relevant, - Resources.FailureMechanismContextMenuStrip_Is_relevant_Tooltip, - Resources.Checkbox_empty, - (o, args) => - { - failureMechanismContext.WrappedData.IsRelevant = true; - failureMechanismContext.WrappedData.NotifyObservers(); - }); - } - - /// /// Creates a which is bound to the action of clearing the output of all calculations in a failure mechanism. /// /// The failure mechanism to clear the output for. @@ -263,21 +245,27 @@ /// /// The type of the failure mechanism context. /// The failure mechanism context belonging to the failure mechanism. - /// The action that removes all views. + /// The action to perform when relevance changes. /// The created . - public static StrictContextMenuItem CreateChangeRelevancyOfFailureMechanismItem( + public static StrictContextMenuItem CreateToggleRelevancyOfFailureMechanismItem( TFailureMechanismContext failureMechanismContext, - Action removeAllViewsForItemAction) + Action onChangeAction) where TFailureMechanismContext : IFailureMechanismContext { + var isRelevant = failureMechanismContext.WrappedData.IsRelevant; + var checkboxImage = isRelevant ? Resources.Checkbox_ticked : Resources.Checkbox_empty; return new StrictContextMenuItem( Resources.FailureMechanismContextMenuStrip_Is_relevant, Resources.FailureMechanismContextMenuStrip_Is_relevant_Tooltip, - Resources.Checkbox_ticked, + checkboxImage, (sender, args) => { - removeAllViewsForItemAction(failureMechanismContext); - failureMechanismContext.WrappedData.IsRelevant = false; + if (onChangeAction != null) + { + onChangeAction(failureMechanismContext); + } + + failureMechanismContext.WrappedData.IsRelevant = !isRelevant; failureMechanismContext.WrappedData.NotifyObservers(); }); }