示例#1
0
        private void UpdatePropertyValues()
        {
            Label = WpfHelper.IdToText(
                EdgeBehind.HasAttribute("label")
                    ? EdgeBehind.GetAttribute("label")
                    : null);
            if (Label != null)
            {
                var labelPos = WpfHelper.IdToText(EdgeBehind.GetAttribute("lp"))
                               .Split(',')
                               .Select(p => p + "pt")
                               .Select(WpfHelper.StringToPixel)
                               .ToList();
                LabelMargin = FormattableString.Invariant($"{labelPos[0]},{labelPos[1]},0,0");
            }
            var pos = WpfHelper.IdToText(EdgeBehind.GetAttribute("pos"));
            var pathGeometryData = new PathGeometryData(pos);

            Geometry          = pathGeometryData.PathGeometry;
            HasArrowHead      = pathGeometryData.HasArrowHead;
            HasArrowTail      = pathGeometryData.HasArrowTail;
            ArrowHeadGeometry = pathGeometryData.ArrowHeadGeometry;
            ArrowTailGeometry = pathGeometryData.ArrowTailGeometry;

            Styles = WpfHelper.IdToStyles(
                EdgeBehind.HasAttribute("style", true)
                    ? EdgeBehind.GetAttribute("style", true)
                    : null);
            StrokeColor     = GetEdgeStrokeColor();
            StrokeThickness = GetEdgeStrokeThickness();
            StrokeDashList  = WpfHelper.AbsoluteStrokeDash(Styles, StrokeThickness);
            //FontFamily = GetFontFamily();
            FontColor = GetFontColor();
            FontSize  = GetFontSize();
        }
示例#2
0
        private static Point ConvertStringToPoint(string point)
        {
            var p1 = WpfHelper.StringToPixel(point.Split(',')[0] + "pt");
            var p2 = WpfHelper.StringToPixel(point.Split(',')[1] + "pt");

            return(new Point(p1, p2));
        }
示例#3
0
        //private string GetFontFamily() {
        //    var fontname = WpfHelper.IdToText(
        //        NodeBehind.HasAttribute("fontname", true)
        //            ? NodeBehind.GetAttribute("fontname", true)
        //            : "Times-Roman");
        //    return null;
        //}

        private string GetFontColor()
        {
            return(WpfHelper.IdToText(
                       NodeBehind.HasAttribute("fontcolor", true)
                    ? NodeBehind.GetAttribute("fontcolor", true)
                    : "black"));
        }
示例#4
0
        private string GetNodeStrokeColor()
        {
            var color = WpfHelper.IdToText(
                NodeBehind.HasAttribute("color", true)
                    ? NodeBehind.GetAttribute("color", true)
                    : null);

            return(color ?? "black");
        }
示例#5
0
        private double GetSubGraphStrokeThickness()
        {
            var thicknessStr = WpfHelper.IdToText(
                SubGraphBehind.HasAttribute("penwidth", true)
                    ? SubGraphBehind.GetAttribute("penwidth", true) + "pt"
                    : "1");

            return(WpfHelper.StringToPixel(thicknessStr));
        }
示例#6
0
        private string GetGraphFillColor()
        {
            var bgColor = WpfHelper.IdToText(
                GraphBehind.HasAttribute("bgcolor", true)
                    ? GraphBehind.GetAttribute("bgcolor", true)
                    : null);

            return(bgColor);
        }
示例#7
0
        private string GetGraphPad()
        {
            var padStr = WpfHelper.IdToText(
                GraphBehind.HasAttribute("pad")
                    ? GraphBehind.GetAttribute("pad")
                    : "0.0555");
            var padSplit = padStr.Split(',').Select(s => WpfHelper.StringToPixel(s + "in")).ToList();

            return(string.Join(",", padSplit.Select(s => s.ToString(CultureInfo.InvariantCulture))));
        }
