示例#1
0
        public override void Draw(Graphics g, RectangleD worldRect, Rectangle canvasRect)
        {
            base.Draw(g, worldRect, canvasRect);
            var pen  = new Pen(UpLineColor, LineWidth);
            var path = new GraphicsPath();

            pen.DashStyle = (DashStyle)Enum.Parse(typeof(DashStyle), LineStyle.ToString());
            using (pen)
            {
                using (path)
                {
                    for (int i = 1; i < Data.Count; i++)
                    {
                        GetPriceByField(i);
                        var tf =
                            (PointF)
                            Conversion.WorldToScreen(
                                new PointD(i - 1, GetPriceByField(i - 1)), worldRect,
                                canvasRect);
                        var tf2 =
                            (PointF)
                            Conversion.WorldToScreen(new PointD(i, GetPriceByField(i)), worldRect,
                                                     canvasRect);
                        path.AddLine(tf, tf2);
                    }
                    g.DrawPath(pen, path);
                }
            }
        }
示例#2
0
        protected override void DumpBody(XmlWriter writer, SwfTagCode shapeType)
        {
            writer.WriteAttributeString("state", State.ToString());

            if ((State & SwfStyleState.HasMoveTo) != 0)
            {
                writer.WriteAttributeString("dx", DeltaX.ToString());
                writer.WriteAttributeString("dy", DeltaY.ToString());
            }

            if ((State & SwfStyleState.HasFillStyle0) != 0)
            {
                writer.WriteAttributeString("fs0", FillStyle0.ToString());
            }

            if ((State & SwfStyleState.HasFillStyle1) != 0)
            {
                writer.WriteAttributeString("fs1", FillStyle1.ToString());
            }

            if ((State & SwfStyleState.HasLineStyle) != 0)
            {
                writer.WriteAttributeString("ls", LineStyle.ToString());
            }

            if ((State & SwfStyleState.HasNewStyles) != 0)
            {
                Styles.Dump(writer, shapeType);
            }
        }
示例#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
 private void ExportBorder(XmlWriter writer, string border)
 {
     writer.WriteStartElement("Border");
     writer.WriteAttributeString("ss", "Position", null, border);
     writer.WriteAttributeString("ss", "LineStyle", null, LineStyle.ToString());
     writer.WriteAttributeString("ss", "Weight", null, Weight.ToString(CultureInfo.InvariantCulture));
     if (Color != Color.Black)
     {
         writer.WriteAttributeString("ss", "Color", null, XmlStyle.ColorToExcelFormat(Color));
     }
     writer.WriteEndElement();
 }
