Esempio n. 1
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));
        }
Esempio n. 2
0
        private double GetSubGraphStrokeThickness()
        {
            var thicknessStr = WpfHelper.IdToText(
                SubGraphBehind.HasAttribute("penwidth", true)
                    ? SubGraphBehind.GetAttribute("penwidth", true) + "pt"
                    : "1");

            return(WpfHelper.StringToPixel(thicknessStr));
        }
Esempio n. 3
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))));
        }
Esempio n. 4
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");
                }
            }
        }
Esempio n. 5
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));
        }
Esempio n. 6
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();
        }