Example #1
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                Logger.WriteLog("TataruHelper v" + Convert.ToString(System.Reflection.Assembly.GetEntryAssembly().GetName().Version));
            }
            catch (Exception) { }

            try
            {
                try
                {
                    _TataruModel = new TataruModel(this);

                    await _TataruModel.InitializeComponent();

                    _TataruUIModel = _TataruModel.TataruUIModel;

                    InitTataruModel();
                }
                catch (Exception ex)
                {
                    Logger.WriteLog(ex);
                }

                _TataruModel.AsyncLoadSettings().Forget();

                _TataruModel.FFMemoryReader.AddExclusionWindowHandler((new WindowInteropHelper(this).Handle));

                this.DataContext = _TataruModel.TataruViewModel;

                _TataruModel.TataruViewModel.ShutdownRequested += OnShutDownRequsted;

                _OptimizeFootprint = new OptimizeFootprint();
                _OptimizeFootprint.Start();

                _WinMessagesHandler = new WinMessagesHandler(this);
                _WinMessagesHandler.ShowFirstInstance += OnShowFirstInstance;

                _Updater.UpdatingStateChanged += OnUpdaterEvent;

#if DEBUG
#else
                Task.Run(() =>
                {
                    _Updater.CheckAndInstallUpdates(CmdArgsStatus.PreRelease);

                    _UpdaterTimer           = new Timer(TimeSpan.FromMinutes(30).TotalMilliseconds);
                    _UpdaterTimer.Elapsed  += async(senderr, ee) => await UpdateTimerHandler();
                    _UpdaterTimer.AutoReset = true;
                    _UpdaterTimer.Start();
                }).Forget();
#endif
            }
            catch (Exception ex)
            {
                Logger.WriteLog(ex);
            }
        }
Example #2
0
 public async Task SaveSettings()
 {
     await Task.Run(() =>
     {
         try
         {
             var userSettings = TataruUIModel.GetSettings();
             Helper.SaveJson(userSettings, GlobalSettings.Settings);
         }
         catch (Exception e)
         {
             Logger.WriteLog(e);
         }
     });
 }
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                try
                {
                    _TataruModel = new TataruModel();
                    await _TataruModel.InitializeComponent();

                    _TataruUIModel = _TataruModel.TataruUIModel;

                    InitTataruModel();
                }
                catch (Exception ex)
                {
                    Logger.WriteLog(ex);
                }

                _TataruModel.AsyncLoadSettings().Forget();

                _TataruModel.FFMemoryReader.AddExclusionWindowHandler((new WindowInteropHelper(this).Handle));

                try
                {
                    Logger.WriteLog("TataruHelper v" + Convert.ToString(System.Reflection.Assembly.GetEntryAssembly().GetName().Version));
                }
                catch (Exception) { }

                _Updater.StartUpdate();


                this.DataContext = _TataruModel.TataruViewModel;

                _TataruModel.TataruViewModel.ShutdownRequested += OnShutDownRequsted;

                _OptimizeFootprint = new OptimizeFootprint();
                _OptimizeFootprint.Start();

                _WinMessagesHandler = new WinMessagesHandler(this);
                _WinMessagesHandler.ShowFirstInstance += OnShowFirstInstance;
            }
            catch (Exception ex)
            {
                Logger.WriteLog(ex);
            }
        }
Example #4
0
        public TataruModel()
        {
            CmdArgsStatus.LoadArgs();

            _PropertyBinders = new List <PropertyBinder>();
            _ChatWindows     = new List <ChatWindow>();

            _HotKeyManager = new HotKeyManager(UiWindow.Window);

            _SaveSettingsCancellationTokenSource = new CancellationTokenSource();

            _WebTranslator = new WebTranslator(new LoggerWrapper());

            _TataruUIModel = new TataruUIModel();

            _FFMemoryReader = new FFMemoryReader();

            _ChatProcessor = new ChatProcessor(_WebTranslator);

            _TataruViewModel = new TataruViewModel(this);
        }
Example #5
0
        public void LoadSettings()
        {
            try
            {
                if (!Helper.LoadStaticFromJson(typeof(GlobalSettings), SystemSettingFileName))
                {
                    Helper.SaveStaticToJson(typeof(GlobalSettings), SystemSettingFileName);
                    Helper.LoadStaticFromJson(typeof(GlobalSettings), SystemSettingFileName);
                }

                var userSettings = Helper.LoadJsonData <UserSettings>(GlobalSettings.Settings);
                LoadOldSettings(userSettings);

                if (userSettings == null)
                {
                    userSettings = new UserSettings();
                    Logger.WriteLog("userSettings == null");
                }

                LoadMissingChatCodes(userSettings);

                for (int i = 0; i < userSettings.ChatWindows.Count; i++)
                {
                    userSettings.ChatWindows[i].WinId = i;
                    userSettings.ChatWindows[i].Name  = Convert.ToString(i + 1);
                }

                TataruUIModel.SetSettings(userSettings);

                _TataruUIModel.PropertyChanged += OnUiSettingsChanged;
                SettingsChangeTime              = DateTime.UtcNow;
                SettingsSaveTime = DateTime.UtcNow;

                WatchAndSaveChangedSettings();
            }
            catch (Exception e)
            {
                Logger.WriteLog(e);
            }
        }