Skip to content

Commit

Permalink
Add mana bulb and add clipboard settings
Browse files Browse the repository at this point in the history
  • Loading branch information
C1rdec committed Mar 12, 2020
1 parent 4e2ce5d commit 8e94a6c
Show file tree
Hide file tree
Showing 16 changed files with 442 additions and 84 deletions.
1 change: 1 addition & 0 deletions src/Lurker.UI/AppBootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ protected override void Configure()
this._container.PerRequest<TradebarViewModel, TradebarViewModel>();
this._container.PerRequest<OutgoingbarViewModel, OutgoingbarViewModel>();
this._container.PerRequest<LifeBulbViewModel, LifeBulbViewModel>();
this._container.PerRequest<ManaBulbViewModel, ManaBulbViewModel>();
this._container.RegisterInstance(typeof(SimpleContainer), null, this._container);
}

Expand Down
11 changes: 11 additions & 0 deletions src/Lurker.UI/Lurker.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@
<Compile Include="Helpers\DockingHelper.cs" />
<Compile Include="Helpers\UpdateManager.cs" />
<Compile Include="Models\DoubleClickCommand.cs" />
<Compile Include="Models\BulbMessage.cs" />
<Compile Include="Models\ManaBulbMessage.cs" />
<Compile Include="Models\LifeBulbMessage.cs" />
<Compile Include="Models\OutgoingbarContext.cs" />
<Compile Include="Models\PoeWindowInformation.cs" />
Expand All @@ -192,6 +194,8 @@
<DependentUpon>Svg.tt</DependentUpon>
</Compile>
<Compile Include="ViewModels\ItemOverlayViewModel.cs" />
<Compile Include="ViewModels\BulbViewModelBase.cs" />
<Compile Include="ViewModels\ManaBulbViewModel.cs" />
<Compile Include="ViewModels\LifeBulbViewModel.cs" />
<Compile Include="ViewModels\OfferStatus.cs" />
<Compile Include="ViewModels\OutgoingbarViewModel.cs" />
Expand All @@ -205,6 +209,9 @@
<Compile Include="Views\ItemOverlayView.xaml.cs">
<DependentUpon>ItemOverlayView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ManaBulbView.xaml.cs">
<DependentUpon>ManaBulbView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\LifeBulbView.xaml.cs">
<DependentUpon>LifeBulbView.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -242,6 +249,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\ManaBulbView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\LifeBulbView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
32 changes: 32 additions & 0 deletions src/Lurker.UI/Models/BulbMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//-----------------------------------------------------------------------
// <copyright file="BulbMessage.cs" company="Wohs">
// Missing Copyright information from a valid stylecop.json file.
// </copyright>
//-----------------------------------------------------------------------

namespace Lurker.UI.Models
{
using System;

public class BulbMessage
{
#region Properties

/// <summary>
/// Gets or sets the action.
/// </summary>
public Action Action { get; set; }

/// <summary>
/// Gets or sets the view.
/// </summary>
public System.ComponentModel.INotifyPropertyChanged View { get; set; }

/// <summary>
/// Gets or sets the on show.
/// </summary>
public Action<Action> OnShow { get; set; }

#endregion
}
}
22 changes: 1 addition & 21 deletions src/Lurker.UI/Models/LifeBulbMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,7 @@

namespace Lurker.UI.Models
{
using System;

public class LifeBulbMessage
public class LifeBulbMessage : BulbMessage
{
#region Properties

/// <summary>
/// Gets or sets the action.
/// </summary>
public Action Action { get; set; }

/// <summary>
/// Gets or sets the view.
/// </summary>
public System.ComponentModel.INotifyPropertyChanged View { get; set; }

/// <summary>
/// Gets or sets the on show.
/// </summary>
public Action<Action> OnShow { get; set; }

#endregion
}
}
12 changes: 12 additions & 0 deletions src/Lurker.UI/Models/ManaBulbMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//-----------------------------------------------------------------------
// <copyright file="ManaBulbMessage.cs" company="Wohs">
// Missing Copyright information from a valid stylecop.json file.
// </copyright>
//-----------------------------------------------------------------------

namespace Lurker.UI.Models
{
public class ManaBulbMessage : BulbMessage
{
}
}
116 changes: 116 additions & 0 deletions src/Lurker.UI/ViewModels/BulbViewModelBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
//-----------------------------------------------------------------------
// <copyright file="BulbViewModelBase.cs" company="Wohs">
// Missing Copyright information from a valid stylecop.json file.
// </copyright>
//-----------------------------------------------------------------------

