Index: src/Common/DelftTools.Controls.Swf/Charting/Tools/MarkerTool.cs =================================================================== diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -r5fc71a385897af92ccb092f2f969b5709afab85a --- src/Common/DelftTools.Controls.Swf/Charting/Tools/MarkerTool.cs (.../MarkerTool.cs) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9) +++ src/Common/DelftTools.Controls.Swf/Charting/Tools/MarkerTool.cs (.../MarkerTool.cs) (revision 5fc71a385897af92ccb092f2f969b5709afab85a) @@ -12,52 +12,39 @@ /// internal class MarkerTool : ToolSeries, IMarkerTool { + public event EventHandler ValueChanged; + public event EventHandler MouseDown; private readonly CursorLineTool bottomLine; private readonly DeltaShellTChart chartControl; - - /// - /// Series the markertool is connected to. ex. cross-section - /// - public ILineChartSeries BoundedSeries { get; set; } /// - /// BottomLine - /// - public ICursorLineTool BottomLine - { - get { return bottomLine; } - } - - /// /// Constructor of MarkerTool /// public MarkerTool(DeltaShellTChart chart) { chartControl = chart; bottomLine = new CursorLineTool(chartControl, CursorToolStyles.Horizontal); - chartControl.Tools.Add((CursorLineTool)BottomLine); + chartControl.Tools.Add((CursorLineTool) BottomLine); //event handlers BottomLine.Drop += BottomLineDrop; } - public void Hide(bool hide) + /// + /// Series the markertool is connected to. ex. cross-section + /// + public ILineChartSeries BoundedSeries { get; set; } + + /// + /// BottomLine + /// + public ICursorLineTool BottomLine { - if (hide) + get { - if (chartControl.Tools.IndexOf((CursorLineTool)BottomLine) != -1) - { - chartControl.Tools.Remove((CursorLineTool) BottomLine); - } + return bottomLine; } - else - { - if (chartControl.Tools.IndexOf((CursorLineTool)BottomLine) == -1) - { - chartControl.Tools.Add((CursorLineTool)BottomLine); - } - } } /// @@ -82,9 +69,48 @@ public IChartView ChartView { get; set; } - public event EventHandler ValueChanged; - public event EventHandler MouseDown; + public void Hide(bool hide) + { + if (hide) + { + if (chartControl.Tools.IndexOf((CursorLineTool) BottomLine) != -1) + { + chartControl.Tools.Remove((CursorLineTool) BottomLine); + } + } + else + { + if (chartControl.Tools.IndexOf((CursorLineTool) BottomLine) == -1) + { + chartControl.Tools.Add((CursorLineTool) BottomLine); + } + } + } + #region private stuff + + private void ValidateBottomLine() + { + if (BoundedSeries != null) + { + if (BottomLine.YValue > BoundedSeries.MaxYValue()) + { + BottomLine.YValue = BoundedSeries.MaxYValue(); + } + if (BottomLine.YValue < BoundedSeries.MinYValue()) + { + BottomLine.YValue = BoundedSeries.MinYValue(); + } + } + + if (ValueChanged != null) + { + ValueChanged(BottomLine, new EventArgs()); + } + } + + #endregion + #region eventHandlers /// @@ -98,7 +124,9 @@ protected override void MouseEvent(MouseEventKinds kind, MouseEventArgs e, ref Cursor c) { if (!Enabled) + { return; + } if (kind == MouseEventKinds.Down) { ChartMouseDown(null, e); @@ -123,9 +151,13 @@ } private bool enabled = true; + public bool Enabled { - get { return enabled; } + get + { + return enabled; + } set { enabled = value; @@ -136,30 +168,5 @@ public event EventHandler ActiveChanged; #endregion - - #region private stuff - - - private void ValidateBottomLine() - { - if (BoundedSeries != null) - { - if (BottomLine.YValue > BoundedSeries.MaxYValue()) - { - BottomLine.YValue = BoundedSeries.MaxYValue(); - } - if (BottomLine.YValue < BoundedSeries.MinYValue()) - { - BottomLine.YValue = BoundedSeries.MinYValue(); - } - } - - if(ValueChanged != null) - { - ValueChanged(BottomLine, new EventArgs()); - } - } - - #endregion } } \ No newline at end of file