Skip to content

Commit 8b246d8

Browse files
author
KELEV6
committed
Added a bunch of new scans, fixed major bug where scan was required to load libraries so compare would crash, more user friendly UI
1 parent e150713 commit 8b246d8

31 files changed

Lines changed: 1294 additions & 116 deletions

FreeDiskSpace/FreeDiskSpace.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using Microsoft.Win32;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.IO;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
using System.Xml.Serialization;
9+
using WindowsSystemDiffToolsCore;
10+
11+
namespace FreeDiskSpace
12+
{
13+
14+
public class FreeDiskSpace : Component
15+
{
16+
17+
public FreeDiskSpace() { }
18+
19+
public string Name { get; set; }
20+
public long AvailaibleSpace { get; set; }
21+
22+
public FreeDiskSpace(DriveInfo drive)
23+
{
24+
this.Name = drive.Name;
25+
this.AvailaibleSpace = (long)(drive.AvailableFreeSpace / 1024f);
26+
}
27+
28+
29+
public override string ToString()
30+
{
31+
return $"{this.Name} [AvailaibleSpace '{this.AvailaibleSpace} kB']";
32+
}
33+
34+
35+
}
36+
}

FreeDiskSpace/FreeDiskSpace.csproj

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{07CC1B48-EEA2-430F-9160-1DCD6D7B1865}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>FreeDiskSpace</RootNamespace>
11+
<AssemblyName>FreeDiskSpace</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<ItemGroup>
33+
<Reference Include="System" />
34+
<Reference Include="System.Core" />
35+
<Reference Include="System.Xml.Linq" />
36+
<Reference Include="System.Data.DataSetExtensions" />
37+
<Reference Include="Microsoft.CSharp" />
38+
<Reference Include="System.Data" />
39+
<Reference Include="System.Net.Http" />
40+
<Reference Include="System.Xml" />
41+
</ItemGroup>
42+
<ItemGroup>
43+
<Compile Include="Properties\AssemblyInfo.cs" />
44+
<Compile Include="FreeDiskSpace.cs" />
45+
<Compile Include="FreeDiskSpaceDiff.cs" />
46+
<Compile Include="FreeDiskSpaceScanner.cs" />
47+
</ItemGroup>
48+
<ItemGroup>
49+
<ProjectReference Include="..\WindowsSystemDiffToolsCore\WindowsSystemDiffToolsCore.csproj">
50+
<Project>{87e4859a-d7b0-4a84-a2d3-1d54f8b74568}</Project>
51+
<Name>WindowsSystemDiffToolsCore</Name>
52+
</ProjectReference>
53+
</ItemGroup>
54+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
55+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
56+
Other similar extension points exist, see Microsoft.Common.targets.
57+
<Target Name="BeforeBuild">
58+
</Target>
59+
<Target Name="AfterBuild">
60+
</Target>
61+
-->
62+
</Project>

