Ejemplo n.º 1
0
        public void DrawCursor(Graphics g, FormulaArea fa, FormulaData fd)
        {
            float x = this.Rect.X + fa.Canvas.GetX(this.CursorPos);
            float y = this.Rect.Y + fa.AxisY.CalcY(fd[this.CursorPos]);

            this.DrawCursor(g, x, y);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Render the X-Axis
        /// </summary>
        /// <param name="Canvas">FormulaCanvas</param>
        /// <param name="fa">FormulaArea</param>
        public void Render(FormulaCanvas Canvas, FormulaArea fa)
        {
            if (Visible)
            {
                if (fa.AxisY.AxisPos == AxisPos.Left)
                {
                    Rect.X--;
                }
                Graphics g = Canvas.CurrentGraph;
                Back.Render(g, Rect);
            }

            if (majorTick.Visible || minorTick.Visible)
            {
                double[] Date;
                Date          = fa.Parent.DataProvider["DATE"];
                fdDate        = new FormulaData(Date);
                fdDate.Canvas = Canvas;
                fdDate.AxisY  = fa.AxisY;

                PointF[] pfs = fdDate.GetPoints();

                majorTick.DataCycle          = DataCycle;
                majorTick.Format             = Format;
                majorTick.DateFormatProvider = DateFormatProvider;

                majorTick.DrawXAxisTick(Canvas, Date, fdDate, pfs, this, IntradayInfo);
                minorTick.DrawXAxisTick(Canvas, Date, fdDate, pfs, this, IntradayInfo);
            }
        }
Ejemplo n.º 3
0
 public void Render(FormulaCanvas Canvas, FormulaArea fa)
 {
     if (this.Visible)
     {
         if (fa.AxisY.AxisPos == AxisPos.Left)
         {
             this.Rect.X--;
         }
         Graphics currentGraph = Canvas.CurrentGraph;
         this.Back.Render(currentGraph, this.Rect);
     }
     if (this.MajorTick.Visible || this.MinorTick.Visible)
     {
         double[] data = fa.Parent.DataProvider["DATE"];
         this.fdDate        = new FormulaData(data);
         this.fdDate.Canvas = Canvas;
         this.fdDate.AxisY  = fa.AxisY;
         PointF[] points = this.fdDate.GetPoints();
         this.MajorTick.DataCycle          = this.DataCycle;
         this.MajorTick.Format             = this.Format;
         this.MajorTick.DateFormatProvider = this.DateFormatProvider;
         this.MajorTick.DrawXAxisTick(Canvas, data, this.fdDate, points, this, this.IntradayInfo);
         this.MinorTick.DrawXAxisTick(Canvas, data, this.fdDate, points, this, this.IntradayInfo);
     }
 }
Ejemplo n.º 4
0
        public static FormulaData operator -(FormulaData f1)
        {
            FormulaData data = new FormulaData(f1.Length);

            for (int i = 0; i < f1.Length; i++)
            {
                data.Data[i] = -f1.Data[i];
            }
            return(data);
        }
Ejemplo n.º 5
0
        public static FormulaData operator -(FormulaData f1, FormulaData f2)
        {
            MakeSameLength(f1, f2);
            FormulaData data = new FormulaData(f1.Length);

            for (int i = 0; i < f1.Length; i++)
            {
                data.Data[i] = f1.Data[i] - f2.Data[i];
            }
            return(data);
        }
Ejemplo n.º 6
0
        public static FormulaData operator -(FormulaData f1)
        {
            FormulaData f = new FormulaData(f1.Length);

            for (int i = 0; i < f1.Length; i++)
            {
                f.Data[i] = -f1.Data[i];
            }
            f.FormulaType = f1.FormulaType;
            return(f);
        }
Ejemplo n.º 7
0
 public void AdjustCursorByPos(Graphics g, int NewPos, int NewStart, bool NeedDrawCursor)
 {
     foreach (FormulaArea area in this.Areas)
     {
         if (!area.IsMain())
         {
             continue;
         }
         double[]    numArray = this.DataProvider["DATE"];
         FormulaData fd       = this.DataProvider["CLOSE"];
         if (fd.Length <= 0)
         {
             break;
         }
         int start = this.Start;
         this.Start = NewStart;
         if (this.Start < 0)
         {
             this.Start = 0;
         }
         if (this.Start > (fd.Length - 1))
         {
             this.Start = fd.Length - 1;
         }
         if (NewPos < 0)
         {
             NewPos = 0;
         }
         if (NewPos > (fd.Length - 1))
         {
             NewPos = fd.Length - 1;
         }
         if (NewPos != this.CursorPos)
         {
             if (NewPos < area.Canvas.Stop)
             {
                 this.Start += area.Canvas.Stop - NewPos;
             }
             if (NewPos > ((fd.Length - 1) - this.Start))
             {
                 this.Start = (fd.Length - 1) - NewPos;
             }
             this.CursorPos = NewPos;
         }
         if (NeedDrawCursor)
         {
             this.DrawCursor(g, area, fd);
         }
     }
 }
Ejemplo n.º 8
0
        public static FormulaData operator ~(FormulaData f1)
        {
            if (FormulaBase.Testing)
            {
                return(FormulaBase.TestData(0, new FormulaData[] { f1 }));
            }
            FormulaData data = new FormulaData(f1.Length);

            for (int i = 0; i < f1.Length; i++)
            {
                data.Data[i] = ~((int)f1.Data[i]);
            }
            return(data);
        }
Ejemplo n.º 9
0
 public static void MakeSameLength(FormulaData f1, FormulaData f2)
 {
     if (f1.Length != f2.Length)
     {
         if (f1.Length < f2.Length)
         {
             f1.FillTo(f2.Length);
         }
         else
         {
             f2.FillTo(f1.Length);
         }
     }
 }
Ejemplo n.º 10
0
        public static FormulaData operator --(FormulaData f1)
        {
            if (FormulaBase.Testing)
            {
                return(FormulaBase.TestData(0, f1));
            }
            FormulaData nf = new FormulaData(f1.Length);

            for (int i = 0; i < f1.Length; i++)
            {
                nf.Data[i] = f1.Data[i] - 1;
            }
            return(nf);
        }
Ejemplo n.º 11
0
        public static FormulaData operator -(FormulaData f1, FormulaData f2)
        {
            MakeSameLength(f1, f2);
            FormulaData f = new FormulaData(f1.Length);

            for (int i = 0; i < f1.Length; i++)
            {
                f.Data[i] = f1.Data[i] - f2.Data[i];
            }
            if (f1.FormulaType == FormulaType.Const && f2.FormulaType == FormulaType.Const)
            {
                f.FormulaType = FormulaType.Const;
            }
            return(f);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Return the formula data by name
 /// </summary>
 public FormulaData this[string Name]
 {
     get
     {
         for (int i = 0; i < List.Count; i++)
         {
             FormulaData fd = (FormulaData)List[i];
             if (Name == i.ToString() || (fd.Name != null && string.Compare(fd.Name.Trim(), Name, true) == 0))
             {
                 return(fd);
             }
         }
         return(null);
     }
 }
Ejemplo n.º 13
0
        public static FormulaData operator *(FormulaData f1, FormulaData f2)
        {
            MakeSameLength(f1, f2);
            if (FormulaBase.Testing)
            {
                return(FormulaBase.TestData(0, new FormulaData[] { f1, f2 }));
            }
            FormulaData data = new FormulaData(f1.Length);

            for (int i = 0; i < f1.Length; i++)
            {
                data.Data[i] = f1.Data[i] * f2.Data[i];
            }
            return(data);
        }
Ejemplo n.º 14
0
        public static FormulaData operator %(FormulaData f1, FormulaData f2)
        {
            MakeSameLength(f1, f2);
            if (FormulaBase.Testing)
            {
                return(FormulaBase.TestData(0, f1, f2));
            }
            FormulaData f = new FormulaData(f1.Length);

            for (int i = 0; i < f1.Length; i++)
            {
                f.Data[i] = f1.Data[i] % f2.Data[i];
            }
            return(f);
        }
Ejemplo n.º 15
0
 public void DrawCursor(Graphics g)
 {
     foreach (FormulaArea area in this.Areas)
     {
         if (area.IsMain())
         {
             FormulaData data = this.DataProvider["CLOSE"];
             if ((this.CursorPos >= 0) && (this.CursorPos < data.Length))
             {
                 float x = this.Rect.X + area.Canvas.GetX(this.CursorPos);
                 float y = this.Rect.Y + area.AxisY.CalcY(data[this.CursorPos]);
                 this.DrawCursor(g, x, y, false);
             }
         }
     }
 }
Ejemplo n.º 16
0
 public override bool Equals(object obj)
 {
     if (obj is FormulaData)
     {
         FormulaData data = (FormulaData)obj;
         for (int i = 0; i < data.Length; i++)
         {
             if (data.Data[i] != this.Data[i])
             {
                 return(false);
             }
         }
         return(true);
     }
     return(base.Equals(obj));
 }
Ejemplo n.º 17
0
        public object Clone()
        {
            FormulaData nd = new FormulaData(this);

            nd.Canvas           = Canvas;
            nd.AxisYIndex       = AxisYIndex;
            nd.AxisY            = AxisY;
            nd.AxisX            = AxisX;
            nd.Name             = Name;
            nd.RenderType       = RenderType;
            nd.FormulaType      = FormulaType;
            nd.Align            = Align;
            nd.Dot              = Dot;
            nd.FormulaUpColor   = FormulaUpColor;
            nd.FormulaDownColor = FormulaDownColor;

            nd.DashStyle   = DashStyle;
            nd.LineWidth   = LineWidth;
            nd.Transform   = Transform;
            nd.PercentView = PercentView;
            nd.Format      = Format;
            nd.Smoothing   = Smoothing;
            //nd.TextInvisible = TextInvisible;
            nd.ValueTextMode = ValueTextMode;
            nd.ParentFormula = ParentFormula;

            nd.LinePen         = LinePen;
            nd.AreaBrush       = AreaBrush;
            nd.TextFont        = TextFont;
            nd.NameFont        = NameFont;
            nd.LabelIndex      = LabelIndex;
            nd.AxisMargin      = AxisMargin;
            nd.VAlign          = VAlign;
            nd.LastValueInAxis = LastValueInAxis;
            nd.SameColor       = SameColor;
            nd.htPoints        = htPoints;
            if (htDataArray != null)
            {
                foreach (string Key in SubData.Keys)
                {
                    nd[Key] = (double[])((double[])SubData[Key]).Clone();
                }
            }
            return(nd);
        }
Ejemplo n.º 18
0
        private string GetTextData(FormulaPackage FormulaDataArray, string Separator, bool ShowHeader)
        {
            FormulaData data = this.DataProvider["DATE"];

            data.Name = "Date";
            ArrayList list = new ArrayList();

            list.Add(data);
            list.AddRange(FormulaDataArray);
            StringBuilder builder = new StringBuilder();

            if (list.Count > 0)
            {
                for (int i = -(ShowHeader ? 1 : 0); i < data.Length; i++)
                {
                    for (int j = 0; j < list.Count; j++)
                    {
                        FormulaData data2 = (FormulaData)list[j];
                        if (ShowHeader && (i < 0))
                        {
                            builder.Append(data2.Name);
                        }
                        if (i >= 0)
                        {
                            if (j == 0)
                            {
                                builder.Append(DateTime.FromOADate(data2[i]).ToString("dd-MMM-yy", DateTimeFormatInfo.InvariantInfo));
                            }
                            else
                            {
                                builder.Append(data2[i].ToString("f2", NumberFormatInfo.InvariantInfo));
                            }
                        }
                        if (j < (FormulaDataArray.Count - 1))
                        {
                            builder.Append(Separator);
                        }
                    }
                    builder.Append("\r\n");
                }
            }
            return(builder.ToString());
        }
Ejemplo n.º 19
0
        public static FormulaData operator /(FormulaData f1, FormulaData f2)
        {
            MakeSameLength(f1, f2);
            if (FormulaBase.Testing)
            {
                return(FormulaBase.TestData(0, f1, f2));
            }
            FormulaData f = new FormulaData(f1.Length);

            for (int i = 0; i < f1.Length; i++)
            {
                f.Data[i] = f1.Data[i] / f2.Data[i];
            }
            if (f1.FormulaType == FormulaType.Const && f2.FormulaType == FormulaType.Const)
            {
                f.FormulaType = FormulaType.Const;
            }
            return(f);
        }
Ejemplo n.º 20
0
 public override bool Equals(object obj)
 {
     if (obj is FormulaData)
     {
         FormulaData f = (FormulaData)obj;
         for (int i = 0; i < f.Length; i++)
         {
             if (f.Data[i] != Data[i])
             {
                 return(false);
             }
         }
         return(true);
     }
     else
     {
         return(base.Equals(obj));
     }
 }
Ejemplo n.º 21
0
        public static FormulaData operator !(FormulaData f1)//op_LogicalNot(FormulaData f1)
        {
            if (FormulaBase.Testing)
            {
                return(FormulaBase.TestData(0, new FormulaData[] { f1 }));
            }
            FormulaData data = new FormulaData(f1.Length);

            for (int i = 0; i < f1.Length; i++)
            {
                if (f1.Data[i] == 0.0)
                {
                    data.Data[i] = 1.0;
                }
                else
                {
                    data.Data[i] = 0.0;
                }
            }
            return(data);
        }
Ejemplo n.º 22
0
        private double GetLastValue(FormulaCanvas Canvas, FormulaArea Area, int LineIndex, out bool IsUp)
        {
            LatestValueType lvt = Area.Parent.LatestValueType;
            FormulaData     f   = Area.FormulaDataArray[LineIndex];
            double          d   = double.NaN;

            IsUp = true;
            if (Area.AxisYs[f.AxisYIndex] == this &&
                ((lvt == LatestValueType.All && f.ValueTextMode != ValueTextMode.None /*!f.TextInvisible*/) ||
                 ((lvt == LatestValueType.All || lvt == LatestValueType.StockOnly) && f.RenderType == FormulaRenderType.STOCK) ||
                 (lvt == LatestValueType.Custom && f.LastValueInAxis)))
            {
                int Start = Math.Max(0, Canvas.Start);
                if (f.Length > Start)
                {
                    int LastIndex = f.Length - 1 - Start;
                    for (int k = f.Length - 1 - Start; k >= 0; k--)
                    {
                        if (!double.IsNaN(f[k]))
                        {
                            LastIndex = k;
                            break;
                        }
                    }

                    d = f[LastIndex];
                    if (LastIndex > 0)
                    {
                        if (f[LastIndex - 1] > d)
                        {
                            IsUp = false;
                        }
                    }
                }
            }
            return(d);
        }
Ejemplo n.º 23
0
 public int IndexOf(FormulaData fa)
 {
     return(base.List.IndexOf(fa));
 }
Ejemplo n.º 24
0
 public virtual void Add(FormulaData fd)
 {
     base.List.Add(fd);
 }
Ejemplo n.º 25
0
        public void Render(FormulaCanvas Canvas, FormulaArea Area)
        {
            this.CalcLableLine(Canvas);
            Rectangle frameRect    = this.FrameRect;
            Graphics  currentGraph = Canvas.CurrentGraph;
            int       left         = frameRect.Left;

            if (this.AxisPos == Easychart.Finance.AxisPos.Left)
            {
                left = frameRect.Right;
            }
            int tickWidth = this.MajorTick.TickWidth;

            if (this.MajorTick.FullTick)
            {
                tickWidth = frameRect.Width;
            }
            if (this.MajorTick.Inside)
            {
                tickWidth = -tickWidth;
            }
            int width = this.MinorTick.TickWidth;

            if (this.MinorTick.FullTick)
            {
                width = frameRect.Width;
            }
            if (this.MinorTick.Inside)
            {
                width = -width;
            }
            if (this.AxisPos == Easychart.Finance.AxisPos.Left)
            {
                tickWidth = -tickWidth;
                width     = -width;
            }
            this.Back.Render(currentGraph, frameRect);
            float maxValue = float.MaxValue;

            for (int i = 0; i < this.LabelPos.Length; i++)
            {
                if ((this.LabelPos[i] >= Canvas.Rect.Top) && (this.LabelPos[i] <= Canvas.Rect.Bottom))
                {
                    int    num6 = left;
                    string text = (this.LabelValues[i] / this.MultiplyFactor).ToString(this.Format);
                    SizeF  ef   = currentGraph.MeasureString(text, this.LabelFont);
                    if (this.AxisPos == Easychart.Finance.AxisPos.Left)
                    {
                        num6 -= (int)ef.Width;
                        if (tickWidth < 0)
                        {
                            num6 += tickWidth;
                        }
                    }
                    else if (tickWidth > 0)
                    {
                        num6 += tickWidth;
                    }
                    float y = this.LabelPos[i] - (Canvas.LabelHeight / 2f);
                    if ((maxValue - y) > ef.Height)
                    {
                        currentGraph.DrawString(text, this.LabelFont, this.LabelBrush, (float)num6, y);
                        maxValue = y;
                    }
                    if (this.MajorTick.ShowLine)
                    {
                        currentGraph.DrawLine(this.MajorTick.LinePen, (float)Canvas.Rect.Left, this.LabelPos[i], (float)Canvas.Rect.Right, this.LabelPos[i]);
                    }
                    if (this.MajorTick.ShowTick)
                    {
                        currentGraph.DrawLine(this.MajorTick.TickPen, (float)left, this.LabelPos[i], (float)(left + tickWidth), this.LabelPos[i]);
                    }
                }
                if ((this.MinorTick.Visible && !double.IsInfinity((double)this.LabelPos[i])) && (i != (this.LabelPos.Length - 1)))
                {
                    int count = this.MinorTick.Count;
                    if (this.MinorTick.MinimumPixel != 0)
                    {
                        count = (int)((this.LabelPos[i] - this.LabelPos[i + 1]) / ((float)this.MinorTick.MinimumPixel));
                    }
                    for (float j = this.LabelPos[i]; j > this.LabelPos[i + 1]; j += (this.LabelPos[i + 1] - this.LabelPos[i]) / ((float)count))
                    {
                        if ((j >= frameRect.Top) && (j <= frameRect.Bottom))
                        {
                            currentGraph.DrawLine(this.MinorTick.TickPen, (float)left, j, (float)(left + width), j);
                        }
                    }
                }
            }
            if (this.MultiplyFactor != 1.0)
            {
                string    str2 = this.MultiplyFactorToString();
                Rectangle r    = frameRect;
                r.Y = (int)((r.Bottom - Canvas.LabelHeight) - 2f);
                if (Area.AxisX.Visible)
                {
                    r.Y -= (int)((Canvas.LabelHeight / 2f) + 1f);
                }
                r.Height = (int)Canvas.LabelHeight;
                r.Width  = ((int)currentGraph.MeasureString(str2, this.LabelFont).Width) + 1;
                if (this.AxisPos == Easychart.Finance.AxisPos.Left)
                {
                    r.Offset((frameRect.Width - r.Width) - 2, 0);
                }
                this.MultiplyBack.Render(currentGraph, r);
                currentGraph.DrawString(str2, this.LabelFont, this.LabelBrush, r);
            }
            if (Area.Selected && (Area.SelectedPen != null))
            {
                Rectangle rect = frameRect;
                rect.Inflate(-1, -1);
                currentGraph.DrawRectangle(Area.SelectedPen, rect);
            }
            LatestValueType latestValueType = Area.Parent.LatestValueType;

            if (latestValueType != LatestValueType.None)
            {
                for (int k = 0; k < Area.FormulaDataArray.Count; k++)
                {
                    FormulaData data = Area.FormulaDataArray[k];
                    if ((!data.TextInvisible || (data.RenderType == FormulaRenderType.STOCK)) && (((latestValueType == LatestValueType.All) || ((latestValueType == LatestValueType.StockOnly) && (Area.AxisYs[data.AxisYIndex] == this))) || ((latestValueType == LatestValueType.Custom) && data.LastValueInAxis)))
                    {
                        FormulaLabel label = Area.Labels[2];
                        if (latestValueType != LatestValueType.StockOnly)
                        {
                            label = (FormulaLabel)label.Clone();
                            Pen currentPen = Area.GetCurrentPen(k);
                            label.BGColor = currentPen.Color;
                            if (label.BGColor == Color.Empty)
                            {
                                label.BGColor = Color.White;
                            }
                            label.SetProperTextColor();
                        }
                        if (data.Length > Canvas.Start)
                        {
                            double d = data[(data.Length - 1) - Canvas.Start];
                            if (((latestValueType == LatestValueType.StockOnly) && (data.Length > (Canvas.Start + 1))) && (data[(data.Length - 2) - Canvas.Start] > d))
                            {
                                label = Area.Labels[1];
                            }
                            string       str3  = " " + ((d / this.MultiplyFactor)).ToString(this.Format);
                            FormulaAlign right = FormulaAlign.Left;
                            if (this.AxisPos == Easychart.Finance.AxisPos.Left)
                            {
                                right = FormulaAlign.Right;
                            }
                            label.DrawString(currentGraph, str3, this.LabelFont, label.TextBrush, VerticalAlign.Bottom, right, new PointF((float)left, this.CalcY(d)), false);
                        }
                    }
                }
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Render Y-axis
        /// </summary>
        /// <param name="Canvas"></param>
        /// <param name="Area"></param>
        public void Render(FormulaCanvas Canvas, FormulaArea Area)
        {
            CalcLableLine(Canvas);
            Rectangle R = FrameRect;            //Canvas.FrameRect;
            Graphics  g = Canvas.CurrentGraph;

            int X = R.Left;

            if (AxisPos == AxisPos.Left)
            {
                X = R.Right;
            }

            int w1 = majorTick.TickWidth;

            if (majorTick.FullTick)
            {
                w1 = R.Width;
            }
            if (majorTick.Inside)
            {
                w1 = -w1;
            }

            int w2 = MinorTick.TickWidth;

            if (MinorTick.FullTick)
            {
                w2 = R.Width;
            }
            if (MinorTick.Inside)
            {
                w2 = -w2;
            }

            if (AxisPos == AxisPos.Left)
            {
                w1 = -w1;
                w2 = -w2;
            }

            Back.Render(g, R);

            if (!LineBinded)
            {
                return;
            }

            Pen MajorLinePen = majorTick.LinePen.GetPen();
            Pen MajorTickPen = majorTick.TickPen.GetPen();
            Pen MinorLinePen = minorTick.LinePen.GetPen();
            Pen MinorTickPen = minorTick.TickPen.GetPen();

            float LastY = float.MaxValue;
            Brush LB    = labelBrush.GetBrush();

            for (int i = 0; i < LabelPos.Length; i++)
            {
                if (LabelPos[i] >= Canvas.Rect.Top && LabelPos[i] <= Canvas.Rect.Bottom)
                {
                    int    TextX     = X;
                    double d         = (LabelValues[i] / MultiplyFactor);
                    string s         = FormulaHelper.FormatDouble(d, format);
                    SizeF  LabelSize = g.MeasureString(s, LabelFont);
                    if (AxisPos == AxisPos.Left)
                    {
                        TextX -= (int)LabelSize.Width;
                        if (w1 < 0)
                        {
                            TextX += w1;
                        }
                    }
                    else
                    {
                        if (w1 > 0)
                        {
                            TextX += w1;
                        }
                    }
                    float TextY = LabelPos[i] - Canvas.LabelHeight / 2;

                    if (majorTick.ShowText && LastY - TextY > LabelSize.Height)
                    {
                        g.DrawString(
                            s,
                            labelFont,
                            LB,
                            TextX,
                            TextY);
                        LastY = TextY;
                    }

                    if (majorTick.ShowLine)
                    {
                        g.DrawLine(MajorLinePen, Canvas.Rect.Left, LabelPos[i], Canvas.Rect.Right, LabelPos[i]);
                    }

                    if (majorTick.ShowTick)
                    {
                        g.DrawLine(MajorTickPen,
                                   X, LabelPos[i],
                                   X + w1, LabelPos[i]);
                    }
                }

                if (minorTick.Visible && !double.IsInfinity(LabelPos[i]))
                {
                    if (i != LabelPos.Length - 1)
                    {
                        int TickCount = MinorTick.Count;
                        if (minorTick.MinimumPixel != 0)
                        {
                            TickCount = (int)((LabelPos[i] - LabelPos[i + 1]) / MinorTick.MinimumPixel);
                        }

                        if (minorTick.ShowTick)
                        {
                            for (float d1 = LabelPos[i]; d1 > LabelPos[i + 1]; d1 += (float)(LabelPos[i + 1] - LabelPos[i]) / TickCount)
                            {
                                if (d1 >= R.Top && d1 <= R.Bottom)
                                {
                                    g.DrawLine(MinorTickPen,
                                               X, d1,
                                               X + w2, d1);
                                }
                            }
                        }
                    }
                }
            }

//			if (customTick.Visible)
//			{
//				for(int i=0; i<CustomPos.Length; i++)
//				{
//					if (customTick.ShowText && LastY-TextY>LabelSize.Height)
//					{
//						g.DrawString(
//							s,
//							labelFont,
//							LB,
//							TextX,
//							TextY);
//						LastY = TextY;
//					}
//
//					if (customTick.ShowLine)
//						g.DrawLine(MajorLinePen,Canvas.Rect.Left,CustomPos[i],Canvas.Rect.Right,CustomPos[i]);
//				}
//			}

            // Draw multiply factor
            if (MultiplyFactor != 1)
            {
                string    s  = MultiplyFactorToString();
                Rectangle MR = R;
                MR.Y = (int)(MR.Bottom - Canvas.LabelHeight - 2);
                if (Area.AxisX.Visible)
                {
                    MR.Y -= (int)(Canvas.LabelHeight / 2 + 1);
                }
                MR.Height = (int)Canvas.LabelHeight;
                MR.Width  = (int)g.MeasureString(s, LabelFont).Width + 1;

                if (AxisPos == AxisPos.Left)
                {
                    MR.Offset(R.Width - MR.Width - 2, 0);
                }

                MultiplyBack.Render(g, MR);
                g.DrawString(s, LabelFont, LB, MR);
            }

            //Draw selected frame
            if (Area.Selected)
            {
                if (Area.SelectedPen != null)
                {
                    Rectangle SelectRect = R;
                    SelectRect.Inflate(-1, -1);
                    g.DrawRectangle(Area.SelectedPen, SelectRect);
                }
            }

            LatestValueType lvt = Area.Parent.LatestValueType;

            if (lvt != LatestValueType.None)
            {
                for (int i = 0; i < Area.FormulaDataArray.Count; i++)
                {
                    bool   IsUp;
                    double d = GetLastValue(Canvas, Area, i, out IsUp);
                    if (!double.IsNaN(d))
                    {
//					}
                        FormulaData f = Area.FormulaDataArray[i];
//					if (Area.AxisYs[f.AxisYIndex]==this &&
//						((lvt==LatestValueType.All && !f.TextInvisible) ||
//						((lvt==LatestValueType.All || lvt==LatestValueType.StockOnly) && f.RenderType==FormulaRenderType.STOCK) ||
//						(lvt==LatestValueType.Custom && f.LastValueInAxis)	))
//					{
                        FormulaLabel fl = Area.Labels[2];
                        if (lvt != LatestValueType.StockOnly)
                        {
                            fl = (FormulaLabel)fl.Clone();
                            Pen p = Area.GetCurrentPen(f, i);
                            fl.BGColor = Color.FromArgb(255, p.Color);
                            if (fl.BGColor == Color.Empty)
                            {
                                fl.BGColor = Color.White;
                            }
                            fl.SetProperTextColor();
                        }
//						int Start = Math.Max(0,Canvas.Start);
//						if (f.Length>Start)
//						{
//							int LastIndex = f.Length-1-Start;
//							for(int k = f.Length-1-Start; k>=0; k--)
//								if (!double.IsNaN(f[k]))
//								{
//									LastIndex = k;
//									break;
//								}
//
//							double d = f[LastIndex];
                        if (lvt == LatestValueType.StockOnly)
                        {
//								if (LastIndex>0)
//									if (f[LastIndex-1]>d)
                            if (!IsUp)
                            {
                                fl = Area.Labels[1];
                            }
                        }
                        string       s  = " " + FormulaHelper.FormatDouble(d / MultiplyFactor, format);
                        FormulaAlign fa = FormulaAlign.Left;
                        if (AxisPos == AxisPos.Left)
                        {
                            fa = FormulaAlign.Right;
                        }
                        fl.DrawString(g, s, LabelFont, fl.TextBrush, VerticalAlign.Bottom, fa, new PointF(X, CalcY(d)), false);
//						}
                    }
                }
            }
        }
Ejemplo n.º 27
0
 public FormulaData(FormulaData f) : this(f.Length)
 {
     f.Data.CopyTo(this.Data, 0);
 }
Ejemplo n.º 28
0
 public virtual void Insert(int Index, FormulaData fd)
 {
     base.List.Insert(Index, fd);
 }
Ejemplo n.º 29
0
 public void Remove(FormulaData value)
 {
     base.List.Remove(value);
 }
Ejemplo n.º 30
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);
 }