コード例 #1
0
        private void StashTabPicker_Load(object sender, EventArgs e)
        {
            switch (Properties.Settings.Default.StashToDepositTo)
            {
            case 0:
                radioOutputSecondToLast.Checked = true;
                break;

            case 1:
                radioOutput1.Checked = true;
                break;

            case 2:
                radioOutput2.Checked = true;
                break;

            case 3:
                radioOutput3.Checked = true;
                break;

            case 4:
                radioOutput4.Checked = true;
                break;

            case 5:
                radioOutput5.Checked = true;
                break;
            }
            switch (Properties.Settings.Default.StashToLootFrom)
            {
            case 0:
                radioInputLast.Checked = true;
                break;

            case 1:
                radioInput1.Checked = true;
                break;

            case 2:
                radioInput2.Checked = true;
                break;

            case 3:
                radioInput3.Checked = true;
                break;

            case 4:
                radioInput4.Checked = true;
                break;

            case 5:
                radioInput5.Checked = true;
                break;
            }

            LocalizationLoader.ApplyLanguage(Controls, GlobalSettings.Language);
        }
コード例 #2
0
ファイル: ExportMode.cs プロジェクト: haapanen/iagd
 private void ExportMode_Load(object sender, EventArgs e)
 {
     cbItemSelection.Items.Add("All items");
     cbItemSelection.Items.AddRange(_modSelection);
     cbItemSelection.SelectedIndex = 0;
     buttonExport.Enabled          = false;
     cbItemSelection.Visible       = false;
     LocalizationLoader.ApplyLanguage(Controls, GlobalSettings.Language);
 }
コード例 #3
0
ファイル: StashTabPicker.cs プロジェクト: marius00/iagd
        private void StashTabPicker_Load(object sender, EventArgs e)
        {
            // Calculate the height dynamically depending on how many stashes the user has
            Height            = Math.Min(800, Math.Max(357, 202 + 31 * _numStashTabs));
            gbMoveTo.Height   = Math.Max(248, 83 + 33 * _numStashTabs);
            gbLootFrom.Height = Math.Max(248, 83 + 33 * _numStashTabs);


            for (int i = 1; i <= Math.Max(5, _numStashTabs); i++)
            {
                int p = i; // Don't reference out scope (mutated)
                FirefoxRadioButton.CheckedChangedEventHandler callback = (o, args) => {
                    if (p <= _numStashTabs)
                    {
                        // Don't trust the "Firefox framework" to not trigger clicks on disabled buttons.
                        _settings.GetLocal().StashToDepositTo = p;
                    }
                };

                int y  = 32 + 33 * i;
                var cb = CreateCheckbox($"moveto_tab_{i}", $"iatag_ui_tab_{i}", $"Tab {i}", new Point(6, y), callback);

                cb.Checked     = _settings.GetLocal().StashToDepositTo == i;
                cb.Enabled     = i <= _numStashTabs;
                cb.EnabledCalc = i <= _numStashTabs;
                this.gbMoveTo.Controls.Add(cb);
                helpWhyAreTheseDisabled.Visible = _numStashTabs <= 4;
            }


            for (int i = 1; i <= Math.Max(5, _numStashTabs); i++)
            {
                int p = i; // Don't reference out scope (mutated)
                FirefoxRadioButton.CheckedChangedEventHandler callback = (o, args) => {
                    if (p <= _numStashTabs)
                    {
                        // Don't trust the "Firefox framework" to not trigger clicks on disabled buttons.
                        _settings.GetLocal().StashToLootFrom = p;
                    }
                };

                int y  = 32 + 33 * i;
                var cb = CreateCheckbox($"lootfrom_tab_{i}", $"iatag_ui_tab_{i}", $"Tab {i}", new Point(6, y), callback);
                cb.Checked     = _settings.GetLocal().StashToLootFrom == i;
                cb.Enabled     = i <= _numStashTabs;
                cb.EnabledCalc = i <= _numStashTabs;
                this.gbLootFrom.Controls.Add(cb);
            }



            radioOutputSecondToLast.Checked = _settings.GetLocal().StashToDepositTo == 0;
            radioInputLast.Checked          = _settings.GetLocal().StashToLootFrom == 0;

            LocalizationLoader.ApplyLanguage(Controls, RuntimeSettings.Language);
        }
