Replaced duplicate events ItemSelectionNull and ItemSelectionNotNull with SrSelectionChanged.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2018-10-08 15:35:11 +01:00 committed by Mihaela Stoica
parent 0fe584cdba
commit f1d5abb7a5
9 changed files with 26 additions and 73 deletions

View File

@ -54,11 +54,10 @@ namespace XenAdmin.Controls
}
private IXenConnection connection;
private Host affinity;
private SrPickerItem LastSelectedItem;
public event Action ItemSelectionNull;
public event Action ItemSelectionNotNull;
public event Action<object> SrSelectionChanged;
public event EventHandler DoubleClickOnRow;
public long DiskSize = 0;
@ -133,13 +132,13 @@ namespace XenAdmin.Controls
SrPickerItem item = srListBox.SelectedItem as SrPickerItem;
if (item == null || !item.Enabled)
{
if (ItemSelectionNull != null)
ItemSelectionNull();
if (SrSelectionChanged != null)
SrSelectionChanged(null);
return;
}
if (ItemSelectionNotNull != null)
ItemSelectionNotNull();
if (SrSelectionChanged != null)
SrSelectionChanged(item);
if (!item.Enabled && LastSelectedItem != null && LastSelectedItem.TheSR.opaque_ref != item.TheSR.opaque_ref)
srListBox.SelectedItem = LastSelectedItem;
@ -153,9 +152,6 @@ namespace XenAdmin.Controls
}
else
LastSelectedItem = item;
}
public SR SR
@ -315,8 +311,8 @@ namespace XenAdmin.Controls
}
}
if (ItemSelectionNull != null)
ItemSelectionNull();
if (SrSelectionChanged != null)
SrSelectionChanged(null);
}
internal void selectDefaultSROrAny()
@ -333,8 +329,8 @@ namespace XenAdmin.Controls
return;
}
}
if (ItemSelectionNull != null)
ItemSelectionNull();
if (SrSelectionChanged != null)
SrSelectionChanged(null);
}
public void selectSRorDefaultorAny(SR sr)
@ -370,7 +366,4 @@ namespace XenAdmin.Controls
}
}
}
}

View File

@ -60,8 +60,7 @@ namespace XenAdmin.Dialogs
IsRealVm = !vm.is_a_template;
TheVM = vm;
srPicker1.Usage = SrPicker.SRPickerType.MoveOrCopy;
srPicker1.ItemSelectionNotNull += srPicker1_ItemSelectionNotNull;
srPicker1.ItemSelectionNull += srPicker1_ItemSelectionNull;
srPicker1.SrSelectionChanged += srPicker1_SrSelectionChanged;
Host affinity = TheVM.Home();
srPicker1.Connection = TheVM.Connection;
srPicker1.DiskSize = vm.TotalVMSize();
@ -106,12 +105,7 @@ namespace XenAdmin.Dialogs
srPicker1.selectDefaultSROrAny();
}
private void srPicker1_ItemSelectionNull()
{
EnableMoveButton();
}
private void srPicker1_ItemSelectionNotNull()
private void srPicker1_SrSelectionChanged(object obj)
{
EnableMoveButton();
}

View File

@ -65,8 +65,7 @@
this.tableLayoutPanel2.SetColumnSpan(this.srPicker1, 2);
this.srPicker1.Connection = null;
this.srPicker1.Name = "srPicker1";
this.srPicker1.ItemSelectionNull += new System.Action(this.srPicker1_ItemSelectionNull);
this.srPicker1.ItemSelectionNotNull += new System.Action(this.srPicker1_ItemSelectionNotNull);
this.srPicker1.SrSelectionChanged += new System.Action<object>(this.srPicker1_SrSelectionChanged);
this.srPicker1.DoubleClickOnRow += new System.EventHandler(this.srPicker1_DoubleClickOnRow);
//
// tableLayoutPanel2

View File

@ -85,12 +85,7 @@ namespace XenAdmin.Dialogs
get { return SrPicker.SRPickerType.MoveOrCopy; }
}
private void srPicker1_ItemSelectionNull()
{
updateButtons();
}
private void srPicker1_ItemSelectionNotNull()
private void srPicker1_SrSelectionChanged(object obj)
{
updateButtons();
}

View File

