Can individual DrawLineItems be selectable or not ..

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Snarkle
Newbie
Newbie
Posts: 91
Joined: Wed Jun 30, 2010 12:00 am

Can individual DrawLineItems be selectable or not ..

Post by Snarkle » Wed Jul 21, 2010 6:06 am

Greetings,

I have a DrawLine that is made up of 4 drawlineItems .. two of these I want to be selectable and two I dont want to be selectable .
Is there a way to make DrawLineItems that are grouped together in a Drawline programatically selectable.
As I wish the user to be able to drag two of the lines and the other two I shall programatically position them using the DragLine Eventhandler.

Below is how I am creating this DrawLine.

Code: Select all

        private void btn_drawLine_Click(object sender, EventArgs e)
        {
            drawline1 = new Steema.TeeChart.Tools.DrawLine(tChart1.Chart);
            drawline1.EnableDraw = true;
            drawline1.NewLine +=new DrawLineEventHandler(drawline1_NewLine);
            drawline1.Select += new DrawLineEventHandler(drawline1_Select);
            drawline1.DragLine += new DrawLineEventHandler(drawline1_DragLine);
            drawline1.EnableSelect = true;

            drawline1.Pen.Width = 2;

            I1 = new DrawLineItem(drawline1);
            I1.Pen.Color = Color.Red;
            I1.Pen.Width = 2;

            I2 = new DrawLineItem(drawline1);
            I2.Pen.Color = Color.Blue;
            I2.Pen.Width = 2;

            I3 = new DrawLineItem(drawline1);
            I3.Pen.Color = Color.MediumPurple;
            I3.Pen.Width = 2;
        }
--------------------
Cheers Phil.

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Can individual DrawLineItems be selectable or not ..

Post by Yeray » Wed Jul 21, 2010 2:04 pm

Hi Snarkle,

I'm afraid that the easiest way to do this would be using a DrawLine tool for each group of lines, one for the lines you can drag and one for the lines you don't want to drag.
If there is a reason why you want to use a unique DrawLine tool, you may explain it to us so we may evaluate if there is a workaround or not.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Snarkle
Newbie
Newbie
Posts: 91
Joined: Wed Jun 30, 2010 12:00 am

Re: Can individual DrawLineItems be selectable or not ..

Post by Snarkle » Thu Jul 22, 2010 3:02 am

Greetings Yeray,

Yes there is a reason .. I'll try to make the background info as brief as possible.

We are using the chart for some technical analysis of stocks.
The user will be expecting to be able to apply such things as a trendline, andrews pitchfork, value lines, fibonacci etc etc.
Once applied the user will be expecting to save each individual 'line Study' and load them back individually.

Now nearly all of the tools are really just made up of multiple lines, example .. the andrews Pitchfork is at minimum 3 parallel lines that get controlled by the position of 3 points.

So having a DrawLine for each group of lines (i.e. for each tool) meant that when I needed to find a particular tool I could look through tChart1.tools[index] and easily locate the 'group' of lines that are the current tool ... so tChart1.tools[0] could be a trendLine (1 line) tChart1.tools[1] could be the Andrews pitchfork (4 lines) etc etc. If I have a DrawLine for each line of the pitchfork I will have to create a more complex way of determining which DrawLines make up each tool ... I was really using it as a convenient container to keep all the individual lines of a tool organised. Easy to Find a required Tool (as long I stored its index) and then iterate through its Lines and save out the values for later use.

The problem I am finding especially in the case of the Andrews Pitchfork is that given its made up of (in this case 4 lines) there are only 3 points that the user should be allowed to drag .. and from these I determine the new shape (i.e. draw the lines in parallel based on some simple trignometry) the default behaviour of Drawlines means that you can grab a line anywhere and drag it .. (nightmare for me) and also of the 6 - 8 endpoints of the lines I really only want 3 of these to be dragged around the screen .. So far I have not found a way to stop this behaviour. So my thought was if I COULD make 2 of the DrawLineItems non selectable then I could simply plot the other point that I dont want draggable off the screen somewhere ... but alas as you have pointed out to me you cant set the enableSelect of DrawLineItems only the container the DrawLine ... all or none so it seems. I can create a better way to track my lines and make everythign out of individual DrawLines , is there any control I can have over the draggable handles .. i.e. turn one or both off programatically?

I attached my prototype code ... if you click the bottom right button thats a pitchfork usign individual drawlInes and thats the behaviour I want, you'll notice you can only drag 3 points .. the button above uses DrawLineItems but if you grab the blue or purple lines you can drag them all over the place .. and the bottom point on the black line is underneath the purple line. (ignore the flakey moving red line as I didnt bother finishing off that code)

Cheers Phil
Attachments
Pitchfork.zip
PitchFork Prototype
(10.1 KiB) Downloaded 313 times
--------------------
Cheers Phil.

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Can individual DrawLineItems be selectable or not ..

Post by Yeray » Fri Jul 23, 2010 7:44 am

Hi Phil,

I can't run your example project. It gives me "Error 2 Resource file "Properties\Resources.resx" cannot be found. TChart Sandbox 2". I think you missed to add the Properties folder of the solution.
For your explanations, I think you could still maintain your DrawLine tools organized if you create arrays of them. For example:

Code: Select all

            Steema.TeeChart.Tools.DrawLine[] group1 = new Steema.TeeChart.Tools.DrawLine[3];
            for (int i = 0; i < group1.Length; i++)
            {
                group1[i] = new Steema.TeeChart.Tools.DrawLine(tChart1.Chart);
            }

            Steema.TeeChart.Tools.DrawLine[] group2 = new Steema.TeeChart.Tools.DrawLine[4];
            for (int i = 0; i < group2.Length; i++)
            {
                group2[i] = new Steema.TeeChart.Tools.DrawLine(tChart1.Chart);
            }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply