private SelectedPointInfo GetBlockInfo(KLineBar_KLineData chart, KLineBar_KLineData lastChart) { SelectedPointInfo b = new SelectedPointInfo(); b.LineHeight = 20; b.Width = 58; b.StartPoint = new Point(drawer.DisplayRect.X - b.Width, drawer.DisplayRect.Y); double lastEndPrice = lastChart != null ? lastChart.End : chart.Start; Pen pen = new Pen(Color.White); Brush brushNormal = new SolidBrush(Color.White); Font font = new Font("New Times Roman", 10, FontStyle.Regular); b.Lines.Add(new BlockLineInfo(FormatTime(chart.Time), brushNormal, font)); b.Lines.Add(new BlockLineInfo("开盘", brushNormal, font)); b.Lines.Add(new BlockLineInfo(chart.Start.ToString(), GetPriceBrush(chart.Start, lastEndPrice), font)); b.Lines.Add(new BlockLineInfo("最高", brushNormal, font)); b.Lines.Add(new BlockLineInfo(chart.High.ToString(), GetPriceBrush(chart.High, lastEndPrice), font)); b.Lines.Add(new BlockLineInfo("最低", brushNormal, font)); b.Lines.Add(new BlockLineInfo(chart.Low.ToString(), GetPriceBrush(chart.Low, lastEndPrice), font)); b.Lines.Add(new BlockLineInfo("收盘", brushNormal, font)); b.Lines.Add(new BlockLineInfo(chart.End.ToString(), GetPriceBrush(chart.End, lastEndPrice), font)); double uprange = Math.Round(chart.End - lastEndPrice, 2); b.Lines.Add(new BlockLineInfo(uprange.ToString(), GetPriceBrush(uprange, 0), font)); //涨幅 //double uppercent = Math.Round((chart.EndPrice - lastEndPrice) / lastEndPrice,2); double uppercent = Math.Round(uprange / lastEndPrice * 100, 2); b.Lines.Add(new BlockLineInfo(uppercent.ToString(), GetPriceBrush(uppercent, 0), font)); return(b); }
public SelectedPointInfo GetBlockInfo(int index) { IKLineData data = drawer.DataProvider.GetKLineData(); KLineBar_KLineData chart = new KLineBar_KLineData(data, index); KLineBar_KLineData lastChart; if (index == 0) { lastChart = null; } else { lastChart = new KLineBar_KLineData(data, index - 1); } return(GetBlockInfo(chart, lastChart)); }