WPF Colorline drawing priority

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
zizou5
Newbie
Newbie
Posts: 17
Joined: Mon Jun 11, 2007 12:00 am
Contact:

WPF Colorline drawing priority

Post by zizou5 » Mon Jun 15, 2015 10:48 am

Hi Steema,
I'm having a problem to draw colorline behind series, anotations, etc. in my WPF .NET application.
I'm using these Colorlines as an tolerance limits for charts in steel mill visualization application.
Drawbehind = true property is used but Lines are always on top though.
Is there a way to fix it?
Thank you for your help.

Branislav Baran
Attachments
strip_thick_chart.png
this chart has series and annotation drawn behind the colorlines, but it is requred to have them drawn behind everything else.
strip_thick_chart.png (28.58 KiB) Viewed 6807 times

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

Re: WPF Colorline drawing priority

Post by Christopher » Tue Jun 16, 2015 9:24 am

Hello Branislav,

Unfortunately the Drawbehind is non-functional in WPF as the tool uses an AdornerLayer to do its drawing, and this layer is always drawn before all others.

However, this behaviour can be overridden using a very simple derivative of the ColorLine class, e.g.

Code: Select all

  public class MyColorLine : ColorLine
  {
    public MyColorLine(Chart c)
      : base(c) { }

    public MyColorLine()
      : this(null) { }

    protected override void ChartEvent(EventArgs e)
    {
      if ((iAxis != null) &&
       ((e is BeforeDrawSeriesEventArgs) || (e is AfterDrawEventArgs)))
      {
        Chart.Graphics3D.Pen = Pen;

        DrawColorLine(Chart.Graphics3D, e is BeforeDrawSeriesEventArgs);
      }
    }
  }
And then used like this:

Code: Select all

    private void InitializeChart()
    {
      Steema.TeeChart.WPF.Styles.Line line = new Steema.TeeChart.WPF.Styles.Line(tChart1.Chart);
      tChart1.Aspect.View3D = false;
      line.LinePen.Width = 3;
      line.FillSampleValues();

      MyColorLine tool = new MyColorLine(tChart1.Chart);
      tool.Axis = tChart1.Axes.Bottom;
      tool.Value = 5;
      tool.Pen.Color = Colors.LimeGreen;
      tool.Pen.Width = 2;
      tool.DrawBehind = true;
    }
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

zizou5
Newbie
Newbie
Posts: 17
Joined: Mon Jun 11, 2007 12:00 am
Contact:

Re: WPF Colorline drawing priority

Post by zizou5 » Wed Jun 17, 2015 9:31 am

Thank you Christopher,
it works fine!

Branislav Baran

Post Reply