Compare commits

...
1 Commits
Author SHA1 Message Date
Alexandru Macocian 6de52f5585 Ability to test placement while guildwars is running. 2021-04-26 11:26:43 +02:00
3 changed files with 34 additions and 2 deletions
+1 -1
View File
@@ -9,7 +9,7 @@
<CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
<LangVersion>preview</LangVersion>
<ApplicationIcon>Daybreak.ico</ApplicationIcon>
<Version>0.8.3</Version>
<Version>0.8.4</Version>
</PropertyGroup>
<ItemGroup>
+5
View File
@@ -6,6 +6,7 @@
xmlns:local="clr-namespace:Daybreak.Views"
xmlns:controls="clr-namespace:Daybreak.Controls"
mc:Ignorable="d"
x:Name="_this"
d:DesignHeight="450" d:DesignWidth="800">
<Grid Background="#A0202020">
<Grid.RowDefinitions>
@@ -14,6 +15,10 @@
</Grid.RowDefinitions>
<controls:BackButton Foreground="White" Height="30" Width="30" Grid.Column="0" HorizontalAlignment="Left" Margin="5"
Clicked="BackButton_Clicked"></controls:BackButton>
<TextBlock Text="Choose screen" FontSize="18" Foreground="White" HorizontalAlignment="Center"></TextBlock>
<controls:OpaqueButton Text="Test" Foreground="White" HighlightOpacity="0.3" Highlight="White" FontSize="18" Width="80"
HorizontalAlignment="Right" Margin="0, 0, 50, 0" Clicked="OpaqueButton_Clicked"
IsEnabled="{Binding ElementName=_this, Path=CanTest, Mode=OneWay}"></controls:OpaqueButton>
<controls:SaveButton Foreground="White" Height="30" Width="30" Grid.Column="1" HorizontalAlignment="Right" Margin="5"
Clicked="SaveButton_Clicked"></controls:SaveButton>
<Viewbox Grid.Row="1">
+28 -1
View File
@@ -1,12 +1,15 @@
using Daybreak.Controls.Templates;
using Daybreak.Models;
using Daybreak.Services.ApplicationLauncher;
using Daybreak.Services.Configuration;
using Daybreak.Services.Screens;
using Daybreak.Services.ViewManagement;
using System;
using System.Extensions;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Extensions;
using System.Windows.Media;
namespace Daybreak.Views
@@ -16,21 +19,34 @@ namespace Daybreak.Views
/// </summary>
public partial class ScreenChoiceView : UserControl
{
public static readonly DependencyProperty CanTestProperty =
DependencyPropertyExtensions.Register<ScreenChoiceView, bool>(nameof(CanTest));
private readonly IScreenManager screenManager;
private readonly IViewManager viewManager;
private readonly IConfigurationManager configurationManager;
private readonly IApplicationLauncher applicationLauncher;
private int selectedId;
public bool CanTest
{
get => this.GetTypedValue<bool>(CanTestProperty);
set => this.SetValue(CanTestProperty, value);
}
public ScreenChoiceView(
IViewManager viewManager,
IScreenManager screenManager,
IConfigurationManager configurationManager)
IConfigurationManager configurationManager,
IApplicationLauncher applicationLauncher)
{
this.viewManager = viewManager.ThrowIfNull(nameof(viewManager));
this.screenManager = screenManager.ThrowIfNull(nameof(screenManager));
this.configurationManager = configurationManager.ThrowIfNull(nameof(configurationManager));
this.applicationLauncher = applicationLauncher.ThrowIfNull(nameof(applicationLauncher));
this.InitializeComponent();
this.selectedId = configurationManager.GetConfiguration().DesiredGuildwarsScreen;
this.CanTest = applicationLauncher.IsGuildwarsRunning;
this.SetupView();
}
@@ -77,5 +93,16 @@ namespace Daybreak.Views
this.configurationManager.GetConfiguration().DesiredGuildwarsScreen = this.selectedId;
this.viewManager.ShowView<SettingsCategoryView>();
}
private void OpaqueButton_Clicked(object sender, EventArgs e)
{
var screen = this.screenManager.Screens.Skip(this.selectedId).FirstOrDefault();
if (screen is null)
{
throw new InvalidOperationException($"Unable to test placement. No screen with id {this.selectedId}");
}
this.screenManager.MoveGuildwarsToScreen(screen);
}
}
}