This commit is contained in:
Miha Kralj
2024-09-30 10:31:57 -07:00
parent 8a3c257038
commit 3879266977
+6 -10
View File
@@ -14,7 +14,7 @@ public abstract class IndicatorBarBase : Indicator, IWatchlistIndicator
[InputParameter("Show cold values", sortIndex: 20)] [InputParameter("Show cold values", sortIndex: 20)]
public bool ShowColdValues { get; set; } = true; public bool ShowColdValues { get; set; } = true;
public int MinHistoryDepths; public int MinHistoryDepths { get; set; }
// LineSeries.LineSeries(string, Color, int, LineStyle)' // LineSeries.LineSeries(string, Color, int, LineStyle)'
@@ -30,13 +30,9 @@ public abstract class IndicatorBarBase : Indicator, IWatchlistIndicator
Series = new(name: $"{Name}", color: Color.RoyalBlue, width: 2, style: LineStyle.Solid); Series = new(name: $"{Name}", color: Color.RoyalBlue, width: 2, style: LineStyle.Solid);
AddLineSeries(Series); AddLineSeries(Series);
InitIndicator();
} }
protected virtual void InitIndicator() protected abstract void InitIndicator();
{
SourceName = GetName(Source);
}
protected override void OnInit() protected override void OnInit()
{ {
@@ -64,7 +60,7 @@ public abstract class IndicatorBarBase : Indicator, IWatchlistIndicator
{ {
base.OnPaintChart(args); base.OnPaintChart(args);
List<Point> allPoints = new List<Point>(); List<Point> allPoints = new List<Point>();
if (CurrentChart == null) return; if (CurrentChart == null) { return; }
Graphics gr = args.Graphics; Graphics gr = args.Graphics;
@@ -96,7 +92,7 @@ public abstract class IndicatorBarBase : Indicator, IWatchlistIndicator
private void DrawSmoothCombinedCurve(Graphics gr, List<Point> allPoints, int hotCount) private void DrawSmoothCombinedCurve(Graphics gr, List<Point> allPoints, int hotCount)
{ {
if (allPoints.Count < 2) return; if (allPoints.Count < 2) { return; }
using (Pen defaultPen = new(Series!.Color, Series.Width) { DashStyle = ConvertLineStyleToDashStyle(Series.Style) }) using (Pen defaultPen = new(Series!.Color, Series.Width) { DashStyle = ConvertLineStyleToDashStyle(Series.Style) })
using (Pen coldPen = new(Series!.Color, Series.Width) { DashStyle = DashStyle.Dot }) using (Pen coldPen = new(Series!.Color, Series.Width) { DashStyle = DashStyle.Dot })
@@ -116,7 +112,7 @@ public abstract class IndicatorBarBase : Indicator, IWatchlistIndicator
} }
} }
} }
private DashStyle ConvertLineStyleToDashStyle(LineStyle lineStyle) private static DashStyle ConvertLineStyleToDashStyle(LineStyle lineStyle)
{ {
return lineStyle switch return lineStyle switch
{ {
@@ -127,7 +123,7 @@ public abstract class IndicatorBarBase : Indicator, IWatchlistIndicator
_ => DashStyle.Solid, _ => DashStyle.Solid,
}; };
} }
protected void DrawText(Graphics gr, string text, Rectangle clientRect) protected static void DrawText(Graphics gr, string text, Rectangle clientRect)
{ {
Font font = new Font("Inter", 8); Font font = new Font("Inter", 8);
SizeF textSize = gr.MeasureString(text, font); SizeF textSize = gr.MeasureString(text, font);