Пример #1
0
        /// <summary>
        /// Gnuplotコマンド用の文字列を取得します。
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            List <string> format = new List <string>();

            if (LineType > 0)
            {
                format.Add($"lt {LineType}");
            }
            if (!string.IsNullOrEmpty(LineColor))
            {
                format.Add($"lc rgbcolor '{LineColor}'");
            }
            else
            {
                format.Add($"lc {LineColorIndex}");
            }
            if (LineWidth > 0)
            {
                format.Add($"lw {LineWidth.ToString("f1")}");
            }
            if (PointType > 0)
            {
                format.Add($"pt {PointType}");
            }
            if (PointSize > 0)
            {
                format.Add($"ps {LineWidth.ToString("f1")}");
            }

            return(string.Join(" ", format.ToArray()));
        }
Пример #2
0
        /// <summary>
        /// Converts object to the string of the format specified.
        /// </summary>
        /// <param name="format"></param>
        /// <param name="formatProvider"></param>
        /// <returns></returns>
        protected override string ToStringInternal(string format, IFormatProvider formatProvider)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("Path(")
            .Append("w=")
            .Append(LineWidth?.ToString(format, formatProvider) ?? "null")
            .Append(",c=")
            .Append(Color ?? "null")
            .Append(",f=")
            .Append(Fill?.ToString(formatProvider).ToLower() ?? "null");

            if (Elements.Count > 0)
            {
                sb.Append(",[");
                for (int i = 0; i < Elements.Count; i++)
                {
                    if (i > 0)
                    {
                        sb.Append(',');
                    }
                    sb.Append(Elements[i].ToString());
                }
                sb.Append("]");
            }
            sb.Append(')');
            return(sb.ToString());
        }
Пример #3
0
        public override void Serialize(XmlDocument dom, XmlElement node)
        {
            base.Serialize(dom, node);

            node.SetAttribute("target", Target.ID);

            if (LayoutData != null)
            {
                node.SetAttribute("cp1_length", LayoutData.CP1.Length.ToString());
                node.SetAttribute("cp1_angle", LayoutData.CP1.Angle.ToString());
                node.SetAttribute("cp2_length", LayoutData.CP2.Length.ToString());
                node.SetAttribute("cp2_angle", LayoutData.CP2.Angle.ToString());
            }

            node.SetAttribute("width", LineWidth.ToString());
            if (!Color.IsEmpty)
            {
                node.SetAttribute("color", ST.ToString(Color));
            }
            node.SetAttribute("line_style", LineStyle.ToString());
            node.SetAttribute("start_cap", StartCap.ToString());
            node.SetAttribute("end_cap", EndCap.ToString());
            node.SetAttribute("text", Text);
            node.SetAttribute("hyperlink", Hyperlink);

            if (!string.IsNullOrEmpty(Remark))
            {
                ST.WriteTextNode(node, "remark", Remark);
            }
        }
Пример #4
0
        }  ///  获得线的长度及方向

        public override void Out2Sw(System.IO.StreamWriter sw)
        {
            sw.WriteLine("Start");
            sw.WriteLine("Line");
            sw.WriteLine(Layer);
            sw.WriteLine(Color.R.ToString() + "," + Color.G.ToString() + "," + Color.B.ToString());
            sw.WriteLine(LineWidth.ToString());
            sw.WriteLine(_startpoint.X.ToString() + "," + _startpoint.Y.ToString());
            sw.WriteLine(_endpoint.X.ToString() + "," + _endpoint.Y.ToString());
            sw.WriteLine("End");
        }
Пример #5
0
 public override void Out2Sw(System.IO.StreamWriter sw)
 {
     sw.WriteLine("Start");
     sw.WriteLine("Circle");
     sw.WriteLine(Layer);
     sw.WriteLine(Color.R.ToString() + "," + Color.G.ToString() + "," + Color.B.ToString());
     sw.WriteLine(LineWidth.ToString());
     sw.WriteLine(_center.X.ToString() + "," + _center.Y.ToString());
     sw.WriteLine(_r.ToString());
     sw.WriteLine("End");
 }
Пример #6
0
 public override void Out2Sw(System.IO.StreamWriter sw)
 {
     sw.WriteLine("Start");
     sw.WriteLine("PolyLine");
     sw.WriteLine(Layer);
     sw.WriteLine(Color.R.ToString() + "," + Color.G.ToString() + "," + Color.B.ToString());
     sw.WriteLine(LineWidth.ToString());
     sw.WriteLine(Count.ToString());
     for (int i = 0; i < Count; i++)
     {
         sw.WriteLine(Vertexs[i].X.ToString() + "," + Vertexs[i].Y.ToString());
     }
     sw.WriteLine("End");
 }
        /// <summary>
        /// Converts object to the string of the format specified.
        /// </summary>
        /// <param name="format"></param>
        /// <param name="formatProvider"></param>
        /// <returns></returns>
        protected override string ToStringInternal(string format, IFormatProvider formatProvider)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("Line(")
            .Append("s=")
            .Append(Start.ToString(format, formatProvider))
            .Append(",e=")
            .Append(End.ToString(format, formatProvider))
            .Append(",w=")
            .Append(LineWidth?.ToString(format, formatProvider) ?? "null")
            .Append(",c=")
            .Append(Color ?? "null")
            .Append(')');
            return(sb.ToString());
        }
