Skip to content

Commit

Permalink
GoG Game Detection.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew committed Jan 12, 2016
1 parent dc3b4af commit 0417528
Show file tree
Hide file tree
Showing 14 changed files with 155 additions and 111 deletions.
24 changes: 9 additions & 15 deletions SteamCleaner/ActionCommand.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
#region

using System;
using System.Windows.Input;

#endregion

namespace SteamCleaner
{
public class ActionCommand : ICommand
{
private readonly Action<object> _execute;
private readonly Func<object, bool> _canExecute;
private readonly Action<object> _execute;

public ActionCommand(Action execute) : this(_ => execute(), null)
{
Expand Down Expand Up @@ -40,19 +40,13 @@ public void Execute(object parameter)

public event EventHandler CanExecuteChanged
{
add
{
CommandManager.RequerySuggested += value;
}
remove
{
CommandManager.RequerySuggested -= value;
}
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}

public void Refresh()
{
CommandManager.InvalidateRequerySuggested();
}
}
}
}
18 changes: 7 additions & 11 deletions SteamCleaner/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
#region

using System.Windows;
using SteamCleaner.Utilities;

#endregion

namespace SteamCleaner
{
/// <summary>
/// Interaction logic for App.xaml
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{

void AppStartup(object sender, StartupEventArgs args)
private void AppStartup(object sender, StartupEventArgs args)
{


var mainWindow = new MainWindow
{
DataContext = new MainWindowViewModel()
Expand All @@ -26,4 +22,4 @@ void AppStartup(object sender, StartupEventArgs args)
Tools.CheckForUpdates();
}
}
}
}
21 changes: 6 additions & 15 deletions SteamCleaner/ConfirmationDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
#region

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;

#endregion

namespace SteamCleaner
{
/// <summary>
/// Interaction logic for ConfirmationDialog.xaml
/// Interaction logic for ConfirmationDialog.xaml
/// </summary>
public partial class ConfirmationDialog : UserControl
{
Expand All @@ -25,4 +16,4 @@ public ConfirmationDialog()
InitializeComponent();
}
}
}
}
21 changes: 6 additions & 15 deletions SteamCleaner/FailuresDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
#region

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;

#endregion

namespace SteamCleaner
{
/// <summary>
/// Interaction logic for FailuresDialog.xaml
/// Interaction logic for FailuresDialog.xaml
/// </summary>
public partial class FailuresDialog : UserControl
{
Expand All @@ -25,4 +16,4 @@ public FailuresDialog()
InitializeComponent();
}
}
}
}
6 changes: 5 additions & 1 deletion SteamCleaner/FileViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using System;
#region

using System;

#endregion

namespace SteamCleaner
{
Expand Down
22 changes: 6 additions & 16 deletions SteamCleaner/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
using System;
using System.Collections.Generic;
#region

using System.Diagnostics;
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.Shapes;

#endregion

namespace SteamCleaner
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
Expand Down Expand Up @@ -45,6 +37,4 @@ private void ReportABugMenuItem_OnClick(object sender, RoutedEventArgs e)
Process.Start("https://github.com/Codeusa/SteamCleaner/issues");
}
}


}
}
34 changes: 20 additions & 14 deletions SteamCleaner/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
using System.Collections.Generic;
#region

using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using SteamCleaner.Utilities;

#endregion

namespace SteamCleaner
{
public class MainWindowViewModel : INotifyPropertyChanged
{
private readonly ObservableCollection<string> _pathsInternal = new ObservableCollection<string>();
private readonly ObservableCollection<FileViewModel> _filesInternal = new ObservableCollection<FileViewModel>();
private readonly ObservableCollection<string> _pathsInternal = new ObservableCollection<string>();
private string _statistics;

public MainWindowViewModel()
Expand All @@ -27,7 +27,6 @@ public MainWindowViewModel()

//TODO run on a background thread, add spinner etc
RunRefresh();

}


Expand All @@ -50,39 +49,46 @@ public string Statistics
}
}

public event PropertyChangedEventHandler PropertyChanged;

private void RunRefresh()
{
//needs to be called to ensure we aren't loading a previously stored object.
CleanerUtilities.updateRedistributables = true;
_pathsInternal.Clear();
foreach (var steamPath in SteamUtilities.SteamPaths())
_pathsInternal.Add(steamPath);
if (GoGUtilities.GoGExisit())
{
_pathsInternal.Add("GoG Games Detected");
}

_filesInternal.Clear();
foreach (var fileViewModel in CleanerUtilities.FindRedistributables().Select(r => new FileViewModel(r.Path, StringUtilities.GetBytesReadable(r.Size))))
_filesInternal.Add(fileViewModel);

Statistics = CleanerUtilities.TotalFiles() + " files have been found (" + CleanerUtilities.TotalTakenSpace() + ") ";
foreach (
var fileViewModel in
CleanerUtilities.FindRedistributables()
.Select(r => new FileViewModel(r.Path, StringUtilities.GetBytesReadable(r.Size))))
_filesInternal.Add(fileViewModel);

Statistics = CleanerUtilities.TotalFiles() + " files have been found (" + CleanerUtilities.TotalTakenSpace() +
") ";
}

private async void RunClean()
{
await CleanerUtilities.CleanData();

RunRefresh();

}

private async void CheckForUpdate()
{
Tools.CheckForUpdates();
}

public event PropertyChangedEventHandler PropertyChanged;

protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}
4 changes: 2 additions & 2 deletions SteamCleaner/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyVersion("1.4.0.0")]
[assembly: AssemblyFileVersion("1.4.0.0")]
1 change: 1 addition & 0 deletions SteamCleaner/SteamCleaner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
</Compile>
<Compile Include="MainWindowViewModel.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utilities\GoGUtilities.cs" />
<Compile Include="Utilities\SteamUtilities.cs" />
<Compile Include="Utilities\StringUtilities.cs" />
<Compile Include="Utilities\CleanerUtilities.cs" />
Expand Down
Loading

0 comments on commit 0417528

Please sign in to comment.