示例#5
0
        public override void Draw(Graphics g, RectangleD worldRect, Rectangle canvasRect)
        {
            if (Hidden)
            {
                return;
            }
            base.Draw(g, worldRect, canvasRect);
            var pen   = new Pen(LineColor ?? ForeColor, LineWidth);
            var brush = new SolidBrush(BackColor);
            var path  = new GraphicsPath();
            var path2 = new GraphicsPath();

            pen.Alignment = PenAlignment.Center;
            if (LineDashStyle.HasValue)
            {
                pen.DashStyle = LineDashStyle.Value;
            }
            else
            {
                pen.DashStyle = (DashStyle)Enum.Parse(typeof(DashStyle), LineStyle.ToString());
            }
            if (pen.DashStyle == DashStyle.Custom)
            {
                pen.DashPattern = dashPattern;
            }

            var markerPen = new Pen(ColorMarker);

            // измерить расстояние между маркерами в пикселях
            var markerSpanPointsView = MarkerSpanPoints;

            if (MinPixelsBetweenMarkers > 0)
            {
                for (var i = 0; i < 10; i++)
                {
                    var sizeUnit = Conversion.WorldToScreen(new SizeD(markerSpanPointsView, 0), worldRect, canvasRect);
                    if (sizeUnit.Width >= MinPixelsBetweenMarkers)
                    {
                        break;
                    }
                    markerSpanPointsView *= markerSpanPointsMultiplier;
                }
            }

            using (pen)
            {
                using (brush)
                {
                    using (path)
                    {
                        using (path2)
                        {
                            using (markerPen)
                            {
                                PointF tf;
                                PointF tf2;
                                if (Data.BarCount > 0)
                                {
                                    tf =
                                        (PointF)
                                        Conversion.WorldToScreen(
                                            new PointD(Data.StartIndex,
                                                       Data[Data.StartIndex]), worldRect, canvasRect);

                                    path2.AddLine(tf.X, canvasRect.Bottom, tf.X, tf.Y);
                                }
                                // разлиновать
                                if (Data.StartIndex < Data.LastIndex && markerSpanPointsView > 0)
                                {
                                    for (var i = Data.StartIndex; i <= Data.LastIndex; i += markerSpanPointsView)
                                    {
                                        var pointTop = (PointF)Conversion.WorldToScreen(
                                            new PointD(
                                                i + ShiftX,
                                                0),
                                            worldRect, canvasRect);
                                        pointTop.Y = canvasRect.Top;
                                        var pointBottom = new PointF(pointTop.X, canvasRect.Bottom);
                                        g.DrawLine(markerPen, pointTop, pointBottom);
                                    }
                                }

                                // построить график
                                var startIndex = Math.Max(Data.StartIndex, (int)Chart.StockPane.WorldRect.Left);
                                var endIndex   = Math.Min(Data.LastIndex, (int)Chart.StockPane.WorldRect.Right);

                                for (var i = startIndex + 1; i <= endIndex; i++)
                                {
                                    if (double.IsNaN(Data[i - 1]) || double.IsNaN(Data[i]))
                                    {
                                        g.DrawPath(pen, path);
                                        path.Reset();
                                        continue;
                                    }
                                    tf =
                                        (PointF)
                                        Conversion.WorldToScreen(
                                            new PointD((i - 1 - 1) + ShiftX,
                                                       Data[i - 1]),
                                            worldRect,
                                            canvasRect);
                                    tf2 =
                                        (PointF)
                                        Conversion.WorldToScreen(new PointD(i - 1 + ShiftX,
                                                                            Data[i]), worldRect, canvasRect);

                                    path2.AddLine(tf, tf2);
                                    path.AddLine(tf, tf2);
                                }
                                if (Data.BarCount > 0)
                                {
                                    if (Data[Data.LastIndex] != double.NaN)
                                    {
                                        tf2 =
                                            (PointF)
                                            Conversion.WorldToScreen(
                                                new PointD(Data.LastIndex,
                                                           Data[Data.LastIndex]), worldRect, canvasRect);
                                        path2.AddLine(tf2.X, tf2.Y, tf2.X, canvasRect.Bottom);
                                    }
                                }
                                try
                                {
                                    if (!Transparent)
                                    {
                                        g.FillPath(brush, path2);
                                    }
                                    if (DrawShadow)
                                    {
                                        DrawShadowPath(path, g);
                                    }
                                    g.DrawPath(pen, path);
                                }
                                catch
                                {
                                }
                            }
                        }
                    }
                }
            }
        }
