internal void ShowSelection(bool bShow) { _selectionVisible = bShow; SetCursor(); if (!_selectionVisible) { _selectionDots.RemoveAll(); return; } _selectionDots.C = C; _selectionDots.Start(); foreach (SelectionDotInfo point in GetSelectionPoints()) { SelectionDot dot = _selectionDots.GetPaintObject(point.Corner, point.Clickable); dot.SetPos(point.Position); dot.Tag = this; //dot.SetClip(Clip); Shape shape = dot.Shape; shape.Clip = GetClip(Canvas.GetLeft(shape), Canvas.GetTop(shape), _paintableRect); dot.ZIndex = ZIndexConstants.SelectionPoint1; } _selectionDots.Stop(); }
internal override void RemoveLineStudy() { foreach (Line line in _lines) { C.Children.Remove(line); } _linesSel.RemoveAll(); }
internal override void RemoveLineStudy() { _lines.RemoveAll(); foreach (var line in _linesError) { C.Children.Remove(line); } }
internal override void RemoveLineStudy() { foreach (System.Windows.Shapes.Line l in _lines) { C.Children.Remove(l); } _linesSel.RemoveAll(); }
public override void RemovePaint() { if (_subscribedToCustomBrush) { _series._chartPanel._chartX.OnCandleCustomBrush -= ChartX_OnCandleCustomBrush; } _stocks.RemoveAll(); }
internal override void RemovePaint() { if (!_chartPanel._chartX.OptimizePainting) { _lines.RemoveAll(); } else if (_pathDown != null) { Canvas c = _chartPanel._rootCanvas; c.Children.Remove(_pathUp); c.Children.Remove(_pathNormal); c.Children.Remove(_pathDown); _pathUp = _pathDown = _pathNormal = null; } }
public override void RemovePaint() { _lines.RemoveAll(); _rects.RemoveAll(); _rects3D.RemoveAll(); }
public override void RemovePaint() { _lines.RemoveAll(); _ellipses.RemoveAll(); }
private void PaintSideVolumeDepthBars() { if (_sideVolumeDepthBars == 0) //remove { _rectsSideVolumeDepth.RemoveAll(); return; } if (_chartX._endIndex == 0) { return; } if (_series.Count < 3) { return; } Series open = null; foreach (Series series in _series) { if (series.OHLCType != SeriesTypeOHLC.Open) { continue; } open = series; break; } if (open == null) { return; } Series close = GetSeriesOHLCV(open, SeriesTypeOHLC.Close); if (close == null) { return; } Series volume = _chartX.GetSeriesOHLCV(open, SeriesTypeOHLC.Volume); if (volume == null) { return; } double maxVolume = double.MinValue, minVolume = double.MaxValue; int i; for (i = _chartX._startIndex; i < _chartX._endIndex; i++) { if (!volume[i].Value.HasValue) { continue; } if (volume[i].Value.Value > maxVolume) { maxVolume = volume[i].Value.Value; } else if (volume[i].Value.Value < minVolume) { minVolume = volume[i].Value.Value; } } double range = maxVolume - minVolume; double barVolumeIncrement = range / _sideVolumeDepthBars; double barHeight = _rootCanvas.ActualHeight / _sideVolumeDepthBars; double volBar = minVolume; int[] volBarsPos = new int[_sideVolumeDepthBars]; int[] volBarsNeg = new int[_sideVolumeDepthBars]; for (int n = 0; n < _sideVolumeDepthBars; n++) { for (int j = _chartX._startIndex; j < _chartX._endIndex; j++) { if (!volume[j].Value.HasValue) { continue; } double v = volume[j].Value.Value; if (v < volBar || v > volBar + barVolumeIncrement) { continue; } if (close[j].Value > open[j].Value) { volBarsPos[n]++; } else if (close[j].Value < open[j].Value) { volBarsNeg[n]++; } } volBar += barVolumeIncrement; } double[] volBarsWidthPos = new double[_sideVolumeDepthBars]; double[] volBarsWidthNeg = new double[_sideVolumeDepthBars]; double maxVolBars = Math.Max(Algorithms.Maximum(volBarsPos), Algorithms.Maximum(volBarsNeg)); double minVolBars = Math.Min(Algorithms.Minimum(volBarsPos), Algorithms.Minimum(volBarsNeg)); double volumeBarScaleWidth = _rootCanvas.ActualWidth * 0.15; //15% for positive values and 15% for negative values _rectsSideVolumeDepth.C = _rootCanvas; _rectsSideVolumeDepth.Start(); for (int n = 0; n < _sideVolumeDepthBars; n++) { volBarsWidthPos[n] = (volBarsPos[n] - minVolBars) / (maxVolBars - minVolBars); volBarsWidthNeg[n] = (volBarsNeg[n] - minVolBars) / (maxVolBars - minVolBars); volBarsWidthPos[n] *= volumeBarScaleWidth; volBarsWidthNeg[n] *= volumeBarScaleWidth; double x1 = _chartX.LeftChartSpace; double y1 = n * barHeight; double x2 = _chartX.LeftChartSpace + volBarsWidthPos[n]; double y2 = (n + 1) * barHeight; Utils.DrawRectangle(x1, y1, x2, y2, Brushes.Blue, _rectsSideVolumeDepth); x1 = x2; x2 = x1 + volBarsWidthNeg[n]; Utils.DrawRectangle(x1, y1, x2, y2, Brushes.Red, _rectsSideVolumeDepth); } _rectsSideVolumeDepth.Stop(); _rectsSideVolumeDepth.Do(r => { r.ZIndex = ZIndexConstants.VolumeDepthBars; r._rectangle.Opacity = 0.5; r._rectangle.IsHitTestVisible = false; }); }
public override void RemovePaint() { _rects.RemoveAll(); }
internal void HideSelection() { _selected = false; _selectionDots.RemoveAll(); }
public override bool Paint() { if (_series.OHLCType == SeriesTypeOHLC.Volume) { return(false); } //Find Series Series open = _series._chartPanel.GetSeriesOHLCV(_series, SeriesTypeOHLC.Open); if (open == null || open.RecordCount == 0 || open.Painted) { return(false); } Series high = _series._chartPanel.GetSeriesOHLCV(_series, SeriesTypeOHLC.High); if (high == null || high.RecordCount == 0 || high.Painted) { return(false); } Series low = _series._chartPanel.GetSeriesOHLCV(_series, SeriesTypeOHLC.Low); if (low == null || low.RecordCount == 0 || low.Painted) { return(false); } Series close = _series._chartPanel.GetSeriesOHLCV(_series, SeriesTypeOHLC.Close); if (close == null || close.RecordCount == 0 || close.Painted) { return(false); } _series = close; open.Painted = high.Painted = low.Painted = close.Painted = true; CalculateCandleSpacing(); if (ChartX._barSpacing < 0) { return(false); } _upColor = _series._upColor.HasValue ? _series._upColor.Value : ChartX.UpColor; _downColor = _series._downColor.HasValue ? _series._downColor.Value : ChartX.DownColor; if (_oldOptimizePainting.HasValue && _oldOptimizePainting.Value != ChartX.OptimizePainting) { if (!ChartX.OptimizePainting) { Canvas c = _series._chartPanel._rootCanvas; c.Children.Remove(_pathCandlesDown); c.Children.Remove(_pathCandlesUp); c.Children.Remove(_pathWicksUp); c.Children.Remove(_pathWicksDown); _pathCandlesDown = null; _pathCandlesUp = null; _pathWicksUp = null; _pathWicksDown = null; } else { _candles.RemoveAll(); } } _oldOptimizePainting = ChartX.OptimizePainting; if (ChartX.OptimizePainting) { return(PaintOptimized(new[] { open, high, low, close }, _series)); } if (!_subscribedToCustomBrush) { _subscribedToCustomBrush = true; ChartX.OnCandleCustomBrush += ChartX_OnCandleCustomBrush; } //bool setBrushes = false; if (!_old3DStyle.HasValue || _old3DStyle.Value != ChartX.ThreeDStyle || !_oldUpColor.HasValue || _oldUpColor.Value != _upColor || !_oldDownColor.HasValue || _oldDownColor.Value != _downColor || (ChartX._candleDownOutlineColor.HasValue && ChartX._candleDownOutlineColor.Value != _oldCandleDownOutline) || ChartX._candleUpOutlineColor.HasValue && ChartX._candleUpOutlineColor.Value != _oldCandleUpOutline) { //setBrushes = true; _old3DStyle = ChartX.ThreeDStyle; _oldUpColor = _upColor; _oldDownColor = _downColor; _upBrush = !ChartX.ThreeDStyle ? (Brush) new SolidColorBrush(_upColor) : new LinearGradientBrush { StartPoint = new Point(0, 0.5), EndPoint = new Point(1, 0.5), GradientStops = { new GradientStop { Color = _upColor, Offset = 0 }, new GradientStop { Color = Constants.FadeColor, Offset = 1.25 } } }; #if WPF _upBrush.Freeze(); #endif _downBrush = !ChartX.ThreeDStyle ? (Brush) new SolidColorBrush(_downColor) : new LinearGradientBrush { StartPoint = new Point(0, 0.5), EndPoint = new Point(1, 0.5), GradientStops = { new GradientStop { Color = _downColor, Offset = 0 }, new GradientStop { Color = Constants.FadeColor, Offset = 1.25 } } }; #if WPF _downBrush.Freeze(); #endif if (ChartX._candleDownOutlineColor.HasValue) { _oldCandleDownOutline = ChartX._candleDownOutlineColor.Value; _candleDownOutlineBrush = new SolidColorBrush(ChartX._candleDownOutlineColor.Value); #if WPF _candleDownOutlineBrush.Freeze(); #endif } if (ChartX._candleUpOutlineColor.HasValue) { _oldCandleUpOutline = ChartX._candleUpOutlineColor.Value; _candleUpOutlineBrush = new SolidColorBrush(ChartX._candleUpOutlineColor.Value); #if WPF _candleUpOutlineBrush.Freeze(); #endif } } int n; _candles.C = _series._chartPanel._rootCanvas; _candles.Start(); for (n = ChartX._startIndex; n < ChartX._endIndex; n++) { if (!open[n].Value.HasValue || !high[n].Value.HasValue || !low[n].Value.HasValue || !close[n].Value.HasValue) { continue; } Candle candle = _candles.GetPaintObject(_upBrush, _downBrush); candle.Init(_series); //if (setBrushes) //because if we have a small number of bars, then enlarge the new brushes won't be propagated to new candles. candle.SetBrushes(_upBrush, _downBrush, _candleUpOutlineBrush, _candleDownOutlineBrush); candle.SetValues(open[n].Value.Value, high[n].Value.Value, low[n].Value.Value, close[n].Value.Value, ChartX._barSpacing, _halfwick, n - ChartX._startIndex); } _candles.Stop(); _candles.Do(c => c.ZIndex = ZIndexConstants.PriceStyles1); return(true); }
internal override void RemoveLineStudy() { _lines.RemoveAll(); }
public override void RemovePaint() { _candles.RemoveAll(); }