Page 1 of 1
Steema.TeeChart.Drawing.DashStyle assignment issue
Posted: Thu Jul 27, 2023 10:08 am
by 16088757
Hello,
The below line of code is already exist in 4.2021.7.22. Now we are planning to upgrade to 4.2023.7.5 netframework48 version.
CursorTool.Pen.Style style = MovingCursorStyle;//System.Windows.Media.DashStyle
How can we assign System.Windows.Media.DashStyle to Steema.TeeChart.Drawing.DashStyle?
Thanks,
Venkat
Re: Steema.TeeChart.Drawing.DashStyle assignment issue
Posted: Fri Jul 28, 2023 10:14 am
by Christopher
Hello Venkat,
here's a small example:
Code: Select all
public partial class MainWindow : Window
{
private TChart _tChart1 = new TChart();
public MainWindow()
{
InitializeComponent();
grid1.Children.Add(_tChart1);
_tChart1.AfterDraw += _tChart1_AfterDraw;
}
private void _tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.IGraphics3D g)
{
g.Pen.Color = System.Drawing.Color.Red;
g.Pen.Width = 3;
g.Pen.Style = Steema.TeeChart.Drawing.DashStyle.DashDot;
g.MoveTo(10, 10);
g.LineTo(150, 150);
}
}
which here gives me:
- Screenshot from 2023-07-28 12-10-07.png (33.95 KiB) Viewed 12279 times
Internally we convert System.Windows.Media.DashStyle to TeeChart.Drawing.DashStyle like this:
Code: Select all
TeeChart.Drawing.DashStyle IChartPen.Style
{
get
{
if (Style == DashStyles.Dash) return TeeChart.Drawing.DashStyle.Dash;
else if (Style == DashStyles.Dot) return TeeChart.Drawing.DashStyle.Dot;
else if (Style == DashStyles.DashDot) return TeeChart.Drawing.DashStyle.DashDot;
else if (Style == DashStyles.DashDotDot) return TeeChart.Drawing.DashStyle.DashDotDot;
else return TeeChart.Drawing.DashStyle.Solid;
}
set
{
Style = SetStyle(value);
}
}
And SetStyle:
Code: Select all
static System.Windows.Media.DashStyle SetStyle(Steema.TeeChart.Drawing.DashStyle style)
{
switch (style)
{
case TeeChart.Drawing.DashStyle.Dash:
return DashStyles.Dash;
case TeeChart.Drawing.DashStyle.Dot:
return DashStyles.Dot;
case TeeChart.Drawing.DashStyle.DashDot:
return DashStyles.DashDot;
case TeeChart.Drawing.DashStyle.DashDotDot:
return DashStyles.DashDotDot;
default:
return DashStyles.Solid;
}
}