Index: Core/Plugins/src/Core.Plugins.OxyPlot/Core.Plugins.OxyPlot.csproj =================================================================== diff -u -r0d7895f07d2c1b15457ffdc8e8762780a5837030 -ra49c98841cb7c943ff7abbfef8110b4bf6f52a8b --- Core/Plugins/src/Core.Plugins.OxyPlot/Core.Plugins.OxyPlot.csproj (.../Core.Plugins.OxyPlot.csproj) (revision 0d7895f07d2c1b15457ffdc8e8762780a5837030) +++ Core/Plugins/src/Core.Plugins.OxyPlot/Core.Plugins.OxyPlot.csproj (.../Core.Plugins.OxyPlot.csproj) (revision a49c98841cb7c943ff7abbfef8110b4bf6f52a8b) @@ -66,9 +66,6 @@ ChartDataView.cs - - Component - UserControl Fisheye: Tag a49c98841cb7c943ff7abbfef8110b4bf6f52a8b refers to a dead (removed) revision in file `Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendTreeView.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.Designer.cs =================================================================== diff -u -r2ac724ffe21f3e67a82559d0e9fb03ffa21ce995 -ra49c98841cb7c943ff7abbfef8110b4bf6f52a8b --- Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.Designer.cs (.../LegendView.Designer.cs) (revision 2ac724ffe21f3e67a82559d0e9fb03ffa21ce995) +++ Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.Designer.cs (.../LegendView.Designer.cs) (revision a49c98841cb7c943ff7abbfef8110b4bf6f52a8b) @@ -19,7 +19,7 @@ { components.Dispose(); } - seriesTree.Dispose(); + treeView.Dispose(); base.Dispose(disposing); } @@ -33,30 +33,29 @@ { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LegendView)); - this.seriesTree = new Core.Plugins.OxyPlot.Legend.LegendTreeView(); + this.treeView = new TreeView(); this.SuspendLayout(); // - // seriesTree + // treeView // - this.seriesTree.AllowDrop = true; - this.seriesTree.ChartData = null; - resources.ApplyResources(this.seriesTree, "seriesTree"); - this.seriesTree.HideSelection = false; - this.seriesTree.LabelEdit = true; - this.seriesTree.Name = "seriesTree"; + this.treeView.AllowDrop = true; + resources.ApplyResources(this.treeView, "treeView"); + this.treeView.HideSelection = false; + this.treeView.LabelEdit = true; + this.treeView.Name = "treeView"; // // LegendView // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.seriesTree); + this.Controls.Add(this.treeView); this.Name = "LegendView"; this.ResumeLayout(false); } #endregion - private LegendTreeView seriesTree; + private TreeView treeView; } } \ No newline at end of file Index: Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.cs =================================================================== diff -u -rfbb37872d09f1ded75ce2209e8e48a6b64d8a78f -ra49c98841cb7c943ff7abbfef8110b4bf6f52a8b --- Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.cs (.../LegendView.cs) (revision fbb37872d09f1ded75ce2209e8e48a6b64d8a78f) +++ Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.cs (.../LegendView.cs) (revision a49c98841cb7c943ff7abbfef8110b4bf6f52a8b) @@ -19,12 +19,18 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Linq; using System.Windows.Forms; +using Core.Common.Base; +using Core.Common.Controls.TreeView; using Core.Common.Controls.Views; using Core.Components.Charting.Data; using Core.Components.OxyPlot.Forms; using Core.Plugins.OxyPlot.Properties; +using OxyPlotResources = Core.Plugins.OxyPlot.Properties.Resources; +using GuiResources = Core.Common.Gui.Properties.Resources; + namespace Core.Plugins.OxyPlot.Legend { /// @@ -39,30 +45,112 @@ { InitializeComponent(); Text = Resources.General_Chart; + + treeView.TreeViewController.RegisterTreeNodeInfo(new TreeNodeInfo + { + Text = pointData => OxyPlotResources.ChartDataNodePresenter_Point_data_label, + Image = pointData => OxyPlotResources.PointsIcon, + CanDrag = (pointData, sourceNode) => DragOperations.Move, + CanCheck = pointData => true, + IsChecked = pointData => pointData.IsVisible, + OnNodeChecked = PointBasedChartDataOnNodeChecked + }); + + treeView.TreeViewController.RegisterTreeNodeInfo(new TreeNodeInfo + { + Text = lineData => OxyPlotResources.ChartDataNodePresenter_Line_data_label, + Image = lineData => OxyPlotResources.LineIcon, + CanDrag = (lineData, sourceNode) => DragOperations.Move, + CanCheck = lineData => true, + IsChecked = lineData => lineData.IsVisible, + OnNodeChecked = PointBasedChartDataOnNodeChecked + }); + + treeView.TreeViewController.RegisterTreeNodeInfo(new TreeNodeInfo + { + Text = areaData => OxyPlotResources.ChartDataNodePresenter_Area_data_label, + Image = areaData => OxyPlotResources.AreaIcon, + CanDrag = (areaData, sourceNode) => DragOperations.Move, + CanCheck = areaData => true, + IsChecked = areaData => areaData.IsVisible, + OnNodeChecked = PointBasedChartDataOnNodeChecked + }); + + treeView.TreeViewController.RegisterTreeNodeInfo(new TreeNodeInfo + { + Text = baseChart => OxyPlotResources.General_Chart, + Image = baseChart => GuiResources.folder, + ChildNodeObjects = baseChart => baseChart.List.Reverse().Cast().ToArray(), + CanDrop = BaseChartCanDrop, + CanInsert = BaseChartCanInsert, + OnDrop = BaseChartOnDrop + }); } public object Data { get { - return seriesTree.ChartData; + return (ChartData) treeView.TreeViewController.Data; } set { - UpdateTree((ChartData) value); + if (IsDisposed) + { + return; + } + + treeView.TreeViewController.Data = (ChartData) value; } } - /// - /// Updates the tree with the current state of the chart. - /// - private void UpdateTree(ChartData data) + # region ChartData + + private void PointBasedChartDataOnNodeChecked(TreeNode node) { - if (IsDisposed) + var pointBasedChartData = node.Tag as PointBasedChartData; + if (pointBasedChartData != null) { - return; + pointBasedChartData.IsVisible = node.Checked; + pointBasedChartData.NotifyObservers(); + + var parentData = node.Parent != null ? node.Parent.Tag as IObservable : null; + if (parentData != null) + { + parentData.NotifyObservers(); + } } - seriesTree.ChartData = data; } + + # endregion + + # region ChartDataCollection + + private DragOperations BaseChartCanDrop(TreeNode sourceNode, TreeNode targetNode, DragOperations validOperations) + { + if (sourceNode.Tag is ChartData) + { + return validOperations; + } + + return DragOperations.None; + } + + private bool BaseChartCanInsert(TreeNode sourceNode, TreeNode targetNode) + { + return sourceNode.Tag is ChartData; + } + + private void BaseChartOnDrop(TreeNode sourceNode, TreeNode previousParentNode, DragOperations operation, int position) + { + var draggedData = (ChartData)sourceNode.Tag; + var target = (ChartDataCollection)previousParentNode.Tag; + + target.List.Remove(draggedData); + target.List.Insert(target.List.Count - position, draggedData); // Note: target is the same as the previous parent in this case + target.NotifyObservers(); + } + + # endregion } } \ No newline at end of file Index: Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.resx =================================================================== diff -u -r2ac724ffe21f3e67a82559d0e9fb03ffa21ce995 -ra49c98841cb7c943ff7abbfef8110b4bf6f52a8b --- Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.resx (.../LegendView.resx) (revision 2ac724ffe21f3e67a82559d0e9fb03ffa21ce995) +++ Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendView.resx (.../LegendView.resx) (revision a49c98841cb7c943ff7abbfef8110b4bf6f52a8b) @@ -118,36 +118,36 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + Fill - + 0 - + 0, 0 - + 0 - + 228, 412 - + 2 - - seriesTree + + treeView - + Core.Plugins.OxyPlot.Legend.LegendTreeView, Core.Plugins.OxyPlot, Version=0.5.0.1876, Culture=neutral, PublicKeyToken=null - + $this - + 0 Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Core.Plugins.OxyPlot.Test.csproj =================================================================== diff -u -rb6d165f6edddc4271e94c5f6d70c12d4ba0c60eb -ra49c98841cb7c943ff7abbfef8110b4bf6f52a8b --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Core.Plugins.OxyPlot.Test.csproj (.../Core.Plugins.OxyPlot.Test.csproj) (revision b6d165f6edddc4271e94c5f6d70c12d4ba0c60eb) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Core.Plugins.OxyPlot.Test.csproj (.../Core.Plugins.OxyPlot.Test.csproj) (revision a49c98841cb7c943ff7abbfef8110b4bf6f52a8b) @@ -65,7 +65,6 @@ - Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/AreaDataTreeNodeInfoTest.cs =================================================================== diff -u -rb6d165f6edddc4271e94c5f6d70c12d4ba0c60eb -ra49c98841cb7c943ff7abbfef8110b4bf6f52a8b --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/AreaDataTreeNodeInfoTest.cs (.../AreaDataTreeNodeInfoTest.cs) (revision b6d165f6edddc4271e94c5f6d70c12d4ba0c60eb) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/AreaDataTreeNodeInfoTest.cs (.../AreaDataTreeNodeInfoTest.cs) (revision a49c98841cb7c943ff7abbfef8110b4bf6f52a8b) @@ -4,27 +4,32 @@ using Core.Common.Base; using Core.Common.Controls.TreeView; using Core.Common.TestUtil; +using Core.Common.Utils.Reflection; using Core.Components.Charting.Data; using Core.Plugins.OxyPlot.Legend; using Core.Plugins.OxyPlot.Properties; using NUnit.Framework; using Rhino.Mocks; +using TreeView = Core.Common.Controls.TreeView.TreeView; namespace Core.Plugins.OxyPlot.Test.Legend { [TestFixture] public class AreaDataTreeNodeInfoTest { private MockRepository mocks; - private LegendTreeView legendTreeView; + private LegendView legendView; private TreeNodeInfo info; [SetUp] public void SetUp() { mocks = new MockRepository(); - legendTreeView = new LegendTreeView(); - info = legendTreeView.TreeViewController.TreeNodeInfos.First(tni => tni.TagType == typeof(AreaData)); + legendView = new LegendView(); + + var treeView = TypeUtils.GetField(legendView, "treeView"); + + info = treeView.TreeViewController.TreeNodeInfos.First(tni => tni.TagType == typeof(AreaData)); } [Test] Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/ChartDataCollectionTreeNodeInfoTest.cs =================================================================== diff -u -rb6d165f6edddc4271e94c5f6d70c12d4ba0c60eb -ra49c98841cb7c943ff7abbfef8110b4bf6f52a8b --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/ChartDataCollectionTreeNodeInfoTest.cs (.../ChartDataCollectionTreeNodeInfoTest.cs) (revision b6d165f6edddc4271e94c5f6d70c12d4ba0c60eb) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/ChartDataCollectionTreeNodeInfoTest.cs (.../ChartDataCollectionTreeNodeInfoTest.cs) (revision a49c98841cb7c943ff7abbfef8110b4bf6f52a8b) @@ -5,28 +5,33 @@ using Core.Common.Base; using Core.Common.Controls.TreeView; using Core.Common.TestUtil; +using Core.Common.Utils.Reflection; using Core.Components.Charting.Data; using Core.Plugins.OxyPlot.Legend; using NUnit.Framework; using Rhino.Mocks; using Resources = Core.Plugins.OxyPlot.Properties.Resources; using GuiResources = Core.Common.Gui.Properties.Resources; +using TreeView = Core.Common.Controls.TreeView.TreeView; namespace Core.Plugins.OxyPlot.Test.Legend { [TestFixture] public class ChartDataCollectionTreeNodeInfoTest { private MockRepository mocks; - private LegendTreeView legendTreeView; + private LegendView legendView; private TreeNodeInfo info; [SetUp] public void SetUp() { mocks = new MockRepository(); - legendTreeView = new LegendTreeView(); - info = legendTreeView.TreeViewController.TreeNodeInfos.First(tni => tni.TagType == typeof(ChartDataCollection)); + legendView = new LegendView(); + + var treeView = TypeUtils.GetField(legendView, "treeView"); + + info = treeView.TreeViewController.TreeNodeInfos.First(tni => tni.TagType == typeof(ChartDataCollection)); } [Test] Fisheye: Tag a49c98841cb7c943ff7abbfef8110b4bf6f52a8b refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/LegendTreeViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/LineDataTreeNodeInfoTest.cs =================================================================== diff -u -rb6d165f6edddc4271e94c5f6d70c12d4ba0c60eb -ra49c98841cb7c943ff7abbfef8110b4bf6f52a8b --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/LineDataTreeNodeInfoTest.cs (.../LineDataTreeNodeInfoTest.cs) (revision b6d165f6edddc4271e94c5f6d70c12d4ba0c60eb) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/LineDataTreeNodeInfoTest.cs (.../LineDataTreeNodeInfoTest.cs) (revision a49c98841cb7c943ff7abbfef8110b4bf6f52a8b) @@ -4,27 +4,32 @@ using Core.Common.Base; using Core.Common.Controls.TreeView; using Core.Common.TestUtil; +using Core.Common.Utils.Reflection; using Core.Components.Charting.Data; using Core.Plugins.OxyPlot.Legend; using Core.Plugins.OxyPlot.Properties; using NUnit.Framework; using Rhino.Mocks; +using TreeView = Core.Common.Controls.TreeView.TreeView; namespace Core.Plugins.OxyPlot.Test.Legend { [TestFixture] public class LineDataTreeNodeInfoTest { private MockRepository mocks; - private LegendTreeView legendTreeView; + private LegendView legendView; private TreeNodeInfo info; [SetUp] public void SetUp() { mocks = new MockRepository(); - legendTreeView = new LegendTreeView(); - info = legendTreeView.TreeViewController.TreeNodeInfos.First(tni => tni.TagType == typeof(LineData)); + legendView = new LegendView(); + + var treeView = TypeUtils.GetField(legendView, "treeView"); + + info = treeView.TreeViewController.TreeNodeInfos.First(tni => tni.TagType == typeof(LineData)); } [Test] Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/PointDataTreeNodeInfoTest.cs =================================================================== diff -u -rb6d165f6edddc4271e94c5f6d70c12d4ba0c60eb -ra49c98841cb7c943ff7abbfef8110b4bf6f52a8b --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/PointDataTreeNodeInfoTest.cs (.../PointDataTreeNodeInfoTest.cs) (revision b6d165f6edddc4271e94c5f6d70c12d4ba0c60eb) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/PointDataTreeNodeInfoTest.cs (.../PointDataTreeNodeInfoTest.cs) (revision a49c98841cb7c943ff7abbfef8110b4bf6f52a8b) @@ -4,27 +4,32 @@ using Core.Common.Base; using Core.Common.Controls.TreeView; using Core.Common.TestUtil; +using Core.Common.Utils.Reflection; using Core.Components.Charting.Data; using Core.Plugins.OxyPlot.Legend; using Core.Plugins.OxyPlot.Properties; using NUnit.Framework; using Rhino.Mocks; +using TreeView = Core.Common.Controls.TreeView.TreeView; namespace Core.Plugins.OxyPlot.Test.Legend { [TestFixture] public class PointDataTreeNodeInfoTest { private MockRepository mocks; - private LegendTreeView legendTreeView; + private LegendView legendView; private TreeNodeInfo info; [SetUp] public void SetUp() { mocks = new MockRepository(); - legendTreeView = new LegendTreeView(); - info = legendTreeView.TreeViewController.TreeNodeInfos.First(tni => tni.TagType == typeof(PointData)); + legendView = new LegendView(); + + var treeView = TypeUtils.GetField(legendView, "treeView"); + + info = treeView.TreeViewController.TreeNodeInfos.First(tni => tni.TagType == typeof(PointData)); } [Test]