/// <summary> /// Forces the staff to Logout of the Machine /// </summary> /// <param name="sender">The Sender</param> /// <param name="e">the event args</param> private void MachineLogoutButton_Click(object sender, EventArgs e) { if (MachineListView.SelectedIndices.Count > 0) { var selectedIndex = MachineListView.SelectedIndices[0]; var topItem = MachineListView.TopItem; var lastItem = MachineListView.Items; if (MessageForm.Show(Resources.ConfirmLogOut, Resources.ConfirmLogoutTitle, MessageFormTypes.YesNo, 0) == DialogResult.Yes) { var MachineItem = (Machine)MachineListView.SelectedItems[0].Tag; MachineListView.SelectedItems[0].Remove(); try { SetStaffMachineLogout.Save(MachineItem); } catch (Exception ex) { MessageForm.Show(this, ex.Message, Resources.ConfirmLogoutTitle); } if (lastItem.Count > 0) { if (selectedIndex > 0) { selectedIndex = selectedIndex - 1; } MachineListView.EnsureVisible(selectedIndex); MachineListView.SelectedIndices.Add(selectedIndex); } } } }
/// <summary> /// Refresh the MachineListview /// </summary> /// <param name="sender">The Sender</param> /// <param name="e">the event args</param> private void MachineRefreshButton_Click(object sender, EventArgs e) { PopulateMachineList(); MachineListView.Refresh(); }