Index: src/Common/DelftTools.Controls.Swf/GridBasedDialog.cs
===================================================================
diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -r5fc71a385897af92ccb092f2f969b5709afab85a
--- src/Common/DelftTools.Controls.Swf/GridBasedDialog.cs (.../GridBasedDialog.cs) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9)
+++ src/Common/DelftTools.Controls.Swf/GridBasedDialog.cs (.../GridBasedDialog.cs) (revision 5fc71a385897af92ccb092f2f969b5709afab85a)
@@ -1,4 +1,5 @@
-using System.Collections;
+using System;
+using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
@@ -17,86 +18,101 @@
///
/// This event is raised when the selection in the master grid changes
///
- public event System.EventHandler MasterSelectionChanged;
+ public event EventHandler MasterSelectionChanged;
///
/// This event is raised when the selection in the slave grid changes
///
- public event System.EventHandler SlaveSelectionChanged;
+ public event EventHandler SlaveSelectionChanged;
///
+ /// Default contructor for the form
+ ///
+ public GridBasedDialog()
+ {
+ InitializeComponent();
+ dataGridViewMaster.SelectionChanged += MasterDataGridViewSelectionChanged;
+ dataGridViewSlave.SelectionChanged += SlaveDataGridViewSelectionChanged;
+ }
+
+ ///
/// Set to true to support multiple selection in the master grid; default is false.
///
public bool MasterMultiSelect
{
- get { return dataGridViewMaster.MultiSelect; }
- set { dataGridViewMaster.MultiSelect = value; }
+ get
+ {
+ return dataGridViewMaster.MultiSelect;
+ }
+ set
+ {
+ dataGridViewMaster.MultiSelect = value;
+ }
}
///
/// Set to true to support multiple selection in the slave grid; default is false.
///
public bool SlaveMultiSelect
{
- get { return dataGridViewSlave.MultiSelect; }
- set { dataGridViewSlave.MultiSelect = value; }
+ get
+ {
+ return dataGridViewSlave.MultiSelect;
+ }
+ set
+ {
+ dataGridViewSlave.MultiSelect = value;
+ }
}
///
/// The text used to name the master grid in the form
///
public string MasterTitle
{
- get { return groupBoxMaster.Text; }
- set { groupBoxMaster.Text = value; }
+ get
+ {
+ return groupBoxMaster.Text;
+ }
+ set
+ {
+ groupBoxMaster.Text = value;
+ }
}
///
/// The text used to name the slave grid in the form
///
public string SlaveTitle
{
- get { return groupBoxSlave.Text; }
- set { groupBoxSlave.Text = value; }
+ get
+ {
+ return groupBoxSlave.Text;
+ }
+ set
+ {
+ groupBoxSlave.Text = value;
+ }
}
+
///
/// Set to true if doubleclick in a grid should close the form with DialogResult.OK if there is
/// valid selection.
///
public bool MouseDoubleClickIsOk { get; set; }
///
- /// Default contructor for the form
- ///
- public GridBasedDialog()
- {
- InitializeComponent();
- dataGridViewMaster.SelectionChanged += MasterDataGridViewSelectionChanged;
- dataGridViewSlave.SelectionChanged += SlaveDataGridViewSelectionChanged;
- }
-
- ///
/// Set to true to only use the master grid
///
public bool SingleList
{
- get { return splitContainer1.Panel2Collapsed; }
- set { splitContainer1.Panel2Collapsed = value; }
- }
-
- void MasterDataGridViewSelectionChanged(object sender, System.EventArgs e)
- {
- if (null != MasterSelectionChanged)
+ get
{
- MasterSelectionChanged(this, e);
+ return splitContainer1.Panel2Collapsed;
}
- }
-
- void SlaveDataGridViewSelectionChanged(object sender, System.EventArgs e)
- {
- if (null != SlaveSelectionChanged)
+ set
{
- SlaveSelectionChanged(this, e);
+ splitContainer1.Panel2Collapsed = value;
}
}
@@ -105,8 +121,14 @@
///
public IEnumerable MasterDataSource
{
- get { return (IEnumerable) dataGridViewMaster.DataSource; }
- set { dataGridViewMaster.DataSource = value; }
+ get
+ {
+ return (IEnumerable) dataGridViewMaster.DataSource;
+ }
+ set
+ {
+ dataGridViewMaster.DataSource = value;
+ }
}
///
@@ -116,47 +138,38 @@
///
public IEnumerable SlaveDataSource
{
- get { return (IEnumerable)dataGridViewSlave.DataSource; }
- set { dataGridViewSlave.DataSource = value; }
- }
-
- private static IEnumerable DataGridViewSelectedIndices(DataGridView dataGridView)
- {
- IList selectedIndices = new List();
-
- foreach (DataGridViewRow s in dataGridView.SelectedRows)
+ get
{
- selectedIndices.Add(dataGridView.Rows.IndexOf(s));
+ return (IEnumerable) dataGridViewSlave.DataSource;
}
- return selectedIndices;
+ set
+ {
+ dataGridViewSlave.DataSource = value;
+ }
}
///
/// The indices of the rows that are selected in the master grid
///
public IEnumerable MasterSelectedIndices
{
- get { return DataGridViewSelectedIndices(dataGridViewMaster); }
+ get
+ {
+ return DataGridViewSelectedIndices(dataGridViewMaster);
+ }
}
///
/// The indices of the rows that are selected in the slave grid
///
public IEnumerable SlaveSelectedIndices
{
- get { return DataGridViewSelectedIndices(dataGridViewSlave); }
+ get
+ {
+ return DataGridViewSelectedIndices(dataGridViewSlave);
+ }
}
- private void dataGridViewSlave_MouseDoubleClick(object sender, MouseEventArgs e)
- {
- if ((!MouseDoubleClickIsOk) || (!MasterSelectedIndices.Any()))
- return;
- if ((!SingleList) && ((!SlaveSelectedIndices.Any())))
- return;
- DialogResult = DialogResult.OK;
- Close();
- }
-
public void SetMasterSelectedIndices(IEnumerable pSelectedIndices)
{
var selectedIndices = pSelectedIndices as int[] ?? pSelectedIndices.ToArray();
@@ -166,5 +179,46 @@
row.Selected = selectedIndices.Contains(row.Index);
}
}
+
+ private void MasterDataGridViewSelectionChanged(object sender, EventArgs e)
+ {
+ if (null != MasterSelectionChanged)
+ {
+ MasterSelectionChanged(this, e);
+ }
+ }
+
+ private void SlaveDataGridViewSelectionChanged(object sender, EventArgs e)
+ {
+ if (null != SlaveSelectionChanged)
+ {
+ SlaveSelectionChanged(this, e);
+ }
+ }
+
+ private static IEnumerable DataGridViewSelectedIndices(DataGridView dataGridView)
+ {
+ IList selectedIndices = new List();
+
+ foreach (DataGridViewRow s in dataGridView.SelectedRows)
+ {
+ selectedIndices.Add(dataGridView.Rows.IndexOf(s));
+ }
+ return selectedIndices;
+ }
+
+ private void dataGridViewSlave_MouseDoubleClick(object sender, MouseEventArgs e)
+ {
+ if ((!MouseDoubleClickIsOk) || (!MasterSelectedIndices.Any()))
+ {
+ return;
+ }
+ if ((!SingleList) && ((!SlaveSelectedIndices.Any())))
+ {
+ return;
+ }
+ DialogResult = DialogResult.OK;
+ Close();
+ }
}
}
\ No newline at end of file