void Server_OnClientConnection(string Username, System.Net.Sockets.Socket Socket)
        {
            FavoriteConfigurationElementCollection favorites = Settings.GetFavorites();

            System.Collections.ArrayList list = new System.Collections.ArrayList();
            foreach (FavoriteConfigurationElement elem in favorites)
            {
                list.Add(Network.SharedFavorite.ConvertFromFavorite(elem));
            }

            System.IO.MemoryStream favs = Unified.Serialize.SerializeBinary(list);
            byte[] data = null;
            if (favs != null && favs.Length > 0)
            {
                if (favs.CanRead && favs.Position > 0)
                {
                    favs.Position = 0;
                }
                data = favs.ToArray();
                favs.Close();
                favs.Dispose();
            }
            else
            {
                data = new byte[0];
            }
            Socket.Send(data);
            Network.Server.FinishDisconnect(Socket);
        }
        public AddConnectionForm()
        {
            InitializeComponent();
            FavoriteConfigurationElementCollection favorites = Settings.GetFavorites();

            foreach (FavoriteConfigurationElement favorite in favorites)
            {
                lvFavorites.Items.Add(favorite.Name);
            }
        }
        private void LoadFavorites()
        {
            FavoriteConfigurationElementCollection favorites = Settings.GetFavorites();

            cmbServerList.Items.Clear();
            foreach (FavoriteConfigurationElement favorite in favorites)
            {
                cmbServerList.Items.Add(favorite.Name);
            }
        }
        public static void RebuildTagIndex()
        {
            foreach (string Tag in Settings.Tags)
            {
                Settings.DeleteTag(Tag);
            }

            FavoriteConfigurationElementCollection favs = Settings.GetFavorites();

            foreach (FavoriteConfigurationElement fav in favs)
            {
                foreach (string tag in fav.TagList)
                {
                    Settings.AddTag(tag);
                }
            }
        }
        public static SortedDictionary <string, FavoriteConfigurationElement> GetSortedFavorites(SortProperties SortProperty)
        {
            FavoriteConfigurationElementCollection favlist = GetFavorites();

            if (favlist != null)
            {
                SortedDictionary <string, FavoriteConfigurationElement> favs = new SortedDictionary <string, FavoriteConfigurationElement>();
                int counter = 0;
                foreach (FavoriteConfigurationElement fav in favlist)
                {
                    string key = new string('a', counter);
                    switch (SortProperty)
                    {
                    case SortProperties.ConnectionName:
                        favs.Add(fav.Name + key, fav);
                        break;

                    case SortProperties.Protocol:
                        favs.Add(fav.Protocol + key, fav);
                        break;

                    case SortProperties.ServerName:
                        favs.Add(fav.ServerName + key, fav);
                        break;

                    case SortProperties.None:
                        favs.Add(key, fav);
                        break;

                    default:
                        break;
                    }
                    counter++;
                }
                return(favs);
            }
            return(null);
        }
        private void ImportFromFile()
        {
            bool needsReload = false;

            if (ImportOpenFileDialog.ShowDialog() == DialogResult.OK)
            {
                string filename           = ImportOpenFileDialog.FileName;
                Integration.Integration i = new Terminals.Integration.Integration();

                FavoriteConfigurationElementCollection coll = i.ImportFavorites(filename);
                if (coll != null)
                {
                    needsReload = true;
                    foreach (FavoriteConfigurationElement fav in coll)
                    {
                        Settings.AddFavorite(fav, false);
                    }
                }
            }
            if (needsReload)
            {
                LoadConnections();
            }
        }