Server termination and refactoring message dialogs.

This commit is contained in:
Burak Kaan Köse
2024-08-21 22:42:52 +02:00
parent bab3272970
commit f627226da9
31 changed files with 548 additions and 388 deletions

View File

@@ -1,29 +0,0 @@
<ContentDialog
x:Class="Wino.Dialogs.ConfirmationDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:domain="using:Wino.Core.Domain"
Title="{x:Bind DialogTitle, Mode=OneWay}"
Style="{StaticResource WinoDialogStyle}"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
Closed="DialogClosed"
PrimaryButtonText="{x:Bind ApproveButtonTitle, Mode=OneWay}"
DefaultButton="Primary"
SecondaryButtonText="{x:Bind domain:Translator.Buttons_Cancel}"
PrimaryButtonClick="ApproveClicked"
SecondaryButtonClick="CancelClicked"
mc:Ignorable="d">
<ContentDialog.Resources>
<x:Double x:Key="ContentDialogMinWidth">250</x:Double>
<x:Double x:Key="ContentDialogMaxWidth">500</x:Double>
<x:Double x:Key="ContentDialogMinHeight">200</x:Double>
<x:Double x:Key="ContentDialogMaxHeight">756</x:Double>
</ContentDialog.Resources>
<TextBlock Text="{x:Bind Message, Mode=OneWay}" TextWrapping="Wrap" />
</ContentDialog>

View File

@@ -1,80 +0,0 @@
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Wino.Core.Domain.Interfaces;
namespace Wino.Dialogs
{
public sealed partial class ConfirmationDialog : ContentDialog, IConfirmationDialog
{
private TaskCompletionSource<bool> _completionSource;
#region Dependency Properties
public string DialogTitle
{
get { return (string)GetValue(DialogTitleProperty); }
set { SetValue(DialogTitleProperty, value); }
}
public static readonly DependencyProperty DialogTitleProperty = DependencyProperty.Register(nameof(DialogTitle), typeof(string), typeof(ConfirmationDialog), new PropertyMetadata(string.Empty));
public string Message
{
get { return (string)GetValue(MessageProperty); }
set { SetValue(MessageProperty, value); }
}
public static readonly DependencyProperty MessageProperty = DependencyProperty.Register(nameof(Message), typeof(string), typeof(ConfirmationDialog), new PropertyMetadata(string.Empty));
public string ApproveButtonTitle
{
get { return (string)GetValue(ApproveButtonTitleProperty); }
set { SetValue(ApproveButtonTitleProperty, value); }
}
public static readonly DependencyProperty ApproveButtonTitleProperty = DependencyProperty.Register(nameof(ApproveButtonTitle), typeof(string), typeof(ConfirmationDialog), new PropertyMetadata(string.Empty));
#endregion
private bool _isApproved;
public ConfirmationDialog()
{
InitializeComponent();
}
public async Task<bool> ShowDialogAsync(string title, string message, string approveButtonTitle)
{
_completionSource = new TaskCompletionSource<bool>();
DialogTitle = title;
Message = message;
ApproveButtonTitle = approveButtonTitle;
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
ShowAsync();
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
return await _completionSource.Task;
}
private void DialogClosed(ContentDialog sender, ContentDialogClosedEventArgs args)
{
_completionSource.TrySetResult(_isApproved);
}
private void ApproveClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
_isApproved = true;
Hide();
}
private void CancelClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
_isApproved = false;
Hide();
}
}
}

View File

@@ -0,0 +1,24 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Wino.Core.Domain.Enums;
namespace Wino.Dialogs
{
public partial class CustomMessageDialogInformationContainer : ObservableObject
{
[ObservableProperty]
private bool isDontAskChecked;
public CustomMessageDialogInformationContainer(string title, string description, WinoCustomMessageDialogIcon icon, bool isDontAskAgainEnabled)
{
Title = title;
Description = description;
Icon = icon;
IsDontAskAgainEnabled = isDontAskAgainEnabled;
}
public string Title { get; }
public string Description { get; }
public WinoCustomMessageDialogIcon Icon { get; }
public bool IsDontAskAgainEnabled { get; }
}
}

View File

@@ -1,24 +0,0 @@
<ContentDialog
x:Class="Wino.Dialogs.StoreRatingDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Wino.Dialogs"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:domain="using:Wino.Core.Domain"
PrimaryButtonText="{x:Bind domain:Translator.Buttons_RateWino}"
SecondaryButtonText="{x:Bind domain:Translator.Buttons_No}"
DefaultButton="Primary"
PrimaryButtonClick="RateClicked"
Title="{x:Bind domain:Translator.StoreRatingDialog_Title}"
Style="{StaticResource WinoDialogStyle}">
<Grid>
<StackPanel Spacing="6">
<TextBlock Text="{x:Bind domain:Translator.StoreRatingDialog_MessageFirstLine}" />
<TextBlock Text="{x:Bind domain:Translator.StoreRatingDialog_MessageSecondLine}" />
<CheckBox IsChecked="{x:Bind DontAskAgain, Mode=TwoWay}" Content="{x:Bind domain:Translator.Dialog_DontAskAgain}" />
</StackPanel>
</Grid>
</ContentDialog>

View File

@@ -1,21 +0,0 @@
using Windows.UI.Xaml.Controls;
using Wino.Core.Domain.Interfaces;
namespace Wino.Dialogs
{
public sealed partial class StoreRatingDialog : ContentDialog, IStoreRatingDialog
{
public bool DontAskAgain { get; set; }
public bool RateWinoClicked { get; set; }
public StoreRatingDialog()
{
this.InitializeComponent();
}
private void RateClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
RateWinoClicked = true;
}
}
}

View File

@@ -1,25 +0,0 @@
<ContentDialog
x:Class="Wino.Dialogs.WinoMessageDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="{x:Bind DialogTitle, Mode=OneWay}"
xmlns:domain="using:Wino.Core.Domain"
Style="{StaticResource WinoDialogStyle}"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
CloseButtonText="{x:Bind domain:Translator.Buttons_Close}"
DefaultButton="Close"
Closed="DialogClosed"
mc:Ignorable="d">
<ContentDialog.Resources>
<x:Double x:Key="ContentDialogMinWidth">250</x:Double>
<x:Double x:Key="ContentDialogMaxWidth">900</x:Double>
<x:Double x:Key="ContentDialogMinHeight">200</x:Double>
<x:Double x:Key="ContentDialogMaxHeight">756</x:Double>
</ContentDialog.Resources>
<TextBlock Text="{x:Bind Message, Mode=OneWay}" TextWrapping="Wrap" />
</ContentDialog>

View File

@@ -1,60 +0,0 @@
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace Wino.Dialogs
{
public sealed partial class WinoMessageDialog : ContentDialog
{
private TaskCompletionSource<bool> _completionSource;
#region Dependency Properties
public string DialogTitle
{
get { return (string)GetValue(DialogTitleProperty); }
set { SetValue(DialogTitleProperty, value); }
}
public static readonly DependencyProperty DialogTitleProperty = DependencyProperty.Register(nameof(DialogTitle), typeof(string), typeof(ConfirmationDialog), new PropertyMetadata(string.Empty));
public string Message
{
get { return (string)GetValue(MessageProperty); }
set { SetValue(MessageProperty, value); }
}
public static readonly DependencyProperty MessageProperty = DependencyProperty.Register(nameof(Message), typeof(string), typeof(ConfirmationDialog), new PropertyMetadata(string.Empty));
#endregion
public WinoMessageDialog()
{
InitializeComponent();
}
public async Task<bool> ShowDialogAsync(string title, string message)
{
_completionSource = new TaskCompletionSource<bool>();
DialogTitle = title;
Message = message;
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
ShowAsync();
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
return await _completionSource.Task;
}
private void ApproveClicked(object sender, RoutedEventArgs e)
{
Hide();
}
private void DialogClosed(ContentDialog sender, ContentDialogClosedEventArgs args)
{
_completionSource.TrySetResult(true);
}
}
}