Index: Core/Common/src/Core.Common.Controls/DataGrid/DataGridViewControl.cs
===================================================================
diff -u -re7831d48151958eb3b965bfcc382eeafea11b5d0 -re25d2b8b5045ee7549f406cfb8a4ea0f81ec7a7d
--- Core/Common/src/Core.Common.Controls/DataGrid/DataGridViewControl.cs (.../DataGridViewControl.cs) (revision e7831d48151958eb3b965bfcc382eeafea11b5d0)
+++ Core/Common/src/Core.Common.Controls/DataGrid/DataGridViewControl.cs (.../DataGridViewControl.cs) (revision e25d2b8b5045ee7549f406cfb8a4ea0f81ec7a7d)
@@ -235,7 +235,7 @@
{
dataGridView.CancelEdit();
dataGridView.EndEdit();
- dataGridView.CurrentCell = null;
+ EndCellEdit();
}
}
@@ -377,6 +377,14 @@
dataGridView.CellClick -= handler;
}
+ ///
+ /// Clears the current cell.
+ ///
+ public void ClearCurrentCell()
+ {
+ dataGridView.CurrentCell = null;
+ }
+
private void SubscribeEvents()
{
dataGridView.ColumnAdded += DataGridViewOnColumnAdded;
@@ -438,10 +446,17 @@
dataGridView.CurrentCell.OwningRow.ErrorText = string.Empty;
}
- dataGridView.CurrentCell = null;
+ EndCellEdit();
}
}
+ private void EndCellEdit()
+ {
+ var currentCell = dataGridView.CurrentCell;
+ dataGridView.CurrentCell = null;
+ dataGridView.CurrentCell = currentCell;
+ }
+
#endregion
}
}
\ No newline at end of file
Index: Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj
===================================================================
diff -u -rdd84dcabe5561e637e4ade45457437d9c037535b -re25d2b8b5045ee7549f406cfb8a4ea0f81ec7a7d
--- Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision dd84dcabe5561e637e4ade45457437d9c037535b)
+++ Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision e25d2b8b5045ee7549f406cfb8a4ea0f81ec7a7d)
@@ -132,6 +132,7 @@
+
Index: Core/Common/src/Core.Common.Gui/Forms/ViewHost/AvalonDockViewHost.xaml.cs
===================================================================
diff -u -r22bfc7d1330c3602f2e81cb158c2ce3f13325905 -re25d2b8b5045ee7549f406cfb8a4ea0f81ec7a7d
--- Core/Common/src/Core.Common.Gui/Forms/ViewHost/AvalonDockViewHost.xaml.cs (.../AvalonDockViewHost.xaml.cs) (revision 22bfc7d1330c3602f2e81cb158c2ce3f13325905)
+++ Core/Common/src/Core.Common.Gui/Forms/ViewHost/AvalonDockViewHost.xaml.cs (.../AvalonDockViewHost.xaml.cs) (revision e25d2b8b5045ee7549f406cfb8a4ea0f81ec7a7d)
@@ -39,6 +39,7 @@
{
public event EventHandler ActiveDocumentViewChanging;
public event EventHandler ActiveDocumentViewChanged;
+ public event EventHandler ActiveViewChanged;
public event EventHandler ViewClosed;
private readonly List toolViews;
@@ -247,6 +248,14 @@
}
}
+ private void OnActiveViewChangedEvent()
+ {
+ if (ActiveViewChanged != null)
+ {
+ ActiveViewChanged(this, new ViewChangeEventArgs(GetView(dockingManager.ActiveContent)));
+ }
+ }
+
private void OnViewClosedEvent()
{
if (ViewClosed != null)
@@ -276,7 +285,12 @@
if (documentViews.Contains(focussedView))
{
ActiveDocumentView = focussedView;
+ OnActiveViewChangedEvent();
}
+ else if (toolViews.Contains(focussedView))
+ {
+ OnActiveViewChangedEvent();
+ }
else if (dockingManager.ActiveContent == null)
{
ActiveDocumentView = null;
Index: Core/Common/src/Core.Common.Gui/Forms/ViewHost/IViewHost.cs
===================================================================
diff -u -r399dd53d2efa4adb1a3010184e38515b65cef723 -re25d2b8b5045ee7549f406cfb8a4ea0f81ec7a7d
--- Core/Common/src/Core.Common.Gui/Forms/ViewHost/IViewHost.cs (.../IViewHost.cs) (revision 399dd53d2efa4adb1a3010184e38515b65cef723)
+++ Core/Common/src/Core.Common.Gui/Forms/ViewHost/IViewHost.cs (.../IViewHost.cs) (revision e25d2b8b5045ee7549f406cfb8a4ea0f81ec7a7d)
@@ -42,6 +42,11 @@
event EventHandler ActiveDocumentViewChanged;
///
+ /// Fired after the active document or tool view has changed.
+ ///
+ event EventHandler ActiveViewChanged;
+
+ ///
/// Fired when a document view or a tool view has been closed.
///
event EventHandler ViewClosed;
Index: Core/Common/src/Core.Common.Gui/Forms/ViewHost/ViewChangeEventArgs.cs
===================================================================
diff -u
--- Core/Common/src/Core.Common.Gui/Forms/ViewHost/ViewChangeEventArgs.cs (revision 0)
+++ Core/Common/src/Core.Common.Gui/Forms/ViewHost/ViewChangeEventArgs.cs (revision e25d2b8b5045ee7549f406cfb8a4ea0f81ec7a7d)
@@ -0,0 +1,46 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using Core.Common.Controls.Views;
+
+namespace Core.Common.Gui.Forms.ViewHost
+{
+ ///
+ /// Event arguments for when there has been a view change.
+ ///
+ public class ViewChangeEventArgs : EventArgs
+ {
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The view for which there has been a change.
+ public ViewChangeEventArgs(IView view)
+ {
+ View = view;
+ }
+
+ ///
+ /// Gets the view for which there was a change.
+ ///
+ public IView View { get; private set; }
+ }
+}
\ No newline at end of file
Index: Core/Common/src/Core.Common.Gui/GuiCore.cs
===================================================================
diff -u -rdd84dcabe5561e637e4ade45457437d9c037535b -re25d2b8b5045ee7549f406cfb8a4ea0f81ec7a7d
--- Core/Common/src/Core.Common.Gui/GuiCore.cs (.../GuiCore.cs) (revision dd84dcabe5561e637e4ade45457437d9c037535b)
+++ Core/Common/src/Core.Common.Gui/GuiCore.cs (.../GuiCore.cs) (revision e25d2b8b5045ee7549f406cfb8a4ea0f81ec7a7d)
@@ -238,7 +238,9 @@
if (ViewHost != null)
{
ViewHost.Dispose();
+ ViewHost.ViewClosed -= OnActiveDocumentViewChanged;
ViewHost.ActiveDocumentViewChanged -= OnActiveDocumentViewChanged;
+ ViewHost.ActiveViewChanged -= OnActiveViewChanged;
}
if (storageCommandHandler != null)
@@ -480,6 +482,7 @@
ViewHost = mainWindow.ViewHost;
ViewHost.ViewClosed += OnActiveDocumentViewChanged;
ViewHost.ActiveDocumentViewChanged += OnActiveDocumentViewChanged;
+ ViewHost.ActiveViewChanged += OnActiveViewChanged;
DocumentViewController = new DocumentViewController(ViewHost, Plugins.SelectMany(p => p.GetViewInfos()), mainWindow);
@@ -501,6 +504,15 @@
}
}
+ private void OnActiveViewChanged(object sender, ViewChangeEventArgs e)
+ {
+ var view = e.View as IProjectExplorer;
+ if (view != null)
+ {
+ Selection = view.TreeViewControl.SelectedData;
+ }
+ }
+
private void InitializePlugins()
{
Plugins.ForEachElementDo(p => p.Gui = this);
Index: Core/Common/test/Core.Common.Controls.Test/DataGrid/DataGridViewControlTest.cs
===================================================================
diff -u -r48208a91a766f6e5a0dc7bde910cbb9118f678ae -re25d2b8b5045ee7549f406cfb8a4ea0f81ec7a7d
--- Core/Common/test/Core.Common.Controls.Test/DataGrid/DataGridViewControlTest.cs (.../DataGridViewControlTest.cs) (revision 48208a91a766f6e5a0dc7bde910cbb9118f678ae)
+++ Core/Common/test/Core.Common.Controls.Test/DataGrid/DataGridViewControlTest.cs (.../DataGridViewControlTest.cs) (revision e25d2b8b5045ee7549f406cfb8a4ea0f81ec7a7d)
@@ -703,7 +703,7 @@
// Assert
Assert.IsFalse(dataGridView.IsCurrentCellInEditMode);
- Assert.IsNull(dataGridView.CurrentCell);
+ Assert.AreSame(dataGridViewCell, dataGridView.CurrentCell);
}
}
@@ -1467,7 +1467,6 @@
gridTester.FireEvent("Leave", EventArgs.Empty);
// Assert
- Assert.IsFalse(dataGridView.IsCurrentCellInEditMode);
Assert.AreEqual(new RoundedDouble(2, Convert.ToDouble(newValue)), new RoundedDouble(2, Convert.ToDouble(dataGridViewCell.FormattedValue)));
}
}
@@ -1507,7 +1506,6 @@
gridTester.FireEvent("Leave", EventArgs.Empty);
// Assert
- Assert.IsFalse(dataGridView.IsCurrentCellInEditMode);
Assert.AreEqual(string.Empty, dataGridView.Rows[0].ErrorText);
Assert.AreEqual(initialValue.ToString(CultureInfo.CurrentCulture), dataGridViewCell.FormattedValue);
}
Index: Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj
===================================================================
diff -u -rdd84dcabe5561e637e4ade45457437d9c037535b -re25d2b8b5045ee7549f406cfb8a4ea0f81ec7a7d
--- Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision dd84dcabe5561e637e4ade45457437d9c037535b)
+++ Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision e25d2b8b5045ee7549f406cfb8a4ea0f81ec7a7d)
@@ -109,6 +109,7 @@
+
Index: Core/Common/test/Core.Common.Gui.Test/Forms/ViewHost/ViewChangeEventArgsTest.cs
===================================================================
diff -u
--- Core/Common/test/Core.Common.Gui.Test/Forms/ViewHost/ViewChangeEventArgsTest.cs (revision 0)
+++ Core/Common/test/Core.Common.Gui.Test/Forms/ViewHost/ViewChangeEventArgsTest.cs (revision e25d2b8b5045ee7549f406cfb8a4ea0f81ec7a7d)
@@ -0,0 +1,55 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using Core.Common.Controls.Views;
+using Core.Common.Gui.Forms.ViewHost;
+using NUnit.Framework;
+using Rhino.Mocks;
+
+namespace Core.Common.Gui.Test.Forms.ViewHost
+{
+ [TestFixture]
+ public class ViewChangeEventArgsTest
+ {
+ [Test]
+ public void Constructor_WithoutView_ViewSet()
+ {
+ // Call
+ var args = new ViewChangeEventArgs(null);
+
+ // Assert
+ Assert.IsNull(args.View);
+ }
+
+ [Test]
+ public void Constructor_WithView_ViewSet()
+ {
+ // Setup
+ var view = new MockRepository().StrictMock();
+
+ // Call
+ var args = new ViewChangeEventArgs(view);
+
+ // Assert
+ Assert.AreSame(view, args.View);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationsView.cs
===================================================================
diff -u -rd207738be4ce6f50f4e3e00839ea433acea10bbd -re25d2b8b5045ee7549f406cfb8a4ea0f81ec7a7d
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationsView.cs (.../PipingCalculationsView.cs) (revision d207738be4ce6f50f4e3e00839ea433acea10bbd)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationsView.cs (.../PipingCalculationsView.cs) (revision e25d2b8b5045ee7549f406cfb8a4ea0f81ec7a7d)
@@ -376,6 +376,7 @@
var dataSource = pipingCalculations.Select(pc => new PipingCalculationRow(pc)).ToList();
dataGridViewControl.SetDataSource(dataSource);
+ dataGridViewControl.ClearCurrentCell();
UpdateStochasticSoilModelColumn();
UpdateStochasticSoilProfileColumn();
@@ -503,7 +504,6 @@
private void ListBoxOnSelectedValueChanged(object sender, EventArgs e)
{
UpdateDataGridViewDataSource();
- UpdateApplicationSelection();
}
private void OnGenerateScenariosButtonClick(object sender, EventArgs e)
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs
===================================================================
diff -u -rb954fb6f2dd56ffb96be7b61ab129f19d879d2ab -re25d2b8b5045ee7549f406cfb8a4ea0f81ec7a7d
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs (.../PipingCalculationsViewTest.cs) (revision b954fb6f2dd56ffb96be7b61ab129f19d879d2ab)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs (.../PipingCalculationsViewTest.cs) (revision e25d2b8b5045ee7549f406cfb8a4ea0f81ec7a7d)
@@ -370,17 +370,8 @@
var mocks = new MockRepository();
var applicationSelectionMock = mocks.StrictMock();
var pipingCalculationsView = ShowFullyConfiguredPipingCalculationsView();
- var secondPipingCalculationItem = (PipingCalculationScenario) ((CalculationGroup) pipingCalculationsView.Data).Children[1];
- var secondPipingInputItem = secondPipingCalculationItem.InputParameters;
+ applicationSelectionMock.Expect(asm => asm.Selection).Return(null);
- applicationSelectionMock.Stub(asm => asm.Selection).Return(null);
- applicationSelectionMock.Expect(asm => asm.Selection = new PipingInputContext(secondPipingInputItem,
- secondPipingCalculationItem,
- pipingCalculationsView.PipingFailureMechanism.SurfaceLines,
- pipingCalculationsView.PipingFailureMechanism.StochasticSoilModels,
- pipingCalculationsView.PipingFailureMechanism,
- pipingCalculationsView.AssessmentSection));
-
mocks.ReplayAll();
pipingCalculationsView.ApplicationSelection = applicationSelectionMock;