protected internal CandleMidLineElement(CandleMidLineView view, PlotPane host, Point[] points) : base(host) { m_View = view; m_Points = points; this.Region = new Rectangle(points[0].X, 0, points[points.Length-1].X, host.Height); }
protected internal CandleMidLineElement(CandleMidLineView view, PlotPane host, Point[] points) : base(host) { m_View = view; m_Points = points; this.Region = new Rectangle(points[0].X, 0, points[points.Length - 1].X, host.Height); }
protected internal YLevelElement(PlotPane host, TimeSeries.YLevel level, float minScale, float maxScale) : base(host) { m_Level = level; // m_Style = new Style(null, getBaseStyle()); m_ScaleMin = minScale; m_ScaleMax = maxScale; computeCoords(); this.Region = new Rectangle(0, m_Y - 2, host.Width, m_Y + 2); }
protected internal YLevelElement(PlotPane host, TimeSeries.YLevel level, float minScale, float maxScale) : base(host) { m_Level = level; // m_Style = new Style(null, getBaseStyle()); m_ScaleMin = minScale; m_ScaleMax = maxScale; computeCoords(); this.Region = new Rectangle(0, m_Y-2, host.Width, m_Y+2); }
protected override Elements.Element MakeSampleElement(TimeSeriesChart chart, PlotPane pane, CandleSample sample, int x, float minScale, float maxScale) { var elm = new CandleElement(pane, sample, x, minScale, maxScale, BlackWhite); if (ShowBalloons) { elm.MouseClick += elm_MouseClick; } return(elm); }
protected internal CandleBuySellElement(CandleBuySellView view, PlotPane host, CandleSample sample, int x, float minScale, float maxScale) : base(host) { m_View = view; m_Sample = sample; m_ScaleMin = minScale; m_ScaleMax = maxScale; computeCoords(); var h = Math.Max(m_Lay_BuyHeight, m_Lay_SellHeight); this.Region = new Rectangle(x, (int)(host.Height / host.Zoom) - h, CandleView.BAR_WIDTH, h); }
protected internal CandleBuySellElement(CandleBuySellView view, PlotPane host, CandleSample sample, int x, float minScale, float maxScale) : base(host) { m_View = view; m_Sample = sample; m_ScaleMin = minScale; m_ScaleMax = maxScale; computeCoords(); var h = Math.Max(m_Lay_BuyHeight, m_Lay_SellHeight); this.Region = new Rectangle(x, (int)(host.Height / host.Zoom) - h, CandleView.BAR_WIDTH, h); }
protected internal CandleElement(PlotPane host, CandleSample candle, int x, float minScale, float maxScale) : base(host) { m_Candle = candle; // m_Style = new Style(null, getBaseStyle()); m_ScaleMin = minScale; m_ScaleMax = maxScale; m_Lay_X = x; m_Lay_W = CandleView.BAR_WIDTH; computeCoords(); this.Region = new Rectangle(m_Lay_X, m_Lay_Y, m_Lay_W, m_Lay_H); }
protected internal CandleElement(PlotPane host, CandleSample candle, int x, float minScale, float maxScale) : base(host) { m_Candle = candle; // m_Style = new Style(null, getBaseStyle()); m_ScaleMin = minScale; m_ScaleMax = maxScale; m_Lay_X = x; m_Lay_W = CandleView.BAR_WIDTH; computeCoords(); this.Region = new Rectangle(m_Lay_X, m_Lay_Y, m_Lay_W, m_Lay_H); }
internal ChartPaneMouseEventArgs( MouseEventType type, TimeSeriesChart chart, PlotPane pane, MouseEventArgs mouse, ITimeSeriesSample sample, float value) { this.EventType = type; this.Chart = chart; this.Pane = pane; this.MouseEvent = mouse; this.SampleAtX = sample; this.ValueAtY = value; }
protected internal virtual void OnChartPaneMouseEvent( ChartPaneMouseEventArgs.MouseEventType et, PlotPane senderPane, MouseEventArgs mouse) { if (this.ChartPaneMouseEvent == null) { return; } var sample = MapXToSample(mouse.X); var value = MapPaneYToValue(senderPane, mouse.Y); var args = new ChartPaneMouseEventArgs(et, this, senderPane, mouse, sample, value); ChartPaneMouseEvent(this, args); }
internal ChartPaneMouseEventArgs(MouseEventType type, TimeSeriesChart chart, PlotPane pane, MouseEventArgs mouse, ITimeSeriesSample sample, float value) { this.EventType = type; this.Chart = chart; this.Pane = pane; this.MouseEvent = mouse; this.SampleAtX = sample; this.ValueAtY = value; }
/// <summary> /// Maps mouse Y coordinate per pane's vertical scale value /// </summary> public float MapPaneYToValue(PlotPane pane, int y) { if (pane == null) { throw new WFormsException(StringConsts.ARGUMENT_ERROR + "MapPaneYToValue(pane==null)"); } if (pane.Chart != this) { throw new WFormsException(StringConsts.ARGUMENT_ERROR + "MapPaneYToValue(pane.Chart!=this)"); } var pp = (pane.VRulerMaxScale - pane.VRulerMinScale) / (float)(pane.Height == 0? 1 : pane.Height); return(pane.VRulerMaxScale - (y * pp)); }
public override void BuildElements(Chart chart, PlotPane pane, Series series) { var cdata = series as CandleTimeSeries; if (cdata == null) { throw new WFormsException("CandleView requires CandleTimeSeries source"); } var drawData = getDataPerScroll(cdata); if (!drawData.Any()) { return; //nothing to draw } float minScale; float maxScale; calcMinMaxScale(drawData, out minScale, out maxScale); m_MinScale = minScale; m_MaxScale = maxScale; pane.SetMinMaxScale(minScale, maxScale, true); var x = 0; foreach (var candle in cdata.Data) { if (x > pane.Width) { break; } var elm = new CandleElement(pane, candle, x, minScale, maxScale); elm.Visible = true; x += elm.Width; x++;//margin } }
protected override Element MakeSeriesElement(TimeSeriesChart chart, PlotPane pane, IEnumerable <CandleSample> data, int xStart, float minScale, float maxScale, int maxSampleWidth, out int fitSamplesCount) { var points = new List <Point>(); var pxTotalHeight = (int)(pane.Height / pane.Zoom); var pxPrice = (float)pxTotalHeight / (maxScale - minScale); fitSamplesCount = 0; var x = xStart + (maxSampleWidth / 2); var xcutof = chart.VRulerPosition == VRulerPosition.Right ? pane.Width - 1 - chart.VRulerWidth : pane.Width; foreach (var candle in data) { var midPrice = MidLineType == Temporal.MidLineType.HighLow ? (candle.LowPrice + ((candle.HighPrice - candle.LowPrice) / 2f)) : (Math.Min(candle.OpenPrice, candle.ClosePrice) + (Math.Abs(candle.OpenPrice - candle.ClosePrice) / 2f)); var y = pxTotalHeight - (int)((midPrice - minScale) * pxPrice); points.Add(new Point(x, y)); x += maxSampleWidth; x++; if ((x * pane.Zoom) >= xcutof) { break; } fitSamplesCount++; } return(new CandleMidLineElement(this, pane, points.ToArray())); }
private void buildPanesCore() { if (m_Series == null || m_NeedRebuildPanes) { foreach (var ctl in m_Panes) { m_ChartPanel.Controls.Remove(ctl); ctl.Dispose(); } m_Panes.Clear(); //todo ubit shkalu X vnizy if (m_Series == null) return; } var paneNames = m_Series.GetPaneNames().ToArray(); //1. Delete panes that are no longer in series var toDelete = m_Panes.Select(p => p.Name).Except(paneNames); foreach (var pn in toDelete) { var ctl = m_Panes[pn]; if (ctl != null) { m_Panes.Unregister(ctl); m_ChartPanel.Controls.Remove(ctl); ctl.Dispose(); } } var totPanes = paneNames.Length; var i = 0; int controlHeight = m_ChartPanel.Height; PlotPane lastPane = null; //2. Add panes foreach (var pn in paneNames.Reverse()) { var pane = m_Panes[pn]; if (pane != null) { pane.UpdateZoom(m_Zoom); pane.DeleteAllElements(); //Clear the pane if (lastPane == null) lastPane = pane; continue; //pane already exists } //Add pane pane = new PlotPane(this, pn, m_Panes.Count + 1); pane.TabStop = false; pane.Cursor = Cursors.Cross; pane.Height = (int)(controlHeight * GetPaneVProportion(pn)); SetPaneVProportion(pn, pane.Height/(float)(controlHeight > 0 ? controlHeight : 1)); pane.Parent = m_ChartPanel; pane.UpdateZoom(m_Zoom); pane.Dock = DockStyle.Top; lastPane = pane; //ctl.BackColor = Color.HotPink; m_Panes.Register(pane); if (i < totPanes - 1) { // Build splitter // pane.Dock = DockStyle.Top; if (pane.m_Splitter != null) continue; pane.m_Splitter = new Splitter { Parent = m_ChartPanel, Dock = DockStyle.Top, Height = SPLITTER_HEIGHT, BackColor = SplitterStyle.BGColor, BorderStyle = BorderStyle.FixedSingle }; //this.Controls.SetChildIndex(pane.m_Splitter, this.Controls.GetChildIndex(pane)); //todo Splitter moving - suspend update? pane.m_Splitter.SplitterMoved += delegate (object sender, SplitterEventArgs e) { this.NotifySeriesChange(false); int height = m_ChartPanel.Height; foreach (var p in m_Panes) SetPaneVProportion(p.Name, p.Height / (float)(height > 0 ? height : 1)); }; } } // This must be the last Dock command if (lastPane != null) lastPane.Dock = DockStyle.Fill; }
protected override Elements.Element MakeSampleElement(TimeSeriesChart chart, PlotPane pane, CandleSample sample, int x, float minScale, float maxScale) { return new CandleBuySellElement(this, pane, sample, x, minScale, maxScale); }
private void buildPanesCore() { if (m_Series==null || m_NeedRebuildPanes) { foreach(var ctl in m_Panes) { this.Controls.Remove(ctl); ctl.Dispose(); } m_Panes.Clear(); //todo ubit shkalu X vnizy if (m_Series==null) return; } var paneNames = m_Series.GetPaneNames().ToArray(); //1. Delete panes that are no longer in series var toDelete = m_Panes.Select(p => p.Name).Except(paneNames); foreach(var pn in toDelete) { var ctl = m_Panes[pn]; if (ctl!=null) { m_Panes.Unregister(ctl); this.Controls.Remove(ctl); ctl.Dispose(); } } //2. Add panes foreach(var pn in paneNames.Reverse()) { var ctl = m_Panes[pn]; if (ctl!=null) { ctl.UpdateZoom(m_Zoom); ctl.DeleteAllElements();//Clear the pane continue;//pane already exists } //Add pane ctl = new PlotPane(this, pn, m_Panes.Count+1); ctl.TabStop = false; ctl.Cursor = Cursors.Cross; ctl.Height = (int)(this.Height * GetPaneVProportion(pn)); SetPaneVProportion(pn, ctl.Height / (float)(this.Height>0 ? this.Height : 1)); ctl.Parent = this; ctl.Dock = DockStyle.Top; ctl.UpdateZoom(m_Zoom); //ctl.BackColor = Color.HotPink; m_Panes.Register(ctl); } //3. Build splitters var ilast = m_Panes.Count()-1; for(var i=0; i<=ilast; i++) { var pane = m_Panes[i]; { // pane.Dock = DockStyle.Top; if (pane.m_Splitter==null) { pane.m_Splitter = new Splitter(); pane.m_Splitter.Parent = this; this.Controls.SetChildIndex( pane.m_Splitter, this.Controls.GetChildIndex(pane)); pane.m_Splitter.Dock = DockStyle.Top; pane.m_Splitter.Height = SPLITTER_HEIGHT; pane.m_Splitter.BackColor = Color.Silver; pane.m_Splitter.BorderStyle = BorderStyle.FixedSingle; //todo Splitter moving - suspend update? pane.m_Splitter.SplitterMoved += delegate(object sender, SplitterEventArgs e) { this.NotifySeriesChange(false); foreach(var p in m_Panes) SetPaneVProportion(p.Name, p.Height / (float)(this.Height>0 ? this.Height : 1)); }; } } } }
protected internal virtual void OnChartPaneMouseEvent(ChartPaneMouseEventArgs.MouseEventType et, PlotPane senderPane, MouseEventArgs mouse) { if (this.ChartPaneMouseEvent!=null) { var sample = MapXToSample(mouse.X); var value = MapPaneYToValue(senderPane, mouse.Y); var args = new ChartPaneMouseEventArgs(et, this, senderPane, mouse, sample, value); ChartPaneMouseEvent(this, args); } }
/// <summary> /// Maps mouse Y coordinate per pane's vertical scale value /// </summary> public float MapPaneYToValue(PlotPane pane, int y) { if (pane==null) throw new WFormsException(StringConsts.ARGUMENT_ERROR+"MapPaneYToValue(pane==null)"); if (pane.Chart!=this) throw new WFormsException(StringConsts.ARGUMENT_ERROR+"MapPaneYToValue(pane.Chart!=this)"); var pp = (pane.VRulerMaxScale - pane.VRulerMinScale) / (float)(pane.Height==0? 1 : pane.Height); return pane.VRulerMaxScale - (y * pp); }
private void buildPanesCore() { if (m_Series == null || m_NeedRebuildPanes) { foreach (var ctl in m_Panes) { m_ChartPanel.Controls.Remove(ctl); ctl.Dispose(); } m_Panes.Clear(); //todo ubit shkalu X vnizy if (m_Series == null) { return; } } var paneNames = m_Series.GetPaneNames().ToArray(); //1. Delete panes that are no longer in series var toDelete = m_Panes.Select(p => p.Name).Except(paneNames); foreach (var pn in toDelete) { var ctl = m_Panes[pn]; if (ctl != null) { m_Panes.Unregister(ctl); m_ChartPanel.Controls.Remove(ctl); ctl.Dispose(); } } var totPanes = paneNames.Length; var i = 0; int controlHeight = m_ChartPanel.Height; PlotPane lastPane = null; //2. Add panes foreach (var pn in paneNames.Reverse()) { var pane = m_Panes[pn]; if (pane != null) { pane.UpdateZoom(m_Zoom); pane.DeleteAllElements(); //Clear the pane if (lastPane == null) { lastPane = pane; } continue; //pane already exists } //Add pane pane = new PlotPane(this, pn, m_Panes.Count + 1); pane.TabStop = false; pane.Cursor = Cursors.Cross; pane.Height = (int)(controlHeight * GetPaneVProportion(pn)); SetPaneVProportion(pn, pane.Height / (float)(controlHeight > 0 ? controlHeight : 1)); pane.Parent = m_ChartPanel; pane.UpdateZoom(m_Zoom); pane.Dock = DockStyle.Top; lastPane = pane; //ctl.BackColor = Color.HotPink; m_Panes.Register(pane); if (i < totPanes - 1) { // Build splitter // pane.Dock = DockStyle.Top; if (pane.m_Splitter != null) { continue; } pane.m_Splitter = new Splitter { Parent = m_ChartPanel, Dock = DockStyle.Top, Height = SPLITTER_HEIGHT, BackColor = SplitterStyle.BGColor, BorderStyle = BorderStyle.FixedSingle }; //this.Controls.SetChildIndex(pane.m_Splitter, this.Controls.GetChildIndex(pane)); //todo Splitter moving - suspend update? pane.m_Splitter.SplitterMoved += delegate(object sender, SplitterEventArgs e) { this.NotifySeriesChange(false); int height = m_ChartPanel.Height; foreach (var p in m_Panes) { SetPaneVProportion(p.Name, p.Height / (float)(height > 0 ? height : 1)); } }; } } // This must be the last Dock command if (lastPane != null) { lastPane.Dock = DockStyle.Fill; } }
protected override Elements.Element MakeSampleElement(TimeSeriesChart chart, PlotPane pane, CandleSample sample, int x, float minScale, float maxScale) { return null; }
protected override Element MakeSeriesElement(TimeSeriesChart chart, PlotPane pane, IEnumerable<CandleSample> data, int xStart, float minScale, float maxScale, int maxSampleWidth, out int fitSamplesCount) { var points = new List<Point>(); var pxTotalHeight = (int)(pane.Height / pane.Zoom); var pxPrice = (float)pxTotalHeight / (maxScale - minScale); fitSamplesCount = 0; var x = xStart+(maxSampleWidth / 2); var xcutof = chart.VRulerPosition == VRulerPosition.Right ? pane.Width - 1 - chart.VRulerWidth : pane.Width; foreach(var candle in data) { var midPrice = MidLineType==Temporal.MidLineType.HighLow ? (candle.LowPrice + ((candle.HighPrice - candle.LowPrice) / 2f)) : (Math.Min(candle.OpenPrice, candle.ClosePrice) + (Math.Abs(candle.OpenPrice - candle.ClosePrice) / 2f)); var y = pxTotalHeight - (int)((midPrice-minScale) * pxPrice); points.Add( new Point(x, y)); x += maxSampleWidth; x++; if ((x*pane.Zoom)>=xcutof) break; fitSamplesCount++; } return new CandleMidLineElement(this, pane, points.ToArray()); }
/// <summary> /// Override to build elements that render the data by adding drawable elements to the chart. /// Returns how many samples could fit /// </summary> public abstract int BuildElements(TimeSeriesChart chart, PlotPane pane, TimeSeries series, int maxSampleWidth);
protected override Elements.Element MakeSampleElement(TimeSeriesChart chart, PlotPane pane, CandleSample sample, int x, float minScale, float maxScale) { return(new CandleBuySellElement(this, pane, sample, x, minScale, maxScale)); }
/// <summary> /// Override to build elements that render the data by adding drawable elements to the chart. /// Returns how many samples could fit /// </summary> public abstract int BuildElements(TimeSeriesChart chart, PlotPane pane, TimeSeries series, int maxSampleWidth);
protected override Elements.Element MakeSampleElement(TimeSeriesChart chart, PlotPane pane, CandleSample sample, int x, float minScale, float maxScale) { return(null); }
private void buildPanesCore() { if (m_Series == null || m_NeedRebuildPanes) { foreach (var ctl in m_Panes) { this.Controls.Remove(ctl); ctl.Dispose(); } m_Panes.Clear(); //todo ubit shkalu X vnizy if (m_Series == null) { return; } } var paneNames = m_Series.GetPaneNames().ToArray(); //1. Delete panes that are no longer in series var toDelete = m_Panes.Select(p => p.Name).Except(paneNames); foreach (var pn in toDelete) { var ctl = m_Panes[pn]; if (ctl != null) { m_Panes.Unregister(ctl); this.Controls.Remove(ctl); ctl.Dispose(); } } //2. Add panes foreach (var pn in paneNames.Reverse()) { var ctl = m_Panes[pn]; if (ctl != null) { ctl.UpdateZoom(m_Zoom); ctl.DeleteAllElements(); //Clear the pane continue; //pane already exists } //Add pane ctl = new PlotPane(this, pn, m_Panes.Count + 1); ctl.TabStop = false; ctl.Cursor = Cursors.Cross; ctl.Height = (int)(this.Height * GetPaneVProportion(pn)); SetPaneVProportion(pn, ctl.Height / (float)(this.Height > 0 ? this.Height : 1)); ctl.Parent = this; ctl.Dock = DockStyle.Top; ctl.UpdateZoom(m_Zoom); //ctl.BackColor = Color.HotPink; m_Panes.Register(ctl); } //3. Build splitters var ilast = m_Panes.Count() - 1; for (var i = 0; i <= ilast; i++) { var pane = m_Panes[i]; { // pane.Dock = DockStyle.Top; if (pane.m_Splitter == null) { pane.m_Splitter = new Splitter(); pane.m_Splitter.Parent = this; this.Controls.SetChildIndex(pane.m_Splitter, this.Controls.GetChildIndex(pane)); pane.m_Splitter.Dock = DockStyle.Top; pane.m_Splitter.Height = SPLITTER_HEIGHT; pane.m_Splitter.BackColor = Color.Silver; pane.m_Splitter.BorderStyle = BorderStyle.FixedSingle; //todo Splitter moving - suspend update? pane.m_Splitter.SplitterMoved += delegate(object sender, SplitterEventArgs e) { this.NotifySeriesChange(false); foreach (var p in m_Panes) { SetPaneVProportion(p.Name, p.Height / (float)(this.Height > 0 ? this.Height : 1)); } }; } } } }
public override void BuildElements(Chart chart, PlotPane pane, Series series) { var cdata = series as CandleTimeSeries; if (cdata==null) throw new WFormsException("CandleView requires CandleTimeSeries source"); var drawData = getDataPerScroll(cdata); if (!drawData.Any()) return;//nothing to draw float minScale; float maxScale; calcMinMaxScale(drawData, out minScale, out maxScale); m_MinScale = minScale; m_MaxScale = maxScale; pane.SetMinMaxScale(minScale, maxScale, true); var x = 0; foreach(var candle in cdata.Data) { if (x > pane.Width) break; var elm = new CandleElement(pane, candle, x, minScale, maxScale); elm.Visible = true; x += elm.Width; x++;//margin } }