Ejemplo n.º 1
0
        /// <summary>
        /// Perform a search the moment were initialized
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Browser_IsBrowserInitializedChanged(object sender, EventArgs e)
        {
            var args = e as FrameLoadEndEventArgs;
            ChromiumWebBrowser browser = sender as ChromiumWebBrowser;

            if (args != null && args.Frame.IsMain)
            {
                // https://github.com/cefsharp/CefSharp/issues/3021
                if (browser?.CanExecuteJavascriptInMainFrame ?? true)
                {
                    if (InvokeRequired)
                    {
                        Invoke((MethodInvoker) delegate { Browser_IsBrowserInitializedChanged(sender, e); });
                    }
                    else
                    {
                        _searchWindow?.UpdateListViewDelayed();

                        var isGdParsed      = _serviceProvider.Get <IDatabaseItemDao>().GetRowCount() > 0;
                        var settingsService = _serviceProvider.Get <SettingsService>();
                        _cefBrowserHandler.SetDarkMode(settingsService.GetPersistent().DarkMode);
                        _cefBrowserHandler.SetHideItemSkills(settingsService.GetPersistent().HideSkills);
                        _cefBrowserHandler.SetIsGrimParsed(isGdParsed);


                        _cefBrowserHandler.SetOnlineBackupsEnabled(!settingsService.GetLocal().OptOutOfBackups);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void Process(MessageType type, byte[] data)
        {
            switch (type)
            {
            // This is generally called when adding an item by clicking on the stash tab
            case MessageType.TYPE_InventorySack_AddItem:
            {
                int pos   = 2;
                var items = GetPlayerItemFromInventorySack(data, pos);
                _playerItemDao.Save(items);
                Logger.InfoFormat("A gnome has delivered {0} new items to IA.", items.Count);
                _searchWindow?.UpdateListViewDelayed();
                _stashFileMonitor.CancelQueuedNotify();
                //logger.Debug("TYPE_InventorySack_AddItem ignored");
            }
            break;

            // This is generally called when adding an item to a specific position in the bag
            case MessageType.TYPE_InventorySack_AddItem_Vec2:
            {
                int   pos = 0;
                float x   = IOHelper.GetFloat(data, 0); pos += 4;
                float y   = IOHelper.GetFloat(data, 4); pos += 4;
                bool  b   = data[pos] > 0; pos++;

                var items = GetPlayerItemFromInventorySack(data, pos);
                _playerItemDao.Save(items);
                Logger.InfoFormat("A helpful goblin has delivered {0} new items to IA.", items.Count);
                _searchWindow?.UpdateListViewDelayed();
                _stashFileMonitor.CancelQueuedNotify();
            }
            break;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Perform a search the moment were initialized
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Browser_IsBrowserInitializedChanged(object sender, IsBrowserInitializedChangedEventArgs e)
 {
     if (e.IsBrowserInitialized)
     {
         if (InvokeRequired)
         {
             Invoke((MethodInvoker) delegate { _searchWindow?.UpdateListViewDelayed(); });
         }
         else
         {
             _searchWindow?.UpdateListViewDelayed();
         }
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Perform a search the moment were initialized
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Browser_IsBrowserInitializedChanged(object sender, EventArgs e)
        {
            ChromiumWebBrowser browser = sender as ChromiumWebBrowser;

            if (browser?.CanExecuteJavascriptInMainFrame ?? true)
            {
                if (InvokeRequired)
                {
                    Invoke((MethodInvoker) delegate { _searchWindow?.UpdateListViewDelayed(); });
                }
                else
                {
                    _searchWindow?.UpdateListViewDelayed();
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Perform a search the moment were initialized
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Browser_IsBrowserInitializedChanged(object sender, EventArgs e)
        {
            var args = e as FrameLoadEndEventArgs;
            ChromiumWebBrowser browser = sender as ChromiumWebBrowser;

            if (args != null && args.Frame.IsMain)
            {
                // https://github.com/cefsharp/CefSharp/issues/3021
                if (browser?.CanExecuteJavascriptInMainFrame ?? true)
                {
                    if (InvokeRequired)
                    {
                        Invoke((MethodInvoker) delegate { Browser_IsBrowserInitializedChanged(sender, e); });
                    }
                    else
                    {
                        _searchWindow?.UpdateListViewDelayed();

                        var settingsService = _serviceProvider.Get <SettingsService>();
                        _cefBrowserHandler.SetDarkMode(settingsService.GetPersistent().DarkMode);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Transfer item request from sub control
        /// MUST BE CALLED ON SQL THREAD
        /// </summary>
        public void TransferItem(object ignored, EventArgs _args)
        {
            StashTransferEventArgs args = _args as StashTransferEventArgs;

            _logger.Debug($"Item transfer requested, arguments: {args}");

            if (CanTransfer())
            {
                List <PlayerItem> items = GetItemsForTransfer(args);

                if (items?.Count > 0)
                {
                    string file = GetTransferFile();
                    if (string.IsNullOrEmpty(file))
                    {
                        _logger.Warn("Could not find transfer file, transfer aborted.");
                        return;
                    }

                    _logger.Debug($"Found {items.Count} items to transfer");
                    var result = TransferItems(file, items, (int)args.Count);

                    _logger.InfoFormat("Successfully deposited {0} out of {1} items", result.NumItemsTransferred,
                                       result.NumItemsRequested);
                    try
                    {
                        var message = string.Format(GlobalSettings.Language.GetTag("iatag_stash3_success"),
                                                    result.NumItemsTransferred, result.NumItemsRequested);
                        _browser.ShowMessage(message, UserFeedbackLevel.Success);
                    }
                    catch (FormatException ex)
                    {
                        _logger.Warn(ex.Message);
                        _logger.Warn(ex.StackTrace);
                        _logger.Warn("Language pack error, iatag_stash3_success is of invalid format.");
                    }
                    if (result.NumItemsTransferred == 0)
                    {
                        _setTooltip(GlobalSettings.Language.GetTag("iatag_stash3_failure"));
                        _browser.ShowMessage(GlobalSettings.Language.GetTag("iatag_stash3_failure"), UserFeedbackLevel.Warning);
                    }

                    // Lets do this last, to make sure feedback reaches the user as fast as possible
                    _searchWindow.UpdateListView();
                }
                else
                {
                    _logger.Warn("Could not find any items for the requested transfer");
                }
            }
            else if (GlobalSettings.StashStatus == StashAvailability.OPEN)
            {
                // "InstaTransfer" is an experimental feature
                if (Properties.Settings.Default.InstaTransfer)
                { // disabled for now
                    List <PlayerItem> items = GetItemsForTransfer(args);
                    int numDepositedItems   = 0;
                    int numItemsToTransfer  = items?.Count ?? 0;

                    if (items == null)
                    {
                        _logger.Info("Item previously deposited (ghost item)");
                        _browser.ShowMessage("Item previously deposited (ghost item)", UserFeedbackLevel.Warning);
                        _searchWindow.UpdateListViewDelayed();
                    }
                    else
                    {
                        foreach (var item in items)
                        {
                            if (TransferToOpenStash(item))
                            {
                                _dao.Remove(item);
                                numDepositedItems++;
                            }
                        }

                        var message = string.Format(GlobalSettings.Language.GetTag("iatag_stash3_success"), numDepositedItems, numItemsToTransfer);
                        _setFeedback(message);
                        _browser.ShowMessage(message, UserFeedbackLevel.Success);

                        _logger.InfoFormat("Successfully deposited {0} out of {1} items", numDepositedItems, numItemsToTransfer);
                        if (numDepositedItems > 0)
                        {
                            _searchWindow.UpdateListViewDelayed();
                        }
                    }
                }
                else
                {
                    var message = GlobalSettings.Language.GetTag("iatag_deposit_stash_open");
                    _setFeedback(message);
                    _setTooltip(message);
                    _browser.ShowMessage(message, UserFeedbackLevel.Warning);
                }
            }
            else if (GlobalSettings.StashStatus == StashAvailability.SORTED)
            {
                _setFeedback(GlobalSettings.Language.GetTag("iatag_deposit_stash_sorted"));
                _browser.ShowMessage(GlobalSettings.Language.GetTag("iatag_deposit_stash_sorted"), UserFeedbackLevel.Warning);
            }

            else if (GlobalSettings.StashStatus == StashAvailability.UNKNOWN)
            {
                _setFeedback(GlobalSettings.Language.GetTag("iatag_deposit_stash_unknown_feedback"));
                _setTooltip(GlobalSettings.Language.GetTag("iatag_deposit_stash_unknown_tooltip"));
                _browser.ShowMessage(GlobalSettings.Language.GetTag("iatag_deposit_stash_unknown_feedback"), UserFeedbackLevel.Warning);
            }
        }