Index: Core/Common/src/Core.Common.Controls/DataGrid/DataGridViewControl.cs
===================================================================
diff -u -re052252f6f2523cfb33413867a939834ef763ce5 -r75fe077813084ef8a06b38bd149cf443acf73d27
--- Core/Common/src/Core.Common.Controls/DataGrid/DataGridViewControl.cs (.../DataGridViewControl.cs) (revision e052252f6f2523cfb33413867a939834ef763ce5)
+++ Core/Common/src/Core.Common.Controls/DataGrid/DataGridViewControl.cs (.../DataGridViewControl.cs) (revision 75fe077813084ef8a06b38bd149cf443acf73d27)
@@ -371,6 +371,24 @@
}
///
+ /// Add a handler for the event.
+ ///
+ /// The handler to add.
+ public void AddCellValueChangedHandler(DataGridViewCellEventHandler handler)
+ {
+ dataGridView.CellValueChanged += handler;
+ }
+
+ ///
+ /// Remove a handler from the event.
+ ///
+ /// The handler to remove.
+ public void RemoveCellValueChangedHandler(DataGridViewCellEventHandler handler)
+ {
+ dataGridView.CellValueChanged -= handler;
+ }
+
+ ///
/// Clears the current cell.
///
public void ClearCurrentCell()
Index: Core/Common/test/Core.Common.Controls.Test/DataGrid/DataGridViewControlTest.cs
===================================================================
diff -u -re052252f6f2523cfb33413867a939834ef763ce5 -r75fe077813084ef8a06b38bd149cf443acf73d27
--- Core/Common/test/Core.Common.Controls.Test/DataGrid/DataGridViewControlTest.cs (.../DataGridViewControlTest.cs) (revision e052252f6f2523cfb33413867a939834ef763ce5)
+++ Core/Common/test/Core.Common.Controls.Test/DataGrid/DataGridViewControlTest.cs (.../DataGridViewControlTest.cs) (revision 75fe077813084ef8a06b38bd149cf443acf73d27)
@@ -1015,9 +1015,8 @@
}
}
- [TestCase(true)]
- [TestCase(false)]
- public void RestoreCell_WithoutSpecificReadOnlyState_SetsCellStyleToEnabledWithColumnReadOnlyState(bool columnReadOnlyState)
+ [Test]
+ public void ClearCurrentCell_Always_SetsCurrentCellToNull()
{
// Setup
using (var form = new Form())
@@ -1028,34 +1027,29 @@
var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
- control.AddTextBoxColumn("Test property", "Test header", columnReadOnlyState);
+ control.AddTextBoxColumn("Test property", "Test header"); // Set read-only state of the column to the opposite
dataGridView.DataSource = new[]
{
""
};
- control.DisableCell(0, 0);
+ dataGridView.CurrentCell = dataGridView.Rows[0].Cells[0];
// Precondition
- DataGridViewCell dataGridViewCell = dataGridView.Rows[0].Cells[0];
- Assert.IsTrue(dataGridViewCell.ReadOnly);
- Assert.AreEqual(Color.FromKnownColor(KnownColor.DarkGray), dataGridViewCell.Style.BackColor);
- Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), dataGridViewCell.Style.ForeColor);
+ Assert.IsNotNull(dataGridView.CurrentCell);
// Call
- control.RestoreCell(0, 0);
+ control.ClearCurrentCell();
// Assert
- Assert.AreEqual(columnReadOnlyState, dataGridViewCell.ReadOnly);
- Assert.AreEqual(Color.FromKnownColor(KnownColor.White), dataGridViewCell.Style.BackColor);
- Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), dataGridViewCell.Style.ForeColor);
+ Assert.IsNull(dataGridView.CurrentCell);
}
}
[TestCase(true)]
[TestCase(false)]
- public void RestoreCell_WithSpecificReadOnlyState_SetsCellStyleToEnabledWithSpecificReadOnlyState(bool specificReadOnlyState)
+ public void RestoreCell_WithoutSpecificReadOnlyState_SetsCellStyleToEnabledWithColumnReadOnlyState(bool columnReadOnlyState)
{
// Setup
using (var form = new Form())
@@ -1066,7 +1060,7 @@
var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
- control.AddTextBoxColumn("Test property", "Test header", !specificReadOnlyState); // Set read-only state of the column to the opposite
+ control.AddTextBoxColumn("Test property", "Test header", columnReadOnlyState);
dataGridView.DataSource = new[]
{
@@ -1082,17 +1076,18 @@
Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), dataGridViewCell.Style.ForeColor);
// Call
- control.RestoreCell(0, 0, specificReadOnlyState);
+ control.RestoreCell(0, 0);
// Assert
- Assert.AreEqual(specificReadOnlyState, dataGridViewCell.ReadOnly);
+ Assert.AreEqual(columnReadOnlyState, dataGridViewCell.ReadOnly);
Assert.AreEqual(Color.FromKnownColor(KnownColor.White), dataGridViewCell.Style.BackColor);
Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), dataGridViewCell.Style.ForeColor);
}
}
- [Test]
- public void ClearCurrentCell_Always_SetsCurrentCellToNull()
+ [TestCase(true)]
+ [TestCase(false)]
+ public void RestoreCell_WithSpecificReadOnlyState_SetsCellStyleToEnabledWithSpecificReadOnlyState(bool specificReadOnlyState)
{
// Setup
using (var form = new Form())
@@ -1103,23 +1098,28 @@
var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
- control.AddTextBoxColumn("Test property", "Test header"); // Set read-only state of the column to the opposite
+ control.AddTextBoxColumn("Test property", "Test header", !specificReadOnlyState); // Set read-only state of the column to the opposite
dataGridView.DataSource = new[]
{
""
};
- dataGridView.CurrentCell = dataGridView.Rows[0].Cells[0];
+ control.DisableCell(0, 0);
// Precondition
- Assert.IsNotNull(dataGridView.CurrentCell);
+ DataGridViewCell dataGridViewCell = dataGridView.Rows[0].Cells[0];
+ Assert.IsTrue(dataGridViewCell.ReadOnly);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.DarkGray), dataGridViewCell.Style.BackColor);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), dataGridViewCell.Style.ForeColor);
// Call
- control.ClearCurrentCell();
+ control.RestoreCell(0, 0, specificReadOnlyState);
// Assert
- Assert.IsNull(dataGridView.CurrentCell);
+ Assert.AreEqual(specificReadOnlyState, dataGridViewCell.ReadOnly);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.White), dataGridViewCell.Style.BackColor);
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), dataGridViewCell.Style.ForeColor);
}
}
@@ -1299,6 +1299,84 @@
}
[Test]
+ public void AddCellValueChangedHandler_Always_AddsEventHandler()
+ {
+ // Setup
+ using (var form = new Form())
+ using (var control = new DataGridViewControl())
+ {
+ form.Controls.Add(control);
+ form.Show();
+
+ var gridTester = new ControlTester("dataGridView");
+ var dataGridView = (DataGridView) gridTester.TheObject;
+
+ control.AddTextBoxColumn("Test property", "Test header");
+
+ dataGridView.DataSource = new[]
+ {
+ ""
+ };
+ DataGridViewCell dataGridViewCell = dataGridView.Rows[0].Cells[0];
+ dataGridView.CurrentCell = dataGridViewCell;
+
+ int counter = 0;
+
+ control.AddCellValueChangedHandler((sender, args) => counter++);
+
+ // Precondition
+ Assert.AreEqual(0, counter);
+
+ // Call
+ gridTester.FireEvent("CellValueChanged", new DataGridViewCellEventArgs(0, 0));
+
+ // Assert
+ Assert.AreEqual(1, counter);
+ }
+ }
+
+ [Test]
+ public void RemoveCellValueChangedHandler_Always_RemovesEventHandler()
+ {
+ // Setup
+ using (var form = new Form())
+ using (var control = new DataGridViewControl())
+ {
+ form.Controls.Add(control);
+ form.Show();
+
+ var gridTester = new ControlTester("dataGridView");
+ var dataGridView = (DataGridView) gridTester.TheObject;
+
+ control.AddTextBoxColumn("Test property", "Test header");
+
+ dataGridView.DataSource = new[]
+ {
+ ""
+ };
+ DataGridViewCell dataGridViewCell = dataGridView.Rows[0].Cells[0];
+ dataGridView.CurrentCell = dataGridViewCell;
+
+ int counter = 0;
+
+ DataGridViewCellEventHandler dataGridViewCellEventHandler = (sender, args) => counter++;
+
+ control.AddCellValueChangedHandler(dataGridViewCellEventHandler);
+
+ // Precondition
+ Assert.AreEqual(0, counter);
+ gridTester.FireEvent("CellValueChanged", new DataGridViewCellEventArgs(0, 0));
+ Assert.AreEqual(1, counter);
+
+ // Call
+ control.RemoveCellClickHandler(dataGridViewCellEventHandler);
+
+ // Assert
+ Assert.AreEqual(1, counter);
+ }
+ }
+
+ [Test]
public void DataGridViewControlCheckBoxColumn_EditValueDirtyStateChangedEventFired_ValueCommittedCellInEditMode()
{
// Setup
@@ -1441,7 +1519,7 @@
}
[Test]
- public void DataGridView_ErrorWhenCommitingValue_DoesShowErrorToolTip()
+ public void DataGridView_ErrorWhenCommittingValue_DoesShowErrorToolTip()
{
// Setup
using (var form = new Form())
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs
===================================================================
diff -u -r161308cb864a66713f62357c6bcdb6ede03b619f -r75fe077813084ef8a06b38bd149cf443acf73d27
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 161308cb864a66713f62357c6bcdb6ede03b619f)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 75fe077813084ef8a06b38bd149cf443acf73d27)
@@ -289,20 +289,20 @@
}
///
- /// Looks up a localized string similar to &Berekenen.
+ /// Looks up a localized string similar to Alles &berekenen.
///
- public static string DesignWaterLevel_Calculate {
+ public static string DesignWaterLevel_Calculate_All {
get {
- return ResourceManager.GetString("DesignWaterLevel_Calculate", resourceCulture);
+ return ResourceManager.GetString("DesignWaterLevel_Calculate_All", resourceCulture);
}
}
///
- /// Looks up a localized string similar to Bereken de toetspeilen..
+ /// Looks up a localized string similar to Alle toetspeilen berekenen..
///
- public static string DesignWaterLevel_Calculate_ToolTip {
+ public static string DesignWaterLevel_Calculate_All_ToolTip {
get {
- return ResourceManager.GetString("DesignWaterLevel_Calculate_ToolTip", resourceCulture);
+ return ResourceManager.GetString("DesignWaterLevel_Calculate_All_ToolTip", resourceCulture);
}
}
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx
===================================================================
diff -u -r161308cb864a66713f62357c6bcdb6ede03b619f -r75fe077813084ef8a06b38bd149cf443acf73d27
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx (.../Resources.resx) (revision 161308cb864a66713f62357c6bcdb6ede03b619f)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Properties/Resources.resx (.../Resources.resx) (revision 75fe077813084ef8a06b38bd149cf443acf73d27)
@@ -144,11 +144,11 @@
Weet u zeker dat u wilt doorgaan?
-
- &Berekenen
+
+ Alles &berekenen
-
- Bereken de toetspeilen.
+
+ Alle toetspeilen berekenen.
Er is geen hydraulische randvoorwaardendatabase beschikbaar om de toetspeilen te berekenen.
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.Designer.cs
===================================================================
diff -u -red0ac171987ec828fb4aebf32493a41d43c7599c -r75fe077813084ef8a06b38bd149cf443acf73d27
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.Designer.cs (.../DesignWaterLevelLocationsView.Designer.cs) (revision ed0ac171987ec828fb4aebf32493a41d43c7599c)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.Designer.cs (.../DesignWaterLevelLocationsView.Designer.cs) (revision 75fe077813084ef8a06b38bd149cf443acf73d27)
@@ -37,94 +37,78 @@
private void InitializeComponent()
{
this.dataGridViewControl = new Core.Common.Controls.DataGrid.DataGridViewControl();
- this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
- this.ButtonGroupBox = new System.Windows.Forms.GroupBox();
- this.CalculateForSelectedButton = new System.Windows.Forms.Button();
- this.DeselectAllButton = new System.Windows.Forms.Button();
this.SelectAllButton = new System.Windows.Forms.Button();
- this.tableLayoutPanel.SuspendLayout();
+ this.DeselectAllButton = new System.Windows.Forms.Button();
+ this.CalculateForSelectedButton = new System.Windows.Forms.Button();
+ this.ButtonGroupBox = new System.Windows.Forms.GroupBox();
this.ButtonGroupBox.SuspendLayout();
this.SuspendLayout();
//
// dataGridViewControl
//
this.dataGridViewControl.Dock = System.Windows.Forms.DockStyle.Fill;
- this.dataGridViewControl.Location = new System.Drawing.Point(3, 3);
+ this.dataGridViewControl.Location = new System.Drawing.Point(0, 0);
this.dataGridViewControl.MultiSelect = true;
this.dataGridViewControl.Name = "dataGridViewControl";
this.dataGridViewControl.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.RowHeaderSelect;
- this.dataGridViewControl.Size = new System.Drawing.Size(529, 264);
+ this.dataGridViewControl.Size = new System.Drawing.Size(523, 346);
this.dataGridViewControl.TabIndex = 0;
//
- // tableLayoutPanel
+ // SelectAllButton
//
- this.tableLayoutPanel.ColumnCount = 1;
- this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
- this.tableLayoutPanel.Controls.Add(this.dataGridViewControl, 0, 0);
- this.tableLayoutPanel.Controls.Add(this.ButtonGroupBox, 0, 1);
- this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
- this.tableLayoutPanel.Location = new System.Drawing.Point(0, 0);
- this.tableLayoutPanel.Name = "tableLayoutPanel";
- this.tableLayoutPanel.RowCount = 2;
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle());
- this.tableLayoutPanel.Size = new System.Drawing.Size(535, 329);
- this.tableLayoutPanel.TabIndex = 1;
+ this.SelectAllButton.Location = new System.Drawing.Point(6, 22);
+ this.SelectAllButton.Name = "SelectAllButton";
+ this.SelectAllButton.Size = new System.Drawing.Size(98, 23);
+ this.SelectAllButton.TabIndex = 0;
+ this.SelectAllButton.Text = "Selecteer alles";
+ this.SelectAllButton.UseVisualStyleBackColor = true;
+ this.SelectAllButton.Click += new System.EventHandler(this.SelectAllButton_Click);
//
- // ButtonGroupBox
+ // DeselectAllButton
//
- this.ButtonGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.ButtonGroupBox.Controls.Add(this.CalculateForSelectedButton);
- this.ButtonGroupBox.Controls.Add(this.DeselectAllButton);
- this.ButtonGroupBox.Controls.Add(this.SelectAllButton);
- this.ButtonGroupBox.Location = new System.Drawing.Point(3, 275);
- this.ButtonGroupBox.Margin = new System.Windows.Forms.Padding(3, 5, 3, 3);
- this.ButtonGroupBox.Name = "ButtonGroupBox";
- this.ButtonGroupBox.Size = new System.Drawing.Size(529, 51);
- this.ButtonGroupBox.TabIndex = 1;
- this.ButtonGroupBox.TabStop = false;
- this.ButtonGroupBox.Text = "Toetspeilen berekenen";
+ this.DeselectAllButton.Location = new System.Drawing.Point(110, 22);
+ this.DeselectAllButton.Name = "DeselectAllButton";
+ this.DeselectAllButton.Size = new System.Drawing.Size(111, 23);
+ this.DeselectAllButton.TabIndex = 1;
+ this.DeselectAllButton.Text = "Deselecteer alles";
+ this.DeselectAllButton.UseVisualStyleBackColor = true;
+ this.DeselectAllButton.Click += new System.EventHandler(this.DeselectAllButton_Click);
//
// CalculateForSelectedButton
//
- this.CalculateForSelectedButton.Location = new System.Drawing.Point(227, 19);
+ this.CalculateForSelectedButton.Enabled = false;
+ this.CalculateForSelectedButton.Location = new System.Drawing.Point(227, 22);
this.CalculateForSelectedButton.Name = "CalculateForSelectedButton";
this.CalculateForSelectedButton.Size = new System.Drawing.Size(207, 23);
this.CalculateForSelectedButton.TabIndex = 2;
this.CalculateForSelectedButton.Text = "Bereken voor geselecteerde locaties";
this.CalculateForSelectedButton.UseVisualStyleBackColor = true;
this.CalculateForSelectedButton.Click += new System.EventHandler(this.CalculateForSelectedButton_Click);
//
- // DeselectAllButton
+ // ButtonGroupBox
//
- this.DeselectAllButton.Location = new System.Drawing.Point(110, 19);
- this.DeselectAllButton.Name = "DeselectAllButton";
- this.DeselectAllButton.Size = new System.Drawing.Size(111, 23);
- this.DeselectAllButton.TabIndex = 1;
- this.DeselectAllButton.Text = "Deselecteer alles";
- this.DeselectAllButton.UseVisualStyleBackColor = true;
- this.DeselectAllButton.Click += new System.EventHandler(this.DeselectAllButton_Click);
+ this.ButtonGroupBox.Controls.Add(this.CalculateForSelectedButton);
+ this.ButtonGroupBox.Controls.Add(this.DeselectAllButton);
+ this.ButtonGroupBox.Controls.Add(this.SelectAllButton);
+ this.ButtonGroupBox.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.ButtonGroupBox.Location = new System.Drawing.Point(0, 346);
+ this.ButtonGroupBox.MinimumSize = new System.Drawing.Size(438, 59);
+ this.ButtonGroupBox.Name = "ButtonGroupBox";
+ this.ButtonGroupBox.Size = new System.Drawing.Size(523, 59);
+ this.ButtonGroupBox.TabIndex = 1;
+ this.ButtonGroupBox.TabStop = false;
+ this.ButtonGroupBox.Text = "Toetspeilen berekenen";
//
- // SelectAllButton
- //
- this.SelectAllButton.Location = new System.Drawing.Point(6, 19);
- this.SelectAllButton.Name = "SelectAllButton";
- this.SelectAllButton.Size = new System.Drawing.Size(98, 23);
- this.SelectAllButton.TabIndex = 0;
- this.SelectAllButton.Text = "Selecteer alles";
- this.SelectAllButton.UseVisualStyleBackColor = true;
- this.SelectAllButton.Click += new System.EventHandler(this.SelectAllButton_Click);
- //
// DesignWaterLevelLocationsView
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.Controls.Add(this.tableLayoutPanel);
+ this.AutoScroll = true;
+ this.AutoScrollMinSize = new System.Drawing.Size(520, 342);
+ this.Controls.Add(this.dataGridViewControl);
+ this.Controls.Add(this.ButtonGroupBox);
this.Name = "DesignWaterLevelLocationsView";
- this.Size = new System.Drawing.Size(535, 329);
- this.tableLayoutPanel.ResumeLayout(false);
+ this.Size = new System.Drawing.Size(523, 405);
this.ButtonGroupBox.ResumeLayout(false);
this.ResumeLayout(false);
@@ -133,10 +117,9 @@
#endregion
private Core.Common.Controls.DataGrid.DataGridViewControl dataGridViewControl;
- private System.Windows.Forms.TableLayoutPanel tableLayoutPanel;
- private System.Windows.Forms.GroupBox ButtonGroupBox;
- private System.Windows.Forms.Button CalculateForSelectedButton;
- private System.Windows.Forms.Button DeselectAllButton;
private System.Windows.Forms.Button SelectAllButton;
+ private System.Windows.Forms.Button DeselectAllButton;
+ private System.Windows.Forms.Button CalculateForSelectedButton;
+ private System.Windows.Forms.GroupBox ButtonGroupBox;
}
}
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.cs
===================================================================
diff -u -r161308cb864a66713f62357c6bcdb6ede03b619f -r75fe077813084ef8a06b38bd149cf443acf73d27
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.cs (.../DesignWaterLevelLocationsView.cs) (revision 161308cb864a66713f62357c6bcdb6ede03b619f)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.cs (.../DesignWaterLevelLocationsView.cs) (revision 75fe077813084ef8a06b38bd149cf443acf73d27)
@@ -41,6 +41,7 @@
///
public partial class DesignWaterLevelLocationsView : UserControl, ISelectionProvider
{
+ private const int locationCalculateColumnIndex = 0;
private readonly Observer assessmentSectionObserver;
private readonly Observer hydraulicBoundaryDatabaseObserver;
private IAssessmentSection assessmentSection;
@@ -112,6 +113,7 @@
private void InitializeDataGridView()
{
dataGridViewControl.AddCellClickHandler(DataGridViewOnCellClick);
+ dataGridViewControl.AddCellValueChangedHandler(DataGridViewCellValueChanged);
dataGridViewControl.AddCheckBoxColumn(TypeUtils.GetMemberName(row => row.ToCalculate),
Resources.HydraulicBoundaryLocationsView_Calculate);
@@ -136,6 +138,7 @@
new DesignWaterLevelLocationContext(assessmentSection.HydraulicBoundaryDatabase, hl))).ToArray()
: null);
updatingDataSource = false;
+ UpdateCalculateForSelectedButton();
}
private IEnumerable GetDesignWaterLevelLocationContextRows()
@@ -148,8 +151,22 @@
return GetDesignWaterLevelLocationContextRows().Where(r => r.ToCalculate).Select(r => r.HydraulicBoundaryLocationContext.HydraulicBoundaryLocation);
}
+ private void UpdateCalculateForSelectedButton()
+ {
+ CalculateForSelectedButton.Enabled = GetDesignWaterLevelLocationContextRows().Any(r => r.ToCalculate);
+ }
+
#region Event handling
+ private void DataGridViewCellValueChanged(object sender, DataGridViewCellEventArgs e)
+ {
+ if (updatingDataSource || e.ColumnIndex != locationCalculateColumnIndex)
+ {
+ return;
+ }
+ UpdateCalculateForSelectedButton();
+ }
+
private void DataGridViewOnCellClick(object sender, DataGridViewCellEventArgs e)
{
if (updatingDataSource)
@@ -192,12 +209,14 @@
{
GetDesignWaterLevelLocationContextRows().ForEachElementDo(row => row.ToCalculate = true);
dataGridViewControl.RefreshDataGridView();
+ UpdateCalculateForSelectedButton();
}
private void DeselectAllButton_Click(object sender, EventArgs e)
{
GetDesignWaterLevelLocationContextRows().ForEachElementDo(row => row.ToCalculate = false);
dataGridViewControl.RefreshDataGridView();
+ UpdateCalculateForSelectedButton();
}
private void CalculateForSelectedButton_Click(object sender, EventArgs e)
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs
===================================================================
diff -u -r161308cb864a66713f62357c6bcdb6ede03b619f -r75fe077813084ef8a06b38bd149cf443acf73d27
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 161308cb864a66713f62357c6bcdb6ede03b619f)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 75fe077813084ef8a06b38bd149cf443acf73d27)
@@ -1041,8 +1041,8 @@
private ContextMenuStrip DesignWaterLevelLocationsContextMenuStrip(DesignWaterLevelLocationsContext nodeData, object parentData, TreeViewControl treeViewControl)
{
var designWaterLevelItem = new StrictContextMenuItem(
- RingtoetsFormsResources.DesignWaterLevel_Calculate,
- RingtoetsFormsResources.DesignWaterLevel_Calculate_ToolTip,
+ RingtoetsFormsResources.DesignWaterLevel_Calculate_All,
+ RingtoetsFormsResources.DesignWaterLevel_Calculate_All_ToolTip,
RingtoetsCommonFormsResources.FailureMechanismIcon,
(sender, args) =>
{
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/DesignWaterLevelLocationsContextTreeNodeInfoTest.cs
===================================================================
diff -u -rae8af28b6d5528cbbaa329dcffea6c8dbbe2a39f -r75fe077813084ef8a06b38bd149cf443acf73d27
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/DesignWaterLevelLocationsContextTreeNodeInfoTest.cs (.../DesignWaterLevelLocationsContextTreeNodeInfoTest.cs) (revision ae8af28b6d5528cbbaa329dcffea6c8dbbe2a39f)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/DesignWaterLevelLocationsContextTreeNodeInfoTest.cs (.../DesignWaterLevelLocationsContextTreeNodeInfoTest.cs) (revision 75fe077813084ef8a06b38bd149cf443acf73d27)
@@ -177,7 +177,7 @@
ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl);
// Assert
- const string expectedItemText = "&Berekenen";
+ const string expectedItemText = "Alles &berekenen";
const string expectedItemTooltip = "Er is geen hydraulische randvoorwaardendatabase beschikbaar om de toetspeilen te berekenen.";
TestHelper.AssertContextMenuStripContainsItem(contextMenu, 0, expectedItemText, expectedItemTooltip, RingtoetsCommonFormsResources.FailureMechanismIcon, false);
@@ -214,8 +214,8 @@
ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl);
// Assert
- const string expectedItemText = "&Berekenen";
- const string expectedItemTooltip = "Bereken de toetspeilen.";
+ const string expectedItemText = @"Alles &berekenen";
+ const string expectedItemTooltip = @"Alle toetspeilen berekenen.";
TestHelper.AssertContextMenuStripContainsItem(contextMenu, 0, expectedItemText, expectedItemTooltip, RingtoetsCommonFormsResources.FailureMechanismIcon);
}
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs
===================================================================
diff -u -r161308cb864a66713f62357c6bcdb6ede03b619f -r75fe077813084ef8a06b38bd149cf443acf73d27
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs (.../DesignWaterLevelLocationsViewTest.cs) (revision 161308cb864a66713f62357c6bcdb6ede03b619f)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs (.../DesignWaterLevelLocationsViewTest.cs) (revision 75fe077813084ef8a06b38bd149cf443acf73d27)
@@ -101,6 +101,10 @@
var locationDesignWaterlevelColumn = (DataGridViewTextBoxColumn) dataGridView.Columns[locationDesignWaterlevelColumnIndex];
const string expectedLocationDesignWaterHeaderText = "Toetspeil [m+NAP]";
Assert.AreEqual(expectedLocationDesignWaterHeaderText, locationDesignWaterlevelColumn.HeaderText);
+
+ var buttonTester = new ButtonTester("CalculateForSelectedButton", testForm);
+ var button = (Button) buttonTester.TheObject;
+ Assert.IsFalse(button.Enabled);
}
[Test]
@@ -356,27 +360,22 @@
}
[Test]
- public void CalculateForSelectedButton_NoneSelected_CallsCalculateDesignWaterLevels()
+ public void CalculateForSelectedButton_NoneSelected_CalculateForSelectedButtonDisabled()
{
// Setup
- DesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView();
-
var mockRepository = new MockRepository();
var commandHandlerMock = mockRepository.StrictMock();
-
- IEnumerable locations = null;
- commandHandlerMock.Expect(ch => ch.CalculateDesignWaterLevels(null)).IgnoreArguments().WhenCalled(
- invocation => { locations = (IEnumerable) invocation.Arguments[0]; });
mockRepository.ReplayAll();
+ DesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView();
view.CalculationCommandHandler = commandHandlerMock;
- var button = new ButtonTester("CalculateForSelectedButton", testForm);
+ var buttonTester = new ButtonTester("CalculateForSelectedButton", testForm);
// Call
- button.Click();
+ var button = (Button) buttonTester.TheObject;
// Assert
- Assert.AreEqual(0, locations.Count());
+ Assert.IsFalse(button.Enabled);
mockRepository.VerifyAll();
}
@@ -399,10 +398,10 @@
mockRepository.ReplayAll();
view.CalculationCommandHandler = commandHandlerMock;
- var button = new ButtonTester("CalculateForSelectedButton", testForm);
+ var buttonTester = new ButtonTester("CalculateForSelectedButton", testForm);
// Call
- button.Click();
+ buttonTester.Click();
// Assert
var hydraulicBoundaryLocations = locations.ToArray();
@@ -413,10 +412,15 @@
}
[Test]
- public void CalculateForSelectedButton_CalculationCommandHandlerNotSet_DoesNotThrowException()
+ public void CalculateForSelectedButton_OneSelectedButCalculationCommandHandlerNotSet_DoesNotThrowException()
{
// Setup
ShowFullyConfiguredDesignWaterLevelLocationsView();
+
+ var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
+ var rows = dataGridView.Rows;
+ rows[0].Cells[locationCalculateColumnIndex].Value = true;
+
var button = new ButtonTester("CalculateForSelectedButton", testForm);
// Call