[WIP] Donation request interval settings

This commit is contained in:
Yoshi Askharoun
2025-08-31 18:13:56 -07:00
parent d1cf5ab66a
commit 41576532f6
5 changed files with 281 additions and 1 deletions
+11
View File
@@ -0,0 +1,11 @@
using System;
using System.Windows.Markup;
namespace OwlCore.Wpf;
public class EnumValuesExtension : MarkupExtension
{
public Type Enum { get; set; }
public override object ProvideValue(IServiceProvider serviceProvider) => System.Enum.GetValues(Enum);
}
+3
View File
@@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ZuneModdingHelper"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:ocWC="clr-namespace:OwlCore.Wpf.Converters;assembly=OwlCore.Wpf"
xmlns:ocWCBV="clr-namespace:OwlCore.Wpf.Converters.Bools.Visible;assembly=OwlCore.Wpf"
StartupUri="AppWindow.xaml">
<Application.Resources>
@@ -19,6 +20,8 @@
<Style TargetType="ScrollBar" BasedOn="{StaticResource ZuneScrollBarStyle}"/>
<Style TargetType="Button" BasedOn="{StaticResource ActionButtonStyle}"/>
<Style TargetType="TextBox" BasedOn="{StaticResource ZuneTextBoxBaseStyle}"/>
<Style TargetType="ComboBox" BasedOn="{StaticResource ZuneComboBoxStyle}"/>
<Style TargetType="ComboBoxItem" BasedOn="{StaticResource ZuneComboBoxItemStyle}"/>
<FontFamily x:Key="ZMHIcons">Assets/ZMH_Icons.ttf#ZMHIcons</FontFamily>
<FontFamily x:Key="SegoeMDL2">Segoe MDL2 Assets</FontFamily>
@@ -0,0 +1,32 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using ZuneModdingHelper.Services;
namespace ZuneModdingHelper.Controls;
public class DonationIntervalDescriptionConverter : DependencyObject, IValueConverter
{
/// <inheritdoc/>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value switch
{
DonationRequestInterval.EveryMod => "After every successful mod",
DonationRequestInterval.OneWeek => "Once a week",
DonationRequestInterval.TwoWeeks => "Once every two weeks",
DonationRequestInterval.OneMonth => "Once a month",
DonationRequestInterval.ThreeMonths => "Once a quarter",
DonationRequestInterval.SixMonths => "Once every six months",
DonationRequestInterval.OneYear => "Once a year",
_ => value?.ToString(),
};
}
/// <inheritdoc/>
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
+22
View File
@@ -4,14 +4,21 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ZuneModdingHelper.Pages"
xmlns:zmhc="clr-namespace:ZuneModdingHelper.Controls"
xmlns:zmhs="clr-namespace:ZuneModdingHelper.Services"
xmlns:ocW="clr-namespace:OwlCore.Wpf;assembly=OwlCore.Wpf"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:Background="White"
Unloaded="SettingsPage_Unloaded">
<d:UserControl.DataContext>
<local:SettingsViewModel/>
</d:UserControl.DataContext>
<UserControl.Resources>
<zmhc:DonationIntervalDescriptionConverter x:Key="DonReqIntv"/>
</UserControl.Resources>
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel>
<TextBlock Style="{StaticResource ZuneBodyTextBlockStyle}">
@@ -29,6 +36,21 @@
<Button Content="KILL ALL" HorizontalAlignment="Left" Margin="0,8,0,0"
Visibility="{Binding FolderPickerVisibility, Mode=OneTime}"
Click="KillZuneButton_Click"/>
<TextBlock Margin="0,24,0,0" Style="{StaticResource ZuneBodyTextBlockStyle}">
<Run Text="General" Style="{StaticResource ZuneHeaderTextStyle}"/>
</TextBlock>
<TextBlock Text="Choose how often to request donations." Margin="0,8"
Style="{StaticResource ZuneBodyTextBlockStyle}" />
<ComboBox SelectedValue="{Binding Settings.DonationRequestInterval}"
ItemsSource="{ocW:EnumValues Enum=zmhs:DonationRequestInterval}"
HorizontalAlignment="Left">
<ComboBox.ItemTemplate>
<DataTemplate DataType="{x:Type zmhs:DonationRequestInterval}">
<TextBlock Text="{Binding Converter={StaticResource DonReqIntv}}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</StackPanel>
</ScrollViewer>
</UserControl>
+213 -1
View File
@@ -1,7 +1,8 @@
<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"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:theme="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero2">
<Color x:Key="ZunePink">#F10DA1</Color>
<Color x:Key="ZuneOrange">#E95214</Color>
<Color x:Key="ZunePinkAlt">#EC0D91</Color>
@@ -777,5 +778,216 @@
</MultiTrigger>
</Style.Triggers>
</Style>
<!-- ComboBox -->
<LinearGradientBrush x:Key="NormalComboBoxBackgroundBrush" StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#F7F7F7" Offset="0"/>
<GradientStop Color="#E0E0E0" Offset="1"/>
</LinearGradientBrush>
<LinearGradientBrush x:Key="HoverComboBoxBackgroundBrush" StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#EAEAEA" Offset="0"/>
<GradientStop Color="#FDFDFD" Offset="1"/>
</LinearGradientBrush>
<LinearGradientBrush x:Key="DisabledComboBoxBackgroundBrush" StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#E5E5E5" Offset="0"/>
<GradientStop Color="#D5D5D5" Offset="1"/>
</LinearGradientBrush>
<ControlTemplate x:Key="ZuneComboBoxTemplate" TargetType="{x:Type ComboBox}">
<Border x:Name="ComboBoxBorder" BorderThickness="{TemplateBinding BorderThickness}">
<Grid x:Name="templateRoot" SnapsToDevicePixels="true">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/>
</Grid.ColumnDefinitions>
<Popup x:Name="PART_Popup"
AllowsTransparency="true"
Margin="1"
Placement="Bottom"
Grid.ColumnSpan="2"
IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}">
<theme:SystemDropShadowChrome x:Name="shadow"
Color="Transparent"
MaxHeight="{TemplateBinding MaxDropDownHeight}"
MinWidth="{Binding ActualWidth, ElementName=templateRoot}">
<Border x:Name="DropDownBorder"
BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}"
Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"
BorderThickness="1">
<ScrollViewer x:Name="DropDownScrollViewer">
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
<Canvas x:Name="canvas"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Height="0"
Width="0">
<Rectangle x:Name="OpaqueRect"
Fill="{Binding Background, ElementName=DropDownBorder}"
Height="{Binding ActualHeight, ElementName=DropDownBorder}"
Width="{Binding ActualWidth, ElementName=DropDownBorder}"/>
</Canvas>
<ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Grid>
</ScrollViewer>
</Border>
</theme:SystemDropShadowChrome>
</Popup>
<ToggleButton x:Name="toggleButton"
BorderBrush="{TemplateBinding BorderBrush}"
Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness}"
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Grid.ColumnSpan="2" />
<!--Style="{StaticResource &#269;}"-->
<ContentPresenter x:Name="contentPresenter"
Content="{TemplateBinding SelectionBoxItem}"
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}"
IsHitTestVisible="false"
Margin="{TemplateBinding Padding}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
<Setter Property="Margin" TargetName="shadow" Value="5"/>
<Setter Property="Color" TargetName="shadow" Value="#71000000"/>
</Trigger>
<Trigger Property="HasItems" Value="false">
<Setter Property="Height" TargetName="DropDownBorder" Value="95"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="BorderBrush" Value="#FA6EC9"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsGrouping" Value="true" />
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false" />
</MultiTrigger.Conditions>
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
</MultiTrigger>
<Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="false">
<Setter Property="Canvas.Top" TargetName="OpaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}"/>
<Setter Property="Canvas.Left" TargetName="OpaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style x:Key="ZuneComboBoxStyle" TargetType="{x:Type ComboBox}">
<!--<Setter Property="FocusVisualStyle" Value="{StaticResource &#221;}"/>-->
<Setter Property="Background" Value="{StaticResource NormalComboBoxBackgroundBrush}"/>
<Setter Property="Foreground" Value="#606060"/>
<Setter Property="TextElement.FontWeight" Value="SemiBold"/>
<Setter Property="BorderThickness" Value="1" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="Padding" Value="6,3,5,3"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
<Setter Property="ScrollViewer.PanningMode" Value="Both"/>
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
<Setter Property="Template" Value="{StaticResource ZuneComboBoxTemplate}" />
<Style.Triggers>
<Trigger Property="IsEditable" Value="true">
<Setter Property="IsTabStop" Value="false"/>
<Setter Property="Padding" Value="2"/>
<!--<Setter Property="Template" Value="{StaticResource &#270;}"/>-->
</Trigger>
</Style.Triggers>
</Style>
<SolidColorBrush x:Key="&#273;" Color="#1F26A0DA" />
<SolidColorBrush x:Key="&#274;" Color="#A826A0DA" />
<SolidColorBrush x:Key="&#275;" Color="#3D26A0DA" />
<SolidColorBrush x:Key="&#276;" Color="#FF26A0DA" />
<SolidColorBrush x:Key="&#277;" Color="#2E0080FF" />
<SolidColorBrush x:Key="&#278;" Color="#99006CD9" />
<SolidColorBrush x:Key="&#279;" Color="#3DDADADA" />
<SolidColorBrush x:Key="&#280;" Color="#FFDADADA" />
<SolidColorBrush x:Key="&#281;" Color="#FF26A0DA" />
<SolidColorBrush x:Key="&#282;" Color="#5426A0DA" />
<SolidColorBrush x:Key="&#283;" Color="#FF26A0DA" />
<Style x:Key="ZuneComboBoxItemStyle" TargetType="{x:Type ComboBoxItem}">
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Padding" Value="4,1" />
<Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
<Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="FocusVisualStyle" Value="{StaticResource &#221;}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBoxItem}">
<Border x:Name="Bd"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="true">
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="Bd" Property="TextElement.Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
</Trigger>
<Trigger Property="IsEnabled" Value="True">
<Setter TargetName="Bd" Property="TextElement.Foreground" Value="#3D4042" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="False" />
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="UIElement.IsKeyboardFocused" Value="False" />
</MultiTrigger.Conditions>
<Setter TargetName="Bd" Property="Background" Value="#E7E8E8" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="True" />
<Condition Property="IsMouseOver" Value="False" />
</MultiTrigger.Conditions>
<Setter TargetName="Bd" Property="Background" Value="#D8D8D9" />
<Setter TargetName="Bd" Property="TextElement.Foreground" Value="#1D1D1D" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="True" />
<Condition Property="IsMouseOver" Value="True" />
</MultiTrigger.Conditions>
<Setter TargetName="Bd" Property="Background" Value="#E7E8E8" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="False" />
<Condition Property="IsMouseOver" Value="True" />
</MultiTrigger.Conditions>
<Setter TargetName="Bd" Property="Background" Value="#E7E8E8" />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- Focus Visual -->
<Style x:Key="&#221;">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle Margin="2" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>