From 5bcde889b39e464af22ef8db2f392a04c1ebd5ab Mon Sep 17 00:00:00 2001 From: Jacopo Santoni Date: Sat, 14 Jul 2018 01:38:50 +0200 Subject: [PATCH] Log Window enhancements (#95) * Split type combobox into system combobox and disc type combobox * corrected indentation for xaml file * fixed merge with head * fixed format * fixed issues for PR, added KnownSystem.CUSTOM * removed Updater.cs which ended by error in commit * fixed GetOuptutName() for new drive/system combobox * created LogWindow and first tests of output gathering * integrated all the proof of concept related to stream fetching of DIC output into LogWindow * working on LogWindow\ncreated more efficient output matching management, improved handling of process termination * created Tasks file\nmoved some methods there, created DumpEnvironment to manage are arguments * moved additional methods to Tasks to make it more modular * changed StartDumping flow to avoid returning if extra tools are not found * moved main dump workflow into Tasks class * created specific DumpResult class for better error reporting/management * fixes * fixes Dispatcher thread issue with progress bar * continued refactor - split EnsureDiscInformation into an additional EnsureCorrectInformationForSystemAndMediaType - proof of concept of using custom extensions to enum types to give better functionality (and encapsulation) - changed cmb_MediaType to keep a List and got rid of Tuple * restored GetDiscType functionality * fixed btn_StartStop enabled on EnsureCorrect... error * fixed whitespace * fixed indentation * merged conflicts * moved log window * working on LogWindow resize/location behavior * working on message logging in LogWindow * added working integration between MenuItem for LogWindow and its visibility status, fixes issues with positioning and visibility, correctly bound Verbose flag to property * finished integrating LogWindow, added some verbose logs * added logs * fixed include order * added option to show log window at startup, removed useless QuietMode property from MainWindow * added precise calculation of MainWindow position when LogWindow is shown and fixed topmost cheat --- DICUI/DICUI.csproj | 1 + DICUI/Data/Constants.cs | 2 ++ DICUI/LogWindow.xaml.cs | 3 ++- DICUI/MainWindow.xaml | 2 +- DICUI/MainWindow.xaml.cs | 17 ++++++++++++++--- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/DICUI/DICUI.csproj b/DICUI/DICUI.csproj index 52a652c3..718845c5 100644 --- a/DICUI/DICUI.csproj +++ b/DICUI/DICUI.csproj @@ -76,6 +76,7 @@ + diff --git a/DICUI/Data/Constants.cs b/DICUI/Data/Constants.cs index 7d02baa3..25e6889c 100644 --- a/DICUI/Data/Constants.cs +++ b/DICUI/Data/Constants.cs @@ -7,6 +7,8 @@ { public const string StartDumping = "Start Dumping"; public const string StopDumping = "Stop Dumping"; + + public const int LogWindowMarginFromMainWindow = 10; } /// diff --git a/DICUI/LogWindow.xaml.cs b/DICUI/LogWindow.xaml.cs index 12da66e1..d534411a 100644 --- a/DICUI/LogWindow.xaml.cs +++ b/DICUI/LogWindow.xaml.cs @@ -16,6 +16,7 @@ using System.Windows.Interop; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; +using DICUI.Data; using DICUI.UI; namespace DICUI @@ -135,7 +136,7 @@ namespace DICUI public void AdjustPositionToMainWindow() { this.Left = _mainWindow.Left; - this.Top = _mainWindow.Top + _mainWindow.Height + 10; + this.Top = _mainWindow.Top + _mainWindow.Height + UIElements.LogWindowMarginFromMainWindow; } private void GracefullyTerminateProcess() diff --git a/DICUI/MainWindow.xaml b/DICUI/MainWindow.xaml index 4b2390f7..734f3de3 100644 --- a/DICUI/MainWindow.xaml +++ b/DICUI/MainWindow.xaml @@ -8,7 +8,7 @@ xmlns:utilities="clr-namespace:DICUI.Utilities" mc:Ignorable="d" Title="Disc Image Creator GUI" Height="450" Width="600" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize" - LocationChanged="MainWindowLocationChanged" Activated="MainWindowLocationActivated" Closing="MainWindowClosing"> + LocationChanged="MainWindowLocationChanged" Activated="MainWindowActivated" Closing="MainWindowClosing"> diff --git a/DICUI/MainWindow.xaml.cs b/DICUI/MainWindow.xaml.cs index d0f1af91..770c25bc 100644 --- a/DICUI/MainWindow.xaml.cs +++ b/DICUI/MainWindow.xaml.cs @@ -44,6 +44,17 @@ namespace DICUI StartStopButton.IsEnabled = false; DiskScanButton.IsEnabled = false; CopyProtectScanButton.IsEnabled = false; + + if (_options.OpenLogWindowAtStartup) + { + System.Drawing.Rectangle bounds = WinForms.Screen.PrimaryScreen.WorkingArea; + + this.WindowStartupLocation = WindowStartupLocation.Manual; + double combinedHeight = this.Height + _logWindow.Height + UIElements.LogWindowMarginFromMainWindow; + + this.Left = bounds.Left + (bounds.Width - this.Width) / 2; + this.Top = bounds.Top + (bounds.Height - combinedHeight) / 2; + } } @@ -164,12 +175,12 @@ namespace DICUI _logWindow.AdjustPositionToMainWindow(); } - private void MainWindowLocationActivated(object sender, EventArgs e) + private void MainWindowActivated(object sender, EventArgs e) { - if (_logWindow.IsVisible) + if (_logWindow.IsVisible && !this.Topmost) { _logWindow.Topmost = true; - this.Topmost = true; + _logWindow.Topmost = false; } }