public FormulaXFormat(double Days100Pixel, string Interval, string XFormat) { this.xCursorFormat = "yyyy-MM-dd dddd"; this.days100Pixel = Days100Pixel; this.interval = DataCycle.Parse(Interval); this.xFormat = XFormat; }
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { if (value is string) { return(DataCycle.Parse((string)value)); } return(base.ConvertFrom(context, culture, value)); }
/// <summary> /// Copy attribute from another FormulaAxisX /// </summary> /// <param name="fax"></param> public void CopyFrom(FormulaAxisX fax) { visible = fax.visible; DateFormatProvider = fax.DateFormatProvider; autoScale = fax.autoScale; format = fax.format; majorTick = fax.majorTick.Clone(); minorTick = fax.minorTick.Clone(); back = (FormulaBack)fax.back.Clone(); labelFont = (Font)fax.labelFont.Clone(); labelBrush = fax.labelBrush.Clone(); axisLabelAlign = fax.axisLabelAlign; DataCycle = fax.DataCycle; cursorFormat = fax.cursorFormat; height = fax.height; }
public int Add(DataCycle value) { return(List.Add(value)); }
public FormulaXFormat(double Days100Pixel, string Interval, string XFormat) : this() { this.days100Pixel = Days100Pixel; this.interval = DataCycle.Parse(Interval); this.xFormat = XFormat; }
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 { } }
public Hashtable GetCycleData(Easychart.Finance.DataCycle dc) { if (((dc.CycleBase == DataCycleBase.DAY) && (dc.Repeat == 1)) && !this.Adjusted) { return(this.htData); } Hashtable hashtable = (Hashtable)this.htAllCycle[dc.ToString()]; if (hashtable == null) { if (this.htData == null) { return(this.htData); } Hashtable htData = this.htData; if (this.intradayInfo != null) { htData = this.DoExpandMinute(htData); } if (htData["CLOSE"] != null) { if (htData["OPEN"] == null) { htData["OPEN"] = htData["CLOSE"]; } if (htData["HIGH"] == null) { htData["HIGH"] = htData["CLOSE"]; } if (htData["LOW"] == null) { htData["LOW"] = htData["CLOSE"]; } } double[] oDATE = (double[])htData["DATE"]; if (oDATE == null) { return(null); } int[] nEWDATE = new int[oDATE.Length]; int num = -2147483648; int num2 = -1; for (int i = 0; i < oDATE.Length; i++) { int sequence = this.DataCycle.GetSequence(oDATE[i]); if (sequence > num) { num2++; } nEWDATE[i] = num2; num = sequence; } hashtable = new Hashtable(); foreach (string str in htData.Keys) { hashtable[str] = new double[num2 + 1]; } bool flag = (this.Adjusted && (htData["ADJCLOSE"] != null)) && (htData["CLOSE"] != null); double[] cLOSE = (double[])htData["CLOSE"]; double[] aDJCLOSE = (double[])htData["ADJCLOSE"]; foreach (string str2 in htData.Keys) { MergeCycleType oPEN; bool doAdjust = flag; doAdjust = false; switch (str2) { case "DATE": oPEN = MergeCycleType.OPEN; break; case "VOLUME": case "AMOUNT": oPEN = MergeCycleType.SUM; break; default: try { oPEN = (MergeCycleType)Enum.Parse(typeof(MergeCycleType), str2); doAdjust = true; } catch { oPEN = MergeCycleType.CLOSE; } break; } this.MergeCycle(oDATE, nEWDATE, cLOSE, aDJCLOSE, (double[])htData[str2], (double[])hashtable[str2], oPEN, doAdjust); } this.htAllCycle[dc.ToString()] = hashtable; } return(hashtable); }