From 47019d4982dd43c9d380e22e2275e2fbe04c3a76 Mon Sep 17 00:00:00 2001 From: Carbon Date: Wed, 20 Jan 2021 15:29:29 -0600 Subject: [PATCH] Implement font outline and animated list --- AUCapture-WPF/AUCapture-WPF.csproj | 1 + AUCapture-WPF/App.xaml | 2 + AUCapture-WPF/Controls/BindingProxy.cs | 31 ++++++++++++++ AUCapture-WPF/Controls/PlayerControl.xaml | 12 ++++-- AUCapture-WPF/Controls/SplashScreen.xaml | 12 ++++++ AUCapture-WPF/Controls/SplashScreen.xaml.cs | 28 +++++++++++++ AUCapture-WPF/Converters/BrushInverter.cs | 40 +++++++++++++++++++ .../Converters/GameStateToVisability.cs | 35 ++++++++++++++++ AUCapture-WPF/MainWindow.xaml | 6 ++- AUCapture-WPF/MainWindow.xaml.cs | 1 + 10 files changed, 163 insertions(+), 5 deletions(-) create mode 100644 AUCapture-WPF/Controls/BindingProxy.cs create mode 100644 AUCapture-WPF/Controls/SplashScreen.xaml create mode 100644 AUCapture-WPF/Controls/SplashScreen.xaml.cs create mode 100644 AUCapture-WPF/Converters/BrushInverter.cs create mode 100644 AUCapture-WPF/Converters/GameStateToVisability.cs diff --git a/AUCapture-WPF/AUCapture-WPF.csproj b/AUCapture-WPF/AUCapture-WPF.csproj index 57feb953..96b52cf7 100644 --- a/AUCapture-WPF/AUCapture-WPF.csproj +++ b/AUCapture-WPF/AUCapture-WPF.csproj @@ -72,6 +72,7 @@ + diff --git a/AUCapture-WPF/App.xaml b/AUCapture-WPF/App.xaml index 2165e5c7..e317a904 100644 --- a/AUCapture-WPF/App.xaml +++ b/AUCapture-WPF/App.xaml @@ -7,6 +7,8 @@ + + ./Resources/AUFont.ttf#AUFont diff --git a/AUCapture-WPF/Controls/BindingProxy.cs b/AUCapture-WPF/Controls/BindingProxy.cs new file mode 100644 index 00000000..d28d1853 --- /dev/null +++ b/AUCapture-WPF/Controls/BindingProxy.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace AUCapture_WPF.Controls +{ + public class BindingProxy : Freezable + { + #region Overrides of Freezable + + protected override Freezable CreateInstanceCore() + { + return new BindingProxy(); + } + + #endregion + + public object Data + { + get { return (object)GetValue(DataProperty); } + set { SetValue(DataProperty, value); } + } + + // Using a DependencyProperty as the backing store for Data. This enables animation, styling, binding, etc... + public static readonly DependencyProperty DataProperty = + DependencyProperty.Register("Data", typeof(object), typeof(BindingProxy), new UIPropertyMetadata(null)); + } +} diff --git a/AUCapture-WPF/Controls/PlayerControl.xaml b/AUCapture-WPF/Controls/PlayerControl.xaml index 893283be..a4cf1b85 100644 --- a/AUCapture-WPF/Controls/PlayerControl.xaml +++ b/AUCapture-WPF/Controls/PlayerControl.xaml @@ -5,6 +5,8 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" xmlns:converters1="clr-namespace:AUCapture_WPF.Converters" + xmlns:hc="https://handyorg.github.io/handycontrol" + xmlns:controls="clr-namespace:AUCapture_WPF.Controls" mc:Ignorable="d" x:Name="PlayerControlWindow" d:DesignHeight="212" d:DesignWidth="148"> @@ -14,6 +16,7 @@ + @@ -64,9 +67,12 @@ - + + + + diff --git a/AUCapture-WPF/Controls/SplashScreen.xaml b/AUCapture-WPF/Controls/SplashScreen.xaml new file mode 100644 index 00000000..ede655d3 --- /dev/null +++ b/AUCapture-WPF/Controls/SplashScreen.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/AUCapture-WPF/Controls/SplashScreen.xaml.cs b/AUCapture-WPF/Controls/SplashScreen.xaml.cs new file mode 100644 index 00000000..2df5f8b7 --- /dev/null +++ b/AUCapture-WPF/Controls/SplashScreen.xaml.cs @@ -0,0 +1,28 @@ +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 AUCapture_WPF.Controls +{ + /// + /// Interaction logic for SplashScreen.xaml + /// + public partial class SplashScreen : UserControl + { + public SplashScreen() + { + InitializeComponent(); + } + } +} diff --git a/AUCapture-WPF/Converters/BrushInverter.cs b/AUCapture-WPF/Converters/BrushInverter.cs new file mode 100644 index 00000000..77f58fc0 --- /dev/null +++ b/AUCapture-WPF/Converters/BrushInverter.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using System.Windows.Media; +using AmongUsCapture; + +namespace AUCapture_WPF.Converters +{ + class GameStateToVisability: IValueConverter + { + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is GameState statey) + { + if (statey == GameState.MENU) + { + return System.Windows.Visibility.Hidden; + } + else + { + return System.Windows.Visibility.Visible; + } + } + else + { + return System.Windows.Visibility.Hidden; + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/AUCapture-WPF/Converters/GameStateToVisability.cs b/AUCapture-WPF/Converters/GameStateToVisability.cs new file mode 100644 index 00000000..0ba5a543 --- /dev/null +++ b/AUCapture-WPF/Converters/GameStateToVisability.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using System.Windows.Media; + +namespace AUCapture_WPF.Converters +{ + class BrushInverter : IValueConverter + { + public static Color Invert (Color color) + { + return Color.FromRgb((byte) (255 - color.R), (byte) (255 - color.G), (byte) (255 - color.B)); + } + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is SolidColorBrush) + { + var brushy = (SolidColorBrush) value; + var inverted = Invert(brushy.Color); + return new SolidColorBrush(inverted); + } + + return new SolidColorBrush(Color.FromRgb(0, 0, 0)); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/AUCapture-WPF/MainWindow.xaml b/AUCapture-WPF/MainWindow.xaml index f2fc83b6..a459e8da 100644 --- a/AUCapture-WPF/MainWindow.xaml +++ b/AUCapture-WPF/MainWindow.xaml @@ -10,6 +10,7 @@ xmlns:converters="clr-namespace:AUCapture_WPF.Converters" xmlns:controls="clr-namespace:AUCapture_WPF.Controls" xmlns:wpf="clr-namespace:LoadingIndicators.WPF;assembly=LoadingIndicators.WPF" + xmlns:hc="https://handyorg.github.io/handycontrol" mc:Ignorable="d" Style="{DynamicResource MahApps.Styles.MetroWindow.Clean}" ResizeMode="CanResize" @@ -39,6 +40,7 @@ + @@ -243,7 +245,7 @@ Visibility="{Binding Connected, Converter={StaticResource BooleanToVisibilityConverter}}" Grid.ColumnSpan="3" Grid.RowSpan="3" Header="Players" ScrollViewer.VerticalScrollBarVisibility="Disabled"> - + - + diff --git a/AUCapture-WPF/MainWindow.xaml.cs b/AUCapture-WPF/MainWindow.xaml.cs index 7ee32b18..de450779 100644 --- a/AUCapture-WPF/MainWindow.xaml.cs +++ b/AUCapture-WPF/MainWindow.xaml.cs @@ -598,6 +598,7 @@ private void GameStateChangedHandler(object sender, GameStateChangedEventArgs e) setGameCode(""); Dispatcher.Invoke((Action) (() => { + context.GameState = e.NewState; foreach (var player in context.Players) {