I am trying to implement a trend line for use with a Stock Data Chart.
Code: Select all
private void popMenuTrendLine_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
DrawLine drawLine = new DrawLine();
drawLine.NewLine += new DrawLineEventHandler(drawLine_NewLine);
StockChart.Aspect.View3D = false;
drawLine.Style = DrawLineStyle.Line;
drawLine.Pen.Color = Color.Blue;
drawLine.Pen.Width = 2;
drawLine.Pen.Transparency = 50;
StockChart.Tools.Add(drawLine);
}
void drawLine_NewLine(DrawLine sender)
{
DrawLine drawLn = (DrawLine)sender;
Debug.Print("X0:" + drawLn.Selected.StartPos.X.ToString() +
" Y0:" + drawLn.Selected.StartPos.Y.ToString());
Debug.Print("X1:" + drawLn.Selected.EndPos.X.ToString() +
" Y1:" + drawLn.Selected.EndPos.Y.ToString());
Debug.Print("--------------------------------------------------");
//SaveOutTrendLineVals(X0,Y0,X1,Y1);
drawLn.NewLine -= new DrawLineEventHandler(drawLine_NewLine);
drawLn.Active = false;
Debug.Print(StockChart.Tools.Count.ToString());
Debug.Print("--------------------------------------------------");
}
2. I wish to draw a single line then return to other user tasks ... if I dont have the line "drawLn.Active = false;" I am forever stuck drawing lines on the screen ... if I DO have that line .. all my lines disapear from the chart .. (even though StockChart.Tools.Count shows they are in this collection.)
3. How can I programatically redraw these DrawLines .. as I need to save X0,y0,x1,y1 co-ords to a file and redraw the lines at a later time.
Regards Phil.