Remove AbstractUI implementation (for now)

This commit is contained in:
Joshua Askharoun
2021-04-25 23:55:04 -05:00
parent bd946f2700
commit c8cf308cc3
42 changed files with 50 additions and 1536 deletions
+2 -2
View File
@@ -63,9 +63,9 @@ namespace ZuneModCore.Mods
public override Task<bool> Apply()
{
return Task.FromResult(true);
// TODO: Use user choices from AbstractUI
foreach (AbstractUIElement uiElem in OptionsUI.Items)
if (uiElem is AbstractBooleanUIElement boolElem && boolElem.State)
if (uiElem is AbstractBooleanUIElement boolElem)// && boolElem.State)
SetFeatureOverride(boolElem.Id, true);
return Task.FromResult(true);
+5 -5
View File
@@ -31,12 +31,12 @@ namespace ZuneModCore.Mods
public override IReadOnlyList<Type>? DependentMods => null;
public override async Task<bool> Apply()
public override Task<bool> Apply()
{
// Open ZuneServices.dll
FileInfo zsDllInfo = new(Path.Combine(ZuneInstallDir, "ZuneService.dll"));
if (!zsDllInfo.Exists)
return false;
return Task.FromResult(true);
using FileStream zsDll = zsDllInfo.Open(FileMode.Open);
using BinaryWriter zsDllWriter = new(zsDll);
using BinaryReader zsDllReader = new(zsDll);
@@ -45,7 +45,7 @@ namespace ZuneModCore.Mods
zsDllReader.BaseStream.Position = 0x12C824;
var versionBytes = zsDllReader.ReadBytes(ZUNE_4_8_VERSION_BYTES.Length * 2);
if (versionBytes[0] != '4' || versionBytes[2] != '.' || versionBytes[4] != '8')
return false;
return Task.FromResult(true);
// Patch ZuneServices.dll to use zunes.tk instead of zune.net
zsDllReader.BaseStream.Position = ZUNESERVICES_ENDPOINTS_BLOCK_OFFSET;
@@ -53,7 +53,7 @@ namespace ZuneModCore.Mods
endpointBlock = endpointBlock.Replace("zune.net", "zunes.tk");
byte[] endpointBytes = System.Text.Encoding.Unicode.GetBytes(endpointBlock);
if (endpointBytes.Length != ZUNESERVICES_ENDPOINTS_BLOCK_LENGTH)
return false;
return Task.FromResult(false);
zsDllWriter.Seek(ZUNESERVICES_ENDPOINTS_BLOCK_OFFSET, SeekOrigin.Begin);
zsDllWriter.Write(endpointBytes);
@@ -69,7 +69,7 @@ namespace ZuneModCore.Mods
SetFeatureOverride("Social", true);
SetFeatureOverride("Videos", true);
return true;
return Task.FromResult(true);
}
public override Task<bool> Reset()
@@ -1,17 +0,0 @@
using OwlCore.AbstractUI.Models;
using System.Windows;
using System.Windows.Controls;
namespace ZuneModdingHelper.AbstractUI.Controls
{
/// <summary>
/// A control that displays an <see cref="AbstractBooleanUIElement"/>.
/// </summary>
public sealed partial class AbstractBooleanUIElementPresenter : Control
{
static AbstractBooleanUIElementPresenter()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(AbstractBooleanUIElementPresenter), new FrameworkPropertyMetadata(typeof(AbstractBooleanUIElementPresenter)));
}
}
}
@@ -1,20 +0,0 @@
using OwlCore.AbstractUI.Models;
using System.Windows;
using System.Windows.Controls;
namespace ZuneModdingHelper.AbstractUI.Controls
{
/// <summary>
/// A control that displays an <see cref="AbstractButton"/>.
/// </summary>
public sealed partial class AbstractButtonPresenter : Control
{
/// <summary>
/// Creates a new instance of <see cref="AbstractButtonPresenter"/>.
/// </summary>
public AbstractButtonPresenter()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(AbstractButtonPresenter), new FrameworkPropertyMetadata(typeof(AbstractButtonPresenter)));
}
}
}
@@ -1,17 +0,0 @@
using System.Windows;
using System.Windows.Controls;
using OwlCore.AbstractUI.Models;
namespace ZuneModdingHelper.AbstractUI.Controls
{
/// <summary>
/// A control that displays an <see cref="AbstractDataList"/>.
/// </summary>
public sealed partial class AbstractDataListPresenter : Control
{
static AbstractDataListPresenter()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(AbstractDataListPresenter), new FrameworkPropertyMetadata(typeof(AbstractDataListPresenter)));
}
}
}
@@ -1,17 +0,0 @@
using System.Windows;
using System.Windows.Controls;
using OwlCore.AbstractUI.Models;
namespace ZuneModdingHelper.AbstractUI.Controls
{
/// <summary>
/// A control that displays an <see cref="AbstractMultiChoiceUIElement"/>.
/// </summary>
public sealed partial class AbstractMultiChoicePresenter : Control
{
static AbstractMultiChoicePresenter()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(AbstractMultiChoicePresenter), new FrameworkPropertyMetadata(typeof(AbstractMultiChoicePresenter)));
}
}
}
@@ -1,17 +0,0 @@
using System.Windows;
using System.Windows.Controls;
using OwlCore.AbstractUI.Models;
namespace ZuneModdingHelper.AbstractUI.Controls
{
/// <summary>
/// A control that displays an <see cref="AbstractMutableDataList"/>.
/// </summary>
public sealed partial class AbstractMutableDataListPresenter : Control
{
static AbstractMutableDataListPresenter()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(AbstractMutableDataListPresenter), new FrameworkPropertyMetadata(typeof(AbstractMutableDataListPresenter)));
}
}
}
@@ -1,17 +0,0 @@
using System.Windows;
using System.Windows.Controls;
using OwlCore.AbstractUI.Models;
namespace ZuneModdingHelper.AbstractUI.Controls
{
/// <summary>
/// A control that displays an <see cref="AbstractProgressUIElement"/>.
/// </summary>
public sealed partial class AbstractProgessUIElementPresenter : Control
{
static AbstractProgessUIElementPresenter()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(AbstractProgessUIElementPresenter), new FrameworkPropertyMetadata(typeof(AbstractProgessUIElementPresenter)));
}
}
}
@@ -1,17 +0,0 @@
using System.Windows;
using System.Windows.Controls;
using OwlCore.AbstractUI.Models;
namespace ZuneModdingHelper.AbstractUI.Controls
{
/// <summary>
/// A control that displays an <see cref="AbstractTextBox"/>.
/// </summary>
public sealed partial class AbstractRichTextBlockPresenter : Control
{
static AbstractRichTextBlockPresenter()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(AbstractRichTextBlockPresenter), new FrameworkPropertyMetadata(typeof(AbstractRichTextBlockPresenter)));
}
}
}
@@ -1,17 +0,0 @@
using System.Windows;
using System.Windows.Controls;
using OwlCore.AbstractUI.Models;
namespace ZuneModdingHelper.AbstractUI.Controls
{
/// <summary>
/// A control that displays an <see cref="AbstractTextBox"/>.
/// </summary>
public sealed partial class AbstractTextBoxPresenter : Control
{
static AbstractTextBoxPresenter()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(AbstractTextBoxPresenter), new FrameworkPropertyMetadata(typeof(AbstractTextBoxPresenter)));
}
}
}
@@ -1,109 +0,0 @@
using System.Windows;
using System.Windows.Controls;
using OwlCore.AbstractUI.ViewModels;
using Microsoft.Toolkit.Diagnostics;
using OwlCore.AbstractUI.Models;
namespace ZuneModdingHelper.AbstractUI.Controls
{
/// <summary>
/// The template selector used to display Abstract UI elements. Use this to define your own custom styles for each control. You may specify the existing, default styles for those you don't want to override.
/// </summary>
public class AbstractUIGroupItemTemplateSelector : DataTemplateSelector
{
/// <summary>
/// Creates a new instance of <see cref="AbstractUIGroupItemTemplateSelector"/>.
/// </summary>
public AbstractUIGroupItemTemplateSelector()
{
object textBoxTemplate = new Themes.AbstractTextBoxStyle()["DefaultAbstractTextBoxTemplate"];
if (textBoxTemplate == null)
ThrowHelper.ThrowArgumentNullException<DataTemplate>(nameof(textBoxTemplate));
object dataListTemplate = new Themes.AbstractDataListStyle()["DefaultAbstractDataListTemplate"];
if (dataListTemplate == null)
ThrowHelper.ThrowArgumentNullException<DataTemplate>(nameof(dataListTemplate));
object mutableDataListTemplate = new Themes.AbstractMutableDataListStyle()["DefaultAbstractMutableDataListTemplate"];
if (mutableDataListTemplate == null)
ThrowHelper.ThrowArgumentNullException<DataTemplate>(nameof(mutableDataListTemplate));
object buttonTemplate = new Themes.AbstractButtonStyle()["DefaultAbstractButtonTemplate"];
if (buttonTemplate == null)
ThrowHelper.ThrowArgumentNullException<DataTemplate>(nameof(buttonTemplate));
object multiChoiceTemplate = new Themes.AbstractMultiChoiceUIElementStyle()["DefaultAbstractMultipleChoiceTemplate"];
if (multiChoiceTemplate == null)
ThrowHelper.ThrowArgumentNullException<DataTemplate>(nameof(multiChoiceTemplate));
object booleanTemplate = new Themes.AbstractBooleanUIElementStyle()["DefaultAbstractBooleanUIElementTemplate"];
if (booleanTemplate == null)
ThrowHelper.ThrowArgumentNullException<DataTemplate>(nameof(booleanTemplate));
object progressTemplate = new Themes.AbstractProgressUIElementStyle()["DefaultAbstractProgressUIElementTemplate"];
if (progressTemplate == null)
ThrowHelper.ThrowArgumentNullException<DataTemplate>(nameof(progressTemplate));
TextBoxTemplate = (DataTemplate)textBoxTemplate;
DataListTemplate = (DataTemplate)dataListTemplate;
ButtonTemplate = (DataTemplate)buttonTemplate;
MutableDataListTemplate = (DataTemplate)mutableDataListTemplate;
MultiChoiceTemplate = (DataTemplate)multiChoiceTemplate;
BooleanTemplate = (DataTemplate)booleanTemplate;
ProgressTemplate = (DataTemplate)progressTemplate;
}
/// <summary>
/// The data template used to display an <see cref="AbstractTextBox"/>.
/// </summary>
public DataTemplate TextBoxTemplate { get; set; }
/// <summary>
/// The data template used to display an <see cref="AbstractDataList"/>.
/// </summary>
public DataTemplate DataListTemplate { get; set; }
/// <summary>
/// The data template used to display an <see cref="AbstractMutableDataList"/>.
/// </summary>
public DataTemplate MutableDataListTemplate { get; set; }
/// <summary>
/// The data template used to display an <see cref="AbstractButton"/>.
/// </summary>
public DataTemplate ButtonTemplate { get; set; }
/// <summary>
/// The data template used to display an <see cref="AbstractBooleanUIElement"/>.
/// </summary>
public DataTemplate BooleanTemplate { get; set; }
/// <summary>
/// The data template used to display an <see cref="AbstractProgressUIElement"/>.
/// </summary>
public DataTemplate ProgressTemplate { get; set; }
/// <summary>
/// The data template used to display an <see cref="AbstractMultiChoiceUIElement"/>.
/// </summary>
public DataTemplate MultiChoiceTemplate { get; set; }
/// <inheritdoc />
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
System.Diagnostics.Debug.WriteLine($"{item.GetType()} template selecting for {nameof(AbstractUIGroupItemTemplateSelector)}");
return item switch
{
AbstractTextBoxViewModel _ => TextBoxTemplate,
AbstractDataListViewModel _ => DataListTemplate,
AbstractButtonViewModel _ => ButtonTemplate,
AbstractMutableDataListViewModel _ => MutableDataListTemplate,
AbstractMultiChoiceUIElementViewModel _ => MultiChoiceTemplate,
AbstractBooleanViewModel _ => BooleanTemplate,
AbstractProgressUIElement _ => ProgressTemplate,
_ => base.SelectTemplate(item, container)
};
}
}
}
@@ -1,117 +0,0 @@
using System.Windows;
using System.Windows.Controls;
using OwlCore.AbstractUI.ViewModels;
using OwlCore.AbstractUI.Models;
namespace ZuneModdingHelper.AbstractUI.Controls
{
/// <summary>
/// Displays a group of abstract UI elements.
/// </summary>
public sealed partial class AbstractUIGroupPresenter : Control
{
private bool _dataContextBeingSet;
/// <summary>
/// Backing property for <see cref="ViewModel"/>.
/// </summary>
public static readonly DependencyProperty ViewModelProperty =
DependencyProperty.Register(nameof(ViewModel), typeof(AbstractUIElementGroupViewModel), typeof(AbstractUIGroupPresenter), new PropertyMetadata(null, (d, e) => ((AbstractUIGroupPresenter)d).OnViewModelChanged()));
/// <summary>
/// Backing property for <see cref="TemplateSelector"/>.
/// </summary>
public static readonly DependencyProperty TemplateSelectorProperty =
DependencyProperty.Register(nameof(TemplateSelector), typeof(DataTemplateSelector), typeof(AbstractUIGroupPresenter), new PropertyMetadata(null));
/// <summary>
/// The ViewModel for this UserControl.
/// </summary>
public AbstractUIElementGroupViewModel? ViewModel
{
get => (AbstractUIElementGroupViewModel)GetValue(ViewModelProperty);
set => SetValue(ViewModelProperty, value);
}
/// <summary>
/// The template selector used to display Abstract UI elements. Use this to define your own custom styles for each control. You may specify the existing, default styles for those you don't want to override.
/// </summary>
public DataTemplateSelector? TemplateSelector
{
get => (DataTemplateSelector)GetValue(TemplateSelectorProperty);
set => SetValue(TemplateSelectorProperty, value);
}
/// <summary>
/// Creates a new instance of <see cref="AbstractUIGroupPresenter"/>.
/// </summary>
public AbstractUIGroupPresenter()
{
AttachEvents();
}
static AbstractUIGroupPresenter()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(AbstractUIGroupPresenter), new FrameworkPropertyMetadata(typeof(AbstractUIGroupPresenter)));
}
private void AttachEvents()
{
Loaded += OnLoaded;
DataContextChanged += OnDataContextChanged;
}
private void DetachEvents()
{
DataContextChanged -= OnDataContextChanged;
}
private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (_dataContextBeingSet)
return;
_dataContextBeingSet = true;
if (DataContext is AbstractUIElementGroup elementGroup)
ViewModel = new AbstractUIElementGroupViewModel(elementGroup);
if (DataContext is AbstractUIElementGroupViewModel elementGroupViewModel)
ViewModel = elementGroupViewModel;
_dataContextBeingSet = false;
}
private void OnLoaded(object sender, RoutedEventArgs e)
{
Loaded -= OnLoaded;
Unloaded += OnUnloaded;
}
private void OnUnloaded(object sender, RoutedEventArgs e)
{
Unloaded -= OnUnloaded;
DetachEvents();
}
/// <summary>
/// Raised when the <see cref="ViewModel"/> changes.
/// </summary>
public void OnViewModelChanged()
{
if (_dataContextBeingSet)
return;
_dataContextBeingSet = true;
DataContext = ViewModel;
_dataContextBeingSet = false;
if (GetTemplateChild("GroupItemsControl") is ItemsControl ic)
{
ic.ItemsSource = ViewModel.Items;
}
}
}
}
@@ -1,54 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace ZuneModdingHelper.AbstractUI.Controls
{
/// <summary>
/// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.
///
/// Step 1a) Using this custom control in a XAML file that exists in the current project.
/// Add this XmlNamespace attribute to the root element of the markup file where it is
/// to be used:
///
/// xmlns:MyNamespace="clr-namespace:ZuneModdingHelper.AbstractUI.Controls"
///
///
/// Step 1b) Using this custom control in a XAML file that exists in a different project.
/// Add this XmlNamespace attribute to the root element of the markup file where it is
/// to be used:
///
/// xmlns:MyNamespace="clr-namespace:ZuneModdingHelper.AbstractUI.Controls;assembly=ZuneModdingHelper.AbstractUI.Controls"
///
/// You will also need to add a project reference from the project where the XAML file lives
/// to this project and Rebuild to avoid compilation errors:
///
/// Right click on the target project in the Solution Explorer and
/// "Add Reference"->"Projects"->[Browse to and select this project]
///
///
/// Step 2)
/// Go ahead and use your control in the XAML file.
///
/// <MyNamespace:CustomControl1/>
///
/// </summary>
public class CustomControl1 : Control
{
static CustomControl1()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomControl1), new FrameworkPropertyMetadata(typeof(CustomControl1)));
}
}
}
@@ -1,53 +0,0 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ZuneModdingHelper.AbstractUI.Themes.AbstractBooleanUIElementStyle"
xmlns:abstractUI="clr-namespace:OwlCore.AbstractUI.ViewModels;assembly=OwlCore"
xmlns:controls="clr-namespace:ZuneModdingHelper.AbstractUI.Controls"
xmlns:b="http://schemas.microsoft.com/xaml/behaviors">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/AbstractUI/Themes/AbstractUIResources.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style TargetType="{x:Type controls:AbstractButtonPresenter}">
<Style.Setters>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:AbstractButtonPresenter}">
<ContentControl ContentTemplate="{StaticResource DefaultAbstractBooleanUIElementTemplate}"
HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>
<DataTemplate x:Key="DefaultAbstractBooleanUIElementTemplate" DataType="{x:Type abstractUI:AbstractBooleanViewModel}">
<StackPanel>
<TextBlock Text="{Binding Title}" FontSize="{StaticResource DefaultAbstractUITitleFontSize}" ToolTip="{Binding TooltipText}" />
<TextBlock Text="{Binding Subtitle}" FontSize="{StaticResource DefaultAbstractUISubtitleFontSize}"
FontWeight="{StaticResource DefaultAbstractUISubtitleFontWeight}"
Opacity="{StaticResource DefaultAbstractUISubtitleOpacity}"/>
<!--Visibility="{Binding convertvis:NotNullOrEmptyToVisibilityConverter.Convert(Subtitle), Mode=OneWay}"/>-->
<CheckBox ToolTip="{Binding TooltipText, Mode=OneWay}" Content="{Binding Label, Mode=OneWay}" IsChecked="{Binding IsToggled, Mode=TwoWay}">
<b:Interaction.Triggers>
<b:EventTrigger EventName="Toggled">
<b:InvokeCommandAction Command="{Binding ToggledCommand}" />
</b:EventTrigger>
</b:Interaction.Triggers>
</CheckBox>
<!--<ToggleSwitch ToolTip="{Binding TooltipText, Mode=OneWay}" OffContent="{Binding Label, Mode=OneWay}" OnContent="{Binding Label, Mode=OneWay}" IsOn="{Binding IsToggled, Mode=TwoWay}">
<b:Interaction.Triggers>
<b:EventTrigger EventName="Toggled">
<b:InvokeCommandAction Command="{Binding ToggledCommand}" />
</b:EventTrigger>
</b:Interaction.Triggers>
</ToggleSwitch>-->
</StackPanel>
</DataTemplate>
</ResourceDictionary>
@@ -1,12 +0,0 @@
using System.Windows;
namespace ZuneModdingHelper.AbstractUI.Themes
{
public sealed partial class AbstractBooleanUIElementStyle : ResourceDictionary
{
public AbstractBooleanUIElementStyle()
{
InitializeComponent();
}
}
}
@@ -1,64 +0,0 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ZuneModdingHelper.AbstractUI.Themes.AbstractButtonStyle"
xmlns:abstractUI="clr-namespace:OwlCore.AbstractUI.ViewModels;assembly=OwlCore"
xmlns:controls="clr-namespace:ZuneModdingHelper.AbstractUI.Controls"
xmlns:local="clr-namespace:ZuneModdingHelper.AbstractUI.Themes">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/AbstractUI/Themes/AbstractUIResources.xaml" />
</ResourceDictionary.MergedDictionaries>
<local:AbstractButtonTemplateSelector x:Key="ButtonStyleSelector">
<local:AbstractButtonTemplateSelector.GenericStyle>
<Style TargetType="{x:Type Button}"/>
</local:AbstractButtonTemplateSelector.GenericStyle>
<local:AbstractButtonTemplateSelector.ConfirmStyle>
<Style TargetType="{x:Type Button}">
<!--<Style.Setters>
<Setter Property="Background" Value="{ThemeResource SystemControlHighlightAccentBrush}"/>
</Style.Setters>-->
</Style>
</local:AbstractButtonTemplateSelector.ConfirmStyle>
<local:AbstractButtonTemplateSelector.DeleteStyle>
<Style TargetType="{x:Type Button}">
<Style.Setters>
<Setter Property="Background" Value="Red"/>
</Style.Setters>
</Style>
</local:AbstractButtonTemplateSelector.DeleteStyle>
</local:AbstractButtonTemplateSelector>
<Style TargetType="{x:Type controls:AbstractButtonPresenter}">
<Style.Setters>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:AbstractButtonPresenter}">
<ContentControl ContentTemplate="{StaticResource DefaultAbstractButtonTemplate}"
HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>
<DataTemplate x:Key="DefaultAbstractButtonTemplate" DataType="{x:Type abstractUI:AbstractButtonViewModel}">
<StackPanel>
<TextBlock Text="{Binding Title, Mode=OneWay}" FontSize="{StaticResource DefaultAbstractUITitleFontSize}" ToolTip="{Binding TooltipText, Mode=OneWay}" />
<TextBlock Text="{Binding Subtitle, Mode=OneWay}" FontSize="{StaticResource DefaultAbstractUISubtitleFontSize}"
FontWeight="{StaticResource DefaultAbstractUISubtitleFontWeight}"
Opacity="{StaticResource DefaultAbstractUISubtitleOpacity}"/>
<!--Visibility="{Binding convertvis:NotNullOrEmptyToVisibilityConverter.Convert(Subtitle), Mode=OneWay}"/>-->
<Button Style="{Binding Type, Converter={StaticResource ButtonStyleSelector}, Mode=OneWay}" Command="{Binding ClickCommand}">
<StackPanel Orientation="Horizontal"><!--Spacing="8">-->
<!--<FontIcon Glyph="{Binding IconCode}" FontFamily="Segoe MDL2 Assets" Grid.Column="0" FontSize="16"/>-->
<TextBlock Text="{Binding Text}" Grid.Column="1"/>
</StackPanel>
</Button>
</StackPanel>
</DataTemplate>
</ResourceDictionary>
@@ -1,12 +0,0 @@
using System.Windows;
namespace ZuneModdingHelper.AbstractUI.Themes
{
public sealed partial class AbstractButtonStyle : ResourceDictionary
{
public AbstractButtonStyle()
{
InitializeComponent();
}
}
}
@@ -1,68 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using OwlCore.AbstractUI.Models;
using OwlCore.AbstractUI.ViewModels;
using Microsoft.Toolkit.Diagnostics;
using ZuneModdingHelper.AbstractUI.Controls;
using System.Windows.Data;
using System.Globalization;
namespace ZuneModdingHelper.AbstractUI.Themes
{
/// <summary>
/// Selects the template that is used for an <see cref="AbstractButton"/> based on the <see cref="AbstractButton.Type"/>.
/// </summary>
public class AbstractButtonTemplateSelector : IValueConverter
{
/// <summary>
/// The data template used to a display an <see cref="AbstractButton"/> with a generic style.
/// </summary>
public Style? GenericStyle { get; set; }
/// <summary>
/// The data template used to a display an <see cref="AbstractButton"/> with a confirmation style.
/// </summary>
public Style? ConfirmStyle { get; set; }
/// <summary>
/// The data template used to a display an <see cref="AbstractButton"/> with a deletion style.
/// </summary>
public Style? DeleteStyle { get; set; }
/// <inheritdoc />
public object Convert(object value, Type targetType, object parameter, string language)
{
var type = AbstractButtonType.Generic;
if (value is AbstractButtonType vType)
type = vType;
if (value is AbstractButtonViewModel buttonViewModel)
type = buttonViewModel.Type;
else if (value is AbstractButton button)
type = button.Type;
return type switch
{
AbstractButtonType.Generic => GenericStyle ?? ThrowHelper.ThrowArgumentNullException<Style>(),
AbstractButtonType.Confirm => ConfirmStyle ?? GenericStyle ?? ThrowHelper.ThrowArgumentNullException<Style>(),
AbstractButtonType.Cancel => DeleteStyle ?? GenericStyle ?? ThrowHelper.ThrowArgumentNullException<Style>(),
_ => throw new NotImplementedException(),
};
}
/// <inheritdoc/>
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
Convert(value, targetType, parameter, culture.Name);
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) =>
Convert(value, targetType, parameter, culture.Name);
}
}
@@ -1,125 +0,0 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ZuneModdingHelper.AbstractUI.Themes.AbstractDataListStyle"
xmlns:abstractUI="clr-namespace:OwlCore.AbstractUI.ViewModels;assembly=OwlCore"
xmlns:controls="clr-namespace:ZuneModdingHelper.AbstractUI.Controls"
xmlns:themes="clr-namespace:ZuneModdingHelper.AbstractUI.Themes">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/AbstractUI/Themes/AbstractUIResources.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style TargetType="{x:Type controls:AbstractDataListPresenter}">
<Style.Setters>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:AbstractDataListPresenter}">
<ContentControl ContentTemplate="{StaticResource DefaultAbstractDataListTemplate}"
HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>
<DataTemplate x:Key="DefaultAbstractDataListTemplate" DataType="{x:Type abstractUI:AbstractDataListViewModel}">
<StackPanel>
<TextBlock Text="{Binding Title}" FontSize="{StaticResource DefaultAbstractUITitleFontSize}" ToolTip="{Binding TooltipText}" />
<TextBlock Text="{Binding Subtitle}" FontSize="{StaticResource DefaultAbstractUISubtitleFontSize}"
FontWeight="{StaticResource DefaultAbstractUISubtitleFontWeight}"
Opacity="{StaticResource DefaultAbstractUISubtitleOpacity}"/>
<!--Visibility="{Binding convertvis:NotNullOrEmptyToVisibilityConverter.Convert(Subtitle)}"/>-->
<ListView x:Name="PrimaryListView" Visibility="{Binding IsList}" ItemsSource="{Binding Items}" Margin="10">
<!--<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<ListViewItemPresenter />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>-->
<ListView.ItemTemplate>
<DataTemplate DataType="{x:Type abstractUI:AbstractUIMetadataViewModel}">
<Grid ToolTip="{Binding TooltipText}" Height="60">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border Grid.RowSpan="2" Margin="0,0,5,0"
Height="60" Width="60">
<!--<FontIcon Glyph="{Binding IconCode}" FontFamily="Segoe MDL2 Assets" FontSize="34" />-->
</Border>
<Image Grid.RowSpan="2" Margin="0,0,5,0"
x:Name="Thumbnail"
Height="60" Width="60"
Source="{Binding ImageSource, Mode=OneWay}" />
<TextBlock Grid.Column="1" Text="{Binding Title}" FontSize="22" VerticalAlignment="Center"/>
<!--Visibility="{Binding convertvis:NotNullOrEmptyToVisibilityConverter.Convert(Title)}"/>-->
<TextBlock x:Name="SubtitleTextBlock" Grid.Column="1" Grid.Row="1"
VerticalAlignment="Center"
Text="{Binding Subtitle}"
FontSize="16" FontWeight="Light" Opacity="0.75" />
<!--Visibility="{Binding convertvis:NotNullOrEmptyToVisibilityConverter.Convert(Subtitle)}"-->
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<ListView ItemsSource="{Binding Items}" Visibility="{Binding IsGrid}">
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<Grid x:Name="ContentBorder">
<ContentPresenter x:Name="ContentPresenter" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemTemplate>
<DataTemplate DataType="{x:Type abstractUI:AbstractUIMetadataViewModel}">
<Grid ToolTip="{Binding TooltipText}" Width="150" Margin="15">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border BorderBrush="White" BorderThickness="1" Height="150" Width="150">
<Grid>
<!--<FontIcon Glyph="{Binding IconCode}" FontFamily="Segoe MDL2 Assets" FontSize="34" />-->
<Image Source="{Binding ImageSource, Mode=OneWay}" />
</Grid>
</Border>
<TextBlock Text="{Binding Title}" FontSize="18" Grid.Row="1" />
<TextBlock x:Name="SubtitleTextBlock" Grid.Row="2"
Text="{Binding Subtitle}"
FontSize="14" FontWeight="Light" Opacity="0.5" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
</DataTemplate>
</ResourceDictionary>
@@ -1,12 +0,0 @@
using System.Windows;
namespace ZuneModdingHelper.AbstractUI.Themes
{
public sealed partial class AbstractDataListStyle : ResourceDictionary
{
public AbstractDataListStyle()
{
InitializeComponent();
}
}
}

Some files were not shown because too many files have changed in this diff Show More