/// <summary>
        /// Remove the client selected in the list view
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RemoveClientButtons_Click(object sender, EventArgs e)
        {
            try
            {
                System.Windows.Forms.ListView.SelectedListViewItemCollection slvic = this.ClientListView.SelectedItems;
                ListViewItem toRemove = null;

                if (slvic != null)
                {
                    foreach (ListViewItem lvi in slvic)
                    {
                        System.Windows.Forms.ListViewItem.ListViewSubItemCollection lvsic = lvi.SubItems;

                        if (this.clientHandler.AvailableClients.ContainsKey(lvsic[1].Text))
                        {
                            this.clientHandler.Remove(lvsic[1].Text);
                            toRemove = lvi;
                        }
                    }
                }

                if (toRemove != null)
                {
                    this.ClientListView.Items.Remove(toRemove);
                }
            }
            catch (Exception ex)
            {
                RemoraOutput.WriteLine("Removal of Client Failed: \n " + ex.ToString(), OutputType.Remora);
            }
        }
Exemple #2
0
 public static void AddNullControlData <T>(this System.Windows.Forms.ListViewItem.ListViewSubItemCollection item, Nullable <T> src) where T : struct
 {
     if (src.HasValue)
     {
         item.Add(src.ToString());
     }
     else
     {
         item.Add("");
     }
 }
        /// <summary>
        /// Connect to a client
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ConnectClientButton_Click(object sender, EventArgs e)
        {
            try
            {
                System.Windows.Forms.ListView.SelectedListViewItemCollection slvic = this.ClientListView.SelectedItems;

                if (slvic != null && slvic.Count == 1)
                {
                    ListViewItem lvi = slvic[0];

                    System.Windows.Forms.ListViewItem.ListViewSubItemCollection lvsic = lvi.SubItems;

                    this.clientHandler.SetMachine(lvsic[1].Text);

                    RemoraCommon.Communicator.Shutdown();
                    RemoraCommon.Communicator.ResgisterWithClient();
                }
            }
            catch (Exception ex)
            {
                RemoraOutput.WriteLine("Connection to Client Failed: \n " + ex.ToString(), OutputType.Remora);
            }
        }
 public static IEnumerable <System.Windows.Forms.ListViewItem.ListViewSubItem> AsEnumerable(
     this System.Windows.Forms.ListViewItem.ListViewSubItemCollection source)
 {
     TypeCheckEnumerable(source, (s) => s.AsEnumerable(), (s) => s[0]);
     return(source.Cast <System.Windows.Forms.ListViewItem.ListViewSubItem>());
 }