Skip to content

Commit

Permalink
Merge pull request #1 from Kwalix/develop
Browse files Browse the repository at this point in the history
Release V1
  • Loading branch information
crvwxlf authored Feb 1, 2021
2 parents 8e8afbd + bec25bf commit 2940533
Show file tree
Hide file tree
Showing 16 changed files with 400 additions and 3 deletions.
54 changes: 54 additions & 0 deletions KiwiCleaner/About.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<Window x:Class="KiwiCleaner.About"
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:KiwiCleaner"
mc:Ignorable="d"
Topmost="True"
Title="À propos" Height="392" Width="500" Icon="/res/KiwiCleaner.png" ResizeMode="NoResize" Background="#FF413E4A" WindowStartupLocation="CenterScreen">
<StackPanel>
<StackPanel Margin="50">
<Label Content="Crée par : Kwalix" FontFamily="Bahnschrift" Foreground="#FFF7E4BE" FontSize="24"/>
<Label Content="Version : 1.0.0" FontFamily="Bahnschrift" Foreground="#FFF7E4BE" FontSize="18"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="50" HorizontalAlignment="Center">

<Button x:Name="Bmc_Btn" BorderBrush="{x:Null}" Foreground="{x:Null}" Height="50" Background="{x:Null}" Click="Bmc_Button_Click">
<Image Source="/res/bmc-button.png" Stretch="Fill"/>
<Button.ToolTip>
<ToolTip>
Faite moi un don
</ToolTip>
</Button.ToolTip>
</Button>
<Separator Margin="5,5"/>
<Button x:Name="Ig_Button" BorderBrush="{x:Null}" Foreground="{x:Null}" Height="50" Background="{x:Null}" Click="Ig_Button_Click">
<Image Source="/res/ig-button.png" Stretch="Fill"/>
<Button.ToolTip>
<ToolTip>
Ma Page Instagram
</ToolTip>
</Button.ToolTip>
</Button>
<Separator Margin="5,5"/>
<Button x:Name="Gh_Button" BorderBrush="{x:Null}" Foreground="{x:Null}" Height="50" Background="{x:Null}" Click="Gh_Button_Click">
<Image Source="/res/github.png" Stretch="Fill"/>
<Button.ToolTip>
<ToolTip>
Mon profile GitHub
</ToolTip>
</Button.ToolTip>
</Button>
<Separator Margin="5,5"/>
<Button x:Name="Report_Button" BorderBrush="{x:Null}" Foreground="{x:Null}" Height="50" Background="{x:Null}" Click="Report_Button_Click">
<Image Source="/res/virus.png" Stretch="Fill"/>
<Button.ToolTip>
<ToolTip>
Signaler un problème
</ToolTip>
</Button.ToolTip>
</Button>
</StackPanel>
</StackPanel>
</Window>
63 changes: 63 additions & 0 deletions KiwiCleaner/About.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
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.Navigation;
using System.Windows.Shapes;

namespace KiwiCleaner
{
/// <summary>
/// Logique d'interaction pour About.xaml
/// </summary>
public partial class About : Window
{
public About()
{
InitializeComponent();
}

private void Bmc_Button_Click(object sender,RoutedEventArgs e)
{
ProcessStartInfo psi = new ProcessStartInfo();
psi.UseShellExecute = true;
psi.FileName = "https://www.buymeacoffee.com/kwalix";

Process.Start(psi);
}

private void Ig_Button_Click(object sender, RoutedEventArgs e)
{
ProcessStartInfo psi = new ProcessStartInfo();
psi.UseShellExecute = true;
psi.FileName = "https://www.instagram.com/kwalix.dev/";

Process.Start(psi);
}

private void Gh_Button_Click(object sender, RoutedEventArgs e)
{
ProcessStartInfo psi = new ProcessStartInfo();
psi.UseShellExecute = true;
psi.FileName = "https://github.com/Kwalix";

Process.Start(psi);
}

private void Report_Button_Click(object sender, RoutedEventArgs e)
{
ProcessStartInfo psi = new ProcessStartInfo();
psi.UseShellExecute = true;
psi.FileName = "https://github.com/Kwalix/KiwiCleaner/issues/new";

Process.Start(psi);
}
}
}
50 changes: 50 additions & 0 deletions KiwiCleaner/KiwiCleaner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,56 @@
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
<ApplicationIcon>res\KiwiCleaner.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Version>1.0.0</Version>
<Authors>Kwalix</Authors>
<Description>Logiciel de nettoyage de cache</Description>
<NeutralLanguage></NeutralLanguage>
<Copyright>Kwalix</Copyright>
<SignAssembly>false</SignAssembly>
</PropertyGroup>

