コード例 #1
0
ファイル: FormulaAxisX.cs プロジェクト: Bulletz4mysa/NBTrade
        public void DrawCursor(Graphics g, FormulaChart fc, FormulaArea Area, float X)
        {
            if (!this.LastCursorRect.IsEmpty)
            {
                fc.RestoreMemBmp(g, this.LastCursorRect);
            }
            FormulaLabel label     = Area.Labels[2];
            int          cursorPos = fc.CursorPos;

            if ((Object)fdDate != null && cursorPos >= 0)
            {
                if (cursorPos < this.fdDate.Length)
                {
                    string text = DateTime.FromOADate(this.fdDate[cursorPos]).ToString(this.CursorFormat,
                                                                                       DateTimeFormatInfo.InvariantInfo);
                    SizeF      ef   = g.MeasureString(text, this.LabelFont);
                    RectangleF rect = new RectangleF(X - fc.Rect.X, (float)this.Rect.Y, ef.Width,
                                                     (float)(this.Rect.Height - 1));
                    this.LastCursorRect = rect;
                    this.LastCursorRect.Inflate(2f, 1f);
                    rect.Offset((PointF)fc.Rect.Location);
                    label.DrawString(g, text, this.LabelFont, label.TextBrush, VerticalAlign.Bottom, FormulaAlign.Left,
                                     rect, false);
                }
            }
        }
コード例 #2
0
 public void SetVisible(FormulaChart fc)
 {
     for (int i = 0; i < Visible.Length; i++)
     {
         fc.SetAxisXVisible(i, Visible[i]);
     }
 }
コード例 #3
0
 public void SetMinorLine(FormulaChart fc)
 {
     for (int i = 0; i < ShowMinorLine.Length; i++)
     {
         fc.SetAxisXShowMinorLine(i, ShowMinorLine[i]);
     }
 }
コード例 #4
0
 public void SetMajorLine(FormulaChart fc)
 {
     for (int i = 0; i < this.ShowMajorLine.Length; i++)
     {
         fc.SetAxisXShowMajorLine(i, this.ShowMajorLine[i]);
     }
 }
コード例 #5
0
        /// <summary>
        /// Draw date label at X
        /// </summary>
        /// <param name="g"></param>
        /// <param name="fc"></param>
        /// <param name="Area"></param>
        /// <param name="X"></param>
        public void DrawCursor(Graphics g, FormulaChart fc, FormulaArea Area, float X)
        {
            if (!LastCursorRect.IsEmpty)
            {
                fc.RestoreMemBmp(g, LastCursorRect);
            }

            FormulaLabel fl = Area.Labels[2];
            int          i  = fc.CursorPos;

            if ((object)fdDate != null)
            {
                if (i >= 0)
                {
                    DateTime D  = fc.IndexToDate(i);
                    string   s  = D.ToString(CursorFormat);          //,DateTimeFormatInfo.InvariantInfo
                    SizeF    sf = g.MeasureString(s, LabelFont);

                    RectangleF R = new RectangleF(X - fc.Rect.X, Rect.Y, sf.Width, Rect.Height - 1);
                    if (R.Right > Rect.Right)
                    {
                        R.Offset(-R.Width - 1, 0);
                    }
                    LastCursorRect = R;
                    LastCursorRect.Inflate(2, 1);
                    R.Offset(fc.Rect.Location);

                    fl.DrawString(g, s, LabelFont, fl.TextBrush, VerticalAlign.Bottom, FormulaAlign.Left, R, false);
                }
            }
        }
