Index: Core/Common/src/Core.Common.Controls.Swf/Charting/ChartView.cs =================================================================== diff -u -r40a3475dedb6ce5aacbd38a6d7b8445665fb98cd -r7e4528624b05a7a6a4526ac43a9ae43795bfe24f --- Core/Common/src/Core.Common.Controls.Swf/Charting/ChartView.cs (.../ChartView.cs) (revision 40a3475dedb6ce5aacbd38a6d7b8445665fb98cd) +++ Core/Common/src/Core.Common.Controls.Swf/Charting/ChartView.cs (.../ChartView.cs) (revision 7e4528624b05a7a6a4526ac43a9ae43795bfe24f) @@ -273,9 +273,9 @@ teeChart.Chart.Axes.Bottom.SetMinMax(min, max); } - public IChartViewTool GetTool() + public T GetTool() where T : IChartViewTool { - return tools.FirstOrDefault(t => t is T); + return (T) tools.FirstOrDefault(t => t is T); } /// Index: Core/Common/src/Core.Common.Controls.Swf/Charting/IChartView.cs =================================================================== diff -u -r0c09106be1dfa0dad80232e39fea48b274ecdf37 -r7e4528624b05a7a6a4526ac43a9ae43795bfe24f --- Core/Common/src/Core.Common.Controls.Swf/Charting/IChartView.cs (.../IChartView.cs) (revision 0c09106be1dfa0dad80232e39fea48b274ecdf37) +++ Core/Common/src/Core.Common.Controls.Swf/Charting/IChartView.cs (.../IChartView.cs) (revision 7e4528624b05a7a6a4526ac43a9ae43795bfe24f) @@ -71,10 +71,10 @@ void ZoomToValues(double min, double max); /// - /// Gets the first tool of the right type () + /// Attempts to find the first tool of type . /// /// Type of tool to search for - IChartViewTool GetTool(); + T GetTool() where T : IChartViewTool; /// /// Disables the deleting of points by SelectPointTool (& delete key) Index: Core/Plugins/src/Core.Plugins.CommonTools.Gui/Commands/Charting/RulerCommand.cs =================================================================== diff -u -rfefc0cc505a41a79d4643c80335484daf4ca30ce -r7e4528624b05a7a6a4526ac43a9ae43795bfe24f --- Core/Plugins/src/Core.Plugins.CommonTools.Gui/Commands/Charting/RulerCommand.cs (.../RulerCommand.cs) (revision fefc0cc505a41a79d4643c80335484daf4ca30ce) +++ Core/Plugins/src/Core.Plugins.CommonTools.Gui/Commands/Charting/RulerCommand.cs (.../RulerCommand.cs) (revision 7e4528624b05a7a6a4526ac43a9ae43795bfe24f) @@ -1,11 +1,8 @@ -using Core.Common.Controls.Swf.Charting; -using Core.Common.Controls.Swf.Charting.Tools; -using Core.Common.Controls.Views; -using Core.Common.Gui; +using Core.Common.Controls.Swf.Charting.Tools; namespace Core.Plugins.CommonTools.Gui.Commands.Charting { - public class RulerCommand : GuiCommand + public class RulerCommand : ChartViewCommandBase { public override bool Checked { @@ -19,7 +16,7 @@ { get { - return Gui != null && Gui.DocumentViews.ActiveView != null && RulerTool != null; + return View != null && RulerTool != null; } } @@ -38,18 +35,8 @@ { get { - var chartView = GetChartViewWithRuler(Gui.DocumentViews.ActiveView); - return chartView == null ? null : chartView.GetTool() as RulerTool; + return View != null ? View.GetTool() : null; } } - - private ChartView GetChartViewWithRuler(IView view) - { - var chartView = view as ChartView; - - return chartView == null ? null : - chartView.GetTool() == null ? null : - chartView; - } } } \ No newline at end of file Index: Core/Plugins/src/Core.Plugins.CommonTools.Gui/Commands/Charting/ShowChartLegendViewCommand.cs =================================================================== diff -u -r10671f81a86637fcab2f4a38af58a9899ca1b240 -r7e4528624b05a7a6a4526ac43a9ae43795bfe24f --- Core/Plugins/src/Core.Plugins.CommonTools.Gui/Commands/Charting/ShowChartLegendViewCommand.cs (.../ShowChartLegendViewCommand.cs) (revision 10671f81a86637fcab2f4a38af58a9899ca1b240) +++ Core/Plugins/src/Core.Plugins.CommonTools.Gui/Commands/Charting/ShowChartLegendViewCommand.cs (.../ShowChartLegendViewCommand.cs) (revision 7e4528624b05a7a6a4526ac43a9ae43795bfe24f) @@ -39,9 +39,8 @@ } var view = commonToolsGuiPlugin.ChartLegendView; - var active = Gui.ToolWindowViews.Contains(view); - if (active) + if (Gui.ToolWindowViews.Contains(view)) { Gui.ToolWindowViews.Remove(view); }