diff --git a/src/Lurker.UI/Lurker.UI.csproj b/src/Lurker.UI/Lurker.UI.csproj index c0cce85c..2af89260 100644 --- a/src/Lurker.UI/Lurker.UI.csproj +++ b/src/Lurker.UI/Lurker.UI.csproj @@ -234,6 +234,7 @@ + @@ -260,6 +261,9 @@ PositionView.xaml + + RemainingMonsterView.xaml + SettingsView.xaml @@ -312,6 +316,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/src/Lurker.UI/ViewModels/BulbViewModelBase.cs b/src/Lurker.UI/ViewModels/BulbViewModelBase.cs index 5343eae4..817fcfdd 100644 --- a/src/Lurker.UI/ViewModels/BulbViewModelBase.cs +++ b/src/Lurker.UI/ViewModels/BulbViewModelBase.cs @@ -21,6 +21,7 @@ public abstract class BulbViewModel : PoeOverlayBase private INotifyPropertyChanged _actionView; protected static readonly int DefaultBulbHeight = 220; protected System.Action _action; + private System.Action _previousAction; #endregion @@ -36,6 +37,7 @@ public abstract class BulbViewModel : PoeOverlayBase public BulbViewModel(IWindowManager windowManager, DockingHelper dockingHelper, ClientLurker lurker, SettingsService settingsService) : base(windowManager, dockingHelper, lurker, settingsService) { + this.SetDefaultAction(); } #endregion @@ -64,6 +66,11 @@ protected set } } + /// + /// Defaults the action. + /// + protected virtual System.Action DefaultAction => null; + #endregion #region Methods @@ -82,22 +89,23 @@ public void OnClick() this._action.Invoke(); } - /// - /// Defaults the action. + /// Hides this instance. /// - protected virtual void DefaultAction() + protected void Hide() { + this.ActionView = null; + this._action = this._previousAction; + this._previousAction = null; + this.NotifyOfPropertyChange(nameof(this.HasAction)); } /// - /// Hides this instance. + /// Sets the default action. /// - protected void Hide() + protected void SetDefaultAction() { - this.ActionView = null; - this._action = null; - this.NotifyOfPropertyChange(nameof(this.HasAction)); + this.SetAction(new BulbMessage() { Action = this.DefaultAction }); } /// @@ -107,6 +115,7 @@ protected void Hide() protected void SetAction(BulbMessage message) { message.OnShow?.Invoke(this.Hide); + this._previousAction = this._action; this._action = message.Action; this.ActionView = message.View; diff --git a/src/Lurker.UI/ViewModels/LifeBulbViewModel.cs b/src/Lurker.UI/ViewModels/LifeBulbViewModel.cs index 31a84bc7..40517f30 100644 --- a/src/Lurker.UI/ViewModels/LifeBulbViewModel.cs +++ b/src/Lurker.UI/ViewModels/LifeBulbViewModel.cs @@ -73,10 +73,7 @@ protected override void SetWindowPosition(PoeWindowInformation windowInformation /// /// Defaults the action. /// - protected override void DefaultAction() - { - this._keyboardHelper.JoinHideout(); - } + protected override System.Action DefaultAction => () => this._keyboardHelper.JoinHideout(); #endregion } diff --git a/src/Lurker.UI/ViewModels/ManaBulbViewModel.cs b/src/Lurker.UI/ViewModels/ManaBulbViewModel.cs index 9ff435a2..0e9c909a 100644 --- a/src/Lurker.UI/ViewModels/ManaBulbViewModel.cs +++ b/src/Lurker.UI/ViewModels/ManaBulbViewModel.cs @@ -12,13 +12,13 @@ namespace Lurker.UI.ViewModels using Lurker.UI.Helpers; using Lurker.UI.Models; using Lurker.UI.Views; + using System; public class ManaBulbViewModel : BulbViewModel, IHandle { #region Fields private IEventAggregator _eventAggregator; - private PoeKeyboardHelper _keyboardHelper; private SettingsViewModel _settingsViewModel; #endregion @@ -35,12 +35,22 @@ public class ManaBulbViewModel : BulbViewModel, IHandle public ManaBulbViewModel(IEventAggregator eventAggregator, IWindowManager windowManager, DockingHelper dockingHelper, ClientLurker lurker, SettingsService settingsService, PoeKeyboardHelper keyboard, SettingsViewModel settingsViewModel) : base(windowManager, dockingHelper, lurker, settingsService) { - this._keyboardHelper = keyboard; this._settingsViewModel = settingsViewModel; this._eventAggregator = eventAggregator; this._eventAggregator.Subscribe(this); lurker.LocationChanged += this.Lurker_LocationChanged; + lurker.RemainingMonsters += this.Lurker_RemainingMonsters; + } + + /// + /// Lurkers the remaining monsters. + /// + /// The sender. + /// The e. + private void Lurker_RemainingMonsters(object sender, Patreon.Events.MonstersRemainEvent e) + { + this.SetAction(new ManaBulbMessage() { View = new RemainingMonsterViewModel(e), DisplayTime = TimeSpan.FromSeconds(3)}); } /// @@ -50,16 +60,13 @@ public ManaBulbViewModel(IEventAggregator eventAggregator, IWindowManager window /// The e. private void Lurker_LocationChanged(object sender, Patreon.Events.LocationChangedEvent e) { + var message = new ManaBulbMessage(); if (e.Location.EndsWith("Hideout")) { - this.Hidden = false; - this.ShowView(); - } - else - { - this.Hidden = true; - this.HideView(); + message.Action = this.DefaultAction; } + + this.SetAction(message); } #endregion @@ -95,10 +102,7 @@ protected override void SetWindowPosition(PoeWindowInformation windowInformation /// /// Defaults the action. /// - protected override void DefaultAction() - { - this._eventAggregator.PublishOnUIThread(this._settingsViewModel); - } + protected override System.Action DefaultAction => () => this._eventAggregator.PublishOnUIThread(this._settingsViewModel); #endregion } diff --git a/src/Lurker.UI/ViewModels/PoeOverlayBase.cs b/src/Lurker.UI/ViewModels/PoeOverlayBase.cs index c7e8788e..4b2c9c0d 100644 --- a/src/Lurker.UI/ViewModels/PoeOverlayBase.cs +++ b/src/Lurker.UI/ViewModels/PoeOverlayBase.cs @@ -60,11 +60,6 @@ public PoeOverlayBase(IWindowManager windowManager, DockingHelper dockingHelper, /// public bool DebugEnabled => this._settingsService.DebugEnabled; - /// - /// Gets or sets a value indicating whether this is hidden. - /// - protected bool Hidden { get; set; } - #endregion #region Methods @@ -94,11 +89,6 @@ private void DockingHelper_OnForegroundChange(object sender, bool e) { if (e) { - if (this.Hidden) - { - return; - } - this.ShowView(); } else diff --git a/src/Lurker.UI/ViewModels/RemainingMonsterViewModel.cs b/src/Lurker.UI/ViewModels/RemainingMonsterViewModel.cs new file mode 100644 index 00000000..a4cd82d4 --- /dev/null +++ b/src/Lurker.UI/ViewModels/RemainingMonsterViewModel.cs @@ -0,0 +1,46 @@ +//----------------------------------------------------------------------- +// +// Missing Copyright information from a valid stylecop.json file. +// +//----------------------------------------------------------------------- + +namespace Lurker.UI.ViewModels +{ + using Lurker.Patreon.Events; + + public class RemainingMonsterViewModel : Caliburn.Micro.PropertyChangedBase + { + #region Fields + + private MonstersRemainEvent _monsterEvent; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The monster event. + public RemainingMonsterViewModel(MonstersRemainEvent monsterEvent) + { + this._monsterEvent = monsterEvent; + } + + #endregion + + #region Properties + + /// + /// Gets or sets the monster remaining. + /// + public int MonsterCount => this._monsterEvent.MonsterCount; + + /// + /// Gets a value indicating whether [less than50]. + /// + public bool LessThan50 => this.MonsterCount < 50; + + #endregion + } +} diff --git a/src/Lurker.UI/ViewModels/SettingsViewModel.cs b/src/Lurker.UI/ViewModels/SettingsViewModel.cs index a0fe710a..d3163570 100644 --- a/src/Lurker.UI/ViewModels/SettingsViewModel.cs +++ b/src/Lurker.UI/ViewModels/SettingsViewModel.cs @@ -119,6 +119,26 @@ public string BusyMessage } } + /// + /// Gets or sets the busy message. + /// + /// + /// The busy message. + /// + public bool RemainingMonsterEnabled + { + get + { + return this._settingService.RemainingMonsterEnabled; + } + + set + { + this._settingService.RemainingMonsterEnabled = value; + this.NotifyOfPropertyChange(); + } + } + /// /// Gets or sets the sold message. /// diff --git a/src/Lurker.UI/ViewModels/UpdateViewModel.cs b/src/Lurker.UI/ViewModels/UpdateViewModel.cs index 1fe1b957..091d9904 100644 --- a/src/Lurker.UI/ViewModels/UpdateViewModel.cs +++ b/src/Lurker.UI/ViewModels/UpdateViewModel.cs @@ -10,7 +10,7 @@ namespace Lurker.UI.ViewModels using System.IO; using System.Reflection; - public class UpdateViewModel: Caliburn.Micro.PropertyChangedBase + public class UpdateViewModel : Caliburn.Micro.PropertyChangedBase { #region Constructors diff --git a/src/Lurker.UI/Views/LifeBulbView.xaml b/src/Lurker.UI/Views/LifeBulbView.xaml index 437215cd..6bd8834c 100644 --- a/src/Lurker.UI/Views/LifeBulbView.xaml +++ b/src/Lurker.UI/Views/LifeBulbView.xaml @@ -14,7 +14,7 @@ Title="LifeBulbView"> - + diff --git a/src/Lurker.UI/Views/ManaBulbView.xaml b/src/Lurker.UI/Views/ManaBulbView.xaml index 33b6d2c8..1f3d33b9 100644 --- a/src/Lurker.UI/Views/ManaBulbView.xaml +++ b/src/Lurker.UI/Views/ManaBulbView.xaml @@ -14,7 +14,7 @@ Title="ManaBulbView"> - + + + + + + diff --git a/src/Lurker.UI/Views/RemainingMonsterView.xaml.cs b/src/Lurker.UI/Views/RemainingMonsterView.xaml.cs new file mode 100644 index 00000000..64d71782 --- /dev/null +++ b/src/Lurker.UI/Views/RemainingMonsterView.xaml.cs @@ -0,0 +1,21 @@ +//----------------------------------------------------------------------- +// +// Missing Copyright information from a valid stylecop.json file. +// +//----------------------------------------------------------------------- + +namespace Lurker.UI.Views +{ + using System.Windows.Controls; + + /// + /// Interaction logic for RemainingMonsterView.xaml + /// + public partial class RemainingMonsterView : UserControl + { + public RemainingMonsterView() + { + this.InitializeComponent(); + } + } +} diff --git a/src/Lurker.UI/Views/SettingsView.xaml b/src/Lurker.UI/Views/SettingsView.xaml index 5d38a5a8..29f5e7c2 100644 --- a/src/Lurker.UI/Views/SettingsView.xaml +++ b/src/Lurker.UI/Views/SettingsView.xaml @@ -197,12 +197,17 @@ VerticalAlignment="Top" Text="(Ctrl + F)" /> - + + + + diff --git a/src/Lurker/ClipboardLurker.cs b/src/Lurker/ClipboardLurker.cs index 35be6b30..cd5eda4e 100644 --- a/src/Lurker/ClipboardLurker.cs +++ b/src/Lurker/ClipboardLurker.cs @@ -87,7 +87,7 @@ public ClipboardLurker(SettingsService settingsService, PoeKeyboardHelper keyboa public void BindGlobalClick() { #if (!DEBUG) - this._keyboardEvent.MouseClick += this.KeyboardEvent_MouseClick; + this._keyboardEvent.MouseDownExt += this.KeyboardEvent_MouseClick; #endif } @@ -107,7 +107,7 @@ protected virtual void Dispose(bool disposing) { if (disposing) { - this._keyboardEvent.MouseClick -= this.KeyboardEvent_MouseClick; + this._keyboardEvent.MouseDownExt -= this.KeyboardEvent_MouseClick; this._keyboardEvent.Dispose(); this._clipboardMonitor.ClipboardChanged -= ClipboardMonitor_ClipboardChanged; this._settingsService.OnSave -= this.SettingsService_OnSave; @@ -130,10 +130,17 @@ private async void SettingsService_OnSave(object sender, EventArgs e) /// /// The source of the event. /// The instance containing the event data. - private void KeyboardEvent_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e) + private void KeyboardEvent_MouseClick(object sender, MouseEventExtArgs e) { Task.Run(() => { + if (e.Button == System.Windows.Forms.MouseButtons.Middle && this._settingsService.RemainingMonsterEnabled) + { + e.Handled = true; + this._keyboardHelper.RemainingMonster(); + return; + } + if (!this._settingsService.SearchEnabled || e.Button != System.Windows.Forms.MouseButtons.Left) { return; diff --git a/src/Lurker/Helpers/PoeKeyboardHelper.cs b/src/Lurker/Helpers/PoeKeyboardHelper.cs index b325b956..d79970b1 100644 --- a/src/Lurker/Helpers/PoeKeyboardHelper.cs +++ b/src/Lurker/Helpers/PoeKeyboardHelper.cs @@ -25,6 +25,14 @@ public PoeKeyboardHelper(IntPtr windowHandle) #region Methods + /// + /// Remainings the monster. + /// + public void RemainingMonster() + { + this.SendCommand("/remaining"); + } + /// /// Whoes the is. /// diff --git a/src/Lurker/Models/Settings.cs b/src/Lurker/Models/Settings.cs index 90fc7d92..a49d9e65 100644 --- a/src/Lurker/Models/Settings.cs +++ b/src/Lurker/Models/Settings.cs @@ -88,6 +88,12 @@ public sealed class Settings: SettingsBase [DefaultValue(true)] public bool ItemHighlightEnabled { get; set; } + + /// + /// Gets or sets a value indicating whether [item highlight enabled]. + /// + public bool RemainingMonsterEnabled { get; set; } + /// /// Gets or sets the tooltip delay. /// diff --git a/src/Lurker/Services/SettingsService.cs b/src/Lurker/Services/SettingsService.cs index f8502315..d2574fdf 100644 --- a/src/Lurker/Services/SettingsService.cs +++ b/src/Lurker/Services/SettingsService.cs @@ -270,6 +270,22 @@ public bool ItemHighlightEnabled } } + /// + /// Gets or sets a value indicating whether [remaining monster enabled]. + /// + public bool RemainingMonsterEnabled + { + get + { + return this._settings.RemainingMonsterEnabled; + } + + set + { + this._settings.RemainingMonsterEnabled = value; + } + } + /// /// Gets or sets the alert volume. ///