Skip to content

Commit

Permalink
Role select option & better MVVM bindings
Browse files Browse the repository at this point in the history
Code clean up 👎

Co-Authored-By: ClaraaXD <102316295+ClaraaXD@users.noreply.github.com>
  • Loading branch information
Rokuazery and ClaraImanuel committed Jun 4, 2022
1 parent d116efb commit 4de4c33
Show file tree
Hide file tree
Showing 52 changed files with 2,404 additions and 1,510 deletions.
665 changes: 12 additions & 653 deletions LoL Assist/App.xaml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions LoL Assist/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
Global.Config.debug = false;
Console.Title = "LoL Assist - Debug Console";
ToolTipService.ShowDurationProperty.OverrideMetadata(typeof(DependencyObject), new FrameworkPropertyMetadata(int.MaxValue));
Global.Config.debug = true;
//Console.Title = "LoL Assist - Debug Console";
ToolTipService.ShowDurationProperty.OverrideMetadata(typeof(DependencyObject), new FrameworkPropertyMetadata(int.MaxValue));

if (!Global.Config.debug)
{
Expand Down
8 changes: 4 additions & 4 deletions LoL Assist/BuildEditorWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
Margin="7,0,0,0" FontWeight="DemiBold" HorizontalAlignment="Left" VerticalAlignment="Center"/>
<Border VerticalAlignment="Bottom" Height="1" Background="{DynamicResource bBrushPrimary}" Margin="1.5,0"/>
<DockPanel HorizontalAlignment="Right">
<view:IconButton x:Name="CloseBtn" OnHoverColor="#E74856" VerticalAlignment="Center" ToolTip="Close"
Margin="0,0,6,0" Clicked="CloseBtn_Clicked"/>
<Button Template="{DynamicResource IconStyleButtonRed}" x:Name="CloseBtn" Tag="{DynamicResource XmarkIcon}" VerticalAlignment="Center" ToolTip="Close"
Margin="0,0,6,0" Click="CloseBtn_Click"/>
</DockPanel>
</Grid>

Expand Down Expand Up @@ -69,7 +69,7 @@
</DockPanel>
</DockPanel>
<TextBlock x:Name="saveStatus" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5"
Foreground="White" Text="{Binding Path=saveInfo}" FontSize="10" FontWeight="DemiBold"/>
Foreground="{Binding ElementName=saveStatus, Path=Text, Converter={StaticResource TextToForegroundConverter}}" Text="{Binding Path=saveInfo}" FontSize="10" FontWeight="DemiBold"/>
</Grid>

<Grid x:Name="ConfigGrid" Grid.Row="2" Margin="5,0,5,0" Background="Transparent"
Expand Down Expand Up @@ -206,7 +206,7 @@

<TextBlock Text="keystone:" VerticalAlignment="Center" Margin="0,0,0,3"/>
<ComboBox ItemContainerStyle="{DynamicResource FlatItemContainerStyle}" Style="{DynamicResource FlatComboboxStyle}"
ItemsSource="{Binding Path=KeystoneList, UpdateSourceTrigger=PropertyChanged}" ScrollViewer.CanContentScroll="False"
ItemsSource="{Binding Path=Keystones, UpdateSourceTrigger=PropertyChanged}" ScrollViewer.CanContentScroll="False"
SelectedItem="{Binding Path=SelectedKeystone, UpdateSourceTrigger=PropertyChanged}" ItemTemplate="{DynamicResource ItemImage}" Margin="0,0,0,5"
IsEnabled="{Binding ElementName=PrimaryPathList, Path=SelectedItem, Converter={StaticResource ItemToBoolConverter}}"/>

Expand Down
4 changes: 2 additions & 2 deletions LoL Assist/BuildEditorWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public BuildEditorWindow()
InitializeComponent();
DataContext = viewModel;
}

private void CloseBtn_Clicked(object sender, MouseButtonEventArgs e) => Close();
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
Expand Down Expand Up @@ -119,5 +117,7 @@ private void AnimateClose(FrameworkElement element, double time = 0.13)
Utils.Animation.FadeOut(element, time);
}
#endregion

private void CloseBtn_Click(object sender, RoutedEventArgs e) => Close();
}
}
125 changes: 125 additions & 0 deletions LoL Assist/Colours.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<Color x:Key="aPrimary">#7160E8</Color>
<Color x:Key="aSecondary">#403582</Color>
<Color x:Key="aTritary">#A093EF</Color>

