Beispiel #1
0
        public override void Draw(Graphics g)
        {
            base.Draw(g);
            PointF[] ps = ToPoints();
            if (ShadowWidth > 0)
            {
                PointF[] pss = (PointF[])ps.Clone();
                OffsetPoint(pss, ShadowWidth, ShadowWidth);
                g.FillPolygon(new SolidBrush(Color.FromArgb(64, Color.Black)), pss);
            }

            if (BackBrush.Color != Color.Empty)
            {
                g.FillPolygon(BackBrush.GetBrush(GetMaxRect()), ps);
            }

            if (LinePen.Color != Color.Empty)
            {
                g.DrawLines(LinePen.GetPen(), ps);
            }

            TextRenderingHint trh = g.TextRenderingHint;

            g.TextRenderingHint = TextRenderingHint.AntiAlias;

            LabelFont.DrawString(NewText, g, Rect);
            g.TextRenderingHint = trh;
        }
Beispiel #2
0
        public override void Draw(System.Drawing.Graphics g)
        {
            base.Draw(g);
            PointF p1 = ToPointF(ControlPoints[0]);
            PointF p2 = ToPointF(ControlPoints[1]);
            float  r  = (float)Dist(p1, p2);

            Pen   pen        = LinePen.GetPen();
            float StartAngle = 0;

            if (p2.Y < p1.Y)
            {
                StartAngle = 180;
            }

            if (r > 0)
            {
                foreach (float f in split)
                {
                    g.DrawArc(pen, new RectangleF(p1.X - r * f, p1.Y - r * f, r * 2 * f, r * 2 * f), StartAngle, 180);
                }
            }

            g.DrawLine(pen, p1, p2);
        }
Beispiel #3
0
        public override void Draw(Graphics g)
        {
            base.Draw(g);
            sf = SizeF.Empty;
            for (int i = 0; i < split.Length; i++)
            {
                try
                {
                    ObjectFont.DrawString(GetStr(i), g, GetRect(i));
                }
                catch
                {
                }
            }

            Pen       P  = LinePen.GetPen();
            PointF    p1 = ToPointF(ControlPoints[0]);
            PointF    p2 = ToPointF(ControlPoints[1]);
            Rectangle R  = Area.Canvas.Rect;

            if (InMove && p1 != PointF.Empty && p2 != PointF.Empty)
            {
                g.DrawLine(P, p1.X, p1.Y, p2.X, p2.Y);
            }
        }
Beispiel #4
0
        public override void Draw(Graphics g)
        {
            base.Draw(g);
            PointF p1 = ToPointF(ControlPoints[0]);
            PointF p2 = ToPointF(ControlPoints[1]);
            double r  = Dist(p1, p2);

            g.DrawEllipse(LinePen.GetPen(), (int)(p1.X - r), (int)(p1.Y - r), (int)(r * 2), (int)(r * 2));
        }
Beispiel #5
0
        public override void Draw(System.Drawing.Graphics g)
        {
            base.Draw(g);
            PointF p1 = ToPointF(ControlPoints[0]);
            PointF p2 = ToPointF(ControlPoints[1]);
            float  r1 = p2.X - p1.X;
            float  r2 = p1.Y - p2.Y;

            g.DrawEllipse(LinePen.GetPen(), p1.X, p2.Y, r1 * 2, r2 * 2);
        }
Beispiel #6
0
        public override void Draw(System.Drawing.Graphics g)
        {
            base.Draw(g);

            Pen       P  = LinePen.GetPen();
            PointF    p1 = ToPointF(ControlPoints[0]);
            PointF    p2 = ToPointF(ControlPoints[1]);
            Rectangle R  = Area.Canvas.Rect;

            if ((InMove || showAuxLine) && p1 != PointF.Empty && p2 != PointF.Empty)
            {
                g.DrawLine(P, p1.X, R.Y, p1.X, R.Bottom);
                g.DrawLine(P, p2.X, R.Y, p2.X, R.Bottom);
            }
        }
Beispiel #7
0
 public override void Draw(System.Drawing.Graphics g)
 {
     base.Draw(g);
     AllPoints = CalcPoint();
     if (AllPoints.Length > 0)
     {
         if (Closed)
         {
             g.DrawPolygon(LinePen.GetPen(), AllPoints);
         }
         else
         {
             g.DrawLines(LinePen.GetPen(), AllPoints);
         }
     }
 }
