Skip to content

Commit

Permalink
Fix Update Check
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew committed Jan 9, 2016
1 parent f758c9f commit de5b063
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 9 deletions.
5 changes: 4 additions & 1 deletion SteamCleaner/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using SteamCleaner.Utilities;

namespace SteamCleaner
{
Expand All @@ -15,12 +16,14 @@ public partial class App : Application

void AppStartup(object sender, StartupEventArgs args)
{



var mainWindow = new MainWindow
{
DataContext = new MainWindowViewModel()
};
mainWindow.Show();
Tools.CheckForUpdates();

This comment has been minimized.

Copy link
@ButchersBoy

ButchersBoy Jan 10, 2016

Contributor

Sorry, my bad, missed a couple of lines when re-factoring 😞

}
}
}
2 changes: 1 addition & 1 deletion SteamCleaner/ConfirmationDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<TextBlock x:Name="MessageTextBlock" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0 16 0 0">
<Button Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" Style="{DynamicResource MaterialDesignFlatButton}">CANCEL</Button>
<Button Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" Style="{DynamicResource MaterialDesignFlatButton}" CommandParameter="1" Margin="8 0 0 0">DELETE</Button>
<Button Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" Style="{DynamicResource MaterialDesignFlatButton}" CommandParameter="1" Margin="8 0 0 0">CONTINUE</Button>
</StackPanel>
</StackPanel>

Expand Down
5 changes: 5 additions & 0 deletions SteamCleaner/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Weavers>
<Costura/>

</Weavers>
8 changes: 7 additions & 1 deletion SteamCleaner/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public MainWindowViewModel()

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

}


Expand Down Expand Up @@ -62,14 +63,19 @@ private void RunRefresh()
_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;
Expand Down
49 changes: 49 additions & 0 deletions SteamCleaner/SteamCleaner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -136,7 +138,54 @@
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Resource Include="FodyWeavers.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Fody.1.28.3\build\Fody.targets" Condition="Exists('..\packages\Fody.1.28.3\build\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Fody.1.28.3\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.1.28.3\build\Fody.targets'))" />
</Target>
<UsingTask TaskName="CosturaCleanup" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" TaskFactory="CodeTaskFactory">
<ParameterGroup>
<Config Output="false" Required="true" ParameterType="Microsoft.Build.Framework.ITaskItem" />
<Files Output="false" Required="true" ParameterType="Microsoft.Build.Framework.ITaskItem[]" />
</ParameterGroup>
<Task Evaluate="true">
<Reference xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Include="System.Xml" />
<Reference xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Include="System.Xml.Linq" />
<Using xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Namespace="System" />
<Using xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Namespace="System.IO" />
<Using xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Namespace="System.Xml.Linq" />
<Code xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Type="Fragment" Language="cs">
<![CDATA[
var config = XElement.Load(Config.ItemSpec).Elements("Costura").FirstOrDefault();
if (config == null) return true;
var excludedAssemblies = new List<string>();
var attribute = config.Attribute("ExcludeAssemblies");
if (attribute != null)
foreach (var item in attribute.Value.Split('|').Select(x => x.Trim()).Where(x => x != string.Empty))
excludedAssemblies.Add(item);
var element = config.Element("ExcludeAssemblies");
if (element != null)
foreach (var item in element.Value.Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).Where(x => x != string.Empty))
excludedAssemblies.Add(item);
var filesToCleanup = Files.Select(f => f.ItemSpec).Where(f => !excludedAssemblies.Contains(Path.GetFileNameWithoutExtension(f), StringComparer.InvariantCultureIgnoreCase));
foreach (var item in filesToCleanup)
File.Delete(item);
]]>
</Code></Task>
</UsingTask>
<Target Name="CleanReferenceCopyLocalPaths" AfterTargets="AfterBuild;NonWinFodyTarget">
<CosturaCleanup Config="FodyWeavers.xml" Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
19 changes: 13 additions & 6 deletions SteamCleaner/Utilities/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,18 @@ public static async void CheckForUpdates()
{
MessageTextBlock =
{
Text = "A new Steam CLeaner update is available, update now?"
Text = "A new Steam Cleaner update is available, update now?"
}
};

var result = await DialogHost.Show(dialog);
if ("1".Equals(result))
GotoSite(_releasePageURL);
}
}
catch
{
// ignored
}
}
}
Expand Down Expand Up @@ -192,7 +194,9 @@ public static string GetDataPath()
try
{
// No version!
var companyAttribute = (AssemblyCompanyAttribute)Application.ResourceAssembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false)[0];
var companyAttribute =
(AssemblyCompanyAttribute)
Application.ResourceAssembly.GetCustomAttributes(typeof (AssemblyCompanyAttribute), false)[0];

return Environment.GetEnvironmentVariable("AppData").Trim() + "\\" + companyAttribute.Company + "\\" +
Application.ResourceAssembly.FullName;
Expand All @@ -211,7 +215,10 @@ public static string GetDataPath()
try
{
// App launch folder
return Assembly.GetEntryAssembly().Location.Substring(0, Assembly.GetEntryAssembly().Location.LastIndexOf("\\", StringComparison.InvariantCultureIgnoreCase));
return Assembly.GetEntryAssembly()
.Location.Substring(0,
Assembly.GetEntryAssembly()
.Location.LastIndexOf("\\", StringComparison.InvariantCultureIgnoreCase));
}
catch
{
Expand All @@ -238,15 +245,15 @@ public static string GetDataPath()
}

/// <summary>
/// APF version of user app data path
/// APF version of user app data path
/// </summary>
/// <returns></returns>
private static string GetUserAppDataPath()
{
var assm = Assembly.GetEntryAssembly();
var at = typeof(AssemblyCompanyAttribute);
var at = typeof (AssemblyCompanyAttribute);
var r = assm.GetCustomAttributes(at, false);
var ct = ((AssemblyCompanyAttribute) (r[0]));
var ct = (AssemblyCompanyAttribute) r[0];
var path = Environment.GetFolderPath(
Environment.SpecialFolder.ApplicationData);
path += @"\" + ct.Company;
Expand Down
2 changes: 2 additions & 0 deletions SteamCleaner/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Costura.Fody" version="1.3.3.0" targetFramework="net452" developmentDependency="true" />
<package id="Fody" version="1.28.3" targetFramework="net452" developmentDependency="true" />
<package id="MaterialDesignColors" version="1.1.2" targetFramework="net452" />
<package id="MaterialDesignThemes" version="1.3.1.418" targetFramework="net452" />
<package id="SquaredInfinity.Foundation" version="1.0.45.0" targetFramework="net452" />
Expand Down

0 comments on commit de5b063

Please sign in to comment.