Пример #1
0
        private void ApplyOldSettings(UserSettings userSettings, UIModel.OldSettings oldSettings)
        {
            var trLan = _WebTranslator.GetAllSupportedLanguages();

            userSettings.BackgroundColor = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString(oldSettings.BackgroundColor);
            userSettings.Font1Color      = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString(oldSettings.Font1Color);
            userSettings.Font2Color      = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString(oldSettings.Font2Color);

            userSettings.IsClickThrough = (bool)oldSettings.IsClickThrough;
            userSettings.IsAlwaysOnTop  = (bool)oldSettings.IsAlwaysOnTop;
            userSettings.IsHideToTray   = (bool)oldSettings.IsHideToTray;

            userSettings.FontSize         = (int)oldSettings.FontSize;
            userSettings.LineBreakHeight  = (int)oldSettings.LineBreakHeight;
            userSettings.InsertSpaceCount = (int)oldSettings.InsertSpaceCount;

            userSettings.CurrentTranslationEngine = (int)oldSettings.CurrentTranslationEngine;

            //userSettings.CurrentFFXIVLanguage = oldSettings.CurrentFFXIVLanguage;

            userSettings.CurrentTranslateToLanguage = trLan[userSettings.CurrentTranslationEngine][(int)oldSettings.CurrentTranslateToLanguage].ShownName;

            userSettings.CurentUILanguague = (int)oldSettings.CurentLanguague;

            userSettings.SettingsWindowSize = new System.Drawing.PointD((double)oldSettings.MainWinWidth, (double)oldSettings.MainWinHeight);

            userSettings.ChatWindowLocation = new System.Drawing.RectangleD((double)oldSettings.ChatWinLeft, (double)oldSettings.ChatWinTop,
                                                                            (double)oldSettings.ChatWinWidth, (double)oldSettings.ChatWinHeight);

            userSettings.IsFirstTime = (int)oldSettings.IsFirstTime;
        }
Пример #2
0
        private UIModel.OldSettings LoadOldSettingsFile(UserSettings userSettings)
        {
            UIModel.OldSettings oldSettings = null;

            try
            {
                oldSettings = new UIModel.OldSettings();
                string oldSet = string.Empty;
                using (StreamReader sr = new StreamReader(OldSettingFileName))
                {
                    oldSet = sr.ReadToEnd();
                }
                oldSet = oldSet.Replace("\",", "\":");
                oldSet = oldSet.Replace("[", "{");
                oldSet = oldSet.Replace("]", "}");
                var ind1     = oldSet.IndexOf('{');
                var ind2     = oldSet.LastIndexOf('}');
                var oldSetsb = new StringBuilder(oldSet);
                oldSetsb[ind1] = '[';
                oldSetsb[ind2] = ']';

                oldSet = oldSetsb.ToString();


                oldSet = ReomveBadOccr(oldSet, "FFXIVLanguagles");

                oldSet = ReomveBadOccr(oldSet, "RecentBackgroundColor");
                oldSet = ReomveBadOccr(oldSet, "RecentFont1Colors");
                oldSet = ReomveBadOccr(oldSet, "RecentFont2Colors");

                var res = JsonConvert.DeserializeObject <List <Object> >(oldSet);

                oldSettings.BackgroundColor = (string)((Newtonsoft.Json.Linq.JObject)res[0]).GetValue("BackgroundColor");
                oldSettings.Font1Color      = (string)((Newtonsoft.Json.Linq.JObject)res[1]).GetValue("Font1Color");
                oldSettings.Font2Color      = (string)((Newtonsoft.Json.Linq.JObject)res[2]).GetValue("Font2Color");

                oldSettings.IsClickThrough = (bool)((Newtonsoft.Json.Linq.JObject)res[3]).GetValue("IsClickThrough");
                oldSettings.IsAlwaysOnTop  = (bool)((Newtonsoft.Json.Linq.JObject)res[4]).GetValue("IsAlwaysOnTop");
                oldSettings.IsHideToTray   = (bool)((Newtonsoft.Json.Linq.JObject)res[5]).GetValue("IsHideToTray");

                oldSettings.FontSize         = (int)((Newtonsoft.Json.Linq.JObject)res[6]).GetValue("FontSize");
                oldSettings.LineBreakHeight  = (int)((Newtonsoft.Json.Linq.JObject)res[8]).GetValue("LineBreakHeight");
                oldSettings.InsertSpaceCount = (int)((Newtonsoft.Json.Linq.JObject)res[9]).GetValue("InsertSpaceCount");

                oldSettings.CurrentTranslationEngine = (int)((Newtonsoft.Json.Linq.JObject)res[10]).GetValue("CurrentTranslationEngine");

                oldSettings.CurrentFFXIVLanguage       = (int)((Newtonsoft.Json.Linq.JObject)res[11]).GetValue("CurrentFFXIVLanguage");
                oldSettings.CurrentTranslateToLanguage = (int)((Newtonsoft.Json.Linq.JObject)res[12]).GetValue("CurrentTranslateToLanguage");

                oldSettings.CurentLanguague = (int)((Newtonsoft.Json.Linq.JObject)res[17]).GetValue("CurentLanguague");

                oldSettings.MainWinHeight = (double)((Newtonsoft.Json.Linq.JObject)res[26]).GetValue("MainWinHeight");
                oldSettings.MainWinWidth  = (double)((Newtonsoft.Json.Linq.JObject)res[27]).GetValue("MainWinWidth");

                oldSettings.ChatWinTop    = (double)((Newtonsoft.Json.Linq.JObject)res[28]).GetValue("ChatWinTop");
                oldSettings.ChatWinLeft   = (double)((Newtonsoft.Json.Linq.JObject)res[29]).GetValue("ChatWinLeft");
                oldSettings.ChatWinHeight = (double)((Newtonsoft.Json.Linq.JObject)res[30]).GetValue("ChatWinHeight");
                oldSettings.ChatWinWidth  = (double)((Newtonsoft.Json.Linq.JObject)res[31]).GetValue("ChatWinWidth");

                oldSettings.IsFirstTime = (int)((Newtonsoft.Json.Linq.JObject)res[32]).GetValue("IsFirstTime");


                //oldSettings = JsonConvert.DeserializeObject<UIModel.OldSettings>(oldSet);
            }
            catch (Exception e)
            {
                oldSettings = null;
                Logger.WriteLog(e);
            }

            return(oldSettings);
        }