コード例 #4
0
        private void ImportMode_Load(object sender, EventArgs e)
        {
            this.Dock = DockStyle.Fill;
            this.buttonImport.Enabled = false;
            cbItemSelection.Visible   = false;
            cbItemSelection.Enabled   = false;

            cbItemSelection.Items.AddRange(_modSelection);
            LocalizationLoader.ApplyLanguage(Controls, RuntimeSettings.Language);
        }
コード例 #5
0
 /// <summary>
 /// Update the UI's language
 /// </summary>
 public void UpdateLanguage()
 {
     LocalizationLoader.ApplyLanguage(Controls, GlobalSettings.Language);
     Text = GlobalSettings.Language.GetTag(Tag.ToString());
     if (tsStashStatus.Tag is string)
     {
         tsStashStatus.Text = GlobalSettings.Language.GetTag(tsStashStatus.Tag.ToString());
     }
     Refresh();
 }
コード例 #6
0
        private void LanguagePackPicker_Load(object sender, EventArgs e)
        {
            LocalizationLoader.ApplyLanguage(Controls, RuntimeSettings.Language);
            var loc = new LocalizationLoader();

            var n = 0;

            // Default language: English
            {
                var cb = new FirefoxRadioButton
                {
                    Location = new Point(10, 25 + n * 33),
                    Text     = "English (Official)",
                    Tag      = string.Empty,
                    Checked  = string.IsNullOrEmpty(_settings.GetLocal().LocalizationFile),
                    TabIndex = n,
                    TabStop  = true
                };

                groupBox1.Controls.Add(cb);
                _checkboxes.Add(cb);
                n++;
            }

            foreach (var path in _paths)
            {
                if (Directory.Exists(Path.Combine(path, "localization")))
                {
                    foreach (var file in Directory.EnumerateFiles(Path.Combine(path, "localization"), "*.zip"))
                    {
                        loc.CheckLanguage(file, out var author, out var language);

                        var cb = new FirefoxRadioButton
                        {
                            Location = new Point(10, 25 + n * 33),
                            Text     = RuntimeSettings.Language.GetTag("iatag_ui_language_by_author", language, author),
                            Anchor   = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top,
                            Width    = groupBox1.Width - pictureBox1.Width,
                            Tag      = file,
                            Checked  = file == _settings.GetLocal().LocalizationFile,
                            TabIndex = n,
                            TabStop  = true
                        };

                        groupBox1.Controls.Add(cb);
                        _checkboxes.Add(cb);
                        n++;
                    }
                }
            }

            Height += n * 33;
        }
コード例 #7
0
ファイル: LanguagePackPicker.cs プロジェクト: haapanen/iagd
        public LanguagePackPicker(
            IItemTagDao itemTagDao,
            IPlayerItemDao playerItemDao,
            IEnumerable <string> paths,
            ParsingService parsingService
            )
        {
            InitializeComponent();

            _paths          = paths;
            _parsingService = parsingService;
            _itemTagDao     = itemTagDao;
            _playerItemDao  = playerItemDao;

            LocalizationLoader.ApplyLanguage(Controls, GlobalSettings.Language);
        }
コード例 #8
0
        private void OnlineBackupLogin_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Properties.Settings.Default.BackupLogin))
            {
                SetState(LoginState.WAITING_FOR_CONFIRM);
                StartWaitForVerifyBackgroundWorker();
            }
            else
            {
                SetState(LoginState.NEED_TO_LOGIN);
            }

            tbEmail.KeyDown += TbEmail_KeyDown;

            LocalizationLoader.ApplyLanguage(Controls, GlobalSettings.Language);
        }
コード例 #9
0
ファイル: DonateNagScreen.cs プロジェクト: gvdexile9/iagd
        private void DonateNagScreen_Load(object sender, EventArgs e)
        {
            if (CanNag)
            {
                _aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);

                _aTimer.Interval = 50;
                _aTimer.Enabled  = true;

                DateTime dt = DateTime.Now.AddDays(28 + new Random().Next(0, 5));
                _settings.GetLocal().LastNagTimestamp = dt.Ticks;

                LocalizationLoader.ApplyLanguage(Controls, RuntimeSettings.Language);
            }
            else
            {
                _nagDelay = -1;
                this.Close();
            }
        }
