Esempio n. 1
0
        //private string GetFontFamily() {
        //    var fontname = WpfHelper.IdToText(
        //        SubGraphBehind.HasAttribute("fontname", true)
        //            ? SubGraphBehind.GetAttribute("fontname", true)
        //            : "Times-Roman");
        //    return null;
        //}

        private string GetFontColor()
        {
            return(WpfHelper.IdToText(
                       SubGraphBehind.HasAttribute("fontcolor", true)
                    ? SubGraphBehind.GetAttribute("fontcolor", true)
                    : "black"));
        }
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 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. 4
0
        private double GetFontSize()
        {
            var sizeStr = WpfHelper.IdToText(
                SubGraphBehind.HasAttribute("fontsize", true)
                    ? SubGraphBehind.GetAttribute("fontsize", true)
                    : null);

            if (!string.IsNullOrEmpty(sizeStr))
            {
                return(double.Parse(sizeStr, CultureInfo.InvariantCulture));
            }
            return(14.0);
        }
Esempio n. 5
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");
        }
Esempio n. 6
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");
        }