@ -74,17 +74,16 @@ namespace XenAdmin.Dialogs
// Add events
NameTextBox.Text = GetDefaultVDIName();
SrListBox.srListBox.SelectedIndexChanged += new EventHandler(srListBox_SelectedIndexChanged);
SrListBox.ItemSelectionNotNull += SrListBox_ItemSelectionNotNull;
SrListBox.ItemSelectionNull += SrListBox_ItemSelectionNull;
SrListBox.srListBox.SelectedIndexChanged += srListBox_SelectedIndexChanged;
SrListBox.SrSelectionChanged += SrListBox_SrSelectionChanged;
srListBox_SelectedIndexChanged(null, null);
DiskSizeNumericUpDown.TextChanged += new EventHandler(DiskSizeNumericUpDown_TextChanged);
DiskSizeNumericUpDown.TextChanged += DiskSizeNumericUpDown_TextChanged;
max = (decimal)Math.Pow(1024, 4);//1 Petabit
min = 0;
comboBoxUnits.SelectedItem = comboBoxUnits.Items[0];
comboBoxUnits.SelectedIndexChanged += new EventHandler(comboBoxUnits_SelectedIndexChanged);
comboBoxUnits.SelectedIndexChanged += comboBoxUnits_SelectedIndexChanged;
SetNumUpDownIncrementAndDecimals(DiskSizeNumericUpDown, comboBoxUnits.SelectedItem.ToString());
}
@ -171,14 +170,9 @@ namespace XenAdmin.Dialogs
return Helpers.MakeUniqueName(Messages.DEFAULT_VDI_NAME, usedNames);
}
void SrListBox_ItemSelectionNull()
private void SrListBox_SrSelectionChanged(object obj)
{
SelectionNull = true;
}
void SrListBox_ItemSelectionNotNull()
{
SelectionNull = false;
SelectionNull = obj == null;
}
void srListBox_SelectedIndexChanged(object sender, EventArgs e)

View File

@ -53,8 +53,7 @@ namespace XenAdmin.Dialogs.VMDialogs
{
InitializeComponent();
this.vm = vm;
srPicker1.ItemSelectionNotNull += srPicker1_ItemSelectionNotNull;
srPicker1.ItemSelectionNull += srPicker1_ItemSelectionNull;
srPicker1.SrSelectionChanged += srPicker1_SrSelectionChanged;
srPicker1.DoubleClickOnRow += srPicker1_DoubleClickOnRow;
srPicker1.SrHint.Visible = false;
Host affinity = vm.Home();
@ -93,12 +92,7 @@ namespace XenAdmin.Dialogs.VMDialogs
buttonMove.Enabled = srPicker1.SR != null;
}
private void srPicker1_ItemSelectionNull()
{
EnableMoveButton();
}
private void srPicker1_ItemSelectionNotNull()
private void srPicker1_SrSelectionChanged(object obj)
{
EnableMoveButton();
}

View File

@ -102,8 +102,7 @@ namespace XenAdmin.Wizards.CrossPoolMigrateWizard
public override void PopulatePage()
{
srPicker1.Usage = SrPicker.SRPickerType.MoveOrCopy;
srPicker1.ItemSelectionNotNull += srPicker1_ItemSelectionNotNull;
srPicker1.ItemSelectionNull += srPicker1_ItemSelectionNull;
srPicker1.SrSelectionChanged += srPicker1_SrSelectionChanged;
Host affinity = TheVM.Home();
srPicker1.Connection = TheVM.Connection;
srPicker1.DiskSize = TheVM.TotalVMSize();
@ -181,12 +180,7 @@ namespace XenAdmin.Wizards.CrossPoolMigrateWizard
OnPageUpdated();
}
private void srPicker1_ItemSelectionNull()
{
EnableMoveButton();
}
private void srPicker1_ItemSelectionNotNull()
private void srPicker1_SrSelectionChanged(object obj)
{
EnableMoveButton();
}

View File

@ -37,8 +37,7 @@
this.m_srPicker.Connection = null;
resources.ApplyResources(this.m_srPicker, "m_srPicker");
this.m_srPicker.Name = "m_srPicker";
this.m_srPicker.ItemSelectionNull += new System.Action(this.m_srPicker_ItemSelectionNull);
this.m_srPicker.ItemSelectionNotNull += new System.Action(this.m_srPicker_ItemSelectionNotNull);
this.m_srPicker.SrSelectionChanged += new System.Action<object>(this.m_srPicker_SrSelectionChanged);
//
// StoragePickerPage
//

View File

@ -299,16 +299,7 @@ namespace XenAdmin.Wizards.ImportWizard
});
}
private void m_srPicker_ItemSelectionNotNull()
{
if (ImportInProgress())
return;
SetButtonNextEnabled(m_srPicker.SR != null);
IsDirty = true;
}
private void m_srPicker_ItemSelectionNull()
private void m_srPicker_SrSelectionChanged(object obj)
{
if (ImportInProgress())
return;