示例#8
0
        private void UpdatePropertyValues()
        {
            Id        = SubGraphBehind.Id;
            IsCluster = Id.StartsWith("cluster", StringComparison.OrdinalIgnoreCase);
            Label     = WpfHelper.IdToText(
                SubGraphBehind.HasAttribute("label", true)
                    ? SubGraphBehind.GetAttribute("label", true)
                    : null);

            HasBoundingBox = SubGraphBehind.HasAttribute("bb");
            if (HasBoundingBox)
            {
                StrokeThickness = GetSubGraphStrokeThickness();

                UpperRightX = WpfHelper.StringToPixel(WpfHelper.IdToText(
                                                          SubGraphBehind.GetAttribute("bb")).Split(',')[2] + "pt") +
                              StrokeThickness / 2.0;
                UpperRightY = WpfHelper.StringToPixel(WpfHelper.IdToText(
                                                          SubGraphBehind.GetAttribute("bb")).Split(',')[3] + "pt") +
                              StrokeThickness / 2.0;
                X = WpfHelper.StringToPixel(WpfHelper.IdToText(
                                                SubGraphBehind.GetAttribute("bb")).Split(',')[0] + "pt") -
                    StrokeThickness / 2.0;
                Y = WpfHelper.StringToPixel(WpfHelper.IdToText(
                                                SubGraphBehind.GetAttribute("bb")).Split(',')[1] + "pt") -
                    StrokeThickness / 2.0;
                Width  = UpperRightX - X;
                Height = UpperRightY - Y;
                Margin = FormattableString.Invariant($"{X},{Y},0,0");

                Styles = WpfHelper.IdToStyles(
                    SubGraphBehind.HasAttribute("style", true)
                        ? SubGraphBehind.GetAttribute("style", true)
                        : null);
                FillColor      = GetSubGraphFillColor();
                StrokeColor    = GetSubGraphStrokeColor();
                StrokeDashList = WpfHelper.AbsoluteStrokeDash(Styles, StrokeThickness);
                //FontFamily = GetFontFamily();
                FontColor = GetFontColor();
                FontSize  = GetFontSize();

                if (Label != null)
                {
                    var labelPos = WpfHelper.IdToText(SubGraphBehind.GetAttribute("lp"))
                                   .Split(',')
                                   .Select(p => p + "pt")
                                   .Select(WpfHelper.StringToPixel)
                                   .ToList();
                    LabelMargin = FormattableString.Invariant($"{labelPos[0]},{labelPos[1]},0,0");
                }
            }
        }
示例#9
0
        private double GetFontSize()
        {
            var sizeStr = WpfHelper.IdToText(
                NodeBehind.HasAttribute("fontsize", true)
                    ? NodeBehind.GetAttribute("fontsize", true)
                    : null);

            if (!string.IsNullOrEmpty(sizeStr))
            {
                return(double.Parse(sizeStr, CultureInfo.InvariantCulture));
            }
            return(14.0);
        }
示例#10
0
        private double GetNodeStrokeThickness()
        {
            if (NodeShapeData.Name == "None")
            {
                return(0);
            }
            var thicknessStr = WpfHelper.IdToText(
                NodeBehind.HasAttribute("penwidth", true)
                    ? NodeBehind.GetAttribute("penwidth", true) + "pt"
                    : "1");

            return(WpfHelper.StringToPixel(thicknessStr));
        }
示例#11
0
        private string GetSubGraphStrokeColor()
        {
            var pencolor = WpfHelper.IdToText(
                SubGraphBehind.HasAttribute("pencolor", true)
                    ? SubGraphBehind.GetAttribute("pencolor", true)
                    : null);
            var color = WpfHelper.IdToText(
                SubGraphBehind.HasAttribute("color", true)
                    ? SubGraphBehind.GetAttribute("color", true)
                    : null);

            return(pencolor ?? color ?? "black");
        }
