Skip to content
Permalink
Browse files

Refactoring

  • Loading branch information...
PhantomGamers committed Jun 17, 2019
1 parent 6436a72 commit fa6d84073e428f02a36355eafeb46112c3106b09
@@ -1,14 +1,13 @@
<Application x:Class="SteamFriendsPatcher.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SteamFriendsPatcher"
ShutdownMode="OnLastWindowClose">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary x:Name="IconsDictionary"
<ResourceDictionary

Source="/SteamFriendsPatcher;component/Icons.xaml" />
Source="/Resources/Icons.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
@@ -6,34 +6,35 @@
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using SteamFriendsPatcher.Forms;

namespace SteamFriendsPatcher
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
public partial class App
{
public static MainWindow MainWindowRef { get; private set; }
public static System.Timers.Timer UpdateTimer { get; private set; }

public static bool UpdateTimerActive { get; private set; } = false;
public static bool UpdateTimerActive { get; private set; }

private static bool firstShown { get; set; } = false;
private static bool FirstShown { get; set; }

private static readonly Mutex singleInstance = new Mutex(true, Assembly.GetExecutingAssembly().GetName().Name);
private static readonly Mutex SingleInstance = new Mutex(true, Assembly.GetExecutingAssembly().GetName().Name);

protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
if (singleInstance.WaitOne(TimeSpan.Zero, true))
if (SingleInstance.WaitOne(TimeSpan.Zero, true))
{
MainWindowRef = new MainWindow();

PerformUpgrade();
string ver = ThisAssembly.AssemblyInformationalVersion;
MainWindowRef.Title += $"v{(ver.Substring(0, ver.IndexOf('+') > -1 ? ver.IndexOf('+') : ver.Length))}";
Task.Run(() => Setup());
const string ver = ThisAssembly.AssemblyInformationalVersion;
MainWindowRef.Title += $"v{ver.Substring(0, ver.IndexOf('+') > -1 ? ver.IndexOf('+') : ver.Length)}";
Task.Run(Setup);
if (SteamFriendsPatcher.Properties.Settings.Default.saveLastWindowSize)
{
MainWindowRef.Width = SteamFriendsPatcher.Properties.Settings.Default.windowWidth;
@@ -53,21 +54,21 @@ protected override void OnStartup(StartupEventArgs e)
var workingArea = SystemParameters.WorkArea;
MainWindowRef.Left = (workingArea.Width - SteamFriendsPatcher.Properties.Settings.Default.windowWidth) / 2 + workingArea.Left;
MainWindowRef.Top = (workingArea.Height - SteamFriendsPatcher.Properties.Settings.Default.windowHeight) / 2 + workingArea.Top;
firstShown = true;
FirstShown = true;
}

if (!SteamFriendsPatcher.Properties.Settings.Default.startMinimized)
{
MainWindowRef.WindowState = WindowState.Normal;
}

singleInstance.ReleaseMutex();
SingleInstance.ReleaseMutex();
}
else
{
NativeMethods.PostMessage(
(IntPtr)NativeMethods.HWND_BROADCAST,
NativeMethods.WM_SHOWME,
(IntPtr)NativeMethods.HwndBroadcast,
NativeMethods.WmShowme,
IntPtr.Zero,
IntPtr.Zero);
Current.Shutdown(1);
@@ -78,7 +79,7 @@ private static void Setup()
{
if (SteamFriendsPatcher.Properties.Settings.Default.checkForUpdates)
{
Task.Run(() => Program.UpdateChecker());
Task.Run(Program.UpdateChecker);
ToggleUpdateTimer();
}

@@ -100,12 +101,12 @@ private static void Setup()

public static void ShowMain()
{
if (!firstShown)
if (!FirstShown)
{
var workingArea = SystemParameters.WorkArea;
MainWindowRef.Left = (workingArea.Width - SteamFriendsPatcher.Properties.Settings.Default.windowWidth) / 2 + workingArea.Left;
MainWindowRef.Top = (workingArea.Height - SteamFriendsPatcher.Properties.Settings.Default.windowHeight) / 2 + workingArea.Top;
firstShown = true;
FirstShown = true;
}

if (!MainWindowRef.IsVisible)
@@ -130,7 +131,7 @@ public static void ToggleUpdateTimer(bool status = true)
UpdateTimer = new System.Timers.Timer

{
Interval = System.TimeSpan.FromDays(1).TotalMilliseconds
Interval = TimeSpan.FromDays(1).TotalMilliseconds
};

UpdateTimer.Elapsed += UpdateTimer_Elapsed;
@@ -145,23 +146,21 @@ private static void UpdateTimer_Elapsed(object sender, System.Timers.ElapsedEven

private static void PerformUpgrade()
{
if (SteamFriendsPatcher.Properties.Settings.Default.upgradeRequired)
{
SteamFriendsPatcher.Properties.Settings.Default.Upgrade();
if (!SteamFriendsPatcher.Properties.Settings.Default.upgradeRequired) return;
SteamFriendsPatcher.Properties.Settings.Default.Upgrade();

if (SteamFriendsPatcher.Properties.Settings.Default.upgradeVer == 0)
if (SteamFriendsPatcher.Properties.Settings.Default.upgradeVer == 0)
{
if (File.Exists(Program.StartupLinkOld))
{
if (File.Exists(Program.startupLinkOld))
{
File.Delete(Program.startupLinkOld);
Program.CreateStartUpShortcut();
}
File.Delete(Program.StartupLinkOld);
Program.CreateStartUpShortcut();
}

SteamFriendsPatcher.Properties.Settings.Default.upgradeVer = 1;
SteamFriendsPatcher.Properties.Settings.Default.upgradeRequired = false;
SteamFriendsPatcher.Properties.Settings.Default.Save();
}

SteamFriendsPatcher.Properties.Settings.Default.upgradeVer = 1;
SteamFriendsPatcher.Properties.Settings.Default.upgradeRequired = false;
SteamFriendsPatcher.Properties.Settings.Default.Save();
}
}
}
@@ -1,21 +1,20 @@
<Window x:Class="SteamFriendsPatcher.AboutWindow"
<Window x:Class="SteamFriendsPatcher.Forms.AboutWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SteamFriendsPatcher"
mc:Ignorable="d"
Title="Steam Friends Patcher - About" Background="#FF1E1E1F" Foreground="White" SizeToContent="WidthAndHeight" WindowStartupLocation="CenterOwner" ResizeMode="NoResize" WindowStyle="ToolWindow" TextOptions.TextFormattingMode="Display" TextOptions.TextHintingMode="Fixed">
<Grid Margin="10">
<Label x:Name="programName" Content="Steam Friends Patcher " HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Foreground="White" FontSize="18" TextOptions.TextHintingMode="Fixed" TextOptions.TextFormattingMode="Ideal" />
<Label x:Name="authorName" Content="Made by PhantomGamers" HorizontalAlignment="Left" Margin="10,45,0,0" VerticalAlignment="Top" Foreground="White" FontSize="14" TextOptions.TextHintingMode="Fixed" TextOptions.TextFormattingMode="Display" />
<Label x:Name="label" Content="Github: " HorizontalAlignment="Left" Margin="10,80,0,0" VerticalAlignment="Top" Foreground="White" TextOptions.TextFormattingMode="Display" TextOptions.TextHintingMode="Fixed" />
<Label x:Name="ProgramName" Content="Steam Friends Patcher " HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Foreground="White" FontSize="18" TextOptions.TextHintingMode="Fixed" TextOptions.TextFormattingMode="Ideal" />
<Label x:Name="AuthorName" Content="Made by PhantomGamers" HorizontalAlignment="Left" Margin="10,45,0,0" VerticalAlignment="Top" Foreground="White" FontSize="14" TextOptions.TextHintingMode="Fixed" TextOptions.TextFormattingMode="Display" />
<Label x:Name="Label" Content="Github: " HorizontalAlignment="Left" Margin="10,80,0,0" VerticalAlignment="Top" Foreground="White" TextOptions.TextFormattingMode="Display" TextOptions.TextHintingMode="Fixed" />
<TextBlock HorizontalAlignment="Left" Margin="70,85,0,0" VerticalAlignment="Top" TextOptions.TextFormattingMode="Display" TextOptions.TextHintingMode="Fixed">
<Hyperlink NavigateUri="https://github.com/PhantomGamers/SteamFriendsPatcher" RequestNavigate="Hyperlink_RequestNavigate">
https://github.com/PhantomGamers/SteamFriendsPatcher
</Hyperlink>
</TextBlock>
<TextBlock x:Name="textBlock" HorizontalAlignment="Left" Margin="13,111,0,0" TextWrapping="Wrap" VerticalAlignment="Top" TextOptions.TextFormattingMode="Display" TextOptions.TextHintingMode="Fixed">
<TextBlock x:Name="TextBlock" HorizontalAlignment="Left" Margin="13,111,0,0" TextWrapping="Wrap" VerticalAlignment="Top" TextOptions.TextFormattingMode="Display" TextOptions.TextHintingMode="Fixed">
This utility is designed to allow you to apply themes to the new Steam friends UI.<LineBreak />
To use manually, simply click "Force Check," by default this will run when you start the program.<LineBreak />
You will be required to do this everytime Valve pushes a new version of the friends.css file used by Steam.<LineBreak />
@@ -1,18 +1,17 @@
using System.Diagnostics;
using System.Windows;
using System.Windows.Navigation;

namespace SteamFriendsPatcher
namespace SteamFriendsPatcher.Forms
{
/// <summary>
/// Interaction logic for AboutWindow.xaml
/// </summary>
public partial class AboutWindow : Window
public partial class AboutWindow
{
public AboutWindow()
{
InitializeComponent();
this.programName.Content += $"v{ThisAssembly.AssemblyInformationalVersion}";
ProgramName.Content += $"v{ThisAssembly.AssemblyInformationalVersion}";
}

private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
@@ -1,31 +1,30 @@
<Window x:Name="Main" x:Class="SteamFriendsPatcher.MainWindow"
<Window x:Class="SteamFriendsPatcher.Forms.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SteamFriendsPatcher"
mc:Ignorable="d"
Title="Steam Friends Patcher " Background="#FF1E1E1F" Foreground="White" MinWidth="545" MinHeight="327" HorizontalAlignment="Left" VerticalAlignment="Bottom" Icon="steam_512_0dR_icon.ico" WindowStartupLocation="CenterScreen" Width="768" Height="535" TextOptions.TextHintingMode="Fixed" TextOptions.TextFormattingMode="Display">
<Grid x:Name="mainGrid">
<FlowDocumentScrollViewer x:Name="output" Margin="10,10,10,50" BorderThickness="2" SelectionBrush="#FF1E1E1F" TextOptions.TextHintingMode="Fixed" Padding="0" Block.LineHeight="1.0" TextOptions.TextFormattingMode="Display" VerticalScrollBarVisibility="Auto" ForceCursor="True" Cursor="Arrow">
Title="Steam Friends Patcher " Background="#FF1E1E1F" Foreground="White" MinWidth="545" MinHeight="327" HorizontalAlignment="Left" VerticalAlignment="Bottom" WindowStartupLocation="CenterScreen" Width="768" Height="535" TextOptions.TextHintingMode="Fixed" TextOptions.TextFormattingMode="Display">
<Grid x:Name="MainGrid">
<FlowDocumentScrollViewer x:Name="Output" Margin="10,10,10,50" BorderThickness="2" SelectionBrush="#FF1E1E1F" TextOptions.TextHintingMode="Fixed" Padding="0" Block.LineHeight="1.0" TextOptions.TextFormattingMode="Display" VerticalScrollBarVisibility="Auto" ForceCursor="True" Cursor="Arrow">
<FlowDocument Background="#FF3D3D3E" Foreground="White" FontFamily="Segoe UI" FontSize="12" />
</FlowDocumentScrollViewer>
<Button x:Name="toggleScanButton" Content="Start Scanning" Margin="10,0,0,10" Background="#FF3D3D3E" Foreground="White" FontSize="18" HorizontalAlignment="Left" VerticalAlignment="Bottom" Click="ToggleScanButton_Click" Padding="10,1" BorderBrush="{x:Null}" TextOptions.TextHintingMode="Fixed" TextOptions.TextFormattingMode="Ideal" />
<Button x:Name="settingsButton" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="32" FontFamily="/SteamFriendsPatcher;component/resources/#Font Awesome 5 Free Solid" Background="#00DDDDDD" Foreground="White" Height="32" FontSize="24" BorderThickness="0" Margin="0,0,10,10" Click="SettingsButton_Click">
<Button x:Name="ToggleScanButton" Content="Start Scanning" Margin="10,0,0,10" Background="#FF3D3D3E" Foreground="White" FontSize="18" HorizontalAlignment="Left" VerticalAlignment="Bottom" Click="ToggleScanButton_Click" Padding="10,1" BorderBrush="{x:Null}" TextOptions.TextHintingMode="Fixed" TextOptions.TextFormattingMode="Ideal" />
<Button x:Name="SettingsButton" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="32" Background="#00DDDDDD" Foreground="White" Height="32" FontSize="24" BorderThickness="0" Margin="0,0,10,10" Click="SettingsButton_Click">
<Rectangle Width="24" Height="24" Fill="White">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Fill" Visual="{StaticResource Cog}" />
</Rectangle.OpacityMask>
</Rectangle>
</Button>
<Button x:Name="aboutButton" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="32" FontFamily="/SteamFriendsPatcher;component/resources/#Font Awesome 5 Free Solid" Background="#00DDDDDD" Foreground="White" Height="32" FontSize="24" BorderThickness="0" Margin="0,0,50,10" Click="AboutButton_Click">
<Button x:Name="AboutButton" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="32" Background="#00DDDDDD" Foreground="White" Height="32" FontSize="24" BorderThickness="0" Margin="0,0,50,10" Click="AboutButton_Click">
<Rectangle Width="24" Height="24" Fill="White">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Fill" Visual="{StaticResource InfoCircle}" />
</Rectangle.OpacityMask>
</Rectangle>
</Button>
<Button x:Name="forceCheckButton" Content="Force Check" HorizontalAlignment="Left" Margin="151,0,0,10" VerticalAlignment="Bottom" Background="#FF3D3D3E" Foreground="White" FontSize="18" Padding="10,1" Click="ForceCheckButton_Click" BorderBrush="{x:Null}" TextOptions.TextFormattingMode="Ideal" TextOptions.TextHintingMode="Fixed" />
<Button x:Name="clearCacheButton" Content="Clear Steam Cache" HorizontalAlignment="Left" Margin="274,0,0,10" VerticalAlignment="Bottom" Background="#FF3D3D3E" Foreground="White" FontSize="18" Padding="10,1" Click="ClearCacheButton_Click" BorderBrush="{x:Null}" TextOptions.TextFormattingMode="Ideal" TextOptions.TextHintingMode="Fixed" />
<Button x:Name="ForceCheckButton" Content="Force Check" HorizontalAlignment="Left" Margin="151,0,0,10" VerticalAlignment="Bottom" Background="#FF3D3D3E" Foreground="White" FontSize="18" Padding="10,1" Click="ForceCheckButton_Click" BorderBrush="{x:Null}" TextOptions.TextFormattingMode="Ideal" TextOptions.TextHintingMode="Fixed" />
<Button x:Name="ClearCacheButton" Content="Clear Steam Cache" HorizontalAlignment="Left" Margin="274,0,0,10" VerticalAlignment="Bottom" Background="#FF3D3D3E" Foreground="White" FontSize="18" Padding="10,1" Click="ClearCacheButton_Click" BorderBrush="{x:Null}" TextOptions.TextFormattingMode="Ideal" TextOptions.TextHintingMode="Fixed" />
</Grid>
</Window>

0 comments on commit fa6d840

Please sign in to comment.
You can’t perform that action at this time.