コード例 #6
0
        public Point Render(Graphics g, Rectangle R, FormulaChart fc, Point NowPos, int Bar)
        {
            this.Bar = Bar;
            foreach (LayoutLabel ll in Labels)
            {
                if (ll.Frame != Rectangle.Empty)
                {
                    g.DrawRectangle(new Pen(ll.FrameColor), ll.Frame);
                }
                if (ll.Back != Rectangle.Empty)
                {
                    g.FillRectangle(new SolidBrush(ll.BackColor), ll.Back);
                }
                int    ColorIndex = 0;
                string s          = ReplaceText(fc, ll.Text, out ColorIndex);

                SizeF sf = SizeF.Empty;
                if (ll.Text != null && ll.Text != "")
                {
                    sf = g.MeasureString(s, ll.TextFont);
                    AdjustNowPos(ll, sf, ref R, ref NowPos);

                    Color C;
                    if (ll.UseColor)
                    {
                        C = ColorTextColor[ColorIndex];
                    }
                    else
                    {
                        C = ll.TextColor;
                    }

                    g.DrawString(s, ll.TextFont, new SolidBrush(C), NowPos);
                }
                if (ll.Icon != null && ll.Icon != "")
                {
                    string IconFile = FormulaHelper.GetImageFile(ll.Icon);
                    if (File.Exists(IconFile))
                    {
                        Image I = Bitmap.FromFile(IconFile);
                        sf = new SizeF(I.Width, I.Height);
                        AdjustNowPos(ll, sf, ref R, ref NowPos);
                        g.DrawImage(I, NowPos);
                    }
                }
                if (ll.Pos.X >= 0)
                {
                    NowPos.X += (int)sf.Width;
                }
            }
            return(NowPos);
        }
コード例 #7
0
        public static FormulaChart CreateChart(string Indicators, string Overlays, IDataProvider DataProvider, string Skin)
        {
            FormulaChart chart = new FormulaChart();

            chart.AddAreas(Indicators);
            chart.AddOverlays(Overlays);
            if (DataProvider != null)
            {
                chart.DataProvider = DataProvider;
            }
            if ((Skin != null) && (Skin != ""))
            {
                chart.SetSkin(Skin);
            }
            return(chart);
        }
コード例 #8
0
        public void DrawCursor(Graphics g, FormulaChart fc, FormulaArea Area, float Y, double d)
        {
            if (!this.LastCursorRect.IsEmpty)
            {
                fc.RestoreMemBmp(g, this.LastCursorRect);
            }
            FormulaLabel label = Area.Labels[2];
            string       text  = d.ToString(this.Format);
            SizeF        ef    = g.MeasureString(text, this.LabelFont);
            RectangleF   rect  = new RectangleF((float)this.Rect.Left, Y - fc.Rect.Y, (this.Rect.Width - 1) - this.Back.RightPen.Width, ef.Height);

            this.LastCursorRect = rect;
            this.LastCursorRect.Inflate(2f, 1f);
            rect.Offset((PointF)fc.Rect.Location);
            label.DrawString(g, text, this.LabelFont, label.TextBrush, VerticalAlign.Bottom, FormulaAlign.Left, rect, false);
        }
コード例 #9
0
ファイル: FormulaSkin.cs プロジェクト: traderdata/COMPONENTES
        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;
        }
コード例 #10
0
        /// <summary>
        /// Draw price label at Y
        /// </summary>
        /// <param name="g"></param>
        /// <param name="fc"></param>
        /// <param name="Area"></param>
        /// <param name="Y">Y-Position</param>
        /// <param name="d">Price</param>
        public void DrawCursor(Graphics g, FormulaChart fc, FormulaArea Area, float Y, double d)
        {
            if (!LastCursorRect.IsEmpty)
            {
                fc.RestoreMemBmp(g, LastCursorRect);
            }

            FormulaLabel fl = Area.Labels[2];
            string       s  = FormulaHelper.FormatDouble(d, format);
            SizeF        sf = g.MeasureString(s, LabelFont);

            RectangleF R = new RectangleF(Rect.Left, Y - fc.Rect.Y, Rect.Width - 1 - Back.RightPen.Width, sf.Height);

            LastCursorRect = R;
            LastCursorRect.Inflate(2, 1);
            R.Offset(fc.Rect.Location);

            fl.DrawString(g, s, LabelFont, fl.TextBrush, VerticalAlign.Bottom, FormulaAlign.Left, R, false);
        }