コード例 #10
0
        private void DonateNagScreen_Load(object sender, EventArgs e)
        {
            if (CanNag)
            {
                _aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);

                _aTimer.Interval = 50;
                _aTimer.Enabled  = true;

                DateTime dt = DateTime.Now.AddDays(28 + new Random().Next(0, 5));
                _settings.GetLocal().LastNagTimestamp = dt.Ticks;

                var tags = new [] { "iatag_ui_nagscreen1_button", "iatag_ui_nagscreen2_button", "iatag_ui_nagscreen3_button", "iatag_ui_nagscreen4_button", "iatag_ui_nagscreen5_button" };
                buttonNoThanks.Tag = tags[new Random().Next(tags.Length)];
                LocalizationLoader.ApplyLanguage(Controls, RuntimeSettings.Language);
            }
            else
            {
                _nagDelay = -1;
                this.Close();
            }
        }
コード例 #11
0
        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);
        }
コード例 #12
0
//private void CheckForUpdates()
//{
//    if (GetTickCount64() > 5 * 60 * 1000 && (DateTime.Now - _lastAutomaticUpdateCheck).TotalHours > 36)
//    {
//        AutoUpdater.LetUserSelectRemindLater = true;
//        AutoUpdater.RemindLaterTimeSpan = RemindLaterFormat.Days;
//        AutoUpdater.RemindLaterAt = 7;
//        AutoUpdater.Start(UPDATE_XML);

//        _lastAutomaticUpdateCheck = DateTime.Now;
//        Logger.Info("Checking for updates..");
//    }
//}

//private void TimerTickLookForGrimDawn(object sender, EventArgs e)
//{
//    System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer;
//    if (Thread.CurrentThread.Name == null)
//        Thread.CurrentThread.Name = "DetectGrimDawnTimer";

//    string gdPath = GrimDawnDetector.GetGrimLocation();
//    if (!string.IsNullOrEmpty(gdPath) && Directory.Exists(gdPath))
//    {
//        timer?.Stop();

//        // Attempt to force a database update
//        foreach (Control c in modsPanel.Controls)
//        {
//            ModsDatabaseConfig config = c as ModsDatabaseConfig;
//            if (config != null)
//            {
//                config.ForceDatabaseUpdate(gdPath, true);
//                break;
//            }
//        }

//        Logger.InfoFormat("Found Grim Dawn at {0}", gdPath);
//    }
//}

/// <summary>
/// We've looted some items, so make sure the listview is up to date!
/// Otherwise people freak out.
///
/// The first ~1700 users did not notice at all, but past that seems its the end of days if items don't appear immediately.
/// </summary>
///
//private void ListviewUpdateTrigger() {
//            _searchWindow?.UpdateListviewDelayed();
//        }

