Skip to content

Commit

Permalink
Code cleanup, preparation for rc6
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalsleuth committed Apr 5, 2023
1 parent 101614c commit 65ef9ff
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 24 deletions.
11 changes: 6 additions & 5 deletions WinFOR-Customizer/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
<MenuItem Header="_Download Tool List" x:Name="ToolList" Click="Download_ToolList" ToolTip="This will download the PDF tool list from the Win-FOR GitHub Repo" InputGestureText="Ctrl+T"/>
</MenuItem>
<MenuItem Header="_Help" x:Name="HelpMenu">
<MenuItem Header="Check for Updates" x:Name="CheckForUpdates" Click="Check_Updates" />
<MenuItem Header="Check for Win-FOR Customizer _Updates" x:Name="CheckForUpdates" Click="Check_Updates" InputGestureText="Ctrl+U"/>
<MenuItem Header="Check GitHub for latest Win-FOR version" x:Name="CheckLatestWinFOR" Click="Show_LatestRelease" InputGestureText="Ctrl+G"/>
<MenuItem Header="Show installed Win-FOR _version" x:Name="CheckWinFORVersion" Click="Check_DistroVersion" InputGestureText="Ctrl+V"/>
<Separator />
<MenuItem Header="About" x:Name="ShowAboutBox" Click="Show_About" />
</MenuItem>
Expand Down Expand Up @@ -321,11 +323,10 @@
<Button x:Name="download_button" Grid.Column="1" Content="_Download" HorizontalAlignment="Right" Margin="0,140,20,0" VerticalAlignment="Top" VerticalContentAlignment="Center" Width="90" FontSize="14" Click="Download_Only" ToolTip="Download the current files only, no installation.&#x0a;DOES NOT INCLUDE Python 2/3 Tools, WinDbg,&#x0a;or Windows Sandbox" Height="25" IsTabStop="True" TabIndex="20"/>
<Button x:Name="install_button" Grid.Column="1" Content="_Install" HorizontalAlignment="Right" Margin="0,175,20,0" VerticalAlignment="Top" VerticalContentAlignment="Center" Width="90" IsEnabled="True" FontSize="14" Click="Install_Click" ToolTip="Will install the chosen tools / environment" Height="25" IsTabStop="True" TabIndex="21"/>
<Button x:Name="install_wsl_button" Grid.Column="1" Content="_WSL Only" HorizontalAlignment="Right" Margin="0,210,20,0" VerticalAlignment="Top" VerticalContentAlignment="Center" Width="90" IsEnabled="True" FontSize="14" Click="Install_WslOnly" ToolTip="Will only install the WSLv2 Environment with SIFT and REMnux" Height="25" IsTabStop="True" TabIndex="22"/>
<Button x:Name="version_button" Grid.Column="1" Content="Distro _Version" HorizontalAlignment="Right" Margin="0,245,20,0" VerticalAlignment="Top" VerticalContentAlignment="Center" Height="25" Width="90" FontSize="14" Click="Check_DistroVersion" ToolTip="Displays the version of the selected distro, if installed.&#x0a;If no distro is chosen from the dropdown, it will search for the WIN-FOR distro version." IsTabStop="True" TabIndex="23"/>
<Button x:Name="saveoutput_button" Grid.Column="1" Content="_Save Output" HorizontalAlignment="Right" Margin="0,280,20,0" VerticalAlignment="Top" Click="Save_ConsoleOutput" Width="90" Height="25" FontSize="14" Visibility="Visible"/>
<Button x:Name="results_button" Grid.Column="1" Content="_Results" HorizontalAlignment="Right" Margin="0,315,20,0" VerticalAlignment="Top" VerticalContentAlignment="Center" Width="90" FontSize="14" Click="Results_Button" ToolTip="Check for Win-FOR installation status results." Height="25" IsTabStop="True" TabIndex="24" Visibility="Visible"/>
<Button x:Name="saveoutput_button" Grid.Column="1" Content="_Save Output" HorizontalAlignment="Right" Margin="0,245,20,0" VerticalAlignment="Top" Click="Save_ConsoleOutput" Width="90" Height="25" FontSize="14" Visibility="Visible" IsTabStop="True" TabIndex="23" />
<Button x:Name="results_button" Grid.Column="1" Content="_Results" HorizontalAlignment="Right" Margin="0,280,20,0" VerticalAlignment="Top" VerticalContentAlignment="Center" Width="90" FontSize="14" Click="Results_Button" ToolTip="Check for Win-FOR installation status results." Height="25" IsTabStop="True" TabIndex="24" Visibility="Visible"/>
<CheckBox x:Name="themed" Content="Themed" HorizontalAlignment="Left" VerticalAlignment="Top" VerticalContentAlignment="Center" IsChecked="False" Checked="Enable_Theme" Unchecked="Disable_Theme" FontSize="16" Margin="10,337,0,0" ToolTip="This adds theme customization, Start Menu layout, and distro-specific Wallpaper" Height="20" Width="92" IsTabStop="True" TabIndex="26"/>
<CheckBox x:Name="wsl" Content="WSL v2" HorizontalAlignment="Left" VerticalAlignment="Top" VerticalContentAlignment="Center" IsChecked="False" FontSize="16" Margin="10,366,0,0" ToolTip="Select this option if you wish to install the Windows Subsystem for Linux v2 with SIFT and REMnux" Height="20" Width="72" IsTabStop="True" TabIndex="25"/>
<CheckBox x:Name="wsl" Content="WSL v2" HorizontalAlignment="Left" VerticalAlignment="Top" VerticalContentAlignment="Center" IsChecked="False" FontSize="16" Margin="10,366,0,0" ToolTip="Select this option if you wish to install the Windows Subsystem for Linux v2 with SIFT and REMnux" Height="20" Width="72" IsTabStop="True" TabIndex="25"/>
<Image x:Name="DS_FingerPrint" Grid.Column="1" HorizontalAlignment="Left" Height="80" Margin="64,401,0,0" VerticalAlignment="Top" Width="80" Source="/Images/fpw120.png"/>
<Label x:Name="Version" Grid.Column="1" Content="" HorizontalContentAlignment="Right" HorizontalAlignment="Right" Margin="0,491,4,0" VerticalAlignment="Top" FontSize="10" Height="21" Width="117"/>
<TextBlock x:Name="GitHub" HorizontalAlignment="Center" Margin="0,479,0,0" VerticalAlignment="Top" FontSize="11" Grid.Column="1" Height="15" Width="158">
Expand Down
58 changes: 40 additions & 18 deletions WinFOR-Customizer/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public MainWindow()
install_wsl_button.IsEnabled = false;
download_button.IsEnabled = false;
}
Version.Content = $"v{appversion}-rc5";
Version.Content = $"v{appversion}";
outputter = new TextBoxOutputter(OutputConsole);
Console.SetOut(outputter);
CommandBindings.Add(new CommandBinding(KeyboardShortcuts.LoadFile, (sender, e) => { File_Load(); }, (sender, e) => { e.CanExecute = true; }));
Expand All @@ -63,12 +63,16 @@ public MainWindow()
InputBindings.Add(new KeyBinding(KeyboardShortcuts.ShowCRA, new KeyGesture(Key.R, ModifierKeys.Control)));
CommandBindings.Add(new CommandBinding(KeyboardShortcuts.ShowWIN, (sender, e) => { WINFOR_Default(sender, e); }, (sender, e) => { e.CanExecute = true; }));
InputBindings.Add(new KeyBinding(KeyboardShortcuts.ShowWIN, new KeyGesture(Key.W, ModifierKeys.Control)));
CommandBindings.Add(new CommandBinding(KeyboardShortcuts.CheckAll, (sender, e) => { Check_All(); }, (sender, e) => { e.CanExecute = true; }));
InputBindings.Add(new KeyBinding(KeyboardShortcuts.CheckAll, new KeyGesture(Key.A, ModifierKeys.Control)));
CommandBindings.Add(new CommandBinding(KeyboardShortcuts.UnCheckAll, (sender, e) => { UnCheck_All(); }, (sender, e) => { e.CanExecute = true; }));
InputBindings.Add(new KeyBinding(KeyboardShortcuts.UnCheckAll, new KeyGesture(Key.U, ModifierKeys.Control)));
CommandBindings.Add(new CommandBinding(KeyboardShortcuts.DownloadToolList, (sender, e) => { Download_ToolList(sender, e); }, (sender, e) => { e.CanExecute = true; }));
InputBindings.Add(new KeyBinding(KeyboardShortcuts.DownloadToolList, new KeyGesture(Key.T, ModifierKeys.Control)));
CommandBindings.Add(new CommandBinding(KeyboardShortcuts.CheckForUpdates, (sender, e) => { Check_Updates(sender, e); }, (sender, e) => { e.CanExecute = true; }));
InputBindings.Add(new KeyBinding(KeyboardShortcuts.CheckForUpdates, new KeyGesture(Key.U, ModifierKeys.Control)));
CommandBindings.Add(new CommandBinding(KeyboardShortcuts.ShowLatest, (sender, e) => { Show_LatestRelease(sender, e); }, (sender, e) => { e.CanExecute = true; }));
InputBindings.Add(new KeyBinding(KeyboardShortcuts.ShowLatest, new KeyGesture(Key.G, ModifierKeys.Control)));
CommandBindings.Add(new CommandBinding(KeyboardShortcuts.CheckDistroVersion, (sender, e) => { Check_DistroVersion(sender, e); }, (sender, e) => { e.CanExecute = true; }));
InputBindings.Add(new KeyBinding(KeyboardShortcuts.CheckDistroVersion, new KeyGesture(Key.V, ModifierKeys.Control)));
CommandBindings.Add(new CommandBinding(KeyboardShortcuts.ShowAbout, (sender, e) => { Show_About(sender, e); }, (sender, e) => { e.CanExecute = true; }));
InputBindings.Add(new KeyBinding(KeyboardShortcuts.ShowAbout, new KeyGesture(Key.A, ModifierKeys.Control)));
}
public static class KeyboardShortcuts
// Setup bindings and RoutedCommands for Keyboard Shortcuts for the Menu
Expand All @@ -80,20 +84,23 @@ static KeyboardShortcuts()
ShowCPC = new RoutedCommand("ShowCPC", typeof(MainWindow));
ShowCRA = new RoutedCommand("ShowCRA", typeof(MainWindow));
ShowWIN = new RoutedCommand("ShowWIN", typeof(MainWindow));
CheckAll = new RoutedCommand("CheckAll", typeof(MainWindow));
UnCheckAll = new RoutedCommand("UnCheckAll", typeof(MainWindow));
DownloadToolList = new RoutedCommand("DownloadToolList", typeof(MainWindow));
CheckForUpdates = new RoutedCommand("CheckForUpdates", typeof(MainWindow));
ShowLatest = new RoutedCommand("ShowLatest", typeof(MainWindow));
CheckDistroVersion = new RoutedCommand("CheckDistroVersion", typeof(MainWindow));
ShowAbout = new RoutedCommand("ShowAbout", typeof(MainWindow));
}
public static RoutedCommand LoadFile { get; private set; }
public static RoutedCommand SaveFile { get; private set; }
public static RoutedCommand ShowCPC { get; private set; }
public static RoutedCommand ShowCRA { get; private set; }
public static RoutedCommand ShowWIN { get; private set; }
public static RoutedCommand CheckAll { get; private set; }
public static RoutedCommand UnCheckAll { get; private set; }
public static RoutedCommand DownloadToolList { get; private set; }
public static RoutedCommand CheckForUpdates { get; private set; }
public static RoutedCommand ShowLatest { get; private set; }
public static RoutedCommand CheckDistroVersion { get; private set; }
public static RoutedCommand ShowAbout { get; private set; }
}