FreeDiskSpace/FreeDiskSpaceDiff.cs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using WindowsSystemDiffToolsCore;
7+
8+
namespace FreeDiskSpace
9+
{
10+
public class FreeDiskSpaceDiff : DiffCore
11+
{
12+
public FreeDiskSpaceDiff(){}
13+
14+
15+
List<FreeDiskSpace> beforeList;
16+
List<FreeDiskSpace> afterList;
17+
18+
19+
public override List<DiffResult> Start()
20+
{
21+
List<DiffResult> results = new List<DiffResult>();
22+
23+
beforeList = GetBeforeData<FreeDiskSpace>();
24+
afterList = GetAfterData<FreeDiskSpace>();
25+
26+
27+
foreach(FreeDiskSpace beforeItem in beforeList)
28+
{
29+
FreeDiskSpace afterItem = afterList.FirstOrDefault(x => x.Name == beforeItem.Name);
30+
31+
if (afterItem == null)
32+
{
33+
//Drive has been deleted
34+
results.Add(DiffResult.Removed(beforeItem.ToString()));
35+
continue;
36+
}
37+
38+
39+
//Drive space modified
40+
if((beforeItem.AvailaibleSpace != afterItem.AvailaibleSpace))
41+
{
42+
results.Add(DiffResult.Modified(beforeItem.ToString(), afterItem.ToString()));
43+
continue;
44+
}
45+
}
46+
47+
foreach(FreeDiskSpace afterItem in afterList)
48+
{
49+
FreeDiskSpace beforeItem = beforeList.FirstOrDefault(x => x.Name == afterItem.Name);
50+
51+
//New Drive
52+
if(beforeItem == null)
53+
{
54+
results.Add(DiffResult.Added(afterItem.ToString()));
55+
}
56+
57+
58+
}
59+
60+
return results;
61+
}
62+
63+
64+
65+
}
66+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using Microsoft.Win32;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using WindowsSystemDiffToolsCore;
8+
using WindoesSystemDiffToolsCore;
9+
using System.IO;
10+
11+
namespace FreeDiskSpace
12+
{
13+
class FreeDiskSpaceScanner : ComponentScanner
14+
{
15+
public FreeDiskSpaceScanner(){ }
16+
17+
protected override string Name { get { return "Free disk space"; } }
18+
19+
public override string ComponentName { get { return "FreeDiskSpace"; } }
20+
public override string ComponentNamespace { get { return "FreeDiskSpace"; } }
21+
22+
23+
public override List<Component> Scan()
24+
{
25+
List<Component> drives = new List<Component>();
26+
27+
foreach (DriveInfo drive in DriveInfo.GetDrives())
28+
drives.Add(new FreeDiskSpace(drive));
29+
30+
Listener.sendStringToUI($"Scanned {drives.Count} drives availaible space");
31+
32+
return drives;
33+
}
34+
35+
public override Type TypeOfComponent()
36+
{
37+
return typeof(FreeDiskSpace);
38+
}
39+
40+
public override Type TypeOfComponentDiff()
41+
{
42+
return typeof(FreeDiskSpaceDiff);
43+
}
44+
45+
}
46+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("FreeDiskSpace")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("FreeDiskSpace")]
13+
[assembly: AssemblyCopyright("Copyright © 2017")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("07cc1b48-eea2-430f-9160-1dcd6d7b1865")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

InstalledPrograms64bitsScanner/InstalledProgram64bitsScanner.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class InstalledProgram64bitsScanner : ComponentScanner
1212
{
1313
public InstalledProgram64bitsScanner(){ }
1414

15-
protected override string Name { get { return "Programmes et fonctionnalités (64 bits)"; } }
15+
protected override string Name { get { return "Programs and features (64 bits)"; } }
1616

1717
public override string ComponentName { get { return "InstalledProgram64bits"; } }
1818
public override string ComponentNamespace { get { return "InstalledPrograms64bitsScanner"; } }
@@ -27,7 +27,7 @@ public override List<Component> Scan()
2727
RegistryKey key = hklm.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall");
2828
string[] subKeyNames = key.GetSubKeyNames();
2929

30-
sendMessageToUI("Scan des clés de registre 64 bits...");
30+
sendMessageToUI("Scanning 64 bits programs and features from the registry");
3131
foreach (string subKeyName in subKeyNames)
3232
{
3333
RegistryKey installedProgramKey = key.OpenSubKey(subKeyName);
@@ -37,7 +37,7 @@ public override List<Component> Scan()
3737
if (keyValueNames.Contains("DisplayName"))
3838
installedPrograms.Add(new InstalledProgram64bits(installedProgramKey, 64));
3939
}
40-
sendMessageToUI($"Scan des clés 64 bits terminé, {key.SubKeyCount} clés scannées.");
40+
sendMessageToUI($"Scan completed, {key.SubKeyCount} keys scanned.");
4141

4242

4343
return installedPrograms;

InstalledProgramsScanner/InstalledProgram32bitsScanner.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class InstalledProgram32bitsScanner : ComponentScanner
1313
{
1414
public InstalledProgram32bitsScanner(){ }
1515

16-
protected override string Name { get { return "Programmes et fonctionnalités (32 bits)"; } }
16+
protected override string Name { get { return "Programs and features (32 bits)"; } }
1717

1818
public override string ComponentName { get { return "InstalledProgram32bits"; } }
1919
public override string ComponentNamespace { get { return "InstalledPrograms32bitsScanner"; } }
@@ -28,7 +28,7 @@ public override List<Component> Scan()
2828
RegistryKey key = hklm.OpenSubKey(@"Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall");
2929
string[] subKeyNames = key.GetSubKeyNames();
3030

31-
sendMessageToUI("Scan des clés de registre 32 bits...");
31+
sendMessageToUI("Scanning 32 bits programs and features from the registry");
3232
foreach (string subKeyName in subKeyNames)
3333
{
3434
RegistryKey installedProgramKey = key.OpenSubKey(subKeyName);
@@ -38,7 +38,7 @@ public override List<Component> Scan()
3838
if (keyValueNames.Contains("DisplayName"))
3939
installedPrograms.Add(new InstalledProgram32bits(installedProgramKey, 32));
4040
}
41-
sendMessageToUI($"Scan des clés 32 bits terminé, {key.SubKeyCount} clés scannées.");
41+
sendMessageToUI($"Scan completed, {key.SubKeyCount} keys scanned.");
4242

4343
return installedPrograms;
4444
}

Service/Properties/AssemblyInfo.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("Service")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("Service")]
13+
[assembly: AssemblyCopyright("Copyright © 2017")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("d8bd7d79-05a3-49d2-98a2-e2386620aba9")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)