Skip to content

Commit

Permalink
Going to change colours to hex codes for what I changed today
Browse files Browse the repository at this point in the history
  • Loading branch information
pekempy committed Apr 9, 2019
1 parent 0197991 commit b47fda2
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 32 deletions.
3 changes: 1 addition & 2 deletions MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,7 @@
Tag="" />
<ItemsControl x:Name="GenreSidebar"
ItemsSource="{Binding Source={StaticResource GenreListCVS}, IsAsync=True}"
ScrollViewer.CanContentScroll="True"
Loaded="UpdateGenreColour">
ScrollViewer.CanContentScroll="True">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
Expand Down
19 changes: 4 additions & 15 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows.Media;
using System.IO;
using System.Net;
using System.Windows;
Expand Down Expand Up @@ -455,7 +456,7 @@ public void OpenImageDL(string gametitle, string searchstring, string imagetype)
else { Trace.WriteLine(DateTime.Now + ": -System unsure which dialog currently open"); }
}
}
public void UpdateGenreColours()
public void UpdateGenreColours(Brush colour)
{
if (GenreSidebar.Items.Count != 0)
{
Expand All @@ -465,16 +466,8 @@ public void UpdateGenreColours()
try
{
Button tb = c.ContentTemplate.FindName("GenreButton", c) as Button;
if (Settings.Default.genrecolour == "primary")
{
tb.Style = Application.Current.Resources["MaterialDesignFlatButton"] as Style;
AllGenreBtn.Style = Application.Current.Resources["MaterialDesignFlatButton"] as Style;
}
if (Settings.Default.genrecolour == "accent")
{
tb.Style = Application.Current.Resources["MaterialDesignFlatAccentButton"] as Style;
AllGenreBtn.Style = Application.Current.Resources["MaterialDesignFlatAccentButton"] as Style;
}
tb.Foreground = colour;
AllGenreBtn.Foreground = colour;
}
catch (Exception br) { Trace.WriteLine("Break: " + br); }
}
Expand All @@ -499,10 +492,6 @@ public void UpdateLauncherButtons()
BattleNetLaunchBtn.Style = Application.Current.Resources["MaterialDesignFlatAccentButton"] as Style;
}
}
public void UpdateGenreColour(object sender, RoutedEventArgs e)
{
UpdateGenreColours();
}
public void DownloadImage(string url)
{
if (!File.Exists(@"Resources/img/" + DLGameTitle + "-" + DLImgType + ".png"))
Expand Down
13 changes: 7 additions & 6 deletions Views/SettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -439,12 +439,13 @@
</StackPanel>
<StackPanel Margin="0,20,0,0" Orientation="Horizontal">
<TextBlock>Genre Sidebar uses Primary</TextBlock>
<ToggleButton x:Name="GenreColourToggle"
Margin="60,0,0,0"
HorizontalAlignment="Right"
Checked="GenreColour_Checked"
Style="{StaticResource MaterialDesignSwitchAccentToggleButton}"
Unchecked="GenreColour_Unchecked" />
<TextBox x:Name="GenreColour_Text"
MinWidth="100"
KeyDown="GenreColour_Enter"
PreviewTextInput="GenreColour_PreviewTextInput"/>
<Rectangle x:Name="GenreColour_Display"
Width="50"
Height="50" />
</StackPanel>
<StackPanel Margin="0,20,0,0" Orientation="Horizontal">
<TextBlock>Launcher Buttons uses Primary</TextBlock>
Expand Down
32 changes: 23 additions & 9 deletions Views/SettingsView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
using MaterialDesignThemes.Wpf;
using System;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;

namespace GameLauncher.Views
Expand Down Expand Up @@ -43,7 +46,6 @@ public SettingsView()
if (Settings.Default.theme == "Dark") { themeToggle.IsChecked = true; }
if (Settings.Default.gametitles == "primary") { GameTitlesToggle.IsChecked = true; }
if (Settings.Default.fabcolour == "primary") { FABToggle.IsChecked = true; }
if (Settings.Default.genrecolour == "primary") { GenreColourToggle.IsChecked = true; }
if (Settings.Default.launchercolour == "primary") { LauncherColourToggle.IsChecked = true; }
SelectedThemeColour();
}
Expand Down Expand Up @@ -168,17 +170,29 @@ private void TitleColour_Unchecked(object sender, RoutedEventArgs e)
Settings.Default.gametitles = "accent";
Settings.Default.Save();
}
private void GenreColour_Checked(object sender, RoutedEventArgs e)
private void GenreColour_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
Settings.Default.genrecolour = "primary";
Settings.Default.Save();
MainWindow.UpdateGenreColours();
int hexNumber;
e.Handled = !int.TryParse(e.Text, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out hexNumber);
}
private void GenreColour_Unchecked(object sender, RoutedEventArgs e)
private void GenreColour_Enter(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return)
{
var regexColourCode = new Regex("^#[a-fA-F0-9]{6}$");
if (regexColourCode.IsMatch("#" + GenreColour_Text.Text.Trim()))
{
var converter = new BrushConverter();
var brush = (Brush)converter.ConvertFromString("#" + GenreColour_Text.Text);
GenreColour_Display.Fill = brush;
Settings.Default.genrecolour = GenreColour_Text.Text;
Settings.Default.Save();
MainWindow.UpdateGenreColours(brush);
}
}
}
private void GenreColour(object sender, TextChangedEventArgs e)
{
Settings.Default.genrecolour = "accent";
Settings.Default.Save();
MainWindow.UpdateGenreColours();
}
private void LauncherColour_Checked(object sender, RoutedEventArgs e)
{
Expand Down

0 comments on commit b47fda2

Please sign in to comment.