<!--<Color x:Key="aPrimary">#03A9F7</Color>
<Color x:Key="aSecondary">#0076D1</Color>
<Color x:Key="aTritary">#55ADF1</Color>-->
<Color x:Key="bPrimary">#303030</Color>
<Color x:Key="bSecondary">#18191C</Color>
<Color x:Key="bTritary">#242424</Color>

<Color x:Key="CheckMark">White</Color>
<Color x:Key="title">white</Color>
<Color x:Key="RedColor">#E74856</Color>

<Color x:Key="FontPrimaryColor">Silver</Color>
<Color x:Key="FontSecondaryColor">Gray</Color>
<Color x:Key="FontTritaryColor">#969284</Color>

<SolidColorBrush x:Key="RedBrush" Color="{DynamicResource RedColor}"/>
<SolidColorBrush x:Key="BrushTitle" Color="{DynamicResource title}"/>
<SolidColorBrush x:Key="aBrushPrimary" Color="{DynamicResource aPrimary}"/>
<SolidColorBrush x:Key="aBrushSecondary" Color="{DynamicResource aSecondary}"/>
<SolidColorBrush x:Key="aBrushTritary" Color="{DynamicResource aTritary}"/>
<SolidColorBrush x:Key="bBrushPrimary" Color="{DynamicResource bPrimary}"/>
<SolidColorBrush x:Key="bBrushSecondary" Color="{DynamicResource bSecondary}"/>
<SolidColorBrush x:Key="bBrushTritary" Color="{DynamicResource bTritary}"/>

<SolidColorBrush x:Key="BrushCheckMark" Color="{DynamicResource CheckMark}"/>

<SolidColorBrush x:Key="FontPrimaryBrush" Color="{DynamicResource FontPrimaryColor}"/>
<SolidColorBrush x:Key="FontSecondaryBrush" Color="{DynamicResource FontSecondaryColor}"/>
<SolidColorBrush x:Key="FontTritaryBrush" Color="{DynamicResource FontTritaryColor}"/>

<LinearGradientBrush x:Key="BorderGradientBrush" StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="{DynamicResource aSecondary}" Offset="1"/>
<GradientStop Color="{DynamicResource aPrimary}"/>
</LinearGradientBrush>

<LinearGradientBrush x:Key="SelectedBorderBrush" StartPoint="0,0" EndPoint="0,1">
<GradientStop x:Name="BorderBrushTop" Color="{DynamicResource aPrimary}" Offset="0"/>
<GradientStop x:Name="BorderBrushBot" Color="{DynamicResource aTritary}" Offset="1"/>
</LinearGradientBrush>

<ControlTemplate x:Key="IconStyleButton" TargetType="{x:Type Button}">
<Grid Focusable="False" Cursor="Hand">
<Border x:Name="btnBorder" Width="12" Height="12" Background="Transparent" BorderBrush="Transparent" BorderThickness="0" SnapsToDevicePixels="true">
<Path Data="{Binding Tag, RelativeSource={RelativeSource TemplatedParent}}" Stretch="Uniform">
<Path.Fill>
<SolidColorBrush x:Name="IconBtnPathColor" Color="{DynamicResource FontSecondaryColor}"/>
</Path.Fill>
</Path>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" TargetName="btnBorder" Value="0.56"/>
</Trigger>

<EventTrigger RoutedEvent="UIElement.MouseEnter">
<BeginStoryboard>
<Storyboard>
<ColorAnimation AutoReverse="False" Duration="0:0:0.2" Storyboard.TargetName="IconBtnPathColor" To="{StaticResource FontPrimaryColor}" Storyboard.TargetProperty="Color"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="UIElement.PreviewMouseUp">
<BeginStoryboard>
<Storyboard>
<ColorAnimation AutoReverse="True" Duration="0:0:0.05" Storyboard.TargetName="IconBtnPathColor" To="{StaticResource aPrimary}" Storyboard.TargetProperty="Color"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="UIElement.MouseLeave">
<BeginStoryboard>
<Storyboard>
<ColorAnimation AutoReverse="False" Duration="0:0:0.2" Storyboard.TargetName="IconBtnPathColor" To="{StaticResource FontSecondaryColor}" Storyboard.TargetProperty="Color"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>