<ItemGroup>
<None Remove="analysis.png" />
<None Remove="KiwiCleaner.png" />
<None Remove="res\about.png" />
<None Remove="res\bmc-button.png" />
<None Remove="res\clean.png" />
<None Remove="res\github.png" />
<None Remove="res\ig-button.png" />
<None Remove="res\KiwiCleaner.ico" />
<None Remove="res\virus.png" />
</ItemGroup>

<ItemGroup>
<Resource Include="res\about.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="res\analysis.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="res\bmc-button.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="res\clean.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="res\github.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="res\ig-button.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="res\KiwiCleaner.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="res\KiwiCleaner.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="res\virus.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
</ItemGroup>

</Project>
46 changes: 43 additions & 3 deletions KiwiCleaner/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,48 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:KiwiCleaner"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
Title="KiwiCleaner" Height="500" Width="900" WindowStartupLocation="CenterScreen" WindowState="Normal" ResizeMode="CanMinimize" Icon="/res/KiwiCleaner.png">
<DockPanel>
<StackPanel DockPanel.Dock="Top" Height="108" Background="#FF73626E" Orientation="Horizontal">
<Label Content="KiwiCleaner" Foreground="#FFF7E4BE" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" Width="450" HorizontalAlignment="Left" Height="104" FontSize="36" FontFamily="Bahnschrift"/>
<StackPanel Width="439">
<Label Content="Dernière analyse :" Foreground="#FFF7E4BE" FontSize="24" FontFamily="Bahnschrift"/>
<Label x:Name="LastScanLabel" Content="Jamais" Foreground="#FFF7E4BE" FontSize="20" FontFamily="Bahnschrift"/>
<Label x:Name="SpaceToCleanLabel" Content="Espace à nettoyer : ? Mo" Foreground="#FFF7E4BE" FontSize="24" FontFamily="Bahnschrift"/>

</Grid>
</StackPanel>

<!-- Info section -->
</StackPanel>
<StackPanel DockPanel.Dock="Left" Background="#FF73626E" Width="151">
<Button x:Name="ScanBtn" Height="100" Background="{x:Null}" Foreground="#FFF7E4BE" BorderThickness="10,10,10,10" BorderBrush="#FFF7E4BE" Grid.IsSharedSizeScope="True" Margin="0,10,0,0" FontFamily="Bahnschrift" FontSize="16" Click="ScanBtn_Click">
<StackPanel>
<Image Source="/res/analysis.png" Height="48" Width="48"/>
<Label Content="Analyser" HorizontalAlignment="Center" Foreground="#FFF7E4BE"/>
</StackPanel>
</Button>
<Button IsEnabled="False" x:Name="CleanBtn" Height="100" Background="{x:Null}" Foreground="#FFF7E4BE" BorderThickness="10,10,10,10" BorderBrush="#FFF7E4BE" Margin="0,10,0,0" FontSize="16" FontFamily="Bahnschrift" Click="CleanBtn_Click">
<StackPanel>
<Image Source="/res/clean.png" Height="48" Width="48"/>
<Label Content="Nettoyer" HorizontalAlignment="Center" Foreground="#FFF7E4BE"/>
</StackPanel>
</Button>
<Button x:Name="AboutBtn" Height="100" Background="{x:Null}" Foreground="#FFF7E4BE" BorderThickness="10,10,10,10" BorderBrush="#FFF7E4BE" Margin="0,10,0,0" FontFamily="Bahnschrift" FontSize="16" Click="AboutBtn_Click">
<StackPanel>
<Image Source="/res/about.png" Height="48" Width="48"/>
<Label Content="À propos" HorizontalAlignment="Center" Foreground="#FFF7E4BE"/>
</StackPanel>
</Button>