//        private void DatabaseLoadedTrigger() {
//            _searchWindow.UpdateInterface();
//            _searchWindow?.UpdateListviewDelayed();
//        }



        private void MainWindow_Load(object sender, EventArgs e)
        {
            if (Thread.CurrentThread.Name == null)
            {
                Thread.CurrentThread.Name = "UI";
            }


            //ExceptionReporter.EnableLogUnhandledOnThread();
            SizeChanged += OnMinimizeWindow;

            buttonDevTools.Visible = Debugger.IsAttached;


            //_stashManager = new StashManager(_playerItemDao, _databaseItemStatDao);
            //if (!_stashManager.StartMonitorStashfile(SetFeedback, ListviewUpdateTrigger)) {
            //    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();

            //}

            //ItemHtmlWriter.Write(new List<PlayerHeldItem>());

            // Chicken and the egg..
            SearchController searchController = new SearchController(
                _databaseItemDao,
                _playerItemDao,
                _databaseItemStatDao,
                _itemSkillDao,
                _buddyItemDao
                //_stashManager
                );

            _cefBrowserHandler.InitializeChromium(searchController.JsBind, Browser_IsBrowserInitializedChanged);
            searchController.Browser = _cefBrowserHandler;
            //searchController.JsBind.OnTransfer += TransferItem;
            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);

            //var backupSettings = new BackupSettings(EnableOnlineBackups, _playerItemDao);
            //tabControl1.Selected += ((s, ev) => {
            //    if (ev.TabPage == tabPageBackups)
            //        backupSettings?.BackupSettings_GotFocus();
            //});
            //addAndShow(backupSettings, backupPanel);
            //addAndShow(new ModsDatabaseConfig(DatabaseLoadedTrigger, _databaseSettingDao, _arzParser, _playerItemDao), modsPanel);
            addAndShow(new HelpTab(), panelHelp);
            addAndShow(new LoggingWindow(), panelLogging);


            _searchWindow = new SearchWindow(_cefBrowserHandler.BrowserControl, SetFeedback, _playerItemDao, searchController, _databaseItemDao);
            addAndShow(_searchWindow, searchPanel);


            //addAndShow(
            //    new SettingsWindow(_tooltipHelper,
            //        ListviewUpdateTrigger,
            //        _databaseSettingDao,
            //        _databaseItemDao,
            //        _playerItemDao,
            //        _arzParser,
            //        _searchWindow.ModSelectionHandler.GetAvailableModSelection()
            //        _stashManager
            //    ),
            //    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 CloudBackup(_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, _stashManager, _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 b = !string.IsNullOrEmpty(Settings.Default.OnlineBackupToken) && Settings.Default.OnlineBackupVerified;
            //    EnableOnlineBackups(b);
            //}



            if (BackupNagScreen.ShouldNag)
            {
                var b = new BackupNagScreen();
                b.ShowDialog();
                if (b.UserWantsBackups)
                {
                    tabControl1.SelectedTab = tabPageBackups;
                }
            }

            var titleTag = GlobalSettings.Language.GetTag("iatag_ui_itemassistant");
            if (!string.IsNullOrEmpty(titleTag))
            {
                this.Text += $" - {titleTag}";
            }
        }
コード例 #13
0
        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");
        }
コード例 #14
0
        private void MainWindow_Load(object sender, EventArgs e) {
            if (Thread.CurrentThread.Name == null)
                Thread.CurrentThread.Name = "UI";


            ExceptionReporter.EnableLogUnhandledOnThread();
            SizeChanged += OnMinimizeWindow;

            buttonDevTools.Visible = Debugger.IsAttached;


            _stashManager = new StashManager(_playerItemDao, _databaseItemStatDao);
            if (!_stashManager.StartMonitorStashfile(SetFeedback, ListviewUpdateTrigger)) {
                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();

            }

            //ItemHtmlWriter.Write(new List<PlayerHeldItem>());

            // Chicken and the egg..
            SearchController searchController = new SearchController(
                _databaseItemDao,
                _playerItemDao, 
                _databaseItemStatDao, 
                _itemSkillDao, 
                _buddyItemDao,
                _stashManager
                );
            _cefBrowserHandler.InitializeChromium(searchController.JsBind, Browser_IsBrowserInitializedChanged);
            searchController.Browser = _cefBrowserHandler;
            searchController.JsBind.OnTransfer += TransferItem;
            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();
            }

    

            var addAndShow = UIHelper.AddAndShow;


            // Create the tab contents
            _buddySettingsWindow = new BuddySettings(delegate (bool b) { BuddySyncEnabled = b; }, 
                _buddyItemDao, 
                _buddySubscriptionDao
                );

            addAndShow(_buddySettingsWindow, buddyPanel);

            var backupSettings = new BackupSettings(EnableOnlineBackups, _playerItemDao);
            tabControl1.Selected += ((s, ev) => {
                if (ev.TabPage == tabPageBackups)
                    backupSettings?.BackupSettings_GotFocus();
            });
            addAndShow(backupSettings, backupPanel);
            addAndShow(new ModsDatabaseConfig(DatabaseLoadedTrigger, _databaseSettingDao, _arzParser, _playerItemDao), modsPanel);
            addAndShow(new HelpTab(), panelHelp);            
            addAndShow(new LoggingWindow(), panelLogging);


            _searchWindow = new SearchWindow(_cefBrowserHandler.BrowserControl, SetFeedback, _playerItemDao, searchController, _databaseItemDao);
            addAndShow(_searchWindow, searchPanel);


            addAndShow(
                new SettingsWindow(_tooltipHelper,
                    ListviewUpdateTrigger,
                    _databaseSettingDao,
                    _databaseItemDao,
                    _playerItemDao,
                    _arzParser,
                    _searchWindow.ModSelectionHandler.GetAvailableModSelection(),
                    _stashManager
                ),
                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 CloudBackup(_playerItemDao));



            LocalizationLoader.ApplyLanguage(Controls, GlobalSettings.Language);
            EasterEgg.Activate(this);