namespace Lurker.UI.ViewModels
{
using Caliburn.Micro;
using Lurker.Services;
using Lurker.UI.Helpers;
using Lurker.UI.Models;
using System.ComponentModel;

public abstract class BulbViewModel : PoeOverlayBase
{
#region Fields

private INotifyPropertyChanged _actionView;
protected static readonly int DefaultBulbHeight = 220;
protected System.Action _action;

#endregion

#region Constructors

/// <summary>
/// Initializes a new instance of the <see cref="LifeBulbViewModel"/> class.
/// </summary>
/// <param name="windowManager">The window manager.</param>
/// <param name="dockingHelper">The docking helper.</param>
/// <param name="lurker"></param>
/// <param name="settingsService"></param>H
public BulbViewModel(IWindowManager windowManager, DockingHelper dockingHelper, ClientLurker lurker, SettingsService settingsService)
: base(windowManager, dockingHelper, lurker, settingsService)
{
}

#endregion

#region Properties

/// <summary>
/// Gets a value indicating whether this instance has action.
/// </summary>
public bool HasAction => this._action != null;

/// <summary>
/// Gets the action view.
/// </summary>
public INotifyPropertyChanged ActionView
{
get
{
return this._actionView;
}

protected set
{
this._actionView = value;
this.NotifyOfPropertyChange();
}
}

#endregion

#region Methods

/// <summary>
/// Called when [click].
/// </summary>
public void OnClick()
{
if (this._action == null)
{
this.DefaultAction();
return;
}

this._action.Invoke();
}


/// <summary>
/// Defaults the action.
/// </summary>
protected virtual void DefaultAction()
{
}

/// <summary>
/// Hides this instance.
/// </summary>
protected void Hide()
{
this.ActionView = null;
this._action = null;
this.NotifyOfPropertyChange(nameof(this.HasAction));
}

/// <summary>
/// Sets the action.
/// </summary>
/// <param name="message">The message.</param>
protected void SetAction(BulbMessage message)
{
message.OnShow(this.Hide);
this._action = message.Action;
this.ActionView = message.View;

this.NotifyOfPropertyChange(nameof(this.HasAction));
}

#endregion
}
}
65 changes: 5 additions & 60 deletions src/Lurker.UI/ViewModels/LifeBulbViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@ namespace Lurker.UI.ViewModels
using Lurker.UI.Helpers;
using Lurker.UI.Models;
using Lurker.UI.Views;
using System.ComponentModel;

public class LifeBulbViewModel : PoeOverlayBase, IHandle<LifeBulbMessage>
public class LifeBulbViewModel : BulbViewModel, IHandle<LifeBulbMessage>
{
#region Fields

private static readonly int DefaultLifeBulbHeight = 220;
private INotifyPropertyChanged _actionView;
private System.Action _action;
private IEventAggregator _eventAggregator;
private PoeKeyboardHelper _keyboardHelper;

Expand All @@ -45,59 +41,15 @@ public LifeBulbViewModel(IEventAggregator eventAggregator, IWindowManager window

#endregion

#region Properties

/// <summary>
/// Gets a value indicating whether this instance has action.
/// </summary>
public bool HasAction => this._action != null;

/// <summary>
/// Gets the action view.
/// </summary>
public INotifyPropertyChanged ActionView
{
get
{
return this._actionView;
}

private set
{
this._actionView = value;
this.NotifyOfPropertyChange();
}
}

#endregion

#region Methods

/// <summary>
/// Called when [click].
/// </summary>
public void OnClick()
{
if (this._action == null)
{
this.DefaultAction();
return;
}

this._action.Invoke();
}

/// <summary>
/// Handles the message.
/// </summary>
/// <param name="message">The message.</param>
public void Handle(LifeBulbMessage message)
{
message.OnShow(this.Hide);
this._action = message.Action;
this.ActionView = message.View;

this.NotifyOfPropertyChange(nameof(this.HasAction));
this.SetAction(message);
}

/// <summary>
Expand All @@ -106,7 +58,7 @@ public void Handle(LifeBulbMessage message)
/// <param name="windowInformation"></param>
protected override void SetWindowPosition(PoeWindowInformation windowInformation)
{
var value = DefaultLifeBulbHeight * windowInformation.Height / 1080;
var value = DefaultBulbHeight * windowInformation.Height / 1080;
Execute.OnUIThread(() =>
{
this._view.Height = value;
Expand All @@ -119,16 +71,9 @@ protected override void SetWindowPosition(PoeWindowInformation windowInformation
}

/// <summary>
/// Hides this instance.
/// Defaults the action.
/// </summary>
private void Hide()
{
this.ActionView = null;
this._action = null;
this.NotifyOfPropertyChange(nameof(this.HasAction));
}

private void DefaultAction()
protected override void DefaultAction()
{
this._keyboardHelper.JoinHideout();
}
Expand Down
Loading

0 comments on commit 8e94a6c

Please sign in to comment.