示例#12
0
        private void UpdatePropertyValues()
        {
            Id    = NodeBehind.Id;
            Label = WpfHelper.IdToText(
                NodeBehind.HasAttribute("label")
                    ? NodeBehind.GetAttribute("label")
                    : NodeBehind.Id);

            Styles = WpfHelper.IdToStyles(
                NodeBehind.HasAttribute("style", true)
                    ? NodeBehind.GetAttribute("style", true)
                    : null);

            NodeShapeData = WpfHelper.ConvertToShapeData(
                NodeBehind.HasAttribute("shape", true)
                    ? NodeBehind.GetAttribute("shape", true)
                    : "ellipse",
                NodeBehind.HasAttribute("sides", true)
                    ? NodeBehind.GetAttribute("sides", true)
                    : "4",
                Styles.Contains("diagonals"));

            //Dot extends the border in both directions but wpf only inwards
            //so we compensate this by increasing the Width/Height by StrokeThickness.
            //Side note: Thickness is set to 0 in case of a plain shape
            StrokeThickness = GetNodeStrokeThickness();

            CenterX = WpfHelper.StringToPixel(WpfHelper.IdToText(
                                                  NodeBehind.GetAttribute("pos")).Split(',')[0] + "pt");
            CenterY = WpfHelper.StringToPixel(WpfHelper.IdToText(
                                                  NodeBehind.GetAttribute("pos")).Split(',')[1] + "pt");
            Width = WpfHelper.StringToPixel(WpfHelper.IdToText(
                                                NodeBehind.GetAttribute("width", true)) + "in")
                    + StrokeThickness;
            Height = WpfHelper.StringToPixel(WpfHelper.IdToText(
                                                 NodeBehind.GetAttribute("height", true)) + "in")
                     + StrokeThickness;
            X      = CenterX - Width / 2;
            Y      = CenterY - Height / 2;
            Margin = FormattableString.Invariant($"{X},{Y},0,0");

            FillColor      = GetNodeFillColor();
            StrokeColor    = GetNodeStrokeColor();
            StrokeDashList = WpfHelper.AbsoluteStrokeDash(Styles, StrokeThickness);
            //FontFamily = GetFontFamily();
            FontColor = GetFontColor();
            FontSize  = GetFontSize();
        }
示例#13
0
 private string GetNodeFillColor()
 {
     if (Styles.Contains("filled"))
     {
         var color = WpfHelper.IdToText(
             NodeBehind.HasAttribute("color", true)
                 ? NodeBehind.GetAttribute("color", true)
                 : null);
         var fillcolor = WpfHelper.IdToText(
             NodeBehind.HasAttribute("fillcolor", true)
                 ? NodeBehind.GetAttribute("fillcolor", true)
                 : null);
         return(fillcolor ?? color ?? "lightgray");
     }
     return("Transparent");
 }
示例#14
0
 private void UpdatePropertyValues()
 {
     Id    = GraphBehind.Id;
     Label = WpfHelper.IdToText(
         GraphBehind.HasAttribute("label")
             ? GraphBehind.GetAttribute("label")
             : null);
     if (Label != null)
     {
         var labelPos = WpfHelper.IdToText(GraphBehind.GetAttribute("lp"))
                        .Split(',')
                        .Select(p => p + "pt")
                        .Select(WpfHelper.StringToPixel)
                        .ToList();
         LabelMargin = FormattableString.Invariant($"{labelPos[0]},{labelPos[1]},0,0");
     }
     IsDirected = GraphBehind.IsDirected;
     FillColor  = GetGraphFillColor();
     Pad        = GetGraphPad();
 }
示例#15
0
        private string GetSubGraphFillColor()
        {
            var bgColor = WpfHelper.IdToText(
                SubGraphBehind.HasAttribute("bgcolor", true)
                    ? SubGraphBehind.GetAttribute("bgcolor", true)
                    : null);
            var color = WpfHelper.IdToText(
                SubGraphBehind.HasAttribute("color", true)
                    ? SubGraphBehind.GetAttribute("color", true)
                    : null);
            var fillcolor = WpfHelper.IdToText(
                SubGraphBehind.HasAttribute("fillcolor", true)
                    ? SubGraphBehind.GetAttribute("fillcolor", true)
                    : null);

            if (Styles.Contains("filled"))
            {
                return(fillcolor ?? color ?? bgColor ?? "lightgray");
            }
            return(bgColor ?? "Transparent");
        }