public class TextBoxOutputter : TextWriter
// Idea for the TextBoxOutputter from https://social.technet.microsoft.com/wiki/contents/articles/12347.wpf-howto-add-a-debugoutput-console-to-your-application.aspx
{
Expand Down Expand Up @@ -1533,11 +1540,11 @@ private async Task Execute_SaltStack(string username, string standalones_path, s
await readOutput;
if (saltproc.HasExited && saltproc.ExitCode != 0)
{
Console_Output("SaltStack installation has completed with errors.");
Console_Output("Installation has completed with errors.");
}
else if (saltproc.HasExited && saltproc.ExitCode == 0)
{
Console_Output("SaltStack installation has completed successfully.");
Console_Output("Installation has completed successfully.");
}
}
}
Expand Down Expand Up @@ -1592,11 +1599,11 @@ private async Task Execute_SaltStackDownloads(string release, string download_pa
await readOutput;
if (saltproc.HasExited && saltproc.ExitCode != 0)
{
Console_Output("SaltStack installation has completed with errors.");
Console_Output("Download process has completed with errors.");
}
else if (saltproc.HasExited && saltproc.ExitCode == 0)
{
Console_Output("SaltStack installation has completed successfully.");
Console_Output("Download process has completed successfully.");
}
}
}
Expand Down Expand Up @@ -1668,11 +1675,11 @@ private async Task Execute_Wsl(string username, string release, string standalon
await readOutput;
if (wslproc.HasExited && wslproc.ExitCode != 0)
{
Console_Output("SaltStack installation has completed with errors.");
Console_Output("WSL installation has completed with errors.");
}
else if (wslproc.HasExited && wslproc.ExitCode == 0)
{
Console_Output("SaltStack installation has completed successfully.");
Console_Output("WSL installation has completed successfully.");
}
}
}
Expand Down Expand Up @@ -1953,15 +1960,15 @@ private async void Check_Updates(object sender, RoutedEventArgs e)
MessageBoxResult result = MessageBox.Show(
$"New version found: {release_tag}\n" +
$"Current version: {appversion}\n\n" +
$"Would you like to download the new version?", $"New Version Found - {release_tag}", MessageBoxButton.YesNo, MessageBoxImage.Question);
$"Would you like to download the new version of Win-FOR Customizer?", $"New Version Found - {release_tag}", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
Process.Start(new ProcessStartInfo($"{new_release}") { UseShellExecute = true });
}
}
else if (release_tag <= appversion)
{
MessageBox.Show($"No new release found: {appversion} is the most recent release.", "No new release found", MessageBoxButton.OK, MessageBoxImage.Information);
MessageBox.Show($"No new release of Win-FOR Customizer found:\n{appversion} is the most recent release.", "No new release of Win-FOR Customizer found", MessageBoxButton.OK, MessageBoxImage.Information);
}
else if (appversion > release_tag)
{
Expand Down Expand Up @@ -2127,6 +2134,21 @@ private string Tool_List()
}
return output;
}
private async void Show_LatestRelease(object sender, RoutedEventArgs e)
{
try
{
List<string> release_data = await Identify_Release();
MessageBox.Show($"The latest version of Win-FOR is {release_data[0]}\nIf you wish to update, simply select your tools\nand click Install", $"{release_data[0]} is the latest version", MessageBoxButton.OK, MessageBoxImage.Information);
}
catch (Exception ex)
{
OutputExpander.IsEnabled = true;
OutputExpander.Visibility = Visibility.Visible;
OutputExpander.IsExpanded = true;
Console_Output($"[ERROR] Unable to determine the latest version:\n{ex}");
}
}
private void Test_Button(object sender, RoutedEventArgs e)
// Simply used to test a function without having to modify the GUI environment
{
Expand Down
3 changes: 2 additions & 1 deletion WinFOR-Customizer/Win-FOR Customizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<RepositoryUrl>https://github.com/digitalsleuth/win-for</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<ApplicationIcon>Images\fp.ico</ApplicationIcon>
<Version>6.0.0</Version>
<Version>6.0.0-rc6</Version>
<AssemblyVersion>6.0.0</AssemblyVersion>
<FileVersion>6.0.0</FileVersion>
<Authors>Corey Forman (digitalsleuth)</Authors>
Expand All @@ -26,6 +26,7 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageId>WinFOR.Customizer</PackageId>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
<NeutralLanguage>en</NeutralLanguage>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down

0 comments on commit 65ef9ff

Please sign in to comment.