private static TerminalsConfigurationSection GetSection()
        {
            Configuration configuration     = GetConfiguration();
            TerminalsConfigurationSection c = null;

            try
            {
                c = (TerminalsConfigurationSection)configuration.GetSection("settings");
            }
            catch (Exception exc)
            {
                Terminals.Logging.Log.Info("", exc);
                try
                {
                    //kick into the import routine
                    configuration = ImportConfiguration(Terminals.Program.ConfigurationFileLocation);
                    configuration = GetConfiguration();
                    c             = (TerminalsConfigurationSection)configuration.GetSection("settings");
                    if (configuration != null)
                    {
                        System.Windows.Forms.MessageBox.Show("Terminals was able to automatically upgrade your existing connections.");
                    }
                }
                catch (Exception importException)
                {
                    Terminals.Logging.Log.Info("", importException);
                    System.Windows.Forms.MessageBox.Show(string.Format("Terminals was NOT able to automatically upgrade your existing connections.\r\nError:{0}", importException.Message));
                    //if(System.IO.File.Exists(configuration.FilePath)) System.IO.File.Delete(configuration.FilePath);
                    //configuration = GetConfiguration();
                    //c = (TerminalsConfigurationSection)configuration.GetSection("settings");
                }
            }
            return(c);
        }
        public static FavoriteConfigurationElementCollection GetFavorites()
        {
            TerminalsConfigurationSection section = GetSection();

            if (section != null)
            {
                return(section.Favorites);
            }
            return(null);
        }
        public static void EditFavorite(string oldName, FavoriteConfigurationElement favorite)
        {
            Configuration configuration                  = GetConfiguration();
            TerminalsConfigurationSection section        = GetSection(configuration);
            FavoriteConfigurationElement  editedFavorite = section.Favorites[oldName];

            editedFavorite.VMRCAdministratorMode = favorite.VMRCAdministratorMode;
            editedFavorite.VMRCReducedColorsMode = favorite.VMRCReducedColorsMode;
            editedFavorite.Telnet            = favorite.Telnet;
            editedFavorite.TelnetRows        = favorite.TelnetRows;
            editedFavorite.TelnetCols        = favorite.TelnetCols;
            editedFavorite.TelnetFont        = favorite.TelnetFont;
            editedFavorite.TelnetCursorColor = favorite.TelnetCursorColor;
            editedFavorite.TelnetTextColor   = favorite.TelnetTextColor;
            editedFavorite.TelnetBackColor   = favorite.TelnetBackColor;
            editedFavorite.Protocol          = favorite.Protocol;
            editedFavorite.Colors            = favorite.Colors;
            editedFavorite.ConnectToConsole  = favorite.ConnectToConsole;
            editedFavorite.DesktopSize       = favorite.DesktopSize;
            editedFavorite.DomainName        = favorite.DomainName;
            editedFavorite.EncryptedPassword = favorite.EncryptedPassword;
            editedFavorite.Name                                 = favorite.Name;
            editedFavorite.ServerName                           = favorite.ServerName;
            editedFavorite.UserName                             = favorite.UserName;
            editedFavorite.RedirectDrives                       = favorite.RedirectDrives;
            editedFavorite.RedirectPorts                        = favorite.RedirectPorts;
            editedFavorite.RedirectPrinters                     = favorite.RedirectPrinters;
            editedFavorite.RedirectDevices                      = favorite.RedirectDevices;
            editedFavorite.RedirectClipboard                    = favorite.RedirectClipboard;
            editedFavorite.RedirectSmartCards                   = favorite.RedirectSmartCards;
            editedFavorite.Sounds                               = favorite.Sounds;
            editedFavorite.Port                                 = favorite.Port;
            editedFavorite.DesktopShare                         = favorite.DesktopShare;
            editedFavorite.ExecuteBeforeConnect                 = favorite.ExecuteBeforeConnect;
            editedFavorite.ExecuteBeforeConnectCommand          = favorite.ExecuteBeforeConnectCommand;
            editedFavorite.ExecuteBeforeConnectArgs             = favorite.ExecuteBeforeConnectArgs;
            editedFavorite.ExecuteBeforeConnectInitialDirectory = favorite.ExecuteBeforeConnectInitialDirectory;
            editedFavorite.ExecuteBeforeConnectWaitForExit      = favorite.ExecuteBeforeConnectWaitForExit;
            editedFavorite.DisableWallPaper                     = favorite.DisableWallPaper;

            editedFavorite.DisableCursorBlinking = favorite.DisableCursorBlinking;
            editedFavorite.DisableCursorShadow   = favorite.DisableCursorShadow;
            editedFavorite.DisableFullWindowDrag = favorite.DisableFullWindowDrag;
            editedFavorite.DisableMenuAnimations = favorite.DisableMenuAnimations;
            editedFavorite.DisableTheming        = favorite.DisableTheming;


            editedFavorite.Tags = favorite.Tags;
            configuration.Save();
        }