Index: Core/Common/src/Core.Common.Gui/IGui.cs =================================================================== diff -u -rd04111eb30246d9958c80b0ddc10e9192fd8136a -r03d5df1364557b6f4a184908affb7754e58b3fa4 --- Core/Common/src/Core.Common.Gui/IGui.cs (.../IGui.cs) (revision d04111eb30246d9958c80b0ddc10e9192fd8136a) +++ Core/Common/src/Core.Common.Gui/IGui.cs (.../IGui.cs) (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -11,6 +11,7 @@ using System.Configuration; using Core.Common.Base.Data; using Core.Common.Base.Plugin; +using Core.Common.Controls.Views; using Core.Common.Gui.Forms.MainWindow; using Core.Common.Gui.Forms.PropertyGridView; using Core.Common.Utils.PropertyBag; @@ -163,6 +164,18 @@ /// void UpdateToolTips(); + /// + /// Open the tool view and make it visible in the interface. + /// + /// The tool view to open. + void OpenToolView(IView toolView); + + /// + /// Close the tool view removing it from the interface. + /// + /// The tool view to close. + void CloseToolView(IView toolView); + #endregion #region Events Index: Core/Common/src/Core.Common.Gui/RingtoetsGui.cs =================================================================== diff -u -r42ca97fdb85a553c6aac3bfdfe57c7be4af90821 -r03d5df1364557b6f4a184908affb7754e58b3fa4 --- Core/Common/src/Core.Common.Gui/RingtoetsGui.cs (.../RingtoetsGui.cs) (revision 42ca97fdb85a553c6aac3bfdfe57c7be4af90821) +++ Core/Common/src/Core.Common.Gui/RingtoetsGui.cs (.../RingtoetsGui.cs) (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -402,6 +402,17 @@ } } + public void CloseToolView(IView toolView) + { + ToolWindowViews.Remove(toolView); + } + + public void OpenToolView(IView toolView) + { + ToolWindowViews.Add(toolView); + ToolWindowViews.ActiveView = toolView; + } + protected virtual void Dispose(bool disposing) { if (disposing) Index: Core/Plugins/src/Core.Plugins.Charting/Properties/Resources.Designer.cs =================================================================== diff -u -rd04111eb30246d9958c80b0ddc10e9192fd8136a -r03d5df1364557b6f4a184908affb7754e58b3fa4 --- Core/Plugins/src/Core.Plugins.Charting/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision d04111eb30246d9958c80b0ddc10e9192fd8136a) +++ Core/Plugins/src/Core.Plugins.Charting/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -417,7 +417,7 @@ } /// - /// Looks up a localized string similar to Grafiek. + /// Looks up a localized string similar to Oud Grafiek. /// public static string ChartingGuiPlugin_Chart { get { Index: Core/Plugins/src/Core.Plugins.Charting/Properties/Resources.resx =================================================================== diff -u -rd04111eb30246d9958c80b0ddc10e9192fd8136a -r03d5df1364557b6f4a184908affb7754e58b3fa4 --- Core/Plugins/src/Core.Plugins.Charting/Properties/Resources.resx (.../Resources.resx) (revision d04111eb30246d9958c80b0ddc10e9192fd8136a) +++ Core/Plugins/src/Core.Plugins.Charting/Properties/Resources.resx (.../Resources.resx) (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -467,7 +467,7 @@ Liniaal - Grafiek + Oud Grafiek Lettertype kan niet leeg zijn. Index: Core/Plugins/src/Core.Plugins.OxyPlot/ChartingRibbon.xaml =================================================================== diff -u -rd04111eb30246d9958c80b0ddc10e9192fd8136a -r03d5df1364557b6f4a184908affb7754e58b3fa4 --- Core/Plugins/src/Core.Plugins.OxyPlot/ChartingRibbon.xaml (.../ChartingRibbon.xaml) (revision d04111eb30246d9958c80b0ddc10e9192fd8136a) +++ Core/Plugins/src/Core.Plugins.OxyPlot/ChartingRibbon.xaml (.../ChartingRibbon.xaml) (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -6,6 +6,7 @@ xmlns:fluent="clr-namespace:Fluent;assembly=Fluent" xmlns:gui="clr-namespace:Core.Common.Gui;assembly=Core.Common.Gui" xmlns:p="clr-namespace:Core.Plugins.OxyPlot.Properties" + xmlns:common="clr-namespace:Core.Common.Gui.Properties;assembly=Core.Common.Gui" mc:Ignorable="d" Width="686.4" Height="168" Background="White"> @@ -22,6 +23,12 @@ + + + + + + Index: Core/Plugins/src/Core.Plugins.OxyPlot/ChartingRibbon.xaml.cs =================================================================== diff -u -r42ca97fdb85a553c6aac3bfdfe57c7be4af90821 -r03d5df1364557b6f4a184908affb7754e58b3fa4 --- Core/Plugins/src/Core.Plugins.OxyPlot/ChartingRibbon.xaml.cs (.../ChartingRibbon.xaml.cs) (revision 42ca97fdb85a553c6aac3bfdfe57c7be4af90821) +++ Core/Plugins/src/Core.Plugins.OxyPlot/ChartingRibbon.xaml.cs (.../ChartingRibbon.xaml.cs) (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -1,7 +1,4 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; +using System.Collections.Generic; using System.Windows; using Core.Common.Controls.Commands; using Core.Common.Gui.Forms; @@ -14,49 +11,56 @@ /// public partial class ChartingRibbon : IRibbonCommandHandler { - private readonly ICommand openChartViewCommand; - public ChartingRibbon() { InitializeComponent(); - openChartViewCommand = new OpenChartViewCommand(); } + public ICommand OpenChartViewCommand { private get; set; } + public ICommand ToggleLegendViewCommand { private get; set; } + public IEnumerable Commands { get { - yield return openChartViewCommand; + yield return OpenChartViewCommand; + yield return ToggleLegendViewCommand; } } + public void ShowChartingTab() + { + ChartingContextualGroup.Visibility = Visibility.Visible; + } + + public void HideChartingTab() + { + ChartingContextualGroup.Visibility = Visibility.Collapsed; + } + public Ribbon GetRibbonControl() { return RibbonControl; } public void ValidateItems() { + ToggleLegendButton.IsChecked = ToggleLegendViewCommand.Checked; } public bool IsContextualTabVisible(string tabGroupName, string tabName) { - return tabGroupName == ChartingContextualGroup.Name; + return false; } private void ButtonOpenChartView_Click(object sender, RoutedEventArgs e) { - openChartViewCommand.Execute(); + OpenChartViewCommand.Execute(); } - public void ShowChartingTab() + private void ButtonToggleLegend_Click(object sender, RoutedEventArgs e) { - ChartingContextualGroup.Visibility = Visibility.Visible; + ToggleLegendViewCommand.Execute(); } - - public void HideChartingTab() - { - ChartingContextualGroup.Visibility = Visibility.Collapsed; - } } -} +} \ No newline at end of file Index: Core/Plugins/src/Core.Plugins.OxyPlot/Commands/OpenChartViewCommand.cs =================================================================== diff -u --- Core/Plugins/src/Core.Plugins.OxyPlot/Commands/OpenChartViewCommand.cs (revision 0) +++ Core/Plugins/src/Core.Plugins.OxyPlot/Commands/OpenChartViewCommand.cs (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -0,0 +1,57 @@ +using System; +using System.Collections.ObjectModel; +using Core.Common.Gui; +using Core.Components.OxyPlot.Data; + +namespace Core.Plugins.OxyPlot.Commands +{ + public class OpenChartViewCommand : IGuiCommand { + public bool Enabled + { + get + { + return true; + } + } + + public bool Checked + { + get + { + return false; + } + } + + public IGui Gui { get; set; } + + public void Execute(params object[] arguments) + { + var line = new LineData(new Collection> + { + new Tuple(0.0, 1.1), + new Tuple(1.0, 2.1), + new Tuple(1.6, 1.6) + }); + var area = new AreaData(new Collection> + { + new Tuple(0.0, 1.1), + new Tuple(1.0, 2.1), + new Tuple(1.6, 1.6), + new Tuple(1.6, 0.5), + new Tuple(0.0, 0.5), + new Tuple(0.0, 1.1) + }); + var points = new PointData(new Collection> + { + new Tuple(0.0, 1.1), + new Tuple(0.5, 1.6), + new Tuple(1.0, 2.1) + }); + var data = new CollectionData(); + data.Add(area); + data.Add(line); + data.Add(points); + Gui.DocumentViewsResolver.OpenViewForData(data); + } + } +} \ No newline at end of file Index: Core/Plugins/src/Core.Plugins.OxyPlot/Commands/ToggleLegendViewCommand.cs =================================================================== diff -u --- Core/Plugins/src/Core.Plugins.OxyPlot/Commands/ToggleLegendViewCommand.cs (revision 0) +++ Core/Plugins/src/Core.Plugins.OxyPlot/Commands/ToggleLegendViewCommand.cs (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -0,0 +1,44 @@ +using Core.Common.Controls.Commands; +using Core.Plugins.OxyPlot.Legend; + +namespace Core.Plugins.OxyPlot.Commands +{ + /// + /// This class describes commands which control the state of a and uses a + /// to do so. The state of this command is determined by the state of the . + /// + public class ToggleLegendViewCommand : ICommand + { + private readonly LegendController controller; + + /// + /// Creates a new instance of . + /// + /// The to use to invoke actions and determine state. + public ToggleLegendViewCommand(LegendController controller) + { + this.controller = controller; + } + + public bool Enabled + { + get + { + return true; + } + } + + public bool Checked + { + get + { + return controller.IsLegendViewOpen(); + } + } + + public void Execute(params object[] arguments) + { + controller.ToggleLegend(); + } + } +} \ No newline at end of file Index: Core/Plugins/src/Core.Plugins.OxyPlot/Core.Plugins.OxyPlot.csproj =================================================================== diff -u -rd04111eb30246d9958c80b0ddc10e9192fd8136a -r03d5df1364557b6f4a184908affb7754e58b3fa4 --- Core/Plugins/src/Core.Plugins.OxyPlot/Core.Plugins.OxyPlot.csproj (.../Core.Plugins.OxyPlot.csproj) (revision d04111eb30246d9958c80b0ddc10e9192fd8136a) +++ Core/Plugins/src/Core.Plugins.OxyPlot/Core.Plugins.OxyPlot.csproj (.../Core.Plugins.OxyPlot.csproj) (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -76,11 +76,20 @@ ChartingRibbon.xaml + UserControl + + + UserControl + + + LegendView.cs + - + + @@ -90,6 +99,10 @@ + + {1D27F91F-4E62-4EAF-A0A8-A32708B9A9B1} + Core.Common.Controls.TreeView + {9A2D67E6-26AC-4D17-B11A-2B4372F2F572} Core.Common.Controls @@ -121,9 +134,14 @@ ChartDataView.cs + + LegendView.cs + Designer + PublicResXFileCodeGenerator Resources.Designer.cs + Designer Index: Core/Plugins/src/Core.Plugins.OxyPlot/IOxyPlotGuiPlugin.cs =================================================================== diff -u --- Core/Plugins/src/Core.Plugins.OxyPlot/IOxyPlotGuiPlugin.cs (revision 0) +++ Core/Plugins/src/Core.Plugins.OxyPlot/IOxyPlotGuiPlugin.cs (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -0,0 +1,31 @@ +using Core.Common.Controls.Views; +using Core.Common.Gui; + +namespace Core.Plugins.OxyPlot +{ + /// + /// Interface for the . Describes methods which require knowledge of + /// the . + /// + public interface IOxyPlotGuiPlugin { + + /// + /// Checks whether a tool window of type is open. + /// + /// The type of tool window to check for. + /// true if a tool window of type is open, false otherwise. + bool IsToolWindowOpen(); + + /// + /// Open the tool view and make it visible in the interface. + /// + /// The tool view to open. + void OpenToolView(IView toolView); + + /// + /// Close the tool view removing it from the interface. + /// + /// The tool view to close. + void CloseToolView(IView toolView); + } +} \ No newline at end of file Index: Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendController.cs =================================================================== diff -u --- Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendController.cs (revision 0) +++ Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendController.cs (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -0,0 +1,70 @@ +using System; +using Core.Common.Controls.Views; + +namespace Core.Plugins.OxyPlot.Legend +{ + /// + /// This class controls the actions which are related to a and act upon a . + /// + public class LegendController + { + private readonly IOxyPlotGuiPlugin plugin; + private IView legendView; + + /// + /// Creates a new instance of . + /// + /// The to invoke actions upon. + public LegendController(IOxyPlotGuiPlugin plugin) + { + if (plugin == null) + { + throw new ArgumentNullException("plugin", "Cannot create a LegendController when the plugin is null."); + } + this.plugin = plugin; + } + + /// + /// Toggles the . + /// + public void ToggleLegend() + { + if (IsLegendViewOpen()) + { + CloseLegendView(); + } + else + { + OpenLegendView(); + } + } + + /// + /// Checks whether a is open. + /// + /// true if the is open, false otherwise. + public bool IsLegendViewOpen() + { + return plugin.IsToolWindowOpen(); + } + + /// + /// Open the . + /// + private void OpenLegendView() + { + legendView = new LegendView(); + plugin.OpenToolView(legendView); + } + + /// + /// Closes the . + /// + private void CloseLegendView() + { + plugin.CloseToolView(legendView); + legendView.Dispose(); + legendView = null; + } + } +} \ No newline at end of file Index: Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.Designer.cs =================================================================== diff -u --- Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.Designer.cs (revision 0) +++ Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.Designer.cs (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -0,0 +1,83 @@ +using Core.Common.Controls.TreeView; + +namespace Core.Plugins.OxyPlot.Legend +{ + partial class LegendView + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LegendView)); + this.toolBar = new System.Windows.Forms.ToolStrip(); + this.treeView = new Core.Common.Controls.TreeView.TreeView(); + this.seriesTree = new Core.Common.Controls.TreeView.TreeView(); + this.SuspendLayout(); + // + // toolBar + // + this.toolBar.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; + resources.ApplyResources(this.toolBar, "toolBar"); + this.toolBar.Name = "toolBar"; + // + // treeView + // + this.treeView.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawAll; + this.treeView.HideSelection = false; + resources.ApplyResources(this.treeView, "treeView"); + this.treeView.LabelEdit = true; + this.treeView.LineColor = System.Drawing.Color.Empty; + this.treeView.Name = "treeView"; + this.treeView.SelectNodeOnRightMouseClick = true; + // + // seriesTree + // + this.seriesTree.AllowDrop = true; + resources.ApplyResources(this.seriesTree, "seriesTree"); + this.seriesTree.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawAll; + this.seriesTree.HideSelection = false; + this.seriesTree.LabelEdit = true; + this.seriesTree.Name = "seriesTree"; + this.seriesTree.SelectNodeOnRightMouseClick = true; + // + // LegendView + // + resources.ApplyResources(this, "$this"); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.seriesTree); + this.Controls.Add(this.toolBar); + this.Name = "LegendView"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ToolStrip toolBar; + private TreeView seriesTree; + } +} \ No newline at end of file Index: Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.cs =================================================================== diff -u --- Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.cs (revision 0) +++ Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.cs (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -0,0 +1,32 @@ +using System.Windows.Forms; +using Core.Common.Controls.Views; +using Core.Components.OxyPlot; +using Core.Plugins.OxyPlot.Properties; +using TreeView = Core.Common.Controls.TreeView.TreeView; + +namespace Core.Plugins.OxyPlot.Legend +{ + public sealed partial class LegendView : UserControl, IView + { + private BaseChart chart; + private TreeView treeView; + + public LegendView() + { + InitializeComponent(); + Text = Resources.Ribbon_Chart; + } + + public object Data + { + get + { + return chart; + } + set + { + chart = (BaseChart) value; + } + } + } +} \ No newline at end of file Index: Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.resx =================================================================== diff -u --- Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.resx (revision 0) +++ Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.resx (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -0,0 +1,216 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + + 0, 0 + + + 228, 25 + + + + 1 + + + toolStrip1 + + + toolBar + + + System.Windows.Forms.ToolStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + 0 + + + 0, 0 + + + 0 + + + 121, 97 + + + 0 + + + treeView + + + Core.Common.Controls.TreeView.TreeView, Core.Common.Controls.TreeView, Version=0.5.0.1491, Culture=neutral, PublicKeyToken=null + + + + Fill + + + 0 + + + 0, 25 + + + 0 + + + 228, 387 + + + 2 + + + seriesTree + + + Core.Common.Controls.TreeView.TreeView, Core.Common.Controls.TreeView, Version=0.5.0.1491, Culture=neutral, PublicKeyToken=null + + + $this + + + 0 + + + True + + + 6, 13 + + + 228, 412 + + + LegendView + + + System.Windows.Forms.UserControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file Fisheye: Tag 03d5df1364557b6f4a184908affb7754e58b3fa4 refers to a dead (removed) revision in file `Core/Plugins/src/Core.Plugins.OxyPlot/OpenChartViewCommand.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Plugins/src/Core.Plugins.OxyPlot/OxyPlotGuiPlugin.cs =================================================================== diff -u -rd04111eb30246d9958c80b0ddc10e9192fd8136a -r03d5df1364557b6f4a184908affb7754e58b3fa4 --- Core/Plugins/src/Core.Plugins.OxyPlot/OxyPlotGuiPlugin.cs (.../OxyPlotGuiPlugin.cs) (revision d04111eb30246d9958c80b0ddc10e9192fd8136a) +++ Core/Plugins/src/Core.Plugins.OxyPlot/OxyPlotGuiPlugin.cs (.../OxyPlotGuiPlugin.cs) (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -1,14 +1,18 @@ using System.Collections.Generic; +using System.Linq; +using Core.Common.Controls.Views; using Core.Common.Gui; using Core.Common.Gui.Forms; using Core.Common.Gui.Plugin; using Core.Components.OxyPlot.Data; +using Core.Plugins.OxyPlot.Commands; using Core.Plugins.OxyPlot.Forms; +using Core.Plugins.OxyPlot.Legend; using Core.Plugins.OxyPlot.Properties; namespace Core.Plugins.OxyPlot { - public class OxyPlotGuiPlugin : GuiPlugin + public class OxyPlotGuiPlugin : GuiPlugin, IOxyPlotGuiPlugin { private ChartingRibbon chartingRibbon; @@ -20,12 +24,50 @@ } } + public bool IsToolWindowOpen() + { + return Gui.ToolWindowViews.Any(t => t.GetType() == typeof(T)); + } + + public void OpenToolView(IView toolView) + { + Gui.OpenToolView(toolView); + } + + public void CloseToolView(IView toolView) + { + Gui.CloseToolView(toolView); + } + public override void Activate() { - chartingRibbon = new ChartingRibbon(); + CreateRibbon(); Gui.ActiveViewChanged += GuiOnActiveViewChanged; } + public override IEnumerable GetViewInfoObjects() + { + yield return new ViewInfo + { + Image = Resources.ChartIcon, + GetViewName = (v, o) => "Diagram" + }; + } + + /// + /// Creates the ribbon and the commands that will be used when clicking on the buttons. + /// + private void CreateRibbon() + { + var legendController = new LegendController(this); + + chartingRibbon = new ChartingRibbon + { + OpenChartViewCommand = new OpenChartViewCommand(), + ToggleLegendViewCommand = new ToggleLegendViewCommand(legendController) + }; + } + private void GuiOnActiveViewChanged(object sender, ActiveViewChangeEventArgs activeViewChangeEventArgs) { if (activeViewChangeEventArgs.View is IChartView) @@ -37,14 +79,5 @@ chartingRibbon.HideChartingTab(); } } - - public override IEnumerable GetViewInfoObjects() - { - yield return new ViewInfo - { - Image = Resources.ChartIcon, - GetViewName = (v, o) => "Diagram" - }; - } } } \ No newline at end of file Index: Core/Plugins/src/Core.Plugins.OxyPlot/Properties/Resources.Designer.cs =================================================================== diff -u -r638ecd7e12947000fb77e3e006cecc75ec7784be -r03d5df1364557b6f4a184908affb7754e58b3fa4 --- Core/Plugins/src/Core.Plugins.OxyPlot/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 638ecd7e12947000fb77e3e006cecc75ec7784be) +++ Core/Plugins/src/Core.Plugins.OxyPlot/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -115,5 +115,23 @@ return ResourceManager.GetString("Ribbon_Demo_Header", resourceCulture); } } + + /// + /// Looks up a localized string similar to Grafiek. + /// + public static string Ribbon_Toggle_Legend { + get { + return ResourceManager.GetString("Ribbon_Toggle_Legend", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Open het gereedschapsvenster voor grafieken.. + /// + public static string Ribbon_Toggle_Legend_ToolTip { + get { + return ResourceManager.GetString("Ribbon_Toggle_Legend_ToolTip", resourceCulture); + } + } } } Index: Core/Plugins/src/Core.Plugins.OxyPlot/Properties/Resources.resx =================================================================== diff -u -r638ecd7e12947000fb77e3e006cecc75ec7784be -r03d5df1364557b6f4a184908affb7754e58b3fa4 --- Core/Plugins/src/Core.Plugins.OxyPlot/Properties/Resources.resx (.../Resources.resx) (revision 638ecd7e12947000fb77e3e006cecc75ec7784be) +++ Core/Plugins/src/Core.Plugins.OxyPlot/Properties/Resources.resx (.../Resources.resx) (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -136,4 +136,10 @@ Demo + + Grafiek + + + Open het gereedschapsvenster voor grafieken. + \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Commands/OpenChartViewCommandTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Commands/OpenChartViewCommandTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Commands/OpenChartViewCommandTest.cs (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -0,0 +1,53 @@ +using Core.Common.Gui; +using Core.Plugins.OxyPlot.Commands; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Core.Plugins.OxyPlot.Test +{ + [TestFixture] + public class OpenChartViewCommandTest + { + [Test] + public void Execute_Always_OpensViewForIChartData() + { + // Setup + var mocks = new MockRepository(); + var guiMock = mocks.StrictMock(); + var viewResolverMock = mocks.StrictMock(); + guiMock.Expect(g => g.DocumentViewsResolver).Return(viewResolverMock); + viewResolverMock.Expect(vr => vr.OpenViewForData(null)).IgnoreArguments().Return(true); + + mocks.ReplayAll(); + + var command = new OpenChartViewCommand(); + command.Gui = guiMock; + + // Call + command.Execute(); + + // Assert + mocks.VerifyAll(); + } + + [Test] + public void Enabled_Always_ReturnsTrue() + { + // Setup + var command = new OpenChartViewCommand(); + + // Call & Assert + Assert.IsTrue(command.Enabled); + } + + [Test] + public void Checked_Always_ReturnsFalse() + { + // Setup + var command = new OpenChartViewCommand(); + + // Call & Assert + Assert.IsFalse(command.Checked); + } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Commands/ToggleLegendViewCommandTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Commands/ToggleLegendViewCommandTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Commands/ToggleLegendViewCommandTest.cs (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -0,0 +1,88 @@ +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using Core.Common.Controls.Commands; +using Core.Common.Controls.Views; +using Core.Common.Gui; +using Core.Plugins.OxyPlot.Commands; +using Core.Plugins.OxyPlot.Legend; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Core.Plugins.OxyPlot.Test +{ + [TestFixture] + public class ToggleLegendViewCommandTest + { + [Test] + public void Constructor_Always_CreatesICommand() + { + // Call + var command = new ToggleLegendViewCommand(null); + + // Assert + Assert.IsInstanceOf(command); + } + + [Test] + public void Enabled_Always_ReturnsTrue() + { + // Setup + var command = new ToggleLegendViewCommand(null); + + // Call & Assert + Assert.IsTrue(command.Enabled); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void Checked_LegendViewOpenOrClosed_ReturnsExpectedState(bool open) + { + // Setup + var mocks = new MockRepository(); + var plugin = mocks.StrictMock(); + plugin.Expect(p => p.IsToolWindowOpen()).Return(open); + + mocks.ReplayAll(); + + var controller = new LegendController(plugin); + var command = new ToggleLegendViewCommand(controller); + + // Call + var result = command.Checked; + + // Assert + Assert.AreEqual(open, result); + mocks.VerifyAll(); + } + + [Test] + public void Execute_Always_TogglesLegend() + { + // Setup + var mocks = new MockRepository(); + var plugin = mocks.StrictMock(); + + // Open first + plugin.Expect(p => p.IsToolWindowOpen()).Return(false); + plugin.Expect(p => p.OpenToolView(Arg.Matches(v => true))); + + // Then close + plugin.Expect(p => p.IsToolWindowOpen()).Return(true); + plugin.Expect(p => p.CloseToolView(Arg.Matches(v => true))); + + mocks.ReplayAll(); + + var controller = new LegendController(plugin); + var command = new ToggleLegendViewCommand(controller); + + // Call + command.Execute(); + command.Execute(); + + // Assert + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Core.Plugins.OxyPlot.Test.csproj =================================================================== diff -u -r2cabd8bee5e1046b5a0e46664633de35c3ba8c4a -r03d5df1364557b6f4a184908affb7754e58b3fa4 --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Core.Plugins.OxyPlot.Test.csproj (.../Core.Plugins.OxyPlot.Test.csproj) (revision 2cabd8bee5e1046b5a0e46664633de35c3ba8c4a) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Core.Plugins.OxyPlot.Test.csproj (.../Core.Plugins.OxyPlot.Test.csproj) (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -66,8 +66,11 @@ + - + + + Component Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/LegendControllerTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/LegendControllerTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/LegendControllerTest.cs (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -0,0 +1,93 @@ +using System; +using Core.Plugins.OxyPlot.Legend; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Core.Plugins.OxyPlot.Test.Legend +{ + [TestFixture] + public class LegendControllerTest + { + [Test] + public void Constructor_WithoutPlugin_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new LegendController(null); + + // Assert + Assert.Throws(test); + } + + [Test] + public void Constructor_WithPlugin_DoesNotThrow() + { + // Setup + using (var plugin = new OxyPlotGuiPlugin()) + { + // Call + TestDelegate test = () => new LegendController(plugin); + + // Assert + Assert.DoesNotThrow(test); + } + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void IsLegendViewOpen_LegendViewOpenAndClosedState_ReturnsExpectedState(bool open) + { + // Setup + var mocks = new MockRepository(); + var plugin = mocks.StrictMock(); + plugin.Expect(p => p.IsToolWindowOpen()).Return(open); + + mocks.ReplayAll(); + + var controller = new LegendController(plugin); + + // Call + var result = controller.IsLegendViewOpen(); + + // Assert + Assert.AreEqual(open, result); + mocks.VerifyAll(); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void ToggleLegendView_LegendViewOpenAndClosedState_TogglesStateOfLegendView(bool open) + { + // Setup + var mocks = new MockRepository(); + var plugin = mocks.StrictMock(); + if (open) + { + plugin.Expect(p => p.IsToolWindowOpen()).Return(false); + plugin.Expect(p => p.OpenToolView(Arg.Matches(c => true))); + plugin.Expect(p => p.CloseToolView(Arg.Matches(c => true))); + } + else + { + plugin.Expect(p => p.OpenToolView(Arg.Matches(c => true))); + } + plugin.Expect(p => p.IsToolWindowOpen()).Return(open); + + mocks.ReplayAll(); + + var controller = new LegendController(plugin); + + if (open) + { + controller.ToggleLegend(); + } + + // Call + controller.ToggleLegend(); + + // Assert + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/LegendViewTest.cs =================================================================== diff -u --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/LegendViewTest.cs (revision 0) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/LegendViewTest.cs (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -0,0 +1,51 @@ +using System; +using System.Windows.Forms; +using Core.Common.Controls.Views; +using Core.Components.OxyPlot; +using Core.Plugins.OxyPlot.Legend; +using NUnit.Framework; + +namespace Core.Plugins.OxyPlot.Test.Legend +{ + [TestFixture] + public class LegendViewTest + { + [Test] + public void DefaultConstructor_CreatesUserControl() + { + // Call + var view = new LegendView(); + + // Assert + Assert.IsInstanceOf(view); + Assert.IsInstanceOf(view); + } + + [Test] + public void Data_BaseChart_DataSet() + { + // Setup + var view = new LegendView(); + var baseChart = new BaseChart(); + + // Call + view.Data = baseChart; + + // Assert + Assert.AreSame(baseChart, view.Data); + } + + [Test] + public void Data_OtherObject_ThrowsInvalidCastException() + { + // Setup + var view = new LegendView(); + + // Call + TestDelegate test = () => view.Data = new object(); + + // Assert + Assert.Throws(test); + } + } +} \ No newline at end of file Fisheye: Tag 03d5df1364557b6f4a184908affb7754e58b3fa4 refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.OxyPlot.Test/OpenChartViewCommandTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/OxyPlotGuiPluginTest.cs =================================================================== diff -u -r42ca97fdb85a553c6aac3bfdfe57c7be4af90821 -r03d5df1364557b6f4a184908affb7754e58b3fa4 --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/OxyPlotGuiPluginTest.cs (.../OxyPlotGuiPluginTest.cs) (revision 42ca97fdb85a553c6aac3bfdfe57c7be4af90821) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/OxyPlotGuiPluginTest.cs (.../OxyPlotGuiPluginTest.cs) (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -15,67 +15,71 @@ public class OxyPlotGuiPluginTest { [Test] - [RequiresSTA] public void DefaultConstructor_Always_NoRibbonCommandHandlerSet() { // Call - var plugin = new OxyPlotGuiPlugin(); - - // Assert - Assert.IsInstanceOf(plugin); - Assert.IsNull(plugin.RibbonCommandHandler); + using (var plugin = new OxyPlotGuiPlugin()) + { + // Assert + Assert.IsInstanceOf(plugin); + Assert.IsNull(plugin.RibbonCommandHandler); + } } [Test] [RequiresSTA] public void Activate_WithoutGui_ThrowsNullReferenceException() { // Setup - var plugin = new OxyPlotGuiPlugin(); + using (var plugin = new OxyPlotGuiPlugin()) + { + // Call + TestDelegate test = () => plugin.Activate(); - // Call - TestDelegate test = () => plugin.Activate(); - - // Assert - Assert.Throws(test); + // Assert + Assert.Throws(test); + } } + [Test] [RequiresSTA] public void Activate_WithGui_SetsRibbonCommandHandlerAndBindsActiveViewChanged() { // Setup - var mocks = new MockRepository(); - var plugin = new OxyPlotGuiPlugin(); - var gui = mocks.StrictMock(); - gui.Expect(g => g.ActiveViewChanged += null).IgnoreArguments(); + using (var plugin = new OxyPlotGuiPlugin()) + { + var mocks = new MockRepository(); + var gui = mocks.StrictMock(); + gui.Expect(g => g.ActiveViewChanged += null).IgnoreArguments(); - mocks.ReplayAll(); + mocks.ReplayAll(); - plugin.Gui = gui; + plugin.Gui = gui; - // Call - plugin.Activate(); + // Call + plugin.Activate(); - // Assert - Assert.IsInstanceOf(plugin); - Assert.NotNull(plugin.RibbonCommandHandler); - mocks.VerifyAll(); + // Assert + Assert.IsInstanceOf(plugin); + Assert.NotNull(plugin.RibbonCommandHandler); + mocks.VerifyAll(); + } } [Test] - [RequiresSTA] public void GetViewInfoObjects_Always_ReturnsChartDataViewInfo() { // Setup - var plugin = new OxyPlotGuiPlugin(); + using (var plugin = new OxyPlotGuiPlugin()) + { + // Call + var views = plugin.GetViewInfoObjects().ToArray(); - // Call - var views = plugin.GetViewInfoObjects().ToArray(); - - // Assert - Assert.AreEqual(1, views.Length); - Assert.AreEqual(typeof(IChartData), views[0].DataType); - Assert.AreEqual(typeof(ChartDataView), views[0].ViewType); + // Assert + Assert.AreEqual(1, views.Length); + Assert.AreEqual(typeof(IChartData), views[0].DataType); + Assert.AreEqual(typeof(ChartDataView), views[0].ViewType); + } } [Test] @@ -86,13 +90,13 @@ { // Given using (var gui = new RingtoetsGui()) + using (var plugin = new OxyPlotGuiPlugin()) { var mocks = new MockRepository(); IView viewMock = visible ? (IView) new TestChartView() : new TestView(); mocks.ReplayAll(); - var plugin = new OxyPlotGuiPlugin(); gui.Plugins.Add(plugin); gui.Run(); Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/RibbonTest.cs =================================================================== diff -u -rd04111eb30246d9958c80b0ddc10e9192fd8136a -r03d5df1364557b6f4a184908affb7754e58b3fa4 --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/RibbonTest.cs (.../RibbonTest.cs) (revision d04111eb30246d9958c80b0ddc10e9192fd8136a) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/RibbonTest.cs (.../RibbonTest.cs) (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -1,4 +1,7 @@ using System.Linq; +using Core.Common.Controls.Commands; +using Core.Plugins.OxyPlot.Commands; +using Core.Plugins.OxyPlot.Legend; using NUnit.Framework; namespace Core.Plugins.OxyPlot.Test @@ -8,7 +11,7 @@ { [Test] [RequiresSTA] - public void Commands_Always_ReturnsOpenChartViewCommand() + public void Commands_NoCommandsAssigned_ReturnsNullForCommands() { // Setup var ribbon = new ChartingRibbon(); @@ -17,15 +20,36 @@ var commands = ribbon.Commands.ToArray(); // Assert - Assert.AreEqual(1, commands.Count()); - Assert.IsInstanceOf(commands.First()); + CollectionAssert.AreEqual(Enumerable.Repeat(null,2),commands); } [Test] [RequiresSTA] - public void RibbonControl_Always_ReturnsRibbonControl() + public void Commands_CommandsAssigned_ReturnsAssignedCommands() { // Setup + using(var oxyPlotGuiPlugin = new OxyPlotGuiPlugin()) { + var openChartViewCommand = new OpenChartViewCommand(); + var toggleLegendViewCommand = new ToggleLegendViewCommand(new LegendController(oxyPlotGuiPlugin)); + var ribbon = new ChartingRibbon + { + OpenChartViewCommand = openChartViewCommand, + ToggleLegendViewCommand = toggleLegendViewCommand + }; + + // Call + var commands = ribbon.Commands.ToArray(); + + // Assert + CollectionAssert.AreEqual(new ICommand[]{openChartViewCommand, toggleLegendViewCommand}, commands); + } + } + + [Test] + [RequiresSTA] + public void DefaultConstructor_Always_CreatesControl() + { + // Setup var ribbon = new ChartingRibbon(); // Call & Assert Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/packages.config =================================================================== diff -u -r2cabd8bee5e1046b5a0e46664633de35c3ba8c4a -r03d5df1364557b6f4a184908affb7754e58b3fa4 --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/packages.config (.../packages.config) (revision 2cabd8bee5e1046b5a0e46664633de35c3ba8c4a) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/packages.config (.../packages.config) (revision 03d5df1364557b6f4a184908affb7754e58b3fa4) @@ -1,6 +1,5 @@  -