<ControlTemplate x:Key="IconStyleButtonRed" TargetType="{x:Type Button}">
<Grid Focusable="False" Cursor="Hand">
<Border x:Name="btnBorder" Width="12" Height="12" Background="Transparent" BorderBrush="Transparent" BorderThickness="0" SnapsToDevicePixels="true">
<Path Data="{Binding Tag, RelativeSource={RelativeSource TemplatedParent}}" Stretch="Uniform">
<Path.Fill>
<SolidColorBrush x:Name="IconBtnPathColor" Color="{DynamicResource FontSecondaryColor}"/>
</Path.Fill>
</Path>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" TargetName="btnBorder" Value="0.56"/>
</Trigger>

<EventTrigger RoutedEvent="UIElement.MouseEnter">
<BeginStoryboard>
<Storyboard>
<ColorAnimation AutoReverse="False" Duration="0:0:0.2" Storyboard.TargetName="IconBtnPathColor" To="{StaticResource RedColor}" Storyboard.TargetProperty="Color"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="UIElement.PreviewMouseUp">
<BeginStoryboard>
<Storyboard>
<ColorAnimation AutoReverse="True" Duration="0:0:0.05" Storyboard.TargetName="IconBtnPathColor" To="{StaticResource FontSecondaryColor}" Storyboard.TargetProperty="Color"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="UIElement.MouseLeave">
<BeginStoryboard>
<Storyboard>
<ColorAnimation AutoReverse="False" Duration="0:0:0.2" Storyboard.TargetName="IconBtnPathColor" To="{StaticResource FontSecondaryColor}" Storyboard.TargetProperty="Color"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</ResourceDictionary>
20 changes: 20 additions & 0 deletions LoL Assist/Converters/NullToCollapseConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace LoL_Assist_WAPP.Converters
{
internal class NullToCollapseConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return string.IsNullOrEmpty(value?.ToString()) ? Visibility.Collapsed : Visibility.Visible;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
32 changes: 32 additions & 0 deletions LoL Assist/Converters/TextToForegroundConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;

namespace LoL_Assist_WAPP.Converters
{
public class TextToForegroundConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
switch(value.ToString())
{
case "Declined":
case "Disconnected":
case "Invalid Build Config":
return (SolidColorBrush)Application.Current.Resources["RedBrush"]; // Red
case "Accepted":
return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#29ab87")); // Green
case "Auto Accept is disabled":
return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ffc40c")); // Yellow
default:
return (SolidColorBrush)Application.Current.Resources["FontPrimaryBrush"];
}
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
21 changes: 21 additions & 0 deletions LoL Assist/DataTemplates.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:viewmodel="clr-namespace:LoL_Assist_WAPP.ViewModel"
xmlns:view="clr-namespace:LoL_Assist_WAPP.View">

<DataTemplate DataType="{x:Type viewmodel:RoleSelectViewModel}">
<view:RoleSelectPanel/>
</DataTemplate>

<DataTemplate DataType="{x:Type viewmodel:PatchViewModel}">
<view:PatchNotesPanel/>
</DataTemplate>

<DataTemplate DataType="{x:Type viewmodel:MessageBoxViewModel}">
<view:MessageBox/>
</DataTemplate>

<DataTemplate DataType="{x:Type viewmodel:MatchFoundViewModel}">
<view:MatchFoundPanel/>
</DataTemplate>
</ResourceDictionary>
30 changes: 30 additions & 0 deletions LoL Assist/Extensions/ProgressBarSmoother.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Animation;

namespace LoL_Assist_WAPP.Extensions
{
// Source: https://stackoverflow.com/questions/14485818/how-to-update-a-progress-bar-so-it-increases-smoothly
public class ProgressBarSmoother
{
public static double GetSmoothValue(DependencyObject obj)
{
return (double)obj.GetValue(SmoothValueProperty);
}

public static void SetSmoothValue(DependencyObject obj, double value)
{
obj.SetValue(SmoothValueProperty, value);
}

public static readonly DependencyProperty SmoothValueProperty =
DependencyProperty.RegisterAttached("SmoothValue", typeof(double), typeof(ProgressBarSmoother), new PropertyMetadata(0.0, changing));

private static void changing(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var anim = new DoubleAnimation((double)e.OldValue, (double)e.NewValue, TimeSpan.FromSeconds(1));
(d as ProgressBar).BeginAnimation(ProgressBar.ValueProperty, anim, HandoffBehavior.Compose);
}
}
}
Loading

0 comments on commit 4de4c33

Please sign in to comment.