public NodeData(SerializationInfo info, StreamingContext context)
 {
     Id       = info.GetUInt16("NodeID");
     NodeType = (NodeStyleType)info.GetValue("NodeType", typeof(NodeStyleType));
 }
Exemple #2
0
 /// <summary>
 /// Устанавливает стиль узла
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="style"></param>
 /// <returns></returns>
 public static IGraphNodeBuilder SetStyle(this IGraphNodeBuilder builder, NodeStyleType style)
 {
     builder.Set(DotConstants.StyleAttribute, style);
     return(builder);
 }
Exemple #3
0
 public NodeData InsertNode(NetTool.ControlPoint controlPoint, NodeStyleType nodeType = NodeStyleType.Crossing)
 {
     if (NetTool.CreateNode(controlPoint.m_segment.GetSegment().Info, controlPoint, controlPoint, controlPoint, NetTool.m_nodePositionsSimulation, 0, false, false, true, false, false, false, 0, out var nodeId, out _, out _, out _) != ToolBase.ToolErrors.None)
     {
         return(null);
     }
        /// <summary>
        /// Конвертирует стили узлов
        /// </summary>
        /// <param name="style"></param>
        /// <returns></returns>
        public static string GetAttributeString(this NodeStyleType style)
        {
            var usebold     = false;
            var cornerstyle = "";
            var linestyle   = "";
            var areastyle   = "";

            if (style.HasFlag(NodeStyleType.Bold))
            {
                usebold = true;
            }
            if (style.HasFlag(NodeStyleType.Dashed))
            {
                linestyle = "dashed";
            }
            if (style.HasFlag(NodeStyleType.Dotted))
            {
                linestyle = "dotted";
            }
            if (style.HasFlag(NodeStyleType.Rounded))
            {
                cornerstyle = "rounded";
            }
            if (style.HasFlag(NodeStyleType.Diagonals))
            {
                cornerstyle = "diagonals";
            }
            if (style.HasFlag(NodeStyleType.Striped))
            {
                areastyle = "striped";
            }
            if (style.HasFlag(NodeStyleType.Wedged))
            {
                areastyle = "wedget";
            }
            if (style.HasFlag(NodeStyleType.Filled))
            {
                areastyle = "filled";
            }
            if (areastyle == "striped" || areastyle == "wedged")
            {
                cornerstyle = "";
            }
            var sb           = new StringBuilder();
            var first        = true;
            var requirequots = false;

            if (usebold)
            {
                sb.Append("bold");
                first = false;
            }
            if (!string.IsNullOrWhiteSpace(linestyle))
            {
                if (!first)
                {
                    sb.Append(",");
                    requirequots = true;
                }
                sb.Append(linestyle);
                first = false;
            }
            if (!string.IsNullOrWhiteSpace(cornerstyle))
            {
                if (!first)
                {
                    sb.Append(",");
                    requirequots = true;
                }
                sb.Append(cornerstyle);
                first = false;
            }
            if (!string.IsNullOrWhiteSpace(areastyle))
            {
                if (!first)
                {
                    sb.Append(",");
                    requirequots = true;
                }
                sb.Append(areastyle);
            }
            if (requirequots)
            {
                return("\"" + sb + "\"");
            }
            return(sb.ToString());
        }
 public static NodeStyle GetStyle(this NodeStyleType type, NodeData data) => type switch
 {