Index: Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/CalculationTreeNodeInfoFactory.cs
===================================================================
diff -u -r9643d7e5bbb27a7782b5d939b029a70a1c023138 -re3d1cd330909f943d7cc655d02100cce43bade21
--- Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/CalculationTreeNodeInfoFactory.cs (.../CalculationTreeNodeInfoFactory.cs) (revision 9643d7e5bbb27a7782b5d939b029a70a1c023138)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/CalculationTreeNodeInfoFactory.cs (.../CalculationTreeNodeInfoFactory.cs) (revision e3d1cd330909f943d7cc655d02100cce43bade21)
@@ -112,6 +112,37 @@
}
///
+ /// Creates a object for a failure mechanism context of the type .
+ ///
+ /// The function for obtaining the child node objects when is true.
+ /// The function for obtaining the child node objects when is false.
+ /// The function for obtaining the context menu strip when is true.
+ /// The function for obtaining the context menu strip when is false.
+ /// The type of failure mechanism context to create a object for.
+ /// A object.
+ public static TreeNodeInfo CreateFailureMechanismContextTreeNodeInfo(
+ Func enabledChildeNodeObjects,
+ Func disabledChildeNodeObjects,
+ Func enabledContextMenuStrip,
+ Func disabledContextMenuStrip
+ )
+ where TFailureMechanismContext : FailureMechanismContext
+ {
+ return new TreeNodeInfo
+ {
+ Text = GetFailureMechanismContextText,
+ ForeColor = GetFailureMechanismContextForeColor,
+ Image = GetFailureMechanismContextImage,
+ ChildNodeObjects = context => context.WrappedData.IsRelevant
+ ? enabledChildeNodeObjects(context)
+ : disabledChildeNodeObjects(context),
+ ContextMenuStrip = (context, parentData, treeViewControl) => context.WrappedData.IsRelevant
+ ? enabledContextMenuStrip(context, parentData, treeViewControl)
+ : disabledContextMenuStrip(context, parentData, treeViewControl)
+ };
+ }
+
+ ///
/// This method adds a context menu item for creating new calculation groups.
///
/// The builder to add the context menu item to.
@@ -410,5 +441,26 @@
}
#endregion
+
+ # region Helper methods for CreateFailureMechanismContextTreeNodeInfo
+
+ private static string GetFailureMechanismContextText(FailureMechanismContext failureMechanismContext)
+ {
+ return failureMechanismContext.WrappedData.Name;
+ }
+
+ private static Image GetFailureMechanismContextImage(FailureMechanismContext failureMechanismContext)
+ {
+ return Resources.FailureMechanismIcon;
+ }
+
+ private static Color GetFailureMechanismContextForeColor(FailureMechanismContext failureMechanismContext)
+ {
+ return failureMechanismContext.WrappedData.IsRelevant
+ ? Color.FromKnownColor(KnownColor.ControlText)
+ : Color.FromKnownColor(KnownColor.GrayText);
+ }
+
+ # endregion
}
}
\ No newline at end of file