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); } } }
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); }
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); } } } } }