diff --git a/SuperGrate/Classes/Config.cs b/SuperGrate/Classes/Config.cs index 95c355b..a8bfc96 100644 --- a/SuperGrate/Classes/Config.cs +++ b/SuperGrate/Classes/Config.cs @@ -1,5 +1,7 @@ using System.Xml.Linq; using System.IO; +using System; +using System.Collections.Generic; namespace SuperGrate { @@ -8,13 +10,20 @@ class Config public static string MigrationStorePath = null; public static string ScanStateParameters = null; public static string LoadStateParameters = null; + + public static Dictionary Data = new Dictionary() { //Make config more automagic + "MigrationStorePath", + "ScanStateParameters", + "LoadStateParameters" + }; + public static void GenerateConfig() { Logger.Warning("Generating new SuperGrate.xml config."); new XDocument(new XElement("SuperGrate", - new XComment("The UNC path to the USMT Migration Store."), - new XElement("MigrationStorePath", @"\\share\migrationstore$"), - new XComment("ScanState.exe & LoadState.exe CLI Parameters: https://docs.microsoft.com/en-us/windows/deployment/usmt/usmt-command-line-syntax"), + new XComment(@"The UNC or Direct path to the USMT Migration Store E.g: \\ba-share\s$ or .\STORE."), + new XElement("MigrationStorePath", @".\STORE"), + new XComment("ScanState.exe & LoadState.exe CLI Parameters: https://docs.microsoft.com/en-us/windows/deployment/usmt/usmt-command-line-syntax "), new XElement("ScanStateParameters", "/config:Config_SettingsOnly.xml /i:MigUser.xml /r:3 /o"), new XElement("LoadStateParameters", "/config:Config_SettingsOnly.xml /i:MigUser.xml /r:3") )).Save(@".\SuperGrate.xml"); @@ -25,12 +34,51 @@ public static void LoadConfig() { GenerateConfig(); } - XDocument config = XDocument.Load(@".\SuperGrate.xml"); - XElement root = config.Element("SuperGrate"); - MigrationStorePath = root.Element("MigrationStorePath").Value; - ScanStateParameters = root.Element("ScanStateParameters").Value; - LoadStateParameters = root.Element("LoadStateParameters").Value; - Logger.Success("Config loaded!"); + try + { + XDocument config = XDocument.Load(@".\SuperGrate.xml"); + XElement root = config.Element("SuperGrate"); + + + new Dictionary schema = new Dictionary([ + "", + "" + ]); + + + XElement XMigrationStorePath = root.Element("MigrationStorePath"); + XElement XScanStateParameters = root.Element("ScanStateParameters"); + XElement XLoadStateParameters = root.Element("LoadStateParameters"); + if (XMigrationStorePath == null) + { + + } + else + { + MigrationStorePath = XMigrationStorePath.Value; + } + if (XScanStateParameters == null) + { + + } + else + { + ScanStateParameters = XScanStateParameters.Value; + } + if (XLoadStateParameters == null) + { + + } + else + { + LoadStateParameters = XLoadStateParameters.Value; + } + Logger.Success("Config loaded!"); + } + catch(Exception e) + { + Logger.Exception(e, "Error when loading the Super Grate config file! SuperGrate.xml"); + } } } } diff --git a/SuperGrate/Classes/Misc.cs b/SuperGrate/Classes/Misc.cs index c8886b5..b9a4ad9 100644 --- a/SuperGrate/Classes/Misc.cs +++ b/SuperGrate/Classes/Misc.cs @@ -15,25 +15,23 @@ static public async Task Ping(string Host) { try { + Logger.Information("Pinging: " + Host + "..."); Ping ping = new Ping(); PingReply reply = await ping.SendPingAsync(Host, 1000); if (reply.Status == IPStatus.Success) { + Logger.Success(Host + ": Online."); return true; } else { + Logger.Error(Host + ": Offline."); return false; } } - catch (PingException e) - { - Logger.Error(e.InnerException.Message); - return false; - } catch (Exception e) { - Logger.Error(e.Message); + Logger.Exception(e, "Could not contact: " + Host); return false; } } @@ -55,10 +53,8 @@ public static Task> GetUsersFromHost(string Host) { try { - Logger.Information("Pinging: " + Host + "..."); if (await Ping(Host)) { - Logger.Success("Host Online!"); Dictionary results = new Dictionary(); RegistryKey remoteReg = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, Host); RegistryKey profileList = remoteReg.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList", false); diff --git a/SuperGrate/Classes/USMT.cs b/SuperGrate/Classes/USMT.cs index 4fefcb7..b231f24 100644 --- a/SuperGrate/Classes/USMT.cs +++ b/SuperGrate/Classes/USMT.cs @@ -39,13 +39,13 @@ public static Task Do(USMTMode Mode, string[] SIDs) if(Canceled || Failed) break; if (Mode == USMTMode.LoadState) { - Logger.Information("Importing user data for '" + Misc.GetUserByIdentity(SID).Name + "' on '" + CurrentTarget + "'..."); + Logger.Information("Applying user state: '" + Misc.GetUserByIdentity(SID).Name + "' on '" + CurrentTarget + "'..."); Failed = !await DownloadFromStore(SID); if (Canceled || Failed) break; } else { - Logger.Information("Exporting user data: '" + Misc.GetUserByIdentity(SID).Name + "' on '" + CurrentTarget + "'..."); + Logger.Information("Capturing user state: '" + Misc.GetUserByIdentity(SID).Name + "' on '" + CurrentTarget + "'..."); } Failed = !await StartRemoteProcess( @"C:\SuperGrate\" + exec + " " + @@ -147,10 +147,11 @@ public static Task CleaupUSMT() { Logger.Verbose(e.Message); Logger.Verbose(e.StackTrace); - if (tries++ % 5 == 0) + if (tries % 5 == 0) { Logger.Warning("Could not delete, USMT might still be running. Attempt " + tries + "/30."); } + tries++; await Task.Delay(1000); } } @@ -169,7 +170,7 @@ public static Task CleaupUSMT() private static Task UploadToStore(string SID) { return Task.Run(() => { - Logger.Information("Uploading user data to the Store..."); + Logger.Information("Uploading user state to the Store..."); string Destination = Path.Combine(Config.MigrationStorePath, SID); try { @@ -178,12 +179,12 @@ private static Task UploadToStore(string SID) Path.Combine(@"\\", Main.SourceComputer, @"C$\SuperGrate\USMT\USMT.MIG"), Path.Combine(Destination, "USMT.MIG") ); - Logger.Success("User data successfully uploaded."); + Logger.Success("User state successfully uploaded."); return true; } catch(Exception e) { - Logger.Exception(e, "Failed to upload user data to the Store."); + Logger.Exception(e, "Failed to upload user state to the Store."); return false; } }); @@ -191,7 +192,7 @@ private static Task UploadToStore(string SID) private static Task DownloadFromStore(string SID) { return Task.Run(() => { - Logger.Information("Downloading user data to: " + Main.DestinationComputer + "..."); + Logger.Information("Downloading user state to: " + Main.DestinationComputer + "..."); string Destination = Path.Combine(@"\\", Main.DestinationComputer, @"C$\SuperGrate\USMT\"); try { @@ -200,12 +201,12 @@ private static Task DownloadFromStore(string SID) Path.Combine(Config.MigrationStorePath, SID, "USMT.MIG"), Path.Combine(Destination, "USMT.MIG") ); - Logger.Success("User data successfully transferred."); + Logger.Success("User state successfully transferred."); return true; } catch(Exception e) { - Logger.Exception(e, "Failed to download user data to: " + Main.DestinationComputer + "."); + Logger.Exception(e, "Failed to download state data to: " + Main.DestinationComputer + "."); return false; } }); @@ -240,7 +241,7 @@ private static Task WaitForUsmtExit(string ImageName) { return Task.Run(async () => { Running = true; - Logger.Information("Waiting for USMT to finish..."); + Logger.Verbose("Waiting for USMT to finish..."); try { while (Running) diff --git a/SuperGrate/Main.Designer.cs b/SuperGrate/Main.Designer.cs index e866471..2f556ff 100644 --- a/SuperGrate/Main.Designer.cs +++ b/SuperGrate/Main.Designer.cs @@ -30,29 +30,29 @@ private void InitializeComponent() { this.LogBox = new System.Windows.Forms.RichTextBox(); this.pbMain = new System.Windows.Forms.ProgressBar(); - this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.logTable = new System.Windows.Forms.TableLayoutPanel(); + this.spltContainer = new System.Windows.Forms.SplitContainer(); this.tblMainLayout = new System.Windows.Forms.TableLayoutPanel(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); + this.lblSourceComputer = new System.Windows.Forms.Label(); + this.lblDestinationComputer = new System.Windows.Forms.Label(); this.lblUserList = new System.Windows.Forms.Label(); this.tbSourceComputer = new System.Windows.Forms.TextBox(); this.tbDestinationComputer = new System.Windows.Forms.TextBox(); this.btStartStop = new System.Windows.Forms.Button(); - this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); + this.tbleListUsersButtons = new System.Windows.Forms.TableLayoutPanel(); this.btnListSource = new System.Windows.Forms.Button(); this.btnListStore = new System.Windows.Forms.Button(); this.btnDelete = new System.Windows.Forms.Button(); this.lbxUsers = new System.Windows.Forms.ListBox(); this.pnlLogoBorder = new System.Windows.Forms.Panel(); this.imgLoadLogo = new System.Windows.Forms.PictureBox(); - this.tableLayoutPanel1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); - this.splitContainer1.Panel1.SuspendLayout(); - this.splitContainer1.Panel2.SuspendLayout(); - this.splitContainer1.SuspendLayout(); + this.logTable.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.spltContainer)).BeginInit(); + this.spltContainer.Panel1.SuspendLayout(); + this.spltContainer.Panel2.SuspendLayout(); + this.spltContainer.SuspendLayout(); this.tblMainLayout.SuspendLayout(); - this.tableLayoutPanel3.SuspendLayout(); + this.tbleListUsersButtons.SuspendLayout(); this.pnlLogoBorder.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.imgLoadLogo)).BeginInit(); this.SuspendLayout(); @@ -67,7 +67,7 @@ private void InitializeComponent() this.LogBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.LogBox.Name = "LogBox"; this.LogBox.ReadOnly = true; - this.LogBox.Size = new System.Drawing.Size(314, 363); + this.LogBox.Size = new System.Drawing.Size(311, 272); this.LogBox.TabIndex = 0; this.LogBox.Text = ""; this.LogBox.DoubleClick += new System.EventHandler(this.LogBox_DoubleClick); @@ -76,61 +76,62 @@ private void InitializeComponent() // this.pbMain.Dock = System.Windows.Forms.DockStyle.Fill; this.pbMain.ForeColor = System.Drawing.Color.Black; - this.pbMain.Location = new System.Drawing.Point(3, 375); + this.pbMain.Location = new System.Drawing.Point(3, 284); this.pbMain.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.pbMain.Name = "pbMain"; - this.pbMain.Size = new System.Drawing.Size(314, 22); + this.pbMain.Size = new System.Drawing.Size(311, 22); + this.pbMain.Style = System.Windows.Forms.ProgressBarStyle.Continuous; this.pbMain.TabIndex = 1; // - // tableLayoutPanel1 + // logTable // - this.tableLayoutPanel1.ColumnCount = 1; - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel1.Controls.Add(this.LogBox, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.pbMain, 0, 1); - this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); - this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.tableLayoutPanel1.Name = "tableLayoutPanel1"; - this.tableLayoutPanel1.RowCount = 2; - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(320, 401); - this.tableLayoutPanel1.TabIndex = 2; + this.logTable.ColumnCount = 1; + this.logTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.logTable.Controls.Add(this.LogBox, 0, 0); + this.logTable.Controls.Add(this.pbMain, 0, 1); + this.logTable.Dock = System.Windows.Forms.DockStyle.Fill; + this.logTable.Location = new System.Drawing.Point(0, 0); + this.logTable.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.logTable.Name = "logTable"; + this.logTable.RowCount = 2; + this.logTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.logTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); + this.logTable.Size = new System.Drawing.Size(317, 310); + this.logTable.TabIndex = 2; // - // splitContainer1 + // spltContainer // - this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; - this.splitContainer1.Location = new System.Drawing.Point(5, 5); - this.splitContainer1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.splitContainer1.Name = "splitContainer1"; + this.spltContainer.Dock = System.Windows.Forms.DockStyle.Fill; + this.spltContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; + this.spltContainer.Location = new System.Drawing.Point(5, 5); + this.spltContainer.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.spltContainer.Name = "spltContainer"; // - // splitContainer1.Panel1 + // spltContainer.Panel1 // - this.splitContainer1.Panel1.Controls.Add(this.tblMainLayout); - this.splitContainer1.Panel1MinSize = 330; + this.spltContainer.Panel1.Controls.Add(this.tblMainLayout); + this.spltContainer.Panel1MinSize = 340; // - // splitContainer1.Panel2 + // spltContainer.Panel2 // - this.splitContainer1.Panel2.Controls.Add(this.tableLayoutPanel1); - this.splitContainer1.Panel2MinSize = 300; - this.splitContainer1.Size = new System.Drawing.Size(654, 401); - this.splitContainer1.SplitterDistance = 330; - this.splitContainer1.TabIndex = 3; + this.spltContainer.Panel2.Controls.Add(this.logTable); + this.spltContainer.Panel2MinSize = 300; + this.spltContainer.Size = new System.Drawing.Size(670, 310); + this.spltContainer.SplitterDistance = 349; + this.spltContainer.TabIndex = 3; // // tblMainLayout // this.tblMainLayout.ColumnCount = 2; - this.tblMainLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 120F)); + this.tblMainLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 130F)); this.tblMainLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tblMainLayout.Controls.Add(this.label1, 0, 0); - this.tblMainLayout.Controls.Add(this.label2, 0, 1); + this.tblMainLayout.Controls.Add(this.lblSourceComputer, 0, 0); + this.tblMainLayout.Controls.Add(this.lblDestinationComputer, 0, 1); this.tblMainLayout.Controls.Add(this.lblUserList, 0, 3); this.tblMainLayout.Controls.Add(this.tbSourceComputer, 1, 0); this.tblMainLayout.Controls.Add(this.tbDestinationComputer, 1, 1); this.tblMainLayout.Controls.Add(this.btStartStop, 0, 4); - this.tblMainLayout.Controls.Add(this.tableLayoutPanel3, 1, 2); + this.tblMainLayout.Controls.Add(this.tbleListUsersButtons, 1, 2); this.tblMainLayout.Controls.Add(this.lbxUsers, 1, 3); this.tblMainLayout.Controls.Add(this.pnlLogoBorder, 0, 4); this.tblMainLayout.Dock = System.Windows.Forms.DockStyle.Fill; @@ -144,57 +145,55 @@ private void InitializeComponent() this.tblMainLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tblMainLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 110F)); this.tblMainLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); - this.tblMainLayout.Size = new System.Drawing.Size(330, 401); + this.tblMainLayout.Size = new System.Drawing.Size(349, 310); this.tblMainLayout.TabIndex = 0; // - // label1 + // lblSourceComputer // - this.label1.Dock = System.Windows.Forms.DockStyle.Fill; - this.label1.Location = new System.Drawing.Point(3, 0); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(114, 30); - this.label1.TabIndex = 0; - this.label1.Text = "Source Computer"; - this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.lblSourceComputer.Dock = System.Windows.Forms.DockStyle.Fill; + this.lblSourceComputer.Location = new System.Drawing.Point(3, 0); + this.lblSourceComputer.Name = "lblSourceComputer"; + this.lblSourceComputer.Size = new System.Drawing.Size(124, 30); + this.lblSourceComputer.TabIndex = 0; + this.lblSourceComputer.Text = "Source Computer"; + this.lblSourceComputer.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // - // label2 + // lblDestinationComputer // - this.label2.Dock = System.Windows.Forms.DockStyle.Fill; - this.label2.Location = new System.Drawing.Point(3, 30); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(114, 30); - this.label2.TabIndex = 1; - this.label2.Text = "Destination Computer"; - this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.lblDestinationComputer.Dock = System.Windows.Forms.DockStyle.Fill; + this.lblDestinationComputer.Location = new System.Drawing.Point(3, 30); + this.lblDestinationComputer.Name = "lblDestinationComputer"; + this.lblDestinationComputer.Size = new System.Drawing.Size(124, 30); + this.lblDestinationComputer.TabIndex = 1; + this.lblDestinationComputer.Text = "Destination Computer"; + this.lblDestinationComputer.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // // lblUserList // this.lblUserList.Dock = System.Windows.Forms.DockStyle.Fill; this.lblUserList.Location = new System.Drawing.Point(3, 90); this.lblUserList.Name = "lblUserList"; - this.lblUserList.Size = new System.Drawing.Size(114, 171); + this.lblUserList.Size = new System.Drawing.Size(124, 80); this.lblUserList.TabIndex = 4; this.lblUserList.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // tbSourceComputer // this.tbSourceComputer.Dock = System.Windows.Forms.DockStyle.Fill; - this.tbSourceComputer.Location = new System.Drawing.Point(123, 4); + this.tbSourceComputer.Location = new System.Drawing.Point(133, 4); this.tbSourceComputer.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.tbSourceComputer.Multiline = true; this.tbSourceComputer.Name = "tbSourceComputer"; - this.tbSourceComputer.Size = new System.Drawing.Size(204, 22); + this.tbSourceComputer.Size = new System.Drawing.Size(213, 22); this.tbSourceComputer.TabIndex = 5; this.tbSourceComputer.TextChanged += new System.EventHandler(this.TbSourceComputer_TextChanged); // // tbDestinationComputer // this.tbDestinationComputer.Dock = System.Windows.Forms.DockStyle.Fill; - this.tbDestinationComputer.Location = new System.Drawing.Point(123, 34); + this.tbDestinationComputer.Location = new System.Drawing.Point(133, 34); this.tbDestinationComputer.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.tbDestinationComputer.Multiline = true; this.tbDestinationComputer.Name = "tbDestinationComputer"; - this.tbDestinationComputer.Size = new System.Drawing.Size(204, 22); + this.tbDestinationComputer.Size = new System.Drawing.Size(213, 22); this.tbDestinationComputer.TabIndex = 7; this.tbDestinationComputer.TextChanged += new System.EventHandler(this.TbDestinationComputer_TextChanged); // @@ -204,39 +203,41 @@ private void InitializeComponent() this.btStartStop.Dock = System.Windows.Forms.DockStyle.Fill; this.btStartStop.Enabled = false; this.btStartStop.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.btStartStop.Location = new System.Drawing.Point(3, 374); + this.btStartStop.Location = new System.Drawing.Point(3, 283); + this.btStartStop.Margin = new System.Windows.Forms.Padding(3, 3, 2, 3); this.btStartStop.Name = "btStartStop"; - this.btStartStop.Size = new System.Drawing.Size(324, 24); + this.btStartStop.Size = new System.Drawing.Size(344, 24); this.btStartStop.TabIndex = 9; this.btStartStop.Text = "Start"; this.btStartStop.UseVisualStyleBackColor = true; this.btStartStop.Click += new System.EventHandler(this.BtStartStop_Click); // - // tableLayoutPanel3 - // - this.tableLayoutPanel3.ColumnCount = 3; - this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); - this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); - this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); - this.tableLayoutPanel3.Controls.Add(this.btnListSource, 0, 0); - this.tableLayoutPanel3.Controls.Add(this.btnListStore, 1, 0); - this.tableLayoutPanel3.Controls.Add(this.btnDelete, 2, 0); - this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel3.Location = new System.Drawing.Point(120, 60); - this.tableLayoutPanel3.Margin = new System.Windows.Forms.Padding(0); - this.tableLayoutPanel3.Name = "tableLayoutPanel3"; - this.tableLayoutPanel3.RowCount = 1; - this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanel3.Size = new System.Drawing.Size(210, 30); - this.tableLayoutPanel3.TabIndex = 10; + // tbleListUsersButtons + // + this.tbleListUsersButtons.ColumnCount = 3; + this.tbleListUsersButtons.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); + this.tbleListUsersButtons.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); + this.tbleListUsersButtons.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); + this.tbleListUsersButtons.Controls.Add(this.btnListSource, 0, 0); + this.tbleListUsersButtons.Controls.Add(this.btnListStore, 1, 0); + this.tbleListUsersButtons.Controls.Add(this.btnDelete, 2, 0); + this.tbleListUsersButtons.Dock = System.Windows.Forms.DockStyle.Fill; + this.tbleListUsersButtons.Location = new System.Drawing.Point(130, 60); + this.tbleListUsersButtons.Margin = new System.Windows.Forms.Padding(0); + this.tbleListUsersButtons.Name = "tbleListUsersButtons"; + this.tbleListUsersButtons.RowCount = 1; + this.tbleListUsersButtons.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tbleListUsersButtons.Size = new System.Drawing.Size(219, 30); + this.tbleListUsersButtons.TabIndex = 10; // // btnListSource // this.btnListSource.Dock = System.Windows.Forms.DockStyle.Fill; this.btnListSource.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.btnListSource.Location = new System.Drawing.Point(3, 3); + this.btnListSource.Location = new System.Drawing.Point(2, 3); + this.btnListSource.Margin = new System.Windows.Forms.Padding(2, 3, 3, 3); this.btnListSource.Name = "btnListSource"; - this.btnListSource.Size = new System.Drawing.Size(64, 24); + this.btnListSource.Size = new System.Drawing.Size(68, 25); this.btnListSource.TabIndex = 0; this.btnListSource.Text = "List Source"; this.btnListSource.UseVisualStyleBackColor = true; @@ -246,9 +247,9 @@ private void InitializeComponent() // this.btnListStore.Dock = System.Windows.Forms.DockStyle.Fill; this.btnListStore.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.btnListStore.Location = new System.Drawing.Point(73, 3); + this.btnListStore.Location = new System.Drawing.Point(76, 3); this.btnListStore.Name = "btnListStore"; - this.btnListStore.Size = new System.Drawing.Size(64, 24); + this.btnListStore.Size = new System.Drawing.Size(67, 25); this.btnListStore.TabIndex = 1; this.btnListStore.Text = "List Store"; this.btnListStore.UseVisualStyleBackColor = true; @@ -259,9 +260,10 @@ private void InitializeComponent() this.btnDelete.Dock = System.Windows.Forms.DockStyle.Fill; this.btnDelete.Enabled = false; this.btnDelete.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.btnDelete.Location = new System.Drawing.Point(143, 3); + this.btnDelete.Location = new System.Drawing.Point(149, 3); + this.btnDelete.Margin = new System.Windows.Forms.Padding(3, 3, 2, 3); this.btnDelete.Name = "btnDelete"; - this.btnDelete.Size = new System.Drawing.Size(64, 24); + this.btnDelete.Size = new System.Drawing.Size(68, 25); this.btnDelete.TabIndex = 2; this.btnDelete.Text = "Delete"; this.btnDelete.UseVisualStyleBackColor = true; @@ -272,12 +274,12 @@ private void InitializeComponent() this.lbxUsers.Dock = System.Windows.Forms.DockStyle.Fill; this.lbxUsers.FormattingEnabled = true; this.lbxUsers.IntegralHeight = false; - this.lbxUsers.Location = new System.Drawing.Point(123, 94); + this.lbxUsers.Location = new System.Drawing.Point(133, 94); this.lbxUsers.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.lbxUsers.Name = "lbxUsers"; this.tblMainLayout.SetRowSpan(this.lbxUsers, 2); this.lbxUsers.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; - this.lbxUsers.Size = new System.Drawing.Size(204, 273); + this.lbxUsers.Size = new System.Drawing.Size(213, 182); this.lbxUsers.TabIndex = 8; this.lbxUsers.SelectedIndexChanged += new System.EventHandler(this.UpdateFormRestrictions); // @@ -286,11 +288,11 @@ private void InitializeComponent() this.pnlLogoBorder.BackColor = System.Drawing.Color.DarkGray; this.pnlLogoBorder.Controls.Add(this.imgLoadLogo); this.pnlLogoBorder.Dock = System.Windows.Forms.DockStyle.Fill; - this.pnlLogoBorder.Location = new System.Drawing.Point(4, 261); + this.pnlLogoBorder.Location = new System.Drawing.Point(4, 170); this.pnlLogoBorder.Margin = new System.Windows.Forms.Padding(4, 0, 4, 4); this.pnlLogoBorder.Name = "pnlLogoBorder"; this.pnlLogoBorder.Padding = new System.Windows.Forms.Padding(1); - this.pnlLogoBorder.Size = new System.Drawing.Size(112, 106); + this.pnlLogoBorder.Size = new System.Drawing.Size(122, 106); this.pnlLogoBorder.TabIndex = 11; // // imgLoadLogo @@ -302,31 +304,35 @@ private void InitializeComponent() this.imgLoadLogo.Location = new System.Drawing.Point(1, 1); this.imgLoadLogo.Margin = new System.Windows.Forms.Padding(0); this.imgLoadLogo.Name = "imgLoadLogo"; - this.imgLoadLogo.Size = new System.Drawing.Size(110, 104); + this.imgLoadLogo.Size = new System.Drawing.Size(120, 104); + this.imgLoadLogo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; this.imgLoadLogo.TabIndex = 11; this.imgLoadLogo.TabStop = false; // // Main // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.SystemColors.Control; - this.ClientSize = new System.Drawing.Size(664, 411); - this.Controls.Add(this.splitContainer1); + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.BackColor = System.Drawing.Color.White; + this.ClientSize = new System.Drawing.Size(680, 320); + this.Controls.Add(this.spltContainer); + this.DoubleBuffered = true; + this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.MinimumSize = new System.Drawing.Size(680, 320); this.Name = "Main"; this.Padding = new System.Windows.Forms.Padding(5); + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Super Grate - Remote User Migration & Backup"; this.Load += new System.EventHandler(this.Main_Load); - this.tableLayoutPanel1.ResumeLayout(false); - this.splitContainer1.Panel1.ResumeLayout(false); - this.splitContainer1.Panel2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); - this.splitContainer1.ResumeLayout(false); + this.logTable.ResumeLayout(false); + this.spltContainer.Panel1.ResumeLayout(false); + this.spltContainer.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.spltContainer)).EndInit(); + this.spltContainer.ResumeLayout(false); this.tblMainLayout.ResumeLayout(false); this.tblMainLayout.PerformLayout(); - this.tableLayoutPanel3.ResumeLayout(false); + this.tbleListUsersButtons.ResumeLayout(false); this.pnlLogoBorder.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.imgLoadLogo)).EndInit(); this.ResumeLayout(false); @@ -337,22 +343,22 @@ private void InitializeComponent() private System.Windows.Forms.RichTextBox LogBox; private System.Windows.Forms.ProgressBar pbMain; - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; - private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.TableLayoutPanel logTable; + private System.Windows.Forms.SplitContainer spltContainer; private System.Windows.Forms.TableLayoutPanel tblMainLayout; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label lblSourceComputer; + private System.Windows.Forms.Label lblDestinationComputer; private System.Windows.Forms.Label lblUserList; private System.Windows.Forms.TextBox tbSourceComputer; private System.Windows.Forms.TextBox tbDestinationComputer; private System.Windows.Forms.ListBox lbxUsers; private System.Windows.Forms.Button btStartStop; - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3; private System.Windows.Forms.Button btnListSource; private System.Windows.Forms.Button btnListStore; private System.Windows.Forms.Button btnDelete; private System.Windows.Forms.PictureBox imgLoadLogo; private System.Windows.Forms.Panel pnlLogoBorder; + private System.Windows.Forms.TableLayoutPanel tbleListUsersButtons; } } diff --git a/SuperGrate/Main.cs b/SuperGrate/Main.cs index ff91aa6..841c0ca 100644 --- a/SuperGrate/Main.cs +++ b/SuperGrate/Main.cs @@ -104,10 +104,6 @@ private async void BtnListSource_Click(object sender, EventArgs e) CurrentListSource = ListSources.SourceComputer; Logger.Success("Done!"); } - else - { - Logger.Error("Failed to list users from the source computer."); - } Running = false; } private async void BtnListStore_Click(object sender, EventArgs e) @@ -122,10 +118,6 @@ private async void BtnListStore_Click(object sender, EventArgs e) lbxUsers.Items.AddRange(results.Values.ToArray()); CurrentListSource = ListSources.MigrationStore; } - else - { - Logger.Error("Failed to list users from the migration store."); - } Running = false; } private void LogBox_DoubleClick(object sender, EventArgs e) diff --git a/SuperGrate/Program.cs b/SuperGrate/Program.cs index c05342e..20c3cf8 100644 --- a/SuperGrate/Program.cs +++ b/SuperGrate/Program.cs @@ -15,6 +15,8 @@ static class Program [STAThread] static void Main() { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); Application.ThreadException += Application_ThreadException; Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.Run(new Main()); diff --git a/SuperGrate/Properties/app.manifest b/SuperGrate/Properties/app.manifest index d72e750..7799e02 100644 --- a/SuperGrate/Properties/app.manifest +++ b/SuperGrate/Properties/app.manifest @@ -49,13 +49,12 @@ DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. --> - + -->