Skip to content

Commit

Permalink
Implement font outline and animated list
Browse files Browse the repository at this point in the history
  • Loading branch information
CarbonNeuron committed Jan 20, 2021
1 parent 1d4f40e commit 47019d4
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 5 deletions.
1 change: 1 addition & 0 deletions AUCapture-WPF/AUCapture-WPF.csproj
Expand Up @@ -72,6 +72,7 @@
<ItemGroup>
<PackageReference Include="Config.Net" Version="4.15.0" />
<PackageReference Include="Config.Net.Json" Version="4.15.0" />
<PackageReference Include="HandyControl" Version="3.0.0" />
<PackageReference Include="Humanizer.Core" Version="2.8.26" />
<PackageReference Include="LoadingIndicators.WPF.Core" Version="1.0.1" />
<PackageReference Include="MahApps.Metro" Version="2.4.3" />
Expand Down
2 changes: 2 additions & 0 deletions AUCapture-WPF/App.xaml
Expand Up @@ -7,6 +7,8 @@
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/>
<!-- Theme setting -->
</ResourceDictionary.MergedDictionaries>
<FontFamily x:Key="AUFont">./Resources/AUFont.ttf#AUFont</FontFamily>
Expand Down
31 changes: 31 additions & 0 deletions 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));
}
}
12 changes: 9 additions & 3 deletions AUCapture-WPF/Controls/PlayerControl.xaml
Expand Up @@ -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">
Expand All @@ -14,6 +16,7 @@
<converters1:HatToImage x:Key="HatToImage" />
<converters1:HatToZ x:Key="HatToZ" />
<converters1:PetToImageConverter x:Key="PetToIm" />
<converters1:BrushInverter x:Key="BrushInverter"/>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />

</UserControl.Resources>
Expand Down Expand Up @@ -64,9 +67,12 @@
</Grid>
</Viewbox>
<Viewbox Grid.ColumnSpan="2" Grid.Row="0" StretchDirection="DownOnly" Stretch="Uniform" VerticalAlignment="Center">
<TextBlock Grid.RowSpan="2" HorizontalAlignment="Stretch" Padding="0" Margin="0" VerticalAlignment="Stretch"
FontFamily="{StaticResource AUFont}" Text="{Binding ElementName=PlayerControlWindow, Path=PlayerName}" FontSize="74"
FontStyle="Normal"/>
<Viewbox.Resources>
<controls:BindingProxy x:Key="Proxy" Data="{DynamicResource MahApps.Brushes.Text}"/>
</Viewbox.Resources>
<hc:OutlineText Grid.RowSpan="2" HorizontalAlignment="Stretch" Margin="0" VerticalAlignment="Stretch" Fill="{DynamicResource MahApps.Brushes.Text}"
Text="{Binding ElementName=PlayerControlWindow, Path=PlayerName}" FontSize="40"
FontStyle="Normal" FontWeight="Bold" FontStretch="Condensed" StrokePosition="Outside" StrokeThickness="3" Stroke="{Binding Source={StaticResource Proxy}, Path=Data, Converter={StaticResource BrushInverter}}"/>
</Viewbox>


Expand Down
12 changes: 12 additions & 0 deletions AUCapture-WPF/Controls/SplashScreen.xaml
@@ -0,0 +1,12 @@
<UserControl x:Class="AUCapture_WPF.Controls.SplashScreen"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:AUCapture_WPF.Controls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>

</Grid>
</UserControl>
28 changes: 28 additions & 0 deletions 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
{
/// <summary>
/// Interaction logic for SplashScreen.xaml
/// </summary>
public partial class SplashScreen : UserControl
{
public SplashScreen()
{
InitializeComponent();
}
}
}
40 changes: 40 additions & 0 deletions 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();
}
}
}
35 changes: 35 additions & 0 deletions 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();
}
}
}
6 changes: 4 additions & 2 deletions AUCapture-WPF/MainWindow.xaml
Expand Up @@ -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"
Expand Down Expand Up @@ -39,6 +40,7 @@
<converters:VisabilityInverterConverter x:Key="VisabilityInverterConverter" />
<converters:BoolToVisibilityConverterInverted x:Key="BoolToVisibilityConverterInverted" />
<converters:BoolInverter x:Key="BoolInverter" />
<converters:GameStateToVisability x:Key="GameStateToVisability"/>
<BitmapImage UriSource="Resources/Misc/status-connected.png" x:Key="status-connected"/>
<BitmapImage UriSource="Resources/Misc/status-disconnected.png" x:Key="status-disconnected"/>
</ResourceDictionary>
Expand Down Expand Up @@ -243,7 +245,7 @@
Visibility="{Binding Connected, Converter={StaticResource BooleanToVisibilityConverter}}"
Grid.ColumnSpan="3" Grid.RowSpan="3" Header="Players"
ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ItemsControl Grid.ColumnSpan="3" Grid.RowSpan="4" Name="PlayersList" ItemsSource="{Binding Players}">
<ItemsControl Visibility="{Binding GameState, Converter={StaticResource GameStateToVisability}}" Grid.ColumnSpan="3" Grid.RowSpan="4" Name="PlayersList" ItemsSource="{Binding Players}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<controls:PlayerControl PlayerName="{Binding Name}" Color="{Binding Color}"
Expand All @@ -253,7 +255,7 @@
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid IsItemsHost="True" Rows="3" />
<UniformGrid IsItemsHost="True" Rows="3" hc:PanelElement.FluidMoveBehavior="{StaticResource BehaviorXY400}" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
Expand Down
1 change: 1 addition & 0 deletions AUCapture-WPF/MainWindow.xaml.cs
Expand Up @@ -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)
{
Expand Down

0 comments on commit 47019d4

Please sign in to comment.