Colorband question
Colorband question
Hello,
I have a quick question about the colourband tool:
Is there a way of 'knowing' if a colourband start/end has moved?! The idea behind it is I would like to display the current start/end X location of the colourband as it's being dragged (it's just set to use the vertical axis).
Regards
Chris.
I have a quick question about the colourband tool:
Is there a way of 'knowing' if a colourband start/end has moved?! The idea behind it is I would like to display the current start/end X location of the colourband as it's being dragged (it's just set to use the vertical axis).
Regards
Chris.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Chris,
You could use TChart's MouseMove event for that, for example:
You could use TChart's MouseMove event for that, for example:
Code: Select all
void tChart1_MouseMove(object sender, MouseEventArgs e)
{
if (colorBand1.Clicked(e.X, e.Y))
{
this.Text = colorBand1.Start.ToString() + ", " + colorBand1.End.ToString();
}
}
Best Regards,
Narcís Calvet / 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 |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Chris,
Sorry but I missed specific drag events for each ColorBandTool lines. You can do something like this:
Sorry but I missed specific drag events for each ColorBandTool lines. You can do something like this:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private Line series;
private ColorBand tool;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Series.Add(series = new Line());
series.FillSampleValues();
tChart1.Tools.Add(tool = new ColorBand());
tool.Axis = tChart1.Axes.Bottom;
tool.Start = 2;
tool.End = 4;
tool.ResizeEnd = true;
tool.EndLine.DragLine += new EventHandler(EndLine_DragLine);
}
void EndLine_DragLine(object sender, EventArgs e)
{
tChart1.Header.Text = tool.End.ToString();
}
Best Regards,
Narcís Calvet / 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 |
More on Dragging Color Bands
I have a color band that is attached to the bottom axis.
I cannot figure out how to control the cursor on the drag operation. It appears that the StartLine has some default behaviour, in that the cursor changes on hover over the Start line, but does not change on the EndLine hover or drag.
Target: WPF
This behaviour also appears in the TeeChart demo Drag Color band.
I cannot figure out how to control the cursor on the drag operation. It appears that the StartLine has some default behaviour, in that the cursor changes on hover over the Start line, but does not change on the EndLine hover or drag.
Target: WPF
This behaviour also appears in the TeeChart demo Drag Color band.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi n8soft,
Yes, you are right. I think it's StartLine's cursor that doesn't change. I've added this to the defect list (TF02013567) to be fixed for next releases. A workaround could be doing something like this:
Yes, you are right. I think it's StartLine's cursor that doesn't change. I've added this to the defect list (TF02013567) to be fixed for next releases. A workaround could be doing something like this:
Code: Select all
void tChart1_MouseMove(object sender, MouseEventArgs e)
{
if (tool.Clicked(e.X, e.Y))
{
tChart1.Cursor = Cursors.VSplit;
}
else
{
tChart1.Cursor = Cursors.Default;
}
}
Best Regards,
Narcís Calvet / 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 |
I think there may be a bug in the Clicked method when you have zoomed in.
Best way I can describe it is if I put 3 colourbands (all vertical) on chart, spaced fairly evenly, then zoom in on a portion of the chart which will not have a colourband in it, then click anywhere in the chart, the loop I have going (in mousedown) says that a colourband has been clicked.
Can you reproduce this at all?
Regards
Chris.
Best way I can describe it is if I put 3 colourbands (all vertical) on chart, spaced fairly evenly, then zoom in on a portion of the chart which will not have a colourband in it, then click anywhere in the chart, the loop I have going (in mousedown) says that a colourband has been clicked.
Can you reproduce this at all?
Regards
Chris.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Chris,
Yes, I could reproduce the issue here using code below and added it to the list (TF02013677) to be investigated for next releases.
Yes, I could reproduce the issue here using code below and added it to the list (TF02013677) to be investigated for next releases.
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private Steema.TeeChart.Tools.ColorBand colorBand1;
private Steema.TeeChart.Tools.ColorBand colorBand2;
private Steema.TeeChart.Tools.ColorBand colorBand3;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line1.FillSampleValues(100);
colorBand1 = new Steema.TeeChart.Tools.ColorBand(tChart1.Chart);
colorBand1.Axis = tChart1.Axes.Bottom;
colorBand1.Start = 5;
colorBand1.End = 15;
colorBand2 = new Steema.TeeChart.Tools.ColorBand(tChart1.Chart);
colorBand2.Axis = tChart1.Axes.Bottom;
colorBand2.Start = 45;
colorBand2.End = 55;
colorBand3 = new Steema.TeeChart.Tools.ColorBand(tChart1.Chart);
colorBand3.Axis = tChart1.Axes.Bottom;
colorBand3.Start = 85;
colorBand3.End = 95;
tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);
}
void tChart1_MouseMove(object sender, MouseEventArgs e)
{
tChart1.Cursor = colorBand1.Clicked(e.X, e.Y) ? Cursors.VSplit : Cursors.Default;
}
Best Regards,
Narcís Calvet / 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 |
Infact, another question for you Narcís,
is it at all possible to get, from a region's DragStart (and DragEnd) events, the region that sent it? I noticed it's a colourline for the sender; if somehow I could fetch the region that the colourline is a part of I wouldn't have to worry too much about the bug above, you see.
Cheers,
Chris.
EDIT:
Don't worry, i've done it:
is it at all possible to get, from a region's DragStart (and DragEnd) events, the region that sent it? I noticed it's a colourline for the sender; if somehow I could fetch the region that the colourline is a part of I wouldn't have to worry too much about the bug above, you see.
Cheers,
Chris.
EDIT:
Don't worry, i've done it:
Code: Select all
FieldInfo[] fi = sender.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);
Delegate endDragLineDelegate;
GraphRegion gr;
FieldInfo delegateField = (from theEvent in fi where ((FieldInfo)theEvent).Name == "EndDragLine" select theEvent).SingleOrDefault();
if (delegateField != null)
{
endDragLineDelegate = (Delegate)delegateField.GetValue(sender);
gr = endDragLineDelegate.Target as GraphRegion;
//gr will be the reference in this.Tools
}
yet another colorband question (I seem to be making heavy use of them...)
When you move the drag the sides of a [vertical] colourband, could you make it so it triggers a MouseMove event??
On an unrelated note, can I be the first person to ask for GetNearestPoint to be public?!
Regards
Chris.
When you move the drag the sides of a [vertical] colourband, could you make it so it triggers a MouseMove event??
On an unrelated note, can I be the first person to ask for GetNearestPoint to be public?!
Regards
Chris.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Chris,
No problem but would you mind starting a new thread for each new question? Otherwise threads go off the original topic and becomes difficult to follow them.yet another colorband question (I seem to be making heavy use of them...)
There's StartLine's and EndLine's DragLine event already. You could try enabling a boolean flag there which is checked in MouseMove event and its code only being executed if the flag is true.When you move the drag the sides of a [vertical] colourband, could you make it so it triggers a MouseMove event??
Well, somehow it was asked in the thread you pointed . Anyway, we made it public for the next release which will be published imminently.On an unrelated note, can I be the first person to ask for GetNearestPoint to be public?!
Best Regards,
Narcís Calvet / 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 |