[WIP] Dialog

This commit is contained in:
Yoshi Askharoun
2024-05-15 02:45:02 -05:00
parent 25283bf776
commit 09077b26f9
9 changed files with 158 additions and 5 deletions
+2
View File
@@ -119,6 +119,8 @@
</b:ContentControlExtensions.ContentChangedAnimation>
</ContentControl>
</Border>
<ContentControl x:Name="DialogPresenter" Grid.RowSpan="3" Visibility="Collapsed" />
</Grid>
</Window>
+23 -2
View File
@@ -1,9 +1,12 @@
using System;
using CommunityToolkit.Mvvm.Messaging;
using System;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Interop;
using ZuneModdingHelper.Controls;
using ZuneModdingHelper.Messages;
using ZuneModdingHelper.Pages;
namespace ZuneModdingHelper
@@ -11,7 +14,7 @@ namespace ZuneModdingHelper
/// <summary>
/// Interaction logic for AppWindow.xaml
/// </summary>
public partial class AppWindow
public partial class AppWindow : IRecipient<ShowDialogMessage>, IRecipient<CloseDialogMessage>
{
private IntPtr _windowHandle;
private int _selectedPivotIdx = -1;
@@ -22,6 +25,9 @@ namespace ZuneModdingHelper
{
InitializeComponent();
Pivot.Loaded += Pivot_Loaded;
WeakReferenceMessenger.Default.Register<ShowDialogMessage>(this);
WeakReferenceMessenger.Default.Register<CloseDialogMessage>(this);
}
private void Pivot_Loaded(object sender, RoutedEventArgs e)
@@ -79,5 +85,20 @@ namespace ZuneModdingHelper
ContentFrame.Content = Activator.CreateInstance(_pages[_selectedPivotIdx]);
}
void IRecipient<ShowDialogMessage>.Receive(ShowDialogMessage message)
{
DialogPresenter.Content = new ZuneLightDialog
{
ViewModel = message.ViewModel
};
DialogPresenter.Visibility = Visibility.Visible;
}
void IRecipient<CloseDialogMessage>.Receive(CloseDialogMessage message)
{
DialogPresenter.Visibility = Visibility.Collapsed;
DialogPresenter.Content = null;
}
}
}
@@ -0,0 +1,57 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:zmhc="clr-namespace:ZuneModdingHelper.Controls">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Themes/Zune.xaml"/>
</ResourceDictionary.MergedDictionaries>
<!-- TODO: Convert to UserControl -->
<Style TargetType="zmhc:ZuneLightDialog">
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="zmhc:ZuneLightDialog">
<Border Background="#AFFFFFFF">
<Border MaxHeight="408" MaxWidth="530" Padding="32">
<Border.Background>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFFFFF" Offset="0"/>
<GradientStop Color="#F0F0F0" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Rectangle Height="5" Width="109" Margin="0,-16,0,0"
VerticalAlignment="Top" HorizontalAlignment="Left"
Fill="{StaticResource ZuneHorizontalGradientAlt}"/>
<TextBlock Text="WINDOWS LIVE ID" FontSize="28" Margin="0,-10,0,0"
Foreground="{StaticResource ZuneMediumTextBrush}"/>
<ContentPresenter Grid.Row="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
<Button Content="CANCEL" Grid.Row="2" HorizontalAlignment="Right"
FontSize="12" Height="24"
Style="{StaticResource ActionButtonStyle}"/>
</Grid>
<Border.Effect>
<DropShadowEffect Color="Black" Opacity="0.45" BlurRadius="8"
Direction="0" ShadowDepth="0"/>
</Border.Effect>
</Border>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
@@ -0,0 +1,21 @@
using System.Windows;
using System.Windows.Controls;
using ZuneModdingHelper.Messages;
namespace ZuneModdingHelper.Controls;
public class ZuneLightDialog : ContentControl
{
static ZuneLightDialog()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(ZuneLightDialog), new FrameworkPropertyMetadata(typeof(ZuneLightDialog)));
}
public DialogViewModel ViewModel
{
get => (DialogViewModel)GetValue(DialogViewModelProperty);
set => SetValue(DialogViewModelProperty, value);
}
public static readonly DependencyProperty DialogViewModelProperty = DependencyProperty.Register(
nameof(ViewModel), typeof(DialogViewModel), typeof(ZuneLightDialog), new PropertyMetadata(null));
}
@@ -0,0 +1,22 @@
using CommunityToolkit.Mvvm.ComponentModel;
namespace ZuneModdingHelper.Messages;
public record ShowDialogMessage(DialogViewModel ViewModel);
public record CloseDialogMessage();
public partial class DialogViewModel : ObservableObject
{
[ObservableProperty]
private string _title;
[ObservableProperty]
private string _description;
}
public partial class ProgressDialogViewModel : DialogViewModel
{
[ObservableProperty]
private double _progress;
}
+2 -2
View File
@@ -35,9 +35,9 @@
<!--<Image Source="D:\Repos\ZuneDev\ZuneShell.dll\ZuneShell\Resources\RCDATA\ATTENTION.PNG"
Width="17" Height="18" SnapsToDevicePixels="True"
VerticalAlignment="Center" HorizontalAlignment="Right"/>-->
<Button Content="RESET" Margin="0,0,8,0"
<Button Content="RESET" Margin="0,0,8,0" Click="ResetButton_Click"
Style="{StaticResource ActionButtonStyle}"/>
<Button Content="APPLY"
<Button Content="APPLY" Click="ApplyButton_Click"
Style="{StaticResource ActionButtonStyle}"/>
</StackPanel>
+19 -1
View File
@@ -1,5 +1,7 @@
using System.Windows.Controls;
using CommunityToolkit.Mvvm.Messaging;
using System.Windows.Controls;
using ZuneModCore;
using ZuneModdingHelper.Messages;
namespace ZuneModdingHelper.Pages
{
@@ -13,5 +15,21 @@ namespace ZuneModdingHelper.Pages
InitializeComponent();
ModList.ItemsSource = Mod.AvailableMods;
}
private void ResetButton_Click(object sender, System.Windows.RoutedEventArgs e)
{
WeakReferenceMessenger.Default.Send(new ShowDialogMessage(new DialogViewModel
{
Title = "RESET"
}));
}
private void ApplyButton_Click(object sender, System.Windows.RoutedEventArgs e)
{
WeakReferenceMessenger.Default.Send(new ShowDialogMessage(new DialogViewModel
{
Title = "APPLY"
}));
}
}
}
+1
View File
@@ -6,5 +6,6 @@
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Controls/PathButton.xaml"/>
<ResourceDictionary Source="/Controls/TextButton.xaml"/>
<ResourceDictionary Source="/Controls/ZuneLightDialog.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
+11
View File
@@ -4,6 +4,9 @@
<Color x:Key="ZunePink">#F10DA1</Color>
<Color x:Key="ZuneOrange">#E95214</Color>
<Color x:Key="ZunePinkAlt">#EC0D91</Color>
<Color x:Key="ZuneOrangeAlt">#F8A347</Color>
<SolidColorBrush x:Key="ZuneMediumTextBrush" Color="#3C3C3C"/>
<SolidColorBrush x:Key="ZuneLightTextBrush" Color="#868686"/>
<SolidColorBrush x:Key="ZuneExtraLightTextBrush" Color="#B4B4B4"/>
@@ -21,6 +24,13 @@
<GradientStop Color="{StaticResource ZunePink}" Offset="1"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="ZuneHorizontalGradientAlt" EndPoint="1,0" StartPoint="0,0">
<LinearGradientBrush.GradientStops>
<GradientStop Color="{StaticResource ZuneOrangeAlt}" Offset="0"/>
<GradientStop Color="{StaticResource ZunePinkAlt}" Offset="1"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<Style x:Key="ZuneTextBlock" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Segoe UI"/>
@@ -54,6 +64,7 @@
</LinearGradientBrush>
</Style.Resources>
<Setter Property="Foreground" Value="{StaticResource ZuneMediumTextBrush}"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="FontSize" Value="10"/>
<Setter Property="Template">