示例#1
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);
        }
示例#2
0
        public void SetSettings(UserSettings userSettings)
        {
            UserSettings tmpSettings = new UserSettings();

            UiLanguage = userSettings.CurentUILanguague;

            ChatFontSize = userSettings.FontSize;

            BackgroundColor = userSettings.BackgroundColor;

            ParagraphSpaceCount = userSettings.InsertSpaceCount;

            LineBreakeHeight = userSettings.LineBreakHeight;

            TranslationEngine = (TranslationEngine)userSettings.CurrentTranslationEngine;

            FFLanguage = userSettings.CurrentFFXIVLanguage;

            TranslateToLanguage = userSettings.CurrentTranslateToLanguage;

            IsChatClickThrough = userSettings.IsClickThrough;

            IsChatAlwaysOnTop = userSettings.IsAlwaysOnTop;

            IsHideSettingsToTray = userSettings.IsHideToTray;

            IsAutoHide = userSettings.IsAutoHide;

            IsDirecMemoryReading = userSettings.IsDirecMemoryReading;

            AutoHideTimeout = userSettings.AutoHideTimeout;

            if (userSettings.ShowHideChatKeys != null)
            {
                ShowHideChatKeys = new HotKeyCombination(userSettings.ShowHideChatKeys);
            }
            else
            {
                ShowHideChatKeys = new HotKeyCombination(tmpSettings.ShowHideChatKeys);
            }

            if (userSettings.ClickThoughtChatKeys != null)
            {
                ClickThoughtChatKeys = new HotKeyCombination(userSettings.ClickThoughtChatKeys);
            }
            else
            {
                ClickThoughtChatKeys = new HotKeyCombination(tmpSettings.ClickThoughtChatKeys);
            }

            if (userSettings.ClearChatKeys != null)
            {
                ClearChatKeys = new HotKeyCombination(userSettings.ClearChatKeys);
            }
            else
            {
                ClearChatKeys = new HotKeyCombination(tmpSettings.ClearChatKeys);
            }

            SettingsWindowSize = userSettings.SettingsWindowSize;

            ChatWindowRectangle = userSettings.ChatWindowLocation;

            if (userSettings.RecentBackgroundColors != null)
            {
                RecentBackgroundColors = userSettings.RecentBackgroundColors.Distinct().ToList();
            }
            else
            {
                RecentBackgroundColors = tmpSettings.RecentBackgroundColors.Distinct().ToList();
            }

            var tmpChatList = Helper.LoadJsonData <List <ChatMsgType> >(GlobalSettings.ChatCodesFilePath);

            var tmpChatCodes = new Dictionary <string, ChatMsgType>();

            for (int i = 0; i < tmpChatList.Count; i++)
            {
                tmpChatCodes.TryAdd(tmpChatList[i].ChatCode, tmpChatList[i]);
            }

            var userCodes = userSettings.ChatCodes.Values.ToList();

            for (int i = 0; i < userCodes.Count; i++)
            {
                if (tmpChatCodes.ContainsKey(userCodes[i].ChatCode))
                {
                    tmpChatCodes[userCodes[i].ChatCode] = userCodes[i];
                }
            }

            ChatCodes = tmpChatCodes;

            IsFirstTime = userSettings.IsFirstTime;
        }