Beispiel #8
0
        public void Bind(FormulaChart fc)
        {
            foreach (FormulaArea fa in fc.Areas)
            {
                if (fa.AxisXs.Count != AxisXs.Count)
                {
                    fa.AxisXs.Clear();
                    for (int i = 0; i < AxisXs.Count; i++)
                    {
                        fa.AxisXs.Add(new FormulaAxisX()); //AxisXs[i]
                    }
                    if (AxisXs.Count > 0)
                    {
                        fa.AxisX = fa.AxisXs[0];
                    }
                }

                for (int i = 0; i < AxisXs.Count; i++)
                {
                    fa.AxisXs[i].CopyFrom(AxisXs[i]);
                }

                foreach (FormulaAxisY fay in fa.AxisYs)
                {
                    fay.CopyFrom(AxisY);
                }
                fa.Back    = (FormulaBack)Back.Clone();
                fa.Colors  = (Color[])Colors.Clone();
                fa.LinePen = LinePen.GetPen();                                                                    // LinePen.Clone();

                fa.BarPens         = new Pen[] { BarPens[0].GetPen(), BarPens[1].GetPen(), BarPens[2].GetPen() }; // (Pen[])BarPens.Clone();
                fa.BarBrushes      = new Brush[] { BarBrushes[0].GetBrush(), BarBrushes[1].GetBrush(), BarBrushes[2].GetBrush() };
                fa.NameBrush       = NameBrush.GetBrush();
                fa.NameFont        = (Font)NameFont.Clone();
                fa.TextFont        = (Font)TextFont.Clone();
                fa.StockRenderType = StockRenderType;
                if (fa.IsMain())
                {
                    fa.AxisY.Scale = scaleType;
                }
            }
            fc.StickRenderType     = StickRenderType;
            fc.CursorPen           = CursorPen.GetPen();
            fc.ShowXAxisInLastArea = ShowXAxisInLastArea;
            fc.ShowValueLabel      = ShowValueLabel;
            fc.AllXFormats         = AllXFormats;
        }
Beispiel #9
0
        public override void Draw(Graphics g)
        {
            base.Draw(g);
            PointF p1 = ControlPoints[0];
            PointF p2 = ControlPoints[1];

            PointF pp1 = new PointF(p1.X, p1.Y);
            PointF pp2 = new PointF(p2.X, p1.Y);

            float[] ff = { 0f, 0.382f, 0.5f, 0.618f, 1f };
            foreach (float f in ff)
            {
                pp1.Y = (p2.Y - p1.Y) * f + p1.Y;
                pp2.Y = (p2.Y - p1.Y) * f + p1.Y;
                g.DrawString(f.ToString("p1"), ObjectCanvas.ObjectFont, ObjectCanvas.ObjectBrush, pp1.X, pp1.Y);
                g.DrawLine(LinePen.GetPen(), pp1, pp2);
            }
        }
Beispiel #10
0
 public override void Draw(System.Drawing.Graphics g)
 {
     base.Draw(g);
     CalcPoint();
     if (pfStart != null && pfEnd != null)
     {
         for (int i = 0; i < pfStart.Length; i++)
         {
             try
             {
                 g.DrawLine(LinePen.GetPen(), pfStart[i], pfEnd[i]);
             }
             catch
             {
             }
         }
     }
 }
Beispiel #11
0
        public override void Draw(Graphics g)
        {
            base.Draw(g);
            float X = ToPointF(ControlPoints[0]).X;
            float Y = ToPointF(ControlPoints[0]).Y;

            if (Manager.Canvas != null && Manager.Canvas.BackChart != null && Manager.Canvas.BackChart.DataProvider != null)
            {
                Rectangle R = Manager.Canvas.BackChart.Rect;
                g.DrawLine(LinePen.GetPen(), X, R.Top, X, R.Bottom);
                if (ShowDate)
                {
                    IDataProvider idp = Manager.Canvas.BackChart.DataProvider;
                    double        d   = idp["DATE"][(int)((X - Manager.Canvas.BackChart.Start) / Manager.Canvas.BackChart.ColumnWidth)];
                    g.DrawString(DateTime.FromOADate(d).ToString(DateFormat), Font,
                                 new SolidBrush(Color.FromArgb(LinePen.AlphaBlend, ForeColor)), X, Y);
                }
            }
        }
Beispiel #12
0
        public override void Draw(System.Drawing.Graphics g)
        {
            base.Draw(g);
            PointF p1 = ToPointF(ControlPoints[0]);
            PointF p2 = ToPointF(ControlPoints[1]);

            float r1 = p2.X - p1.X;
            float r2 = p1.Y - p2.Y;

            Pen pen = LinePen.GetPen();

            foreach (float f in split)
            {
                g.DrawEllipse(pen, p1.X - r1 * f, p2.Y - r2 * f, r1 * 2 * f, r2 * 2 * f);
            }

            g.DrawLine(pen, p1.X, p1.Y, p1.X, p2.Y);
            g.DrawLine(pen, p1.X, p2.Y, p2.X, p2.Y);
        }
Beispiel #13
0
        public override void Draw(Graphics g)
        {
            base.Draw(g);
            PointF     P    = ToPointF(ControlPoints[0]);
            SizeF      sf   = g.MeasureString(Text, TextFont, 1000, format);
            RectangleF Rect = new RectangleF(P.X, P.Y, sf.Width + 4, sf.Height + 4);
            ArrayList  al   = new ArrayList();

            al.Add(new PointF(Rect.Left, Rect.Top + RoundWidth));
            al.Add(new PointF(Rect.Left + RoundWidth, Rect.Top));

            al.Add(new PointF(Rect.Right - RoundWidth, Rect.Top));
            al.Add(new PointF(Rect.Right, Rect.Top + RoundWidth));

            al.Add(new PointF(Rect.Right, Rect.Bottom - RoundWidth));
            al.Add(new PointF(Rect.Right - RoundWidth, Rect.Bottom));

            al.Add(new PointF(Rect.Left + RoundWidth, Rect.Bottom));
            al.Add(new PointF(Rect.Left, Rect.Bottom - RoundWidth));
            al.Add(al[0]);

            if (StickHeight > 0)
            {
                float OffsetX = 0;
                float OffsetY = 0;
                int   Index   = 1;
                switch (StickAlignment)
                {
                case StickAlignment.LeftTop:
                    OffsetX = StickHeight;
                    OffsetY = StickHeight;
                    break;

                case StickAlignment.LeftCenter:
                    break;

                case StickAlignment.LeftBottom:
                    OffsetX = StickHeight;
                    OffsetY = -Rect.Height - StickHeight;
                    Index   = 7;
                    break;

                case StickAlignment.CenterTop:
                    break;

                case StickAlignment.CenterCenter:
                    break;

                case StickAlignment.CenterBottom:
                    break;

                case StickAlignment.RightTop:
                    OffsetX = -Rect.Width - StickHeight;
                    OffsetY = StickHeight;
                    Index   = 3;
                    break;

                case StickAlignment.RightCenter:
                    break;

                case StickAlignment.RightBottom:
                    OffsetX = -Rect.Width - StickHeight;
                    OffsetY = -Rect.Height - StickHeight;
                    Index   = 5;
                    break;
                }
                al = OffsetPoint(al, OffsetX, OffsetY);
                al.Insert(Index, P);
                Rect.Offset(OffsetX, OffsetY);
            }

            PointF[] ps = (PointF[])al.ToArray(typeof(PointF));
            if (ShadowWidth > 0)
            {
                PointF[] pss = (PointF[])ps.Clone();
                OffsetPoint(pss, ShadowWidth, ShadowWidth);
                g.FillPolygon(new SolidBrush(Color.FromArgb(64, Color.Black)), pss);
            }

            if (BackBrush.Color != Color.Empty)
            {
                g.FillPolygon(BackBrush.GetBrush(GetMaxRect()), ps);
            }

            if (LinePen.Color != Color.Empty)
            {
                g.DrawLines(LinePen.GetPen(), ps);
            }

            TextRenderingHint trh = g.TextRenderingHint;

            g.TextRenderingHint = TextRenderingHint.AntiAlias;
            g.DrawString(Text, TextFont, TextBrush.GetBrush(), Rect, format);
            g.TextRenderingHint = trh;
        }
Beispiel #14
0
		public override void Draw(Graphics g)
		{
			base.Draw(g);
			PointF[] pfs = ToPoints();
			g.DrawLines(LinePen.GetPen(),pfs);
		}
Beispiel #15
0
        public void DrawXAxisTick(FormulaCanvas Canvas, double[] Date, FormulaData fdDate, PointF[] pfs, FormulaAxisX fax, ExchangeIntraday ei)
        {
            if (DataCycle == null)
            {
                return;
            }

            try
            {
                int      LastCycle   = -1;
                int      NowCycle    = 0;
                string   LastExtDate = "";
                string   NowExtDate;
                int      LastX     = -10000;
                int      LastIndex = -1;
                Graphics g         = Canvas.CurrentGraph;

                double DateSpan = 0;
                if (Date.Length > 0)
                {
                    DateSpan = Date[Date.Length - 1] - Date[0];
                }

                double[] SeqDate = Date;
                if (ei != null && ei.NativeCycle)
                {
                    SeqDate = new double[Date.Length];
                    for (int i = 0; i < SeqDate.Length; i++)
                    {
                        SeqDate[i] = (int)Date[i] + ei.OneDayTime(Date[i]);
                    }
                }

                ArrayList alTick = new ArrayList();
                Font      F      = fax.LabelFont;
                Pen       LP     = LinePen.GetPen();
                Pen       TP     = TickPen.GetPen();
                for (int i = pfs.Length - 1; i >= 0; i--)
                {
                    int      DateIndex = Date.Length - 1 - Math.Max(0, Canvas.Start) - i;
                    double   d         = Date[DateIndex];
                    DateTime D         = DateTime.FromOADate(d);
                    NowCycle = DataCycle.GetSequence(SeqDate[DateIndex]);

                    if (NowCycle != LastCycle)
                    {
                        PointF P = pfs[i];
                        LastCycle = NowCycle;
                        if (ShowLine)
                        {
                            int B = Canvas.Rect.Bottom;
                            if (!fax.Visible)
                            {
                                B = Canvas.FrameRect.Bottom;
                            }
                            g.DrawLine(LP, P.X, Canvas.FrameRect.Top, P.X, B);
                        }

                        if (fax.Visible && ShowTick)
                        {
                            int TickHeight = TickWidth;
                            if (FullTick)
                            {
                                TickHeight = fax.Rect.Height;
                            }
                            if (Inside)
                            {
                                TickHeight = -TickHeight;
                            }
                            g.DrawLine(TP, P.X, fax.Rect.Top, P.X, TickHeight + fax.Rect.Top);
                        }

                        string s  = D.ToString(Format, DateFormatProvider);
                        int    i1 = s.IndexOf('{');
                        int    i2 = s.IndexOf('}');
                        if (i2 > i1)
                        {
                            NowExtDate = s.Substring(i1 + 1, i2 - i1 - 1);
                            if (NowExtDate != LastExtDate)
                            {
                                if (NowExtDate.StartsWith("$"))
                                {
                                    s = s.Remove(i2, s.Length - i2).Remove(i1, 2);
                                }
                                else
                                {
                                    s = s.Remove(i1, 1).Remove(i2 - 1, 1);
                                }
                            }
                            else
                            {
                                s = s.Substring(0, i1) + s.Substring(i2 + 1);
                            }
                            LastExtDate = NowExtDate;
                        }

                        float LabelWidth = g.MeasureString(s, F).Width;
                        float LabelX     = P.X;

                        switch (fax.AxisLabelAlign)
                        {
                        case AxisLabelAlign.TickCenter:
                            LabelX -= LabelWidth / 2;
                            break;

                        case AxisLabelAlign.TickLeft:
                            LabelX -= LabelWidth;
                            break;
                        }
                        if (LabelX < fax.Rect.Left)
                        {
                            LabelX = fax.Rect.Left;
                        }

                        if (fax.Visible && ShowText /*&& LastX+MinimumPixel<LabelX*/)
                        {
                            if (ei == null || ei.ShowFirstXLabel || i < pfs.Length - 1 || DateSpan > 1)
                            {
                                alTick.Add(new object[] { s, LabelX, LabelWidth, d, LastX + MinimumPixel < LabelX });
                                //g.DrawString(s,F,fax.LabelBrush,LabelX,fax.Rect.Top);
                                LastX = (int)(LabelX + LabelWidth);
                            }
                            LastIndex = i;
                        }
                    }             //if (NowCycle!=LastCycle)
                }                 //for

                //Second pass
                for (int i = 0; i < alTick.Count; i++)
                {
                    object[] os = (object[])alTick[i];
                    if (!(bool)os[4])
                    {
                        if ((int)(double)((object[])alTick[i - 1])[3] == (int)(double)((object[])alTick[i])[3])
                        {
                            alTick.RemoveAt(i);
                        }
                        else
                        {
                            alTick.RemoveAt(i - 1);
                        }
                        i--;
                    }
                }

                //Third pass
                Brush lb = fax.LabelBrush.GetBrush();
                for (int i = 0; i < alTick.Count; i++)
                {
                    object[] os = (object[])alTick[i];
                    g.DrawString((string)os[0], F, lb, (float)os[1], fax.Rect.Top);
                }
            }
            catch
            {
            }
        }