private void button4_Click(object sender, EventArgs e)
        {
            try{
                if (listView1.FocusedItem.SubItems[3].Text.Equals("Connesso"))
                {
                    MessageBox.Show("Stai già controllando questo server");
                    return;
                }


                if (listView1.SelectedItems.Count == 0)
                {
                    MessageBox.Show("Per impostare una hotkey devi prima selezionare un server");
                    return;
                }
                Keys          k          = (hotKeyValues != "" && hotKeyValues != null) ? (Keys)Int32.Parse(hotKeyValues) : Keys.None;
                HotKeyWindows hotkeyform = new HotKeyWindows(k);
                if (hotkeyform.ShowDialog() == DialogResult.OK)
                {
                    UnregisterHotKey(this.Handle, listView1.FocusedItem.Index);
                    bool success = RegisterHotKey(this.Handle, listView1.FocusedItem.Index, hotkeyform.Win32Modifiers, hotkeyform.CharCode);
                    if (success)
                    {
                        //(int)hotkeyform.Keys).ToString()
                        idHotkey++;
                        listView1.FocusedItem.SubItems[2].Text = hotkeyform.Keys.ToString();
                        Console.WriteLine(hotkeyform.combinazione);
                    }
                    else
                    {
                        MessageBox.Show("Combinazione già registrata");
                    }
                }
            }
            catch (Exception ex)
            {
                //listView1.Items.RemoveAt(listView1.FocusedItem.Index);
                //client.closeAllSocket();
                MessageBox.Show("Errore nela definizione di un' hotkey");
                return;
            }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            StreamReader confF = null;

            try
            {
                if (client == null)
                {
                    client = new MyClient();// è la prima volta che un client si connette
                }

                if (!Directory.Exists(@"C:\local\"))
                {
                    Directory.CreateDirectory(@"C:\local\");
                }

                if (File.Exists(Application.StartupPath + "\\data.txt"))
                {
                    string line = string.Empty;
                    confF = new StreamReader(Application.StartupPath + "\\data.txt");
                    ListViewItem item2 = null;
                    while ((line = confF.ReadLine()) != null)
                    {
                        /* salto se è un commento */
                        if (isComment(line))
                        {
                            continue;
                        }

                        /* controllo se la parola nel file corrisponde
                         *  a qualcuna della mia lista */
                        int val = 0;
                        foreach (AccettableStrings item in Enum.GetValues(typeof(AccettableStrings)))
                        {
                            if (line.StartsWith(item.ToString()))
                            {
                                switch (item.ToString())
                                {
                                case "ADDRESS":
                                    item2 = new ListViewItem(getContent(line), clientConnected);
                                    break;

                                case "HOTKEYS":
                                    Keys k = (Keys)Enum.Parse(typeof(Keys), getContent(line));
                                    item2.SubItems.Add(getContent(line));
                                    // Keys k = (Keys)val;

                                    bool success = RegisterHotKey(this.Handle, idHotkey, HotKeyWindows.Win32ModifiersFromKeys(k), HotKeyWindows.CharCodeFromKeys(k));
                                    if (success)
                                    {
                                        idHotkey++;
                                        hotKeyValues = val.ToString();
                                    }
                                    else
                                    {
                                        MessageBox.Show("Could not register Hotkey - there is probably a conflict.  ", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    }
                                    break;

                                case "ENDSERVER":
                                    item2.Checked = true;
                                    item2.SubItems.Add(" ");
                                    item2.SubItems.Add(GetTimestamp(DateTime.Now));
                                    //Add the items to the ListView.
                                    listView1.Items.AddRange(new ListViewItem[] { item2 });
                                    clientConnected++;
                                    indexListView++;
                                    client.alignListSocketWithConfigurationFIle();
                                    break;

                                default: item2.SubItems.Add(getContent(line));
                                    break;
                                }
                            }
                        }
                    }
                    confF.Close();
                }
            }catch (Exception ex) {
                if (confF != null)
                {
                    confF.Close();
                }
                MessageBox.Show("Errore nell' apertura del file");
                return;
            }
        }