Пример #8
0
        /// <summary>
        /// Converts object to the string of the format specified.
        /// </summary>
        /// <param name="format"></param>
        /// <param name="formatProvider"></param>
        /// <returns></returns>
        protected override string ToStringInternal(string format, IFormatProvider formatProvider)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("Circle(")
            .Append("p=")
            .Append(Center.ToString(format, formatProvider))
            .Append(",r=")
            .Append(Radius.ToString(format, formatProvider))
            .Append(",w=")
            .Append(LineWidth?.ToString(format, formatProvider) ?? "null")
            .Append(",c=")
            .Append(Color ?? "null")
            .Append(",f=")
            .Append(Fill?.ToString(formatProvider).ToLower() ?? "null")
            .Append(')');

            return(sb.ToString());
        }
Пример #9
0
        /// <summary>
        /// Converts object to the string of the format specified.
        /// </summary>
        /// <param name="format"></param>
        /// <param name="formatProvider"></param>
        /// <returns></returns>
        protected override string ToStringInternal(string format, IFormatProvider formatProvider)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("Rectangle(")
            .Append("p=")
            .Append(TopLeft.ToString(format, formatProvider))
            .Append(",s=")
            .Append(Size.ToString(format, formatProvider))
            .Append(",w=")
            .Append(LineWidth?.ToString(format, formatProvider) ?? "null")
            .Append(",c=")
            .Append(Color ?? "null")
            .Append(",f=")
            .Append(Fill?.ToString(formatProvider).ToLower() ?? "null")
            .Append(')');

            return(sb.ToString());
        }
Пример #10
0
        public override void UpdateSvg(XmlDocument document, IEnumerable items)
        {
            try
            {
                var elements = (IEnumerable <int>)items;

                string linePoints    = string.Empty;
                double pointPosition = 0;
                double svgWidth      = (elements.Count() * PointsDistance) + 13;

                var svgElement = document.DocumentElement;
                var svgAttr    = svgElement.Attributes;
                svgAttr["viewBox"].Value = $"-10 -5 {svgWidth} 105";

                var root = document.DocumentElement.GetElementsByTagName("g").Cast <XmlElement>().LastOrDefault();

                var polylineNodeToCopy = root.GetElementsByTagName("polyline").Cast <XmlElement>()
                                         .FirstOrDefault(x => x.HasAttribute("class") && x.Attributes["class"].Value == "line-chart");

                var pointNodeToCopy = root.GetElementsByTagName("circle").Cast <XmlElement>()
                                      .FirstOrDefault(x => x.HasAttribute("class") && x.Attributes["class"].Value == "point-chart");


                foreach (var el in elements)
                {
                    if (el < 0)
                    {
                        continue;
                    }

                    var yPosition = 100 - el;

                    if (ShowPoints)
                    {
                        var newPointNode = pointNodeToCopy.CloneNode(true);

                        var pointAttr = newPointNode.Attributes;
                        pointAttr["cx"].Value   = pointPosition.ToString();
                        pointAttr["fill"].Value = PointsColor.ToHex();
                        pointAttr["r"].Value    = PointSize.ToString();
                        pointAttr["cy"].Value   = yPosition.ToString();

                        root.InsertAfter(newPointNode, root.LastChild);
                    }

                    linePoints    += $"{pointPosition},{yPosition - 1} ";
                    pointPosition += PointsDistance;
                }

                var barAttr = polylineNodeToCopy.Attributes;
                barAttr["points"].Value       = linePoints;
                barAttr["stroke"].Value       = LineColor.ToHex();
                barAttr["stroke-width"].Value = LineWidth.ToString();

                root.RemoveChild(pointNodeToCopy);
            }
            catch (InvalidCastException ex)
            {
                throw new ItemsSourceException("ItemsSource for Line chart must to be a collection of values IEnumerable<int>", ex);
            }
        }
Пример #11
0
        /// <summary>
        /// Covert to string
        /// </summary>
        public override string ToString()
        {
            string graphicInfo = "Annotation Type: Line" + "\n" +
                                 "Position: " + "[ X " + Start.X.ToString("f2") + ", Y " + Start.Y.ToString("f2") + "] Size: [ Width " + Math.Abs(End.X - Start.X).ToString("f2") + ", Height " + Math.Abs(End.Y - Start.Y).ToString("f2") + "]" + "\n" +
                                 "Color: " + ObjectColor.ToString() + ", LineWidth: " + LineWidth.ToString() + "\n";

            return(graphicInfo);
        }
Пример #12
0
 public void WriteXml(System.Xml.XmlWriter writer)
 {
     writer.WriteAttributeString("Color", Color.ToString());
     writer.WriteAttributeString("LineWidth", LineWidth.ToString());
 }