コード例 #15
0
 private void ImportExportModePicker_Load(object sender, EventArgs e)
 {
     this.Dock = DockStyle.Fill;
     LocalizationLoader.ApplyLanguage(Controls, RuntimeSettings.Language);
 }
コード例 #16
0
 private void UpdatingPlayerItemsScreen_Load(object sender, EventArgs e)
 {
     this.FormClosing += ParsingDatabaseScreen_FormClosing;
     LocalizationLoader.ApplyLanguage(Controls, RuntimeSettings.Language);
 }
コード例 #17
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            if (Thread.CurrentThread.Name == null)
            {
                Thread.CurrentThread.Name = "UI";
            }

            Logger.Debug("Starting UI initialization");


            // Set version number
            var      version   = Assembly.GetExecutingAssembly().GetName().Version;
            DateTime buildDate = new DateTime(2000, 1, 1)
                                 .AddDays(version.Build)
                                 .AddSeconds(version.Revision * 2);

            statusLabel.Text = statusLabel.Text + $" - {version.Major}.{version.Minor}.{version.Build}.{version.Revision} from {buildDate.ToString("dd/MM/yyyy")}";


            var settingsService = _serviceProvider.Get <SettingsService>();

            ExceptionReporter.EnableLogUnhandledOnThread();
            SizeChanged += OnMinimizeWindow;


            // Chicken and the egg.. search controller needs browser, browser needs search controllers var.
            var databaseItemDao  = _serviceProvider.Get <IDatabaseItemDao>();
            var searchController = _serviceProvider.Get <SearchController>();

            searchController.JsIntegration.OnRequestSetItemAssociations += (s, evvv) => { (evvv as GetSetItemAssociationsEventArgs).Elements = databaseItemDao.GetItemSetAssociations(); };

            _cefBrowserHandler.InitializeChromium(searchController.JsIntegration, Browser_IsBrowserInitializedChanged, tabControl1);
            searchController.Browser = _cefBrowserHandler;
            searchController.JsIntegration.OnClipboard += SetItemsClipboard;
            searchController.JsIntegration.OnRequestFeatureRecommendation += (o, args) => {
                var features = settingsService.GetPersistent().FeaturesNotShown;
                (args as FeatureSuggestionArgs).Feature    = features.FirstOrDefault();
                (args as FeatureSuggestionArgs).HasFeature = features.Count > 0;
            };
            searchController.JsIntegration.OnSeenFeatureRecommendation += (o, args) => settingsService.GetPersistent().AddShownFeature((args as FeatureSuggestionArgs).Feature);

            var playerItemDao = _serviceProvider.Get <IPlayerItemDao>();
            var cacher        = _serviceProvider.Get <TransferStashServiceCache>();

            _parsingService.OnParseComplete += (o, args) => cacher.Refresh();


            var stashWriter           = new SafeTransferStashWriter(settingsService, _cefBrowserHandler);
            var transferStashService  = new TransferStashService(_serviceProvider.Get <IDatabaseItemStatDao>(), settingsService, stashWriter);
            var transferStashService2 = new TransferStashService2(playerItemDao, cacher, transferStashService, stashWriter, settingsService, _cefBrowserHandler);

            _serviceProvider.Add(transferStashService2);

            _transferStashWorker = new TransferStashWorker(transferStashService2, _userFeedbackService);

            _stashFileMonitor.OnStashModified += (_, __) => {
                StashEventArg args = __ as StashEventArg;
                _transferStashWorker.Queue(args?.Filename);

                // May not minimize, but
                _usageStatisticsReporter.ResetLastMinimized();
                _automaticUpdateChecker.ResetLastMinimized();
            };

            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");
                _cefBrowserHandler.ShowHelp(HelpService.HelpType.CloudSavesEnabled);

                Logger.Warn("Shutting down IA, unable to monitor stash files.");

                if (!Debugger.IsAttached)
                {
                    Close();
                }
            }

            // Load the grim database
            var    grimDawnDetector = _serviceProvider.Get <GrimDawnDetector>();
            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 buddyItemDao         = _serviceProvider.Get <IBuddyItemDao>();
            var buddySubscriptionDao = _serviceProvider.Get <IBuddySubscriptionDao>();



            var databaseSettingDao = _serviceProvider.Get <IDatabaseSettingDao>();

            _authService = new AuthService(_cefBrowserHandler, new AuthenticationProvider(settingsService), playerItemDao);
            var backupSettings = new BackupSettings(playerItemDao, settingsService, _cefBrowserHandler);

            UIHelper.AddAndShow(backupSettings, backupPanel);

            // TODO: buttonLogin.Visible = !BlockedLogsDetection.DreamcrashBlocked();
            var onlineSettings = new OnlineSettings(playerItemDao, _authService, settingsService, _cefBrowserHandler, buddyItemDao, buddySubscriptionDao);

            UIHelper.AddAndShow(onlineSettings, onlinePanel);
            _cefBrowserHandler.OnAuthSuccess += (_, __) => onlineSettings.UpdateUi();


            UIHelper.AddAndShow(new ModsDatabaseConfig(DatabaseLoadedTrigger, playerItemDao, _parsingService, databaseSettingDao, grimDawnDetector, settingsService, _cefBrowserHandler), modsPanel);

            if (!BlockedLogsDetection.DreamcrashBlocked())
            {
                UIHelper.AddAndShow(new LoggingWindow(), panelLogging);
            }

            var itemTagDao    = _serviceProvider.Get <IItemTagDao>();
            var backupService = new BackupService(_authService, playerItemDao, settingsService);

            _charBackupService   = new CharacterBackupService(settingsService, _authService);
            _backupServiceWorker = new BackupServiceWorker(backupService, _charBackupService);
            searchController.JsIntegration.OnRequestBackedUpCharacterList += (_, args) => {
                RequestCharacterListEventArg a = args as RequestCharacterListEventArg;
                a.Characters = _charBackupService.ListBackedUpCharacters();
            };
            searchController.JsIntegration.OnRequestCharacterDownloadUrl += (_, args) => {
                RequestCharacterDownloadUrlEventArg a = args as RequestCharacterDownloadUrlEventArg;
                a.Url = _charBackupService.GetDownloadUrl(a.Character);
            };

            backupService.OnUploadComplete += (o, args) => _searchWindow.UpdateListView();
            searchController.OnSearch      += (o, args) => backupService.OnSearch();

            _searchWindow = new SplitSearchWindow(_cefBrowserHandler.BrowserControl, SetFeedback, playerItemDao, searchController, itemTagDao, settingsService);
            UIHelper.AddAndShow(_searchWindow, searchPanel);

            searchPanel.Height = searchPanel.Parent.Height;
            searchPanel.Width  = searchPanel.Parent.Width;

            transferStashService2.OnUpdate += (_, __) => { _searchWindow.UpdateListView(); };

            var languagePackPicker = new LanguagePackPicker(itemTagDao, playerItemDao, _parsingService, settingsService);


            var dm = new DarkMode(this);

            UIHelper.AddAndShow(
                new SettingsWindow(
                    _cefBrowserHandler,
                    _tooltipHelper,
                    ListviewUpdateTrigger,
                    playerItemDao,
                    _searchWindow.ModSelectionHandler.GetAvailableModSelection(),
                    transferStashService,
                    transferStashService2,
                    languagePackPicker,
                    settingsService,
                    grimDawnDetector,
                    dm
                    ),
                settingsPanel);

