public override void LoadFromJson(JsonObject o)
        {
            base.LoadFromJson(o);
            Toolbox.JsonGet(ref UseSSL, o[SettingsKey.REGKEY_USESSL]);
            Toolbox.JsonGet(ref RefreshRate, o[SettingsKey.REGKEY_REFRESHRATE]);
            Toolbox.JsonGet(ref RefreshRateTray, o[SettingsKey.REGKEY_REFRESHRATETRAY]);
            Toolbox.JsonGet(ref CustomPath, o[SettingsKey.REGKEY_CUSTOMPATH]);
            Toolbox.JsonGet(ref RetryLimit, o[SettingsKey.REGKEY_RETRYLIMIT]);
            Toolbox.JsonGet(ref DownLimit, o[SettingsKey.REGKEY_DOWNLIMIT]);
            Toolbox.JsonGet(ref UpLimit, o[SettingsKey.REGKEY_UPLIMIT]);
            Toolbox.JsonGet(ref StartPaused, o[SettingsKey.REGKEY_STARTPAUSED]);
            Toolbox.JsonGet(ref PlinkEnable, o[SettingsKey.REGKEY_PLINKENABLE]);
            Toolbox.JsonGet(ref PlinkCmd, o[SettingsKey.REGKEY_PLINKCMD]);

            JsonArray ja;
            if (o[SettingsKey.REGKEY_DESTINATION_PATH_HISTORY] is string)
                ja = (JsonArray)JsonConvert.Import((string)o[SettingsKey.REGKEY_DESTINATION_PATH_HISTORY]);
            else
                ja = (JsonArray)o[SettingsKey.REGKEY_DESTINATION_PATH_HISTORY];
            foreach (string s in ja.ToArray())
            {
                if (s.Length > 0)
                    destpathhistory.Add(s);
            }
            JsonObject jo = (JsonObject)o[SettingsKey.REGKEY_SAMBASHAREMAPPINGS];
            if (jo != null)
            {
                foreach (string n in jo.Names)
                {
                    AddSambaMapping(n, jo[n] as string);
                }
            }
            jo = (JsonObject)o[SettingsKey.REGKEY_PROXY];
            if (jo != null)
            {
                Proxy = new ProxyServer(jo);
            }
        }
        public static LocalSettings TryLoad()
        {
            LocalSettings newsettings = null;
            ILocalSettingsStore[] SettingsSource = new ILocalSettingsStore[] { 
#if !PORTABLE
                new RegistryLocalSettingsStore(), 
                new RegistryJsonLocalSettingsStore(), 
#endif
                new FileLocalSettingsStore() 
            };
            foreach (ILocalSettingsStore ls in SettingsSource)
            {
                try
                {
                    JsonObject jo = ls.Load();
                    newsettings = new LocalSettings(jo);
                    newsettings.DefaultLocalStore = ls;
                    break;
                }
                catch { };
            }
            if (newsettings == null)
            { // not load from any source :(, try old mode
                try
                {
                    LocalSettings tempsettings = new LocalSettings();
#if !PORTABLE
                    LocalSettingsSingleton oldsettings = LocalSettingsSingleton.OneInstance();
                    tempsettings.Locale = oldsettings.Locale;
                    tempsettings.CompletedBaloon = oldsettings.CompletedBaloon;
                    tempsettings.MinOnClose = oldsettings.MinOnClose;
                    tempsettings.MinToTray = oldsettings.MinToTray;
                    tempsettings.PlinkPath = oldsettings.PlinkPath;
                    tempsettings.StartedBalloon = oldsettings.StartedBalloon;
                    tempsettings.UploadPrompt = oldsettings.UploadPrompt;
                    tempsettings.AutoCheckupdate = oldsettings.AutoCheckupdate;
                    string origcurrentprofile = oldsettings.CurrentProfile;
                    foreach (string p in oldsettings.Profiles)
                    {
                        oldsettings.CurrentProfile = p;
                        TransmissionServer ts = new TransmissionServer();
                        ts.CustomPath = oldsettings.CustomPath;
                        ts.DownLimit = oldsettings.DownLimit;
                        ts.UpLimit = oldsettings.UpLimit;
                        ts.Host = oldsettings.Host;
                        ts.Password = oldsettings.Pass;
                        ts.PlinkCmd = oldsettings.PlinkCmd;
                        ts.PlinkEnable = oldsettings.PlinkEnable;
                        ts.Port = oldsettings.Port;
                        ts.RefreshRate = oldsettings.RefreshRate;
                        ts.RefreshRateTray = oldsettings.RefreshRate * 10;
                        ts.StartPaused = oldsettings.StartPaused;
                        ts.Username = oldsettings.User;
                        ts.UseSSL = oldsettings.UseSSL;
                        JsonObject mappings = oldsettings.SambaShareMappings;
                        foreach (string key in mappings.Names)
                        {
                            ts.AddSambaMapping(key, (string)mappings[key]);
                        }
                        ts.destpathhistory.AddRange(oldsettings.DestPathHistory);
                        ProxyServer ps = new ProxyServer();
                        ps.Host = oldsettings.ProxyHost;
                        ps.Password = oldsettings.ProxyPass;
                        ps.Port = oldsettings.ProxyPort;
                        ps.Username = oldsettings.ProxyUser;
                        ps.ProxyMode = (ProxyMode)oldsettings.ProxyMode;
                        ts.Proxy = ps;
                        tempsettings.Servers.Add(p, ts);
                        if (origcurrentprofile.Equals(p))
                            tempsettings.CurrentProfile = p;
                    }
                    if (tempsettings.CurrentProfile.Equals("") && tempsettings.Servers.Count > 0)
                        tempsettings.CurrentProfile = "aa"; //tempsettings.Servers. . Key;
                    foreach (string s in oldsettings.ListObject(true))
                    {
                        if (s.StartsWith("mainwindow-") || s.StartsWith("listview-"))
                            tempsettings.Misc[s] = oldsettings.GetObject(s, true);
                    }
                    // move old stuff to backup!
                    //oldsettings.BackupSettings();
#endif
                    /* Only use the old settings, if we can read completely */
                    newsettings = tempsettings;
                }
                catch
                {
                    newsettings = new LocalSettings();
                };
                newsettings.Commit();
            }
            return newsettings;
        }