示例#6
0
        /// <summary>
        /// Base for rendering a class.
        /// </summary>
        /// <param name="name">The name of the namespace. The name can't contain spaces.</param>
        /// <param name="displayName">Optional display name. The display name can contain spaces.</param>
        /// <param name="generics">Optional class extension.</param>
        /// <param name="stereotype">Optional stereo type.</param>
        /// <param name="customSpot">Optional custom spot.</param>
        /// <param name="tag">Optional tag.</param>
        /// <param name="url">Optional URL.</param>
        /// <param name="backgroundColor">Optional background color.</param>
        /// <param name="lineColor">Optional line color.</param>
        /// <param name="lineStyle">Optional line style.</param>
        /// <param name="extends">Optional extends.</param>
        /// <param name="implements">Optional implementations.</param>
        /// <exception cref="ArgumentException">Thrown when <paramref name="name"/> is <c>null</c>, empty of only white space.</exception>
        internal static void ClassBase(this StringBuilder stringBuilder, ClassType type, string name, string displayName, string generics, string stereotype, CustomSpot customSpot, string tag, Uri url, Color backgroundColor, Color lineColor, LineStyle lineStyle, string[] extends, string[] implements)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentException("A non-empty value should be provided", nameof(name));
            }

            stringBuilder.Append(type.ToString().ToLowerInvariant());
            stringBuilder.Append(Constant.Space);

            if (!(displayName is null))
            {
                stringBuilder.Append(Constant.Quote);
                stringBuilder.Append(displayName);
                stringBuilder.Append(Constant.Quote);
                stringBuilder.Append(Constant.Space);
                stringBuilder.Append(Constant.As);
                stringBuilder.Append(Constant.Space);
            }

            stringBuilder.Append(name);

            if (!(generics is null))
            {
                stringBuilder.Append(Constant.GenericsStart);
                stringBuilder.Append(generics);
                stringBuilder.Append(Constant.GenericsEnd);
            }

            if (!(stereotype is null))
            {
                stringBuilder.Append(Constant.Space);
                stringBuilder.StereoType(stereotype, customSpot);
            }

            if (!(tag is null))
            {
                stringBuilder.Append(Constant.Space);
                stringBuilder.Append(Constant.TagPrefix);
                stringBuilder.Append(tag);
            }

            if (!(url is null))
            {
                stringBuilder.Append(Constant.Space);
                stringBuilder.Append(Constant.UrlStart);
                stringBuilder.Append(url);
                stringBuilder.Append(Constant.UrlEnd);
            }

            if (!(backgroundColor is null))
            {
                stringBuilder.Append(Constant.Space);
                stringBuilder.Append(backgroundColor);
            }

            if (!(lineColor is null) || lineStyle != LineStyle.None)
            {
                stringBuilder.Append(Constant.Space);
                stringBuilder.Append(Constant.ColorPrefix);
                stringBuilder.Append(Constant.ColorPrefix);

                if (lineStyle > LineStyle.None)
                {
                    stringBuilder.Append(Constant.BorderStyleStart);
                    stringBuilder.Append(lineStyle.ToString().ToLowerInvariant());
                    stringBuilder.Append(Constant.BorderStyleEnd);
                }

                if (!(lineColor is null))
                {
                    stringBuilder.Append(lineColor.ToString().TrimStart(Constant.ColorPrefix));
                }
            }

            if (!(extends is null) && extends.Length > 0)
            {
                stringBuilder.Append(Constant.Space);
                stringBuilder.Append(Constant.Extends);
                stringBuilder.Append(Constant.Space);
                stringBuilder.AppendJoin(',', extends);
            }

            if (!(implements is null) && implements.Length > 0)
            {
                stringBuilder.Append(Constant.Space);
                stringBuilder.Append(Constant.Implements);
                stringBuilder.Append(Constant.Space);
                stringBuilder.AppendJoin(',', implements);
            }
        }
示例#7
0
文件: Utility.cs 项目: olesar/Altaxo
 internal static string UnparseLinestyle(LineStyle val)
 {
     return(val.ToString().ToLower());
 }
示例#8
0
文件: Utility.cs 项目: Altaxo/Altaxo
		internal static string UnparseLinestyle(LineStyle val)
		{
			return val.ToString().ToLower();
		}
示例#9
0
        public override void Draw(Graphics g, RectangleD worldRect, Rectangle canvasRect)
        {
            base.Draw(g, worldRect, canvasRect);
            var pen   = new Pen(ForeColor, LineWidth);
            var brush = new SolidBrush(BackColor);
            var path  = new GraphicsPath();
            var path2 = new GraphicsPath();
            var path3 = new GraphicsPath();

            pen.Alignment = PenAlignment.Center;
            pen.DashStyle = (DashStyle)Enum.Parse(typeof(DashStyle), LineStyle.ToString());
            using (pen)
            {
                using (brush)
                {
                    using (path)
                    {
                        using (path2)
                        {
                            using (path3)
                            {
                                PointF tf;
                                PointF tf2;
                                for (int i = Data.StartIndex + 1; i <= Data.LastIndex; i++)
                                {
                                    tf =
                                        (PointF)
                                        Conversion.WorldToScreen(
                                            new PointD(i - 1, Data.Top[i - 1]),
                                            worldRect, canvasRect);
                                    tf2 =
                                        (PointF)
                                        Conversion.WorldToScreen(
                                            new PointD(i, Data.Top[i]), worldRect,
                                            canvasRect);
                                    path3.AddLine(tf, tf2);
                                    path.AddLine(tf, tf2);
                                }
                                for (int j = Data.LastIndex - 1; j >= Data.StartIndex; j--)
                                {
                                    tf =
                                        (PointF)
                                        Conversion.WorldToScreen(
                                            new PointD(j + 1, Data.Bottom[j + 1]),
                                            worldRect, canvasRect);
                                    tf2 =
                                        (PointF)
                                        Conversion.WorldToScreen(
                                            new PointD(j, Data.Bottom[j]), worldRect,
                                            canvasRect);
                                    path3.AddLine(tf, tf2);
                                    path2.AddLine(tf, tf2);
                                }
                                g.FillPath(brush, path3);
                                g.DrawPath(pen, path);
                                g.DrawPath(pen, path2);
                            }
                        }
                    }
                }
            }
        }