Index: src/Common/DelftTools.Controls.Swf/Charting/Tools/CursorLineTool.cs =================================================================== diff -u -r0f4f3090613131cc878aeff213dd14e7658e0a7b -r5fc71a385897af92ccb092f2f969b5709afab85a --- src/Common/DelftTools.Controls.Swf/Charting/Tools/CursorLineTool.cs (.../CursorLineTool.cs) (revision 0f4f3090613131cc878aeff213dd14e7658e0a7b) +++ src/Common/DelftTools.Controls.Swf/Charting/Tools/CursorLineTool.cs (.../CursorLineTool.cs) (revision 5fc71a385897af92ccb092f2f969b5709afab85a) @@ -12,11 +12,16 @@ /// internal class CursorLineTool : CursorTool, ICursorLineTool { - private bool DragMode { get; set; } - private Control ChartControl { get; set; } - private ToolTip ToolTip { get; set; } - public bool ToolTipEnabled { get; set; } + //events + public event EventHandler MouseUp; + public event EventHandler MouseDown; + public event EventHandler Drop; + public event EventHandler ValueChanged; + public event EventHandler ActiveChanged; + + private bool enabled = true; + /// /// Constructor with default Vertical style /// @@ -27,9 +32,7 @@ ToolTipEnabled = true; } - public CursorLineTool(Control chartControl, CursorToolStyles style) : this(chartControl, style, Color.DarkRed, 2, DashStyle.Dash) - { - } + public CursorLineTool(Control chartControl, CursorToolStyles style) : this(chartControl, style, Color.DarkRed, 2, DashStyle.Dash) {} /// /// Constructor with style parameter @@ -48,7 +51,10 @@ Pen.Style = lineDashStyle; ChartControl = chartControl; - ToolTip = new ToolTip { ShowAlways = false }; + ToolTip = new ToolTip + { + ShowAlways = false + }; //event listeners Change += Cursor_Change; @@ -58,14 +64,61 @@ //HACK: force explicit value } + public bool ToolTipEnabled { get; set; } - //events - public event EventHandler MouseUp; - public event EventHandler MouseDown; - public event EventHandler Drop; - public event EventHandler ValueChanged; + public override double XValue + { + get + { + return base.XValue; + } + set + { + //HACK1: force internal change + if (base.XValue == value) + { + base.XValue = value + 1.0; + } + base.XValue = value; + if (base.XValue != value) + { + base.XValue = value; //HACK2: force change (second time's the charm) + } + } + } + + public IChartView ChartView { get; set; } + + public bool Enabled + { + get + { + return enabled; + } + set + { + enabled = value; + } + } + + public new bool Active + { + get + { + return base.Active; + } + set + { + base.Active = value; + if (ActiveChanged != null) + { + ActiveChanged(this, null); + } + } + } + /// /// Handles mouse events for the tools and chart of Teechart. Teechart uses a special /// mechanism to let tools cooperate via chart.CancelMouse. Therefor do not use @@ -77,7 +130,9 @@ protected override void MouseEvent(MouseEventKinds kind, MouseEventArgs e, ref Cursor c) { if (!Enabled) + { return; + } base.MouseEvent(kind, e, ref c); switch (kind) { @@ -88,32 +143,58 @@ tChart_MouseUp(e); break; default: + { + Point P = new Point(e.X, e.Y); + CursorClicked cursorClicked = Clicked(P.X, P.Y); + if (CursorClicked.None != cursorClicked) { - Point P = new Point(e.X, e.Y); - CursorClicked cursorClicked = Clicked(P.X, P.Y); - if (CursorClicked.None != cursorClicked) - { - Chart.CancelMouse = true; - } + Chart.CancelMouse = true; } + } break; } } + /// + /// TOOLS-1158 do draw marker lines outside chart area. + /// Seems a little odd that it is necessary. + /// + /// + protected override void ChartEvent(EventArgs e) + { + if (!(e is AfterDrawEventArgs)) + { + return; + } + Chart.Graphics3D.ClipCube(Chart.ChartRect, 0, 0); + base.ChartEvent(e); + Chart.Graphics3D.UnClip(); + } + + private bool DragMode { get; set; } + private Control ChartControl { get; set; } + private ToolTip ToolTip { get; set; } + private void tChart_MouseDown(MouseEventArgs e) { if (Clicked(e.X, e.Y) == CursorClicked.None) + { return; + } DragMode = true; Chart.CancelMouse = true; if (MouseDown != null) + { MouseDown(this, e); + } } private void tChart_MouseUp(MouseEventArgs e) { if (!DragMode) + { return; + } Chart.CancelMouse = true; if (Drop != null) { @@ -123,7 +204,9 @@ ToolTip.ShowAlways = false; ToolTip.Hide(ChartControl); if (MouseUp != null) + { MouseUp(this, e); + } } private void Cursor_Change(object sender, CursorChangeEventArgs e) @@ -145,92 +228,56 @@ } } - public override double XValue + #region properties + + public Color LinePenColor { get { - return base.XValue; + return Pen.Color; } set - { - //HACK1: force internal change - if (base.XValue == value) - { - base.XValue = value + 1.0; - } - - base.XValue = value; - - if (base.XValue != value) - { - base.XValue = value; //HACK2: force change (second time's the charm) - } + { + Pen.Color = value; } } - /// - /// TOOLS-1158 do draw marker lines outside chart area. - /// Seems a little odd that it is necessary. - /// - /// - protected override void ChartEvent(EventArgs e) + public float[] LinePenDashPattern { - if (!(e is AfterDrawEventArgs)) - return; - Chart.Graphics3D.ClipCube(Chart.ChartRect, 0, 0); - base.ChartEvent(e); - Chart.Graphics3D.UnClip(); - } - - public IChartView ChartView { get; set; } - - private bool enabled = true; - - public bool Enabled - { - get { return enabled; } + get + { + return Pen.DashPattern; + } set { - enabled = value; + Pen.DashPattern = value; } } - public new bool Active + public int LinePenWidth { - get { return base.Active; } + get + { + return Pen.Width; + } set { - base.Active = value; - if (ActiveChanged != null) - { - ActiveChanged(this, null); - } + Pen.Width = value; } } - public event EventHandler ActiveChanged; - - #region properties - public Color LinePenColor - { - get { return Pen.Color; } - set { Pen.Color = value; } - } - public float[] LinePenDashPattern - { - get { return Pen.DashPattern; } - set { Pen.DashPattern = value; } - } - public int LinePenWidth - { - get { return Pen.Width; } - set { Pen.Width = value; } - } public DashStyle LinePenStyle { - get { return Pen.Style; } - set { Pen.Style = value; } + get + { + return Pen.Style; + } + set + { + Pen.Style = value; + } } + #endregion } } \ No newline at end of file