private void firefoxButton1_Click(object sender, EventArgs e) { if ((sender as FirefoxButton).EnabledCalc) { var access = _authAuthService.CheckAuthentication(); switch (access) { case AzureAuthService.AccessStatus.Unauthorized: _authAuthService.Authenticate(); break; case AzureAuthService.AccessStatus.Unknown: MessageBox.Show(GlobalSettings.Language.GetTag("iatag_ui_backup_service_error")); break; default: { var alreadyLoggedIn = GlobalSettings.Language.GetTag("iatag_feedback_already_logged_in"); MessageBox.Show( alreadyLoggedIn, alreadyLoggedIn, MessageBoxButtons.OK, MessageBoxIcon.Information ); break; } } } }
private void firefoxButton1_Click(object sender, EventArgs e) { var access = _authAuthService.CheckAuthentication(); if (access == AzureAuthService.AccessStatus.Unauthorized) { _authAuthService.Authenticate(); } else if (access == AzureAuthService.AccessStatus.Unknown) { MessageBox.Show("The backup service is currently experiencing technical difficulties.\nPlease try again later."); } else { var alreadyLoggedIn = GlobalSettings.Language.GetTag("iatag_feedback_already_logged_in"); MessageBox.Show( alreadyLoggedIn, alreadyLoggedIn, MessageBoxButtons.OK, MessageBoxIcon.Information ); } }
private void MainWindow_Load(object sender, EventArgs e) { if (Thread.CurrentThread.Name == null) { Thread.CurrentThread.Name = "UI"; } ExceptionReporter.EnableLogUnhandledOnThread(); SizeChanged += OnMinimizeWindow; _stashManager = new StashManager(_playerItemDao, _databaseItemStatDao, SetFeedback, ListviewUpdateTrigger); _stashFileMonitor.OnStashModified += (_, __) => { StashEventArg args = __ as StashEventArg; if (_stashManager != null && _stashManager.TryLootStashFile(args?.Filename)) { // STOP TIMER _stashFileMonitor.CancelQueuedNotify(); } // TODO: This logic should be changed to 're queue' but only trigger once, if its slow it triggers multiple times. }; if (!_stashFileMonitor.StartMonitorStashfile(GlobalPaths.SavePath)) { MessageBox.Show("Ooops!\nIt seems you are synchronizing your saves to steam cloud..\nThis tool is unfortunately not compatible.\n"); Process.Start("http://www.grimdawn.com/forums/showthread.php?t=20752"); if (!Debugger.IsAttached) { Close(); } } // Chicken and the egg.. SearchController searchController = new SearchController( _databaseItemDao, _playerItemDao, _databaseItemStatDao, _itemSkillDao, _buddyItemDao, _stashManager, _augmentationItemRepo ); _cefBrowserHandler.InitializeChromium(searchController.JsBind, Browser_IsBrowserInitializedChanged); searchController.Browser = _cefBrowserHandler; searchController.JsBind.OnClipboard += SetItemsClipboard; // Load the grim database string gdPath = GrimDawnDetector.GetGrimLocation(); if (!string.IsNullOrEmpty(gdPath)) { } else { Logger.Warn("Could not find the Grim Dawn install location"); statusLabel.Text = "Could not find the Grim Dawn install location"; var timer = new System.Windows.Forms.Timer(); timer.Tick += TimerTickLookForGrimDawn; timer.Interval = 10000; timer.Start(); } // Load recipes foreach (string file in GlobalPaths.FormulasFiles) { if (!string.IsNullOrEmpty(file)) { bool isHardcore = file.EndsWith("gsh"); Logger.InfoFormat("Reading recipes at \"{0}\", IsHardcore={1}", file, isHardcore); _recipeParser.UpdateFormulas(file, isHardcore); } } var addAndShow = UIHelper.AddAndShow; // Create the tab contents _buddySettingsWindow = new BuddySettings(delegate(bool b) { BuddySyncEnabled = b; }, _buddyItemDao, _buddySubscriptionDao ); addAndShow(_buddySettingsWindow, buddyPanel); _authAuthService = new AzureAuthService(_cefBrowserHandler, new AuthenticationProvider()); var backupSettings = new BackupSettings(_playerItemDao, _authAuthService); addAndShow(backupSettings, backupPanel); addAndShow(new ModsDatabaseConfig(DatabaseLoadedTrigger, _playerItemDao, _parsingService), modsPanel); addAndShow(new HelpTab(), panelHelp); addAndShow(new LoggingWindow(), panelLogging); var backupService = new BackupService(_authAuthService, _playerItemDao, _azurePartitionDao, () => Settings.Default.UsingDualComputer); _backupServiceWorker = new BackupServiceWorker(backupService); backupService.OnUploadComplete += (o, args) => _searchWindow.UpdateListView(); searchController.OnSearch += (o, args) => backupService.OnSearch(); _searchWindow = new SplitSearchWindow(_cefBrowserHandler.BrowserControl, SetFeedback, _playerItemDao, searchController, _itemTagDao); addAndShow(_searchWindow, searchPanel); _stashManager.StashUpdated += (_, __) => { _searchWindow.UpdateListView(); }; addAndShow( new SettingsWindow( _cefBrowserHandler, _itemTagDao, _tooltipHelper, ListviewUpdateTrigger, _databaseSettingDao, _playerItemDao, _arzParser, _searchWindow.ModSelectionHandler.GetAvailableModSelection(), _stashManager, _parsingService ), settingsPanel); new StashTabPicker(_stashManager.NumStashTabs).SaveStashSettingsToRegistry(); #if !DEBUG ThreadPool.QueueUserWorkItem(m => ExceptionReporter.ReportUsage()); CheckForUpdates(); #endif int min = 1000 * 60; int hour = 60 * min; _timerReportUsage = new Timer(); _timerReportUsage.Start(); _timerReportUsage.Elapsed += (a1, a2) => { if (Thread.CurrentThread.Name == null) { Thread.CurrentThread.Name = "ReportUsageThread"; } ReportUsage(); }; _timerReportUsage.Interval = 12 * hour; _timerReportUsage.AutoReset = true; _timerReportUsage.Start(); Shown += (_, __) => { StartInjector(); }; //settingsController.Data.budd BuddySyncEnabled = (bool)Settings.Default.BuddySyncEnabled; // Start the backup task _backupBackgroundTask = new BackgroundTask(new FileBackup(_playerItemDao)); LocalizationLoader.ApplyLanguage(Controls, GlobalSettings.Language); EasterEgg.Activate(this); // Initialize the "stash packer" used to find item positions for transferring items ingame while the stash is open { _dynamicPacker.Initialize(8, 16); var transferFiles = GlobalPaths.TransferFiles; if (transferFiles.Count > 0) { var file = transferFiles.MaxBy(m => m.LastAccess); var stash = StashManager.GetStash(file.Filename); if (stash != null) { _dynamicPacker.Initialize(stash.Width, stash.Height); if (stash.Tabs.Count >= 3) { foreach (var item in stash.Tabs[2].Items) { byte[] bx = BitConverter.GetBytes(item.XOffset); uint x = (uint)BitConverter.ToSingle(bx, 0); byte[] by = BitConverter.GetBytes(item.YOffset); uint y = (uint)BitConverter.ToSingle(by, 0); _dynamicPacker.Insert(item.BaseRecord, item.Seed, x, y); } } } } } _messageProcessors.Add(new ItemPositionFinder(_dynamicPacker)); _messageProcessors.Add(new PlayerPositionTracker()); _messageProcessors.Add(new StashStatusHandler()); _messageProcessors.Add(new ItemReceivedProcessor(_searchWindow, _stashFileMonitor, _playerItemDao)); _messageProcessors.Add(new ItemInjectCallbackProcessor(_searchWindow.UpdateListViewDelayed, _playerItemDao)); _messageProcessors.Add(new ItemSpawnedProcessor()); _messageProcessors.Add(new CloudDetectorProcessor(SetFeedback)); _messageProcessors.Add(new GenericErrorHandler()); //messageProcessors.Add(new LogMessageProcessor()); #if DEBUG //messageProcessors.Add(new DebugMessageProcessor()); #endif GlobalSettings.StashStatusChanged += GlobalSettings_StashStatusChanged; _transferController = new ItemTransferController( _cefBrowserHandler, SetFeedback, SetTooltipAtmouse, _settingsController, _searchWindow, _dynamicPacker, _playerItemDao, _stashManager, new ItemStatService(_databaseItemStatDao, _itemSkillDao) ); Application.AddMessageFilter(new MousewheelMessageFilter()); var titleTag = GlobalSettings.Language.GetTag("iatag_ui_itemassistant"); if (!string.IsNullOrEmpty(titleTag)) { this.Text += $" - {titleTag}"; } // Popup login diag if (_authAuthService.CheckAuthentication() == AzureAuthService.AccessStatus.Unauthorized) { var t = new System.Windows.Forms.Timer { Interval = 100 }; t.Tick += (o, args) => { if (_cefBrowserHandler.BrowserControl.IsBrowserInitialized) { _authAuthService.Authenticate(); t.Stop(); } }; t.Start(); } _cefBrowserHandler.TransferSingleRequested += TransferSingleItem; _cefBrowserHandler.TransferAllRequested += TransferAllItems; new WindowSizeManager(this); }
private void MainWindow_Load(object sender, EventArgs e) { if (Thread.CurrentThread.Name == null) { Thread.CurrentThread.Name = "UI"; } Logger.Debug("Starting UI initialization"); ExceptionReporter.EnableLogUnhandledOnThread(); SizeChanged += OnMinimizeWindow; var cacher = new TransferStashServiceCache(_databaseItemDao); _parsingService.OnParseComplete += (o, args) => cacher.Refresh(); var stashWriter = new SafeTransferStashWriter(_settingsService); _transferStashService = new TransferStashService(_databaseItemStatDao, _settingsService, stashWriter); var transferStashService2 = new TransferStashService2(_playerItemDao, cacher, _transferStashService, stashWriter, _settingsService); _transferStashWorker = new TransferStashWorker(transferStashService2, _userFeedbackService); _stashFileMonitor.OnStashModified += (_, __) => { StashEventArg args = __ as StashEventArg; _transferStashWorker.Queue(args?.Filename); }; if (!_stashFileMonitor.StartMonitorStashfile(GlobalPaths.SavePath)) { MessageBox.Show("Ooops!\nIt seems you are synchronizing your saves to steam cloud..\nThis tool is unfortunately not compatible.\n"); HelpService.ShowHelp(HelpService.HelpType.CloudSavesEnabled); Logger.Warn("Shutting down IA, unable to monitor stash files."); if (!Debugger.IsAttached) { Close(); } } // Chicken and the egg.. SearchController searchController = new SearchController( _databaseItemDao, _playerItemDao, _databaseItemStatDao, _itemSkillDao, _buddyItemDao, _augmentationItemRepo, _settingsService ); searchController.JsBind.SetItemSetAssociations(_databaseItemDao.GetItemSetAssociations()); _cefBrowserHandler.InitializeChromium(searchController.JsBind, Browser_IsBrowserInitializedChanged); searchController.Browser = _cefBrowserHandler; searchController.JsBind.OnClipboard += SetItemsClipboard; // Load the grim database string gdPath = _grimDawnDetector.GetGrimLocation(); if (!string.IsNullOrEmpty(gdPath)) { } else { Logger.Warn("Could not find the Grim Dawn install location"); statusLabel.Text = "Could not find the Grim Dawn install location"; var timer = new System.Windows.Forms.Timer(); timer.Tick += TimerTickLookForGrimDawn; timer.Interval = 10000; timer.Start(); } // Load recipes foreach (string file in GlobalPaths.FormulasFiles) { if (!string.IsNullOrEmpty(file)) { bool isHardcore = file.EndsWith("gsh"); Logger.InfoFormat("Reading recipes at \"{0}\", IsHardcore={1}", file, isHardcore); _recipeParser.UpdateFormulas(file, isHardcore); } } var addAndShow = UIHelper.AddAndShow; // Create the tab contents _buddySettingsWindow = new BuddySettings(delegate(bool b) { BuddySyncEnabled = b; }, _buddyItemDao, _buddySubscriptionDao, _settingsService ); addAndShow(_buddySettingsWindow, buddyPanel); _authAuthService = new AzureAuthService(_cefBrowserHandler, new AuthenticationProvider(_settingsService)); var backupSettings = new BackupSettings(_playerItemDao, _authAuthService, _settingsService); addAndShow(backupSettings, backupPanel); addAndShow(new ModsDatabaseConfig(DatabaseLoadedTrigger, _playerItemDao, _parsingService, _databaseSettingDao, _grimDawnDetector, _settingsService), modsPanel); addAndShow(new HelpTab(), panelHelp); addAndShow(new LoggingWindow(), panelLogging); var backupService = new BackupService(_authAuthService, _playerItemDao, _azurePartitionDao, () => _settingsService.GetPersistent().UsingDualComputer); _backupServiceWorker = new BackupServiceWorker(backupService); backupService.OnUploadComplete += (o, args) => _searchWindow.UpdateListView(); searchController.OnSearch += (o, args) => backupService.OnSearch(); _searchWindow = new SplitSearchWindow(_cefBrowserHandler.BrowserControl, SetFeedback, _playerItemDao, searchController, _itemTagDao, _settingsService); addAndShow(_searchWindow, searchPanel); transferStashService2.OnUpdate += (_, __) => { _searchWindow.UpdateListView(); }; var languagePackPicker = new LanguagePackPicker(_itemTagDao, _playerItemDao, _parsingService, _settingsService); addAndShow( new SettingsWindow( _cefBrowserHandler, _tooltipHelper, ListviewUpdateTrigger, _playerItemDao, _searchWindow.ModSelectionHandler.GetAvailableModSelection(), _transferStashService, transferStashService2, languagePackPicker, _settingsService, _grimDawnDetector ), settingsPanel); #if !DEBUG ThreadPool.QueueUserWorkItem(m => ExceptionReporter.ReportUsage()); _automaticUpdateChecker.CheckForUpdates(); #endif Shown += (_, __) => { StartInjector(); }; //settingsController.Data.budd BuddySyncEnabled = _settingsService.GetPersistent().BuddySyncEnabled; // Start the backup task _backupBackgroundTask = new BackgroundTask(new FileBackup(_playerItemDao, _settingsService)); LocalizationLoader.ApplyLanguage(Controls, RuntimeSettings.Language); new EasterEgg(_settingsService).Activate(this); // Initialize the "stash packer" used to find item positions for transferring items ingame while the stash is open { _dynamicPacker.Initialize(8, 16); var transferFiles = GlobalPaths.TransferFiles; if (transferFiles.Count > 0) { var file = transferFiles.MaxBy(m => m.LastAccess); var stash = TransferStashService.GetStash(file.Filename); if (stash != null) { _dynamicPacker.Initialize(stash.Width, stash.Height); if (stash.Tabs.Count >= 3) { foreach (var item in stash.Tabs[2].Items) { byte[] bx = BitConverter.GetBytes(item.XOffset); uint x = (uint)BitConverter.ToSingle(bx, 0); byte[] by = BitConverter.GetBytes(item.YOffset); uint y = (uint)BitConverter.ToSingle(by, 0); _dynamicPacker.Insert(item.BaseRecord, item.Seed, x, y); } } } } } _messageProcessors.Add(new ItemPositionFinder(_dynamicPacker)); _messageProcessors.Add(new PlayerPositionTracker(Debugger.IsAttached && false)); _messageProcessors.Add(new StashStatusHandler()); _messageProcessors.Add(new ItemSpawnedProcessor()); _messageProcessors.Add(new CloudDetectorProcessor(SetFeedback)); _messageProcessors.Add(new GenericErrorHandler()); //messageProcessors.Add(new LogMessageProcessor()); #if DEBUG _messageProcessors.Add(new DebugMessageProcessor()); #endif RuntimeSettings.StashStatusChanged += GlobalSettings_StashStatusChanged; _transferController = new ItemTransferController( _cefBrowserHandler, SetFeedback, SetTooltipAtmouse, _settingsController, _searchWindow, _dynamicPacker, _playerItemDao, _transferStashService, new ItemStatService(_databaseItemStatDao, _itemSkillDao, _settingsService) ); Application.AddMessageFilter(new MousewheelMessageFilter()); var titleTag = RuntimeSettings.Language.GetTag("iatag_ui_itemassistant"); if (!string.IsNullOrEmpty(titleTag)) { this.Text += $" - {titleTag}"; } // Popup login diag if (_authAuthService.CheckAuthentication() == AzureAuthService.AccessStatus.Unauthorized && !_settingsService.GetLocal().OptOutOfBackups) { var t = new System.Windows.Forms.Timer { Interval = 100 }; t.Tick += (o, args) => { if (_cefBrowserHandler.BrowserControl.IsBrowserInitialized) { _authAuthService.Authenticate(); t.Stop(); } }; t.Start(); } _cefBrowserHandler.TransferSingleRequested += TransferSingleItem; _cefBrowserHandler.TransferAllRequested += TransferAllItems; new WindowSizeManager(this, _settingsService); // Suggest translation packs if available if (!string.IsNullOrEmpty(_settingsService.GetLocal().LocalizationFile) && !_settingsService.GetLocal().HasSuggestedLanguageChange) { if (LocalizationLoader.HasSupportedTranslations(_grimDawnDetector.GetGrimLocations())) { Logger.Debug("A new language pack has been detected, informing end user.."); new LanguagePackPicker(_itemTagDao, _playerItemDao, _parsingService, _settingsService).Show(_grimDawnDetector.GetGrimLocations()); _settingsService.GetLocal().HasSuggestedLanguageChange = true; } } Logger.Debug("UI initialization complete"); }