#if !DEBUG
            if (!BlockedLogsDetection.DreamcrashBlocked())   // Uses dreamcrash server
            {
                ThreadPool.QueueUserWorkItem(m => ExceptionReporter.ReportUsage());
                _automaticUpdateChecker.CheckForUpdates();
            }
#endif

            Shown += (_, __) => { StartInjector(); };
            _buddyItemsService = new BuddyItemsService(
                buddyItemDao,
                3 * 60 * 1000,
                settingsService,
                _authService,
                buddySubscriptionDao
                );

            // 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 CloudDetectorProcessor(SetFeedback));
            _messageProcessors.Add(new GenericErrorHandler());


            RuntimeSettings.StashStatusChanged += GlobalSettings_StashStatusChanged;

            _transferController = new ItemTransferController(
                _cefBrowserHandler,
                SetFeedback,
                SetTooltipAtmouse,
                _searchWindow,
                playerItemDao,
                transferStashService,
                _serviceProvider.Get <ItemStatService>(),
                settingsService
                );
            Application.AddMessageFilter(new MousewheelMessageFilter());


            var titleTag = RuntimeSettings.Language.GetTag("iatag_ui_itemassistant");
            if (!string.IsNullOrEmpty(titleTag))
            {
                this.Text += $" - {titleTag}";
            }


            // Popup login diag
            if (_authService.CheckAuthentication() == AuthService.AccessStatus.Unauthorized && !settingsService.GetLocal().OptOutOfBackups)
            {
                if (!BlockedLogsDetection.DreamcrashBlocked())
                {
                    // Backup login wont work
                    var t = new System.Windows.Forms.Timer {
                        Interval = 100
                    };
                    t.Tick += (o, args) => {
                        if (_cefBrowserHandler.BrowserControl.CanExecuteJavascriptInMainFrame)
                        {
                            _authService.Authenticate();
                            t.Stop();
                        }
                    };
                    t.Start();
                }
            }


            searchController.JsIntegration.ItemTransferEvent += TransferItem;
            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;
                }
            }


            if (settingsService.GetPersistent().DarkMode)
            {
                dm.Activate(); // Needs a lot more work before its ready, for example custom components uses Draw and does not respect coloring.
                _cefBrowserHandler.SetDarkMode(settingsService.GetPersistent().DarkMode);
            }

            Logger.Debug("UI initialization complete");
        }