<!-- Button section -->
</StackPanel>
<DockPanel Background="#FF413E4A">
<ScrollViewer Margin="37">
<TextBox x:Name="LogBox" IsReadOnly="True" Text="Les logs s'afficheront ici..." TextWrapping="Wrap" FontSize="14"/>
</ScrollViewer>
<!-- Main panel -->
</DockPanel>


</DockPanel>
</Window>
100 changes: 100 additions & 0 deletions KiwiCleaner/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;
using Path = System.IO.Path;
using System.Threading;

namespace KiwiCleaner
{
Expand All @@ -23,6 +26,103 @@ public partial class MainWindow : Window
public MainWindow()
{
InitializeComponent();
FetchLastScan();
}

private void ScanBtn_Click(object sender, RoutedEventArgs e)
{
// Generate new date scan and save it to lastscan file
string lastScan = DateTime.Now.ToString("MM/dd/yyyy HH:mm");
File.WriteAllText(@".\lastscan.txt", lastScan);
string[] splitedDate = lastScan.Split(" ");
LastScanLabel.Content = $"Le {splitedDate[0]} à {splitedDate[1]}";

StartScan();
}

private void CleanBtn_Click(object sender, RoutedEventArgs e)
{
Clean();
}

private void AboutBtn_Click(object sender, RoutedEventArgs e)
{
About about = new About();
about.Show();
}

private void FetchLastScan()
{
if (File.Exists(@".\lastscan.txt"))
{
string lastScanDate = File.ReadAllText(@".\lastscan.txt");
string[] splitedDate = lastScanDate.Split();
LastScanLabel.Content = $"Le {splitedDate[0]} à {splitedDate[1]}";
}
}

private void StartScan()
{

string tmpPath = Path.GetTempPath();
string[] tmpFiles = Directory.GetFiles(tmpPath);
DirectoryInfo dir = new DirectoryInfo(tmpPath);

LogBox.Text = "";
LogBox.Text += $"Getting : {tmpPath}" + Environment.NewLine;

foreach(DirectoryInfo d in dir.GetDirectories())
{
LogBox.Text += $"Getting : {d}" + Environment.NewLine;
}
foreach (string file in tmpFiles)
{
LogBox.Text += $"Getting : {file}" + Environment.NewLine;
}


long size = dir.EnumerateFiles("*.*", SearchOption.AllDirectories).Sum(fi => fi.Length);
size /= 1024;
size /= 1024;
SpaceToCleanLabel.Content = $"Espace à nettoyer : {size} Mo";

CleanBtn.IsEnabled = true;
}

private void Clean()
{
CleanBtn.IsEnabled = false;
string pathToDelFiles = Path.GetTempPath();
string[] toDeleteFiles = Directory.GetFiles(pathToDelFiles);
DirectoryInfo dir = new DirectoryInfo(pathToDelFiles);


foreach (DirectoryInfo d in dir.GetDirectories())
{
LogBox.Text += $"Deleting Directory : {d}" + Environment.NewLine;
try
{
d.Delete(true);
} catch(Exception)
{
LogBox.Text += $"Erreur dossier : {d} peux pas etre supprimé" + Environment.NewLine;
}
}
foreach (string f in toDeleteFiles)
{

LogBox.Text += $"Deleting : {f}" + Environment.NewLine;
try
{
File.Delete(f);
}
catch (Exception)
{
LogBox.Text += $"Erreur fichier : {f} peux pas etre supprimé" + Environment.NewLine;
}
}
SpaceToCleanLabel.Content = "Espace à nettoyer : 0 Mo";
LogBox.Text += "Nettoyage réussi !";
}
}
}
Loading

0 comments on commit 2940533

Please sign in to comment.