Esempio n. 1
0
        /// <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;
        }
Esempio n. 2
0
        /// <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);
        }