コード例 #18
0
 private void BackupNagScreen_Load(object sender, EventArgs e)
 {
     LocalizationLoader.ApplyLanguage(Controls, GlobalSettings.Language);
 }
コード例 #19
0
ファイル: LanguagePackPicker.cs プロジェクト: marius00/iagd
        private void LanguagePackPicker_Load(object sender, EventArgs e)
        {
            LocalizationLoader.ApplyLanguage(Controls, RuntimeSettings.Language);
            var loc = new LocalizationLoader();

            var n = 0;

            // Default language: English
            {
                var cb = new FirefoxRadioButton {
                    Location = new Point(10, 25 + n * 33),
                    Text     = "English (Official)",
                    Tag      = string.Empty,
                    Checked  = string.IsNullOrEmpty(_settings.GetLocal().LocalizationFile),
                    TabIndex = n,
                    TabStop  = true
                };

                groupBox1.Controls.Add(cb);
                _checkboxes.Add(cb);
                n++;
            }

            foreach (var path in _paths)
            {
                if (Directory.Exists(Path.Combine(path, "localization")))
                {
                    foreach (var file in Directory.EnumerateFiles(Path.Combine(path, "localization"), "*.zip"))
                    {
                        loc.CheckLanguage(file, out var author, out var language);

                        var isFullyTranslatedTag = LocalizationLoader.IsFullySupportedTranslation(file) ? "" : "[Partial] ";
                        var cb = new FirefoxRadioButton {
                            Location = new Point(10, 25 + n * 33),
                            Text     = isFullyTranslatedTag + RuntimeSettings.Language.GetTag("iatag_ui_language_by_author", language, author),
                            Anchor   = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top,
                            Width    = groupBox1.Width - pictureBox1.Width,
                            Tag      = file,
                            Checked  = file == _settings.GetLocal().LocalizationFile,
                            TabIndex = n,
                            TabStop  = true
                        };

                        groupBox1.Controls.Add(cb);
                        _checkboxes.Add(cb);
                        n++;
                    }
                }
            }


            var delta = Math.Min(Math.Max(0, n - 5), 15) * 33; // We already have space for 5, only expand if we exceed this.

            if (delta > 0)
            {
                var newHeight = Height + delta;
                MaximumSize         = new Size(MaximumSize.Width, newHeight);
                MinimumSize         = new Size(MinimumSize.Width, newHeight);
                Height              = newHeight;
                lblWarning.Location = new Point(lblWarning.Location.X, lblWarning.Location.Y + delta);
            }
        }
コード例 #20
0
 private void ParsingDatabaseProgressView_Load(object sender, EventArgs e)
 {
     LocalizationLoader.ApplyLanguage(Controls, GlobalSettings.Language);
 }