/// <summary> /// Set the style of a graph node /// </summary> /// <param name="node">the microsoft drawing node</param> /// <param name="nodeTitle">the node title</param> /// <param name="flowId">the flow id</param> private static void SetNodeStyle(Microsoft.Msagl.Drawing.Node node, string nodeTitle, int flowId) { var backgroundColor = GetNodeColor(nodeTitle, flowId); var backgroundHex = MaterialDesignColors.MsaglColorToHex(backgroundColor); var foregroundHex = MaterialDesignColors.GetForegroundColor(backgroundHex); var foregroundColor = MaterialDesignColors.MsaglColorFromHex(foregroundHex); node.Attr.FillColor = backgroundColor; node.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Box; node.Attr.Color = MaterialDesignColors.MsaglColorFromHex(MaterialDesignColors.White); node.Label.FontColor = foregroundColor; node.Label.FontSize = 10; }
/// <summary> /// Returns the id of a flow palette for a flow id /// </summary> /// <param name="flowId">the flow id</param> /// <returns>the flow palette id</returns> private static int GetFlowPaletteId(int flowId) { for (int i = 0; i < flowIdPalette.Count; i++) { if (flowIdPalette[i].Item1 == flowId) { return(i); } } // if the palette doesn´t exist for the flow id, create it var flowPaletteId = flowIdPalette.Count; flowIdPalette.Add(new Tuple <int, string[], int>(flowId, MaterialDesignColors.GetRandomPalette(), 0)); return(flowPaletteId); }
/// <summary> /// Returns the color for a use case item /// </summary> /// <param name="nodeTitle">The node title</param> /// <param name="flowId">The flow id</param> /// <returns>The microsoft algorithm drawing color</returns> private static Microsoft.Msagl.Drawing.Color GetNodeColor(string nodeTitle, int flowId) { // if the node color exists for (int i = 0; i < nodeColors.Count; i++) { if (nodeColors[i].Item1.Equals(nodeTitle)) { // return it return(nodeColors[i].Item2); } } // if the node doens´t exists, generate a new color var colorHex = FlowPaletteGetNextColor(flowId); var color = MaterialDesignColors.MsaglColorFromHex(colorHex); var nodeColor = new Tuple <string, Microsoft.Msagl.Drawing.Color>(nodeTitle, color); nodeColors.Add(nodeColor); return(nodeColor.Item2); }