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); }
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); } }
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); }
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); }
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); }
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); } } }
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); } } }
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); }
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)); }
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); } } } }
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()); }
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); }
public void Remove(FormulaData value) { base.List.Remove(value); }
public virtual void Insert(int Index, FormulaData fd) { base.List.Insert(Index, fd); }
public int IndexOf(FormulaData fa) { return(base.List.IndexOf(fa)); }
public virtual void Add(FormulaData fd) { base.List.Add(fd); }
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 == 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 == 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 == 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 == 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 = Area.FormulaDataArray.Count - 1; k >= 0; k--) //(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 == AxisPos.Left) { right = FormulaAlign.Right; } label.DrawString(currentGraph, str3, this.LabelFont, label.TextBrush, VerticalAlign.Bottom, right, new PointF((float)left, this.CalcY(d)), false); } } } } }
public FormulaData(FormulaData f) : this(f.Length) { f.Data.CopyTo(this.Data, 0); }
public void DrawXAxisTick(FormulaCanvas Canvas, double[] Date, FormulaData fdDate, PointF[] pfs, FormulaAxisX fax, ExchangeIntraday ei) { if (this.DataCycle != null) { int num = 0; int sequence = 0; string str = ""; int num3 = -10000; int num4 = -1; Graphics currentGraph = Canvas.CurrentGraph; double num5 = 0.0; if (Date.Length > 0) { num5 = Date[Date.Length - 1] - Date[0]; } double[] numArray = Date; if ((ei != null) && ei.NativeCycle) { numArray = new double[Date.Length]; for (int j = 0; j < numArray.Length; j++) { numArray[j] = ((int)Date[j]) + ei.OneDayTime(Date[j]); } } for (int i = pfs.Length - 1; i >= 0; i--) { int index = ((Date.Length - 1) - Canvas.Start) - i; double d = Date[index]; DateTime time = DateTime.FromOADate(d); sequence = this.DataCycle.GetSequence(numArray[index]); if (sequence != num) { PointF tf = pfs[i]; num = sequence; if (this.ShowLine) { int bottom = Canvas.Rect.Bottom; if (!fax.Visible) { bottom = Canvas.FrameRect.Bottom; } currentGraph.DrawLine(this.LinePen, tf.X, (float)Canvas.FrameRect.Top, tf.X, (float)bottom); } if (fax.Visible && this.ShowTick) { int tickWidth = this.TickWidth; if (this.FullTick) { tickWidth = fax.Rect.Height; } if (this.Inside) { tickWidth = -tickWidth; } currentGraph.DrawLine(this.TickPen, tf.X, (float)fax.Rect.Top, tf.X, (float)(tickWidth + fax.Rect.Top)); } string text = time.ToString(this.Format, this.DateFormatProvider); int startIndex = text.IndexOf('{'); int num13 = text.IndexOf('}'); if (num13 > startIndex) { string str2 = text.Substring(startIndex + 1, (num13 - startIndex) - 1); if (str2 != str) { text = text.Remove(startIndex, 1).Remove(num13 - 1, 1); } else { text = text.Substring(0, startIndex) + text.Substring(num13 + 1); } str = str2; } Font labelFont = fax.LabelFont; float width = currentGraph.MeasureString(text, labelFont).Width; float x = tf.X; switch (fax.AxisLabelAlign) { case AxisLabelAlign.TickCenter: x -= width / 2f; break; case AxisLabelAlign.TickLeft: x -= width; break; } if (x < fax.Rect.Left) { x = fax.Rect.Left; } if ((fax.Visible && this.ShowText) && ((num3 + this.MinimumPixel) < x)) { if (((ei == null) || ei.ShowFirstXLabel) || ((i < (pfs.Length - 1)) || (num5 > 1.0))) { currentGraph.DrawString(text, labelFont, fax.LabelBrush, x, (float)fax.Rect.Top); num3 = (int)(x + width); } num4 = i; } } } } }