コード例 #11
0
ファイル: FormulaSkin.cs プロジェクト: Bulletz4mysa/NBTrade
 public void Bind(FormulaChart fc)
 {
     foreach (FormulaArea area in fc.Areas)
     {
         if (area.AxisXs.Count != this.AxisXs.Count)
         {
             area.AxisXs.Clear();
             for (int j = 0; j < this.AxisXs.Count; j++)
             {
                 area.AxisXs.Add(new FormulaAxisX());
             }
             if (this.AxisXs.Count > 0)
             {
                 area.AxisX = area.AxisXs[0];
             }
         }
         for (int i = 0; i < this.AxisXs.Count; i++)
         {
             area.AxisXs[i].CopyFrom(this.AxisXs[i]);
         }
         foreach (FormulaAxisY sy in area.AxisYs)
         {
             sy.CopyFrom(this.AxisY);
         }
         area.Back             = (FormulaBack)this.Back.Clone();
         area.Colors           = (Color[])this.Colors.Clone();
         area.LinePen          = (Pen)this.LinePen.Clone();
         area.BarPens          = (Pen[])this.BarPens.Clone();
         area.BarBrushes       = (Brush[])this.BarBrushes.Clone();
         area.NameBrush        = (Brush)this.NameBrush.Clone();
         area.NameFont         = (Font)this.NameFont.Clone();
         area.TextFont         = (Font)this.TextFont.Clone();
         area.DrawVolumeAsLine = this.DrawVolumeAsLine;
         area.StockRenderType  = this.StockRenderType;
     }
     fc.CursorPen          = this.CursorPen;
     fc.ShowDateInLastArea = this.ShowDateInLastArea;
     fc.ShowValueLabel     = this.ShowValueLabel;
     fc.AllXFormats        = this.AllXFormats;
 }
コード例 #12
0
 /// <summary>
 /// Draw price label at Y
 /// </summary>
 /// <param name="g"></param>
 /// <param name="fc"></param>
 /// <param name="Area"></param>
 /// <param name="Y">Y-position</param>
 public void DrawCursor(Graphics g, FormulaChart fc, FormulaArea Area, float Y)
 {
     DrawCursor(g, fc, Area, Y, GetValueFromY(Y - fc.Rect.Y));
 }
コード例 #13
0
 public Point Render(Graphics g, Rectangle R, FormulaChart fc, Point NowPos)
 {
     return(Render(g, R, fc, NowPos, -1));
 }
コード例 #14
0
 public void Render(Graphics g, Rectangle R, FormulaChart fc)
 {
     Render(g, R, fc, Point.Empty);
 }
コード例 #15
0
 private string ReplaceText(FormulaChart fc, string s, out int ColorIndex)
 {
     ColorIndex = 0;
     while (true)
     {
         int i1 = s.IndexOf('{');
         int i2 = s.IndexOf('}');
         if (i2 > i1)
         {
             string s1 = s.Substring(i1 + 1, i2 - i1 - 1);
             int    i  = s1.IndexOf(':');
             string s3 = "";
             string s2 = s1;
             if (i > 0)
             {
                 s2 = s1.Substring(0, i);
                 s3 = s1.Substring(i + 1);
             }
             if (s2 == "Company")
             {
                 s2 = CompanyName;
             }
             else if (s2 == "URL")
             {
                 s2 = URL;
             }
             else if (s2 == "Time")
             {
                 s2 = ((DateTime.Now.Ticks - StartTick) / 10000).ToString() + "ms";
             }
             else
             {
                 IDataProvider idp  = fc.DataProvider;
                 FormulaArea   Area = fc.MainArea;
                 //if (DATE==null)
                 //{
                 DATE  = idp["DATE"];
                 CLOSE = idp["CLOSE"];
                 if (CLOSE == null || CLOSE.Length == 0)
                 {
                     return(s);
                 }
                 if (Bar < 0)
                 {
                     for (int j = CLOSE.Length - 1; j >= 0; j--)
                     {
                         if (!double.IsNaN(CLOSE[j]))
                         {
                             Bar = j;
                             break;
                         }
                     }
                 }
                 if (Bar < 0)
                 {
                     Bar = 0;
                 }
                 //}
                 if (string.Compare(s2, "D") == 0)
                 {
                     if (s3 == "")
                     {
                         s3 = "dd-MMM-yyyy dddd";
                     }
                     string   LastTradeTime = idp.GetStringData("LastTradeTime");
                     DateTime dtLastTrade   = fc.IndexToDate(Bar);
                     if (LastTradeTime != null && LastTradeTime != "")
                     {
                         dtLastTrade = FormulaHelper.ToDateDef(LastTradeTime, dtLastTrade);
                     }
                     s2 = dtLastTrade.ToString(s3); //,DateTimeFormatInfo.InvariantInfo
                 }
                 else
                 {
                     string s4 = idp.GetStringData(s2);
                     if (s4 != null)
                     {
                         s2 = s4;
                     }
                     else
                     {
                         try
                         {
                             double Last = 0;
                             //if (s3=="") s3 = "f2";
                             s3 = Area.AxisY.Format;
                             if (string.Compare(s2, "Change", true) == 0)
                             {
                                 Last = GetLast();
                                 if (Bar < CLOSE.Length)
                                 {
                                     double n = CLOSE[Bar];
                                     ColorIndex = GetColorIndex(Last, n);
                                     string Percent = ((n - Last) / Last).ToString("p2"); //,NumberFormatInfo.InvariantInfo
                                     if (!Percent.StartsWith("-"))
                                     {
                                         Percent = "+" + Percent;
                                     }
                                     if (s3 == "")
                                     {
                                         s3 = "f" + FormulaHelper.TestBestFormat(n, 2);
                                     }
                                     s2 = (n - Last).ToString(s3) + "(" + Percent + ")"; //,NumberFormatInfo.InvariantInfo
                                 }
                             }
                             else
                             {
                                 double d = 0;
                                 if (s2 == "LC")
                                 {
                                     d = GetLast();
                                 }
                                 else
                                 {
                                     FormulaData fd = idp[s2];
                                     double[]    dd = null;
                                     if (!object.Equals(fd, null))
                                     {
                                         dd = fd.Data;
                                     }
                                     if (dd != null && Bar < dd.Length)
                                     {
                                         Last = GetLast();
                                         d    = dd[Bar];
                                         if (s2 == "VOLUME")
                                         {
                                             s3         = "f0";
                                             ColorIndex = GetColorIndex(Last, CLOSE[Bar]);
                                         }
                                         else
                                         {
                                             ColorIndex = GetColorIndex(Last, d);
                                         }
                                     }
                                     else
                                     {
                                         d = double.NaN;
                                     }
                                 }
                                 if (s3 == "")
                                 {
                                     s3 = "f" + FormulaHelper.TestBestFormat(d, 2);
                                 }
                                 s2 = FormulaHelper.FormatDouble(d, s3);
                             }
                         }
                         catch
                         {
                             s2 = "";
                         }
                     }
                 }
             }
             s = s.Substring(0, i1) + s2 + s.Substring(i2 + 1);
         }
         else
         {
             break;
         }
     }
     return(s);
 }
コード例 #16
0
ファイル: DemoForm.cs プロジェクト: traderdata/COMPONENTES
 private void ChartControl_CursorPosChanged(Easychart.Finance.FormulaChart Chart, int Pos, Easychart.Finance.DataProvider.IDataProvider idp)
 {
     //lClose.Text = "Volume="+idp["VOLUME"][Pos] +"   $"+idp["CLOSE"][Pos].ToString();
 }