Index: Core/Components/src/Core.Components.Charting/Core.Components.Charting.csproj =================================================================== diff -u -rdaaa148db691a71c042fcdd3ca039cf13c59217c -rd2e8fef372ac718930dabb3952f7d0199764d39c --- Core/Components/src/Core.Components.Charting/Core.Components.Charting.csproj (.../Core.Components.Charting.csproj) (revision daaa148db691a71c042fcdd3ca039cf13c59217c) +++ Core/Components/src/Core.Components.Charting/Core.Components.Charting.csproj (.../Core.Components.Charting.csproj) (revision d2e8fef372ac718930dabb3952f7d0199764d39c) @@ -41,6 +41,7 @@ + Index: Core/Components/src/Core.Components.Charting/IChart.cs =================================================================== diff -u --- Core/Components/src/Core.Components.Charting/IChart.cs (revision 0) +++ Core/Components/src/Core.Components.Charting/IChart.cs (revision d2e8fef372ac718930dabb3952f7d0199764d39c) @@ -0,0 +1,34 @@ +using System.Collections.Generic; +using Core.Components.Charting.Data; + +namespace Core.Components.Charting +{ + public interface IChart { + bool IsPanning { get; } + + /// + /// Gets or sets the data to show in the . + /// + /// The returned collection is a copy of the previously set data. + ICollection Data { get; set; } + + /// + /// Sets the visibility of a series in this . + /// + /// The to set the visibility for. + /// A boolean value representing the new visibility. + void SetVisibility(ChartData serie, bool visibility); + + /// + /// Sets the position of the amongst the other data of the . + /// + /// The to change the position for. + /// The new position. + void SetPosition(ChartData data, int position); + + /// + /// Toggles panning of the . Panning is invoked by clicking the left mouse-button. + /// + void TogglePanning(); + } +} \ No newline at end of file Index: Core/Components/src/Core.Components.OxyPlot.Forms/BaseChart.cs =================================================================== diff -u -r9bf140313b222568c57110c9a8a664e2e1a213e1 -rd2e8fef372ac718930dabb3952f7d0199764d39c --- Core/Components/src/Core.Components.OxyPlot.Forms/BaseChart.cs (.../BaseChart.cs) (revision 9bf140313b222568c57110c9a8a664e2e1a213e1) +++ Core/Components/src/Core.Components.OxyPlot.Forms/BaseChart.cs (.../BaseChart.cs) (revision d2e8fef372ac718930dabb3952f7d0199764d39c) @@ -5,6 +5,7 @@ using System.Linq; using System.Windows.Forms; using Core.Common.Base; +using Core.Components.Charting; using Core.Components.Charting.Data; using Core.Components.OxyPlot.Properties; using OxyPlot; @@ -18,7 +19,7 @@ /// /// This class describes a plot view with configured representation of axes. /// - public sealed class BaseChart : Control, IObservable + public sealed class BaseChart : Control, IObservable, IChart { private readonly SeriesFactory seriesFactory = new SeriesFactory(); private readonly List> series = new List>(); Fisheye: Tag d2e8fef372ac718930dabb3952f7d0199764d39c refers to a dead (removed) revision in file `Core/Plugins/src/Core.Plugins.OxyPlot/ChartingInteractionController.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Plugins/src/Core.Plugins.OxyPlot/ChartingRibbon.xaml.cs =================================================================== diff -u -r9bf140313b222568c57110c9a8a664e2e1a213e1 -rd2e8fef372ac718930dabb3952f7d0199764d39c --- Core/Plugins/src/Core.Plugins.OxyPlot/ChartingRibbon.xaml.cs (.../ChartingRibbon.xaml.cs) (revision 9bf140313b222568c57110c9a8a664e2e1a213e1) +++ Core/Plugins/src/Core.Plugins.OxyPlot/ChartingRibbon.xaml.cs (.../ChartingRibbon.xaml.cs) (revision d2e8fef372ac718930dabb3952f7d0199764d39c) @@ -2,6 +2,7 @@ using System.Windows; using Core.Common.Controls.Commands; using Core.Common.Gui.Forms; +using Core.Components.Charting; using Fluent; namespace Core.Plugins.OxyPlot @@ -11,6 +12,8 @@ /// public partial class ChartingRibbon : IRibbonCommandHandler { + private IChart chart; + /// /// Creates a new instance of . /// @@ -19,6 +22,27 @@ InitializeComponent(); } + public IChart Chart + { + private get + { + return chart; + } + set + { + chart = value; + + if (chart != null) + { + ShowChartingTab(); + } + else + { + HideChartingTab(); + } + } + } + /// /// Sets the command used when the open chart button is clicked. /// @@ -29,11 +53,6 @@ /// public ICommand ToggleLegendViewCommand { private get; set; } - /// - /// Sets the command used when the enable panning button is clicked. - /// - public ICommand TogglePanningCommand { private get; set; } - public IEnumerable Commands { get @@ -46,26 +65,23 @@ { yield return ToggleLegendViewCommand; } - if (TogglePanningCommand != null) - { - yield return TogglePanningCommand; - } } } /// /// Shows the charting contextual tab. /// - public void ShowChartingTab() + private void ShowChartingTab() { ChartingContextualGroup.Visibility = Visibility.Visible; + ValidateItems(); } /// /// Hides the charting contextual tab. /// - public void HideChartingTab() + private void HideChartingTab() { ChartingContextualGroup.Visibility = Visibility.Collapsed; } @@ -78,6 +94,7 @@ public void ValidateItems() { ToggleLegendViewButton.IsChecked = ToggleLegendViewCommand.Checked; + TogglePanningButton.IsChecked = Chart != null && Chart.IsPanning; } public bool IsContextualTabVisible(string tabGroupName, string tabName) @@ -100,7 +117,7 @@ private void ButtonTogglePanning_Click(object sender, RoutedEventArgs e) { - TogglePanningCommand.Execute(); + Chart.TogglePanning(); } } } \ No newline at end of file Fisheye: Tag d2e8fef372ac718930dabb3952f7d0199764d39c refers to a dead (removed) revision in file `Core/Plugins/src/Core.Plugins.OxyPlot/Commands/TogglePanningCommand.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Plugins/src/Core.Plugins.OxyPlot/Core.Plugins.OxyPlot.csproj =================================================================== diff -u -r9bf140313b222568c57110c9a8a664e2e1a213e1 -rd2e8fef372ac718930dabb3952f7d0199764d39c --- Core/Plugins/src/Core.Plugins.OxyPlot/Core.Plugins.OxyPlot.csproj (.../Core.Plugins.OxyPlot.csproj) (revision 9bf140313b222568c57110c9a8a664e2e1a213e1) +++ Core/Plugins/src/Core.Plugins.OxyPlot/Core.Plugins.OxyPlot.csproj (.../Core.Plugins.OxyPlot.csproj) (revision d2e8fef372ac718930dabb3952f7d0199764d39c) @@ -59,13 +59,10 @@ ChartingRibbon.xaml - - UserControl - Index: Core/Plugins/src/Core.Plugins.OxyPlot/Forms/ChartDataView.cs =================================================================== diff -u -rdaaa148db691a71c042fcdd3ca039cf13c59217c -rd2e8fef372ac718930dabb3952f7d0199764d39c --- Core/Plugins/src/Core.Plugins.OxyPlot/Forms/ChartDataView.cs (.../ChartDataView.cs) (revision daaa148db691a71c042fcdd3ca039cf13c59217c) +++ Core/Plugins/src/Core.Plugins.OxyPlot/Forms/ChartDataView.cs (.../ChartDataView.cs) (revision d2e8fef372ac718930dabb3952f7d0199764d39c) @@ -11,19 +11,19 @@ /// public class ChartDataView : UserControl, IChartView { - private readonly BaseChart baseChart; + private readonly BaseChart chart; private ICollection data; /// /// Creates an instance of with just a on it. /// public ChartDataView() { - baseChart = new BaseChart + chart = new BaseChart { Dock = DockStyle.Fill }; - Controls.Add(baseChart); + Controls.Add(chart); } public object Data @@ -35,15 +35,15 @@ set { data = (ICollection) value; - baseChart.Data = data; + chart.Data = data; } } public BaseChart Chart { get { - return baseChart; + return chart; } } } Fisheye: Tag d2e8fef372ac718930dabb3952f7d0199764d39c refers to a dead (removed) revision in file `Core/Plugins/src/Core.Plugins.OxyPlot/IDocumentViewController.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Plugins/src/Core.Plugins.OxyPlot/OxyPlotGuiPlugin.cs =================================================================== diff -u -r9bf140313b222568c57110c9a8a664e2e1a213e1 -rd2e8fef372ac718930dabb3952f7d0199764d39c --- Core/Plugins/src/Core.Plugins.OxyPlot/OxyPlotGuiPlugin.cs (.../OxyPlotGuiPlugin.cs) (revision 9bf140313b222568c57110c9a8a664e2e1a213e1) +++ Core/Plugins/src/Core.Plugins.OxyPlot/OxyPlotGuiPlugin.cs (.../OxyPlotGuiPlugin.cs) (revision d2e8fef372ac718930dabb3952f7d0199764d39c) @@ -15,12 +15,11 @@ /// /// This class ties all the components together to enable charting interaction. /// - public class OxyPlotGuiPlugin : GuiPlugin, IToolViewController, IDocumentViewController + public class OxyPlotGuiPlugin : GuiPlugin, IToolViewController { private ChartingRibbon chartingRibbon; private LegendController legendController; - private static ChartingInteractionController chartInteractionController; private bool activated; @@ -35,7 +34,6 @@ public override void Activate() { legendController = CreateLegendController(this); - chartInteractionController = CreateChartInteractionController(this); chartingRibbon = CreateRibbon(legendController); legendController.ToggleLegend(); @@ -81,18 +79,6 @@ #endregion - #region IDocumentViewController - - public IView ActiveView - { - get - { - return Gui.ActiveView; - } - } - - #endregion - /// /// Creates a new . /// @@ -106,16 +92,6 @@ } /// - /// Creates a new . - /// - /// The to use for the controller. - /// A new instance. - private ChartingInteractionController CreateChartInteractionController(IDocumentViewController controller) - { - return new ChartingInteractionController(controller); - } - - /// /// Creates the and the commands that will be used when clicking on the buttons. /// /// The to use for the @@ -126,8 +102,7 @@ return new ChartingRibbon { OpenChartViewCommand = new OpenChartViewCommand(), - ToggleLegendViewCommand = new ToggleLegendViewCommand(legendController), - TogglePanningCommand = new TogglePanningCommand(chartInteractionController) + ToggleLegendViewCommand = new ToggleLegendViewCommand(legendController) }; } @@ -145,12 +120,12 @@ var chartView = Gui.ActiveView as IChartView; if (chartView != null) { - chartingRibbon.ShowChartingTab(); + chartingRibbon.Chart = chartView.Chart; legendController.UpdateForChart(chartView.Chart); } else { - chartingRibbon.HideChartingTab(); + chartingRibbon.Chart = null; legendController.UpdateForChart(null); } } Fisheye: Tag d2e8fef372ac718930dabb3952f7d0199764d39c refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.OxyPlot.Test/ChartingInteractionControllerTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/ChartingRibbonTest.cs =================================================================== diff -u -r9bf140313b222568c57110c9a8a664e2e1a213e1 -rd2e8fef372ac718930dabb3952f7d0199764d39c --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/ChartingRibbonTest.cs (.../ChartingRibbonTest.cs) (revision 9bf140313b222568c57110c9a8a664e2e1a213e1) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/ChartingRibbonTest.cs (.../ChartingRibbonTest.cs) (revision d2e8fef372ac718930dabb3952f7d0199764d39c) @@ -33,19 +33,17 @@ using(var oxyPlotGuiPlugin = new OxyPlotGuiPlugin()) { var openChartViewCommand = new OpenChartViewCommand(); var toggleLegendViewCommand = new ToggleLegendViewCommand(new LegendController(oxyPlotGuiPlugin)); - var togglePanningCommand = new TogglePanningCommand(new ChartingInteractionController(oxyPlotGuiPlugin)); var ribbon = new ChartingRibbon { OpenChartViewCommand = openChartViewCommand, ToggleLegendViewCommand = toggleLegendViewCommand, - TogglePanningCommand = togglePanningCommand }; // Call var commands = ribbon.Commands.ToArray(); // Assert - CollectionAssert.AreEqual(new ICommand[]{openChartViewCommand, toggleLegendViewCommand, togglePanningCommand}, commands); + CollectionAssert.AreEqual(new ICommand[]{openChartViewCommand, toggleLegendViewCommand}, commands); } } @@ -127,33 +125,6 @@ [Test] [RequiresSTA] - public void TogglePanningButton_OnClick_ExecutesTogglePanningCommand() - { - // Setup - var mocks = new MockRepository(); - var command = mocks.StrictMock(); - command.Expect(c => c.Execute()); - - mocks.ReplayAll(); - - var ribbon = new ChartingRibbon - { - TogglePanningCommand = command - }; - var button = ribbon.GetRibbonControl().FindName("TogglePanningButton") as ToggleButton; - - // Precondition - Assert.IsNotNull(button, "Ribbon should have an open chart view button."); - - // Call - button.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); - - // Assert - mocks.VerifyAll(); - } - - [Test] - [RequiresSTA] [TestCase(true)] [TestCase(false)] public void ValidateItems_Always_IsCheckedEqualToCommandChecked(bool commandChecked) Fisheye: Tag d2e8fef372ac718930dabb3952f7d0199764d39c refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.OxyPlot.Test/Commands/TogglePanningCommandTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Core.Plugins.OxyPlot.Test.csproj =================================================================== diff -u -r9bf140313b222568c57110c9a8a664e2e1a213e1 -rd2e8fef372ac718930dabb3952f7d0199764d39c --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Core.Plugins.OxyPlot.Test.csproj (.../Core.Plugins.OxyPlot.Test.csproj) (revision 9bf140313b222568c57110c9a8a664e2e1a213e1) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Core.Plugins.OxyPlot.Test.csproj (.../Core.Plugins.OxyPlot.Test.csproj) (revision d2e8fef372ac718930dabb3952f7d0199764d39c) @@ -59,9 +59,7 @@ - - Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/ChartNodePresenterTest.cs =================================================================== diff -u -rebc0e549bad9f3ae073dc82376509b9ee5a9fc49 -rd2e8fef372ac718930dabb3952f7d0199764d39c --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/ChartNodePresenterTest.cs (.../ChartNodePresenterTest.cs) (revision ebc0e549bad9f3ae073dc82376509b9ee5a9fc49) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/ChartNodePresenterTest.cs (.../ChartNodePresenterTest.cs) (revision d2e8fef372ac718930dabb3952f7d0199764d39c) @@ -86,16 +86,16 @@ { // Setup var nodePresenter = new ChartNodePresenter(); - BaseChart baseChart = CreateTestBaseChart(); + BaseChart chart = CreateTestBaseChart(); - ChartData testElement = baseChart.Data.ElementAt(0); + ChartData testElement = chart.Data.ElementAt(0); // Call - nodePresenter.OnDragDrop(testElement, null, baseChart, 0, position); + nodePresenter.OnDragDrop(testElement, null, chart, 0, position); // Assert var reversedIndex = 2 - position; - Assert.AreSame(testElement, baseChart.Data.ElementAt(reversedIndex)); + Assert.AreSame(testElement, chart.Data.ElementAt(reversedIndex)); } [Test] @@ -107,12 +107,12 @@ { // Setup var nodePresenter = new ChartNodePresenter(); - BaseChart baseChart = CreateTestBaseChart(); + BaseChart chart = CreateTestBaseChart(); - ChartData testElement = baseChart.Data.ElementAt(0); + ChartData testElement = chart.Data.ElementAt(0); // Call - TestDelegate test = () => nodePresenter.OnDragDrop(testElement, null, baseChart, 0, position); + TestDelegate test = () => nodePresenter.OnDragDrop(testElement, null, chart, 0, position); // Assert Assert.Throws(test); Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/OxyPlotGuiPluginTest.cs =================================================================== diff -u -r9bf140313b222568c57110c9a8a664e2e1a213e1 -rd2e8fef372ac718930dabb3952f7d0199764d39c --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/OxyPlotGuiPluginTest.cs (.../OxyPlotGuiPluginTest.cs) (revision 9bf140313b222568c57110c9a8a664e2e1a213e1) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/OxyPlotGuiPluginTest.cs (.../OxyPlotGuiPluginTest.cs) (revision d2e8fef372ac718930dabb3952f7d0199764d39c) @@ -27,7 +27,6 @@ // Assert Assert.IsInstanceOf(plugin); Assert.IsInstanceOf(plugin); - Assert.IsInstanceOf(plugin); Assert.IsNull(plugin.RibbonCommandHandler); } } @@ -124,30 +123,6 @@ } [Test] - public void ActiveView_Always_ReturnGuiActiveView() - { - // Setup - var mocks = new MockRepository(); - var gui = mocks.StrictMock(); - var view = mocks.StrictMock(); - - gui.Expect(g => g.ActiveView).Return(view); - - mocks.ReplayAll(); - - using (var plugin = new OxyPlotGuiPlugin()) - { - plugin.Gui = gui; - - // Call - var result = plugin.ActiveView; - - // Assert - Assert.AreSame(view, result); - } - } - - [Test] [RequiresSTA] [TestCase(true)] [TestCase(false)] @@ -186,18 +161,22 @@ [TestCase(true)] [TestCase(false)] [RequiresSTA] - public void GivenConfiguredGui_WhenActiveViewChangesToIChartView_ThenRibbonSetVisibility(bool visible) + public void GivenConfiguredGui_WhenActiveViewChangesToViewWithChart_ThenRibbonSetVisibility(bool visible) { // Given using (var gui = new RingtoetsGui()) { var plugin = new OxyPlotGuiPlugin(); gui.MainWindow = new MainWindow(gui); var mocks = new MockRepository(); - IView viewMock = visible ? (IView) new TestChartView() : new TestView(); + var testChartView = new TestChartView(); + var chart = new BaseChart(); + IView viewMock = visible ? (IView) testChartView : new TestView(); mocks.ReplayAll(); + testChartView.Data = chart; + gui.Plugins.Add(plugin); plugin.Gui = gui; gui.Run();