Steema.TeeChart.Drawing.DashStyle assignment issue

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Venkat
Newbie
Newbie
Posts: 3
Joined: Fri May 15, 2020 12:00 am

Steema.TeeChart.Drawing.DashStyle assignment issue

Post by Venkat » Thu Jul 27, 2023 10:08 am

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

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Steema.TeeChart.Drawing.DashStyle assignment issue

Post by Christopher » Fri Jul 28, 2023 10:14 am

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
Screenshot from 2023-07-28 12-10-07.png (33.95 KiB) Viewed 12642 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;
            }
        }
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Post Reply