From b5a40bb92177e70444ab6ab9efa2ba31899b7ffc Mon Sep 17 00:00:00 2001 From: RussKie Date: Sun, 12 Jul 2020 00:11:05 +1000 Subject: [PATCH] Dialogs layout alignment - `FormStatus` and descendants * Update `FormStatus` layout * Update `FormProgress` layout * Update `FormRemoteProgress` layout Relates to #6183 --- GitUI/GitExtensionsDialog.Designer.cs | 6 - GitUI/HelperDialogs/FormProcess.cs | 14 +- GitUI/HelperDialogs/FormRemoteProcess.cs | 4 +- GitUI/HelperDialogs/FormStatus.Designer.cs | 133 +++++++----------- GitUI/HelperDialogs/FormStatus.cs | 18 ++- .../RevisionGrid/RevisionGridControl.cs | 2 +- 6 files changed, 74 insertions(+), 103 deletions(-) diff --git a/GitUI/GitExtensionsDialog.Designer.cs b/GitUI/GitExtensionsDialog.Designer.cs index d4f27216c48..02db2b698d7 100644 --- a/GitUI/GitExtensionsDialog.Designer.cs +++ b/GitUI/GitExtensionsDialog.Designer.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; using System.Windows.Forms; -using GitExtUtils.GitUI; -using ResourceManager; namespace GitUI { diff --git a/GitUI/HelperDialogs/FormProcess.cs b/GitUI/HelperDialogs/FormProcess.cs index c74b1c9da1a..117bcdeca7e 100644 --- a/GitUI/HelperDialogs/FormProcess.cs +++ b/GitUI/HelperDialogs/FormProcess.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Windows.Forms; using GitCommands; @@ -28,8 +28,8 @@ private protected FormProcess() { } - private FormProcess(ConsoleOutputControl outputControl, [CanBeNull] string process, ArgumentString arguments, string workingDirectory, string input, bool useDialogSettings) - : base(outputControl, useDialogSettings) + private FormProcess(GitUICommands commands, ConsoleOutputControl outputControl, [CanBeNull] string process, ArgumentString arguments, string workingDirectory, string input, bool useDialogSettings) + : base(commands, outputControl, useDialogSettings) { ProcessCallback = ProcessStart; AbortCallback = ProcessAbort; @@ -49,14 +49,14 @@ private FormProcess(ConsoleOutputControl outputControl, [CanBeNull] string proce ConsoleOutput.DataReceived += DataReceivedCore; } - public FormProcess(string process, ArgumentString arguments, string workingDirectory, string input, bool useDialogSettings) - : this(null, process, arguments, workingDirectory, input, useDialogSettings) + public FormProcess(GitUICommands commands, string process, ArgumentString arguments, string workingDirectory, string input, bool useDialogSettings) + : this(commands, outputControl: null, process, arguments, workingDirectory, input, useDialogSettings) { } public static bool ShowDialog([CanBeNull] IWin32Window owner, string process, ArgumentString arguments, string workingDirectory, string input, bool useDialogSettings) { - using (var formProcess = new FormProcess(process, arguments, workingDirectory, input, useDialogSettings)) + using (var formProcess = new FormProcess(commands: null, process, arguments, workingDirectory, input, useDialogSettings)) { formProcess.ShowDialog(owner); return !formProcess.ErrorOccurred(); @@ -65,7 +65,7 @@ public static bool ShowDialog([CanBeNull] IWin32Window owner, string process, Ar public static string ReadDialog([CanBeNull] IWin32Window owner, string process, ArgumentString arguments, string workingDirectory, string input, bool useDialogSettings) { - using (var formProcess = new FormProcess(process, arguments, workingDirectory, input, useDialogSettings)) + using (var formProcess = new FormProcess(commands: null, process, arguments, workingDirectory, input, useDialogSettings)) { formProcess.ShowDialog(owner); return formProcess.GetOutputString(); diff --git a/GitUI/HelperDialogs/FormRemoteProcess.cs b/GitUI/HelperDialogs/FormRemoteProcess.cs index e2a6f8d7562..dfa8e7e72b0 100644 --- a/GitUI/HelperDialogs/FormRemoteProcess.cs +++ b/GitUI/HelperDialogs/FormRemoteProcess.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Windows.Forms; using GitCommands; using GitCommands.Config; @@ -37,7 +37,7 @@ private FormRemoteProcess() } public FormRemoteProcess([NotNull] GitUICommands commands, string process, ArgumentString arguments) - : base(process, arguments, commands?.Module?.WorkingDir, null, true) + : base(commands, process, arguments, commands?.Module?.WorkingDir, null, true) { Commands = commands ?? throw new ArgumentNullException(nameof(commands)); } diff --git a/GitUI/HelperDialogs/FormStatus.Designer.cs b/GitUI/HelperDialogs/FormStatus.Designer.cs index 5a0a62f2196..0d78eb4fe5e 100644 --- a/GitUI/HelperDialogs/FormStatus.Designer.cs +++ b/GitUI/HelperDialogs/FormStatus.Designer.cs @@ -32,22 +32,27 @@ private void InitializeComponent() this.ProgressBar = new System.Windows.Forms.ProgressBar(); this.KeepDialogOpen = new System.Windows.Forms.CheckBox(); this.Abort = new System.Windows.Forms.Button(); - this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); + this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); this.picBoxSuccessFail = new System.Windows.Forms.PictureBox(); - this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); - this.tableLayoutPanel1.SuspendLayout(); - this.tableLayoutPanel2.SuspendLayout(); + this.MainPanel.SuspendLayout(); + this.tableLayoutPanel.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.picBoxSuccessFail)).BeginInit(); - this.tableLayoutPanel3.SuspendLayout(); this.SuspendLayout(); // + // MainPanel + // + this.MainPanel.Controls.Add(this.KeepDialogOpen); + this.MainPanel.Controls.Add(this.Abort); + this.MainPanel.Controls.Add(this.tableLayoutPanel); + this.MainPanel.Controls.Add(this.Ok); + this.MainPanel.Padding = new System.Windows.Forms.Padding(16, 20, 40, 20); + this.MainPanel.Size = new System.Drawing.Size(549, 243); + // // Ok // - this.Ok.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); - this.Ok.Location = new System.Drawing.Point(461, 5); + this.Ok.Location = new System.Drawing.Point(314, 234); this.Ok.Name = "Ok"; - this.Ok.Size = new System.Drawing.Size(75, 23); + this.Ok.Size = new System.Drawing.Size(105, 25); this.Ok.TabIndex = 0; this.Ok.Text = "OK"; this.Ok.UseCompatibleTextRendering = true; @@ -56,23 +61,24 @@ private void InitializeComponent() // // ProgressBar // - this.ProgressBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); - this.ProgressBar.Location = new System.Drawing.Point(3, 4); + this.ProgressBar.Dock = System.Windows.Forms.DockStyle.Bottom; + this.ProgressBar.Location = new System.Drawing.Point(0, 0); + this.ProgressBar.Margin = new System.Windows.Forms.Padding(0); this.ProgressBar.MarqueeAnimationSpeed = 1; this.ProgressBar.Name = "ProgressBar"; - this.ProgressBar.Size = new System.Drawing.Size(245, 25); + this.ProgressBar.Size = new System.Drawing.Size(549, 3); this.ProgressBar.Step = 50; this.ProgressBar.Style = System.Windows.Forms.ProgressBarStyle.Marquee; - this.ProgressBar.TabIndex = 3; + this.ProgressBar.TabIndex = 0; // // KeepDialogOpen // - this.KeepDialogOpen.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); this.KeepDialogOpen.AutoSize = true; - this.KeepDialogOpen.Location = new System.Drawing.Point(254, 6); + this.KeepDialogOpen.Location = new System.Drawing.Point(194, 248); this.KeepDialogOpen.Name = "KeepDialogOpen"; - this.KeepDialogOpen.Size = new System.Drawing.Size(120, 22); - this.KeepDialogOpen.TabIndex = 3; + this.KeepDialogOpen.Padding = new System.Windows.Forms.Padding(0, 4, 0, 0); + this.KeepDialogOpen.Size = new System.Drawing.Size(111, 22); + this.KeepDialogOpen.TabIndex = 2; this.KeepDialogOpen.Text = "Keep dialog open"; this.KeepDialogOpen.UseCompatibleTextRendering = true; this.KeepDialogOpen.UseVisualStyleBackColor = true; @@ -80,51 +86,32 @@ private void InitializeComponent() // // Abort // - this.Abort.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); this.Abort.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.Abort.Location = new System.Drawing.Point(380, 5); + this.Abort.Location = new System.Drawing.Point(444, 234); this.Abort.Name = "Abort"; - this.Abort.Size = new System.Drawing.Size(82, 23); - this.Abort.TabIndex = 3; + this.Abort.Size = new System.Drawing.Size(86, 25); + this.Abort.TabIndex = 1; this.Abort.Text = "Abort"; this.Abort.UseCompatibleTextRendering = true; this.Abort.UseVisualStyleBackColor = true; this.Abort.Click += new System.EventHandler(this.Abort_Click); // - // tableLayoutPanel1 - // - this.tableLayoutPanel1.AutoSize = true; - this.tableLayoutPanel1.ColumnCount = 1; - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel3, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel2, 0, 1); - this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel1.Location = new System.Drawing.Point(10, 10); - this.tableLayoutPanel1.Name = "tableLayoutPanel1"; - this.tableLayoutPanel1.RowCount = 1; - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanel1.Size = new System.Drawing.Size(545, 307); - this.tableLayoutPanel1.TabIndex = 3; - // - // tableLayoutPanel2 - // - this.tableLayoutPanel2.ColumnCount = 4; - this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); - this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); - this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); - this.tableLayoutPanel2.Controls.Add(this.Ok, 3, 0); - this.tableLayoutPanel2.Controls.Add(this.Abort, 2, 0); - this.tableLayoutPanel2.Controls.Add(this.KeepDialogOpen, 1, 0); - this.tableLayoutPanel2.Controls.Add(this.ProgressBar, 0, 0); - this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 270); - this.tableLayoutPanel2.Name = "tableLayoutPanel2"; - this.tableLayoutPanel2.RowCount = 1; - this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel2.Size = new System.Drawing.Size(539, 34); - this.tableLayoutPanel2.TabIndex = 0; + // tableLayoutPanel + // + this.tableLayoutPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.tableLayoutPanel.ColumnCount = 2; + this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel.Controls.Add(this.ConsoleOutput, 1, 0); + this.tableLayoutPanel.Controls.Add(this.picBoxSuccessFail, 0, 0); + this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel.Location = new System.Drawing.Point(10, 24); + this.tableLayoutPanel.Name = "tableLayoutPanel"; + this.tableLayoutPanel.RowCount = 2; + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 3F)); + this.tableLayoutPanel.Size = new System.Drawing.Size(515, 209); + this.tableLayoutPanel.TabIndex = 0; // // picBoxSuccessFail // @@ -132,47 +119,31 @@ private void InitializeComponent() this.picBoxSuccessFail.Image = global::GitUI.Properties.Images.StatusBadgeWaiting; this.picBoxSuccessFail.Location = new System.Drawing.Point(3, 3); this.picBoxSuccessFail.Name = "picBoxSuccessFail"; - this.picBoxSuccessFail.Size = new System.Drawing.Size(47, 50); + this.picBoxSuccessFail.Size = new System.Drawing.Size(47, 200); this.picBoxSuccessFail.TabIndex = 1; this.picBoxSuccessFail.TabStop = false; // - // tableLayoutPanel3 - // - this.tableLayoutPanel3.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.tableLayoutPanel3.ColumnCount = 2; - this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); - this.tableLayoutPanel3.Controls.Add(this.picBoxSuccessFail, 1, 0); - this.tableLayoutPanel3.Controls.Add(this.ConsoleOutput, 0, 0); - this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel3.Location = new System.Drawing.Point(3, 3); - this.tableLayoutPanel3.Name = "tableLayoutPanel3"; - this.tableLayoutPanel3.RowCount = 1; - this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel3.Size = new System.Drawing.Size(539, 261); - this.tableLayoutPanel3.TabIndex = 4; - // // FormStatus // this.AcceptButton = this.Ok; this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.CancelButton = this.Abort; - this.ClientSize = new System.Drawing.Size(565, 327); + this.ClientSize = new System.Drawing.Size(549, 288); this.ControlBox = false; - this.Controls.Add(this.tableLayoutPanel1); + this.Controls.Add(this.ProgressBar); this.MinimumSize = new System.Drawing.Size(500, 200); this.Name = "FormStatus"; - this.Padding = new System.Windows.Forms.Padding(10); this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Process"; this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FormStatus_FormClosed); this.Load += new System.EventHandler(this.FormStatus_Load); - this.tableLayoutPanel1.ResumeLayout(false); - this.tableLayoutPanel2.ResumeLayout(false); - this.tableLayoutPanel2.PerformLayout(); + this.Controls.SetChildIndex(this.ProgressBar, 0); + this.Controls.SetChildIndex(this.MainPanel, 0); + this.MainPanel.ResumeLayout(false); + this.MainPanel.PerformLayout(); + this.tableLayoutPanel.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.picBoxSuccessFail)).EndInit(); - this.tableLayoutPanel3.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -184,9 +155,7 @@ private void InitializeComponent() protected System.Windows.Forms.Button Ok; protected System.Windows.Forms.CheckBox KeepDialogOpen; protected System.Windows.Forms.Button Abort; - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; private System.Windows.Forms.PictureBox picBoxSuccessFail; - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel; } } diff --git a/GitUI/HelperDialogs/FormStatus.cs b/GitUI/HelperDialogs/FormStatus.cs index 43691d9ad6b..8b60771dc15 100644 --- a/GitUI/HelperDialogs/FormStatus.cs +++ b/GitUI/HelperDialogs/FormStatus.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Threading.Tasks; using System.Windows.Forms; using System.Windows.Threading; @@ -10,7 +10,7 @@ namespace GitUI.HelperDialogs { - public partial class FormStatus : GitExtensionsForm + public partial class FormStatus : GitExtensionsDialog { private readonly bool _useDialogSettings; @@ -24,8 +24,8 @@ private protected FormStatus() InitializeComponent(); } - public FormStatus([CanBeNull] ConsoleOutputControl consoleOutput, bool useDialogSettings) - : base(true) + public FormStatus(GitUICommands commands, [CanBeNull] ConsoleOutputControl consoleOutput, bool useDialogSettings) + : base(commands, enablePositionRestore: true) { _useDialogSettings = useDialogSettings; @@ -44,11 +44,19 @@ public FormStatus([CanBeNull] ConsoleOutputControl consoleOutput, bool useDialog KeepDialogOpen.Hide(); } + // work-around the designer bug that can't add controls to FlowLayoutPanel + ControlsPanel.Controls.Add(Abort); + ControlsPanel.Controls.Add(Ok); + ControlsPanel.Controls.Add(KeepDialogOpen); + + Controls.SetChildIndex(ProgressBar, 1); + ProgressBar.Dock = DockStyle.Bottom; + InitializeComplete(); } public FormStatus(Action process, string text) - : this(new EditboxBasedConsoleOutputControl(), true) + : this(commands: null, new EditboxBasedConsoleOutputControl(), true) { ProcessCallback = process; Text = text; diff --git a/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs b/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs index ab755dcae81..b1e028318d8 100644 --- a/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs +++ b/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs @@ -2604,7 +2604,7 @@ private void LaunchRebase(string command) LatestSelectedRevision.FirstParentId?.ToString(), interactive: true, preserveMerges: false, autosquash: false, autoStash: true); - using (var formProcess = new FormProcess(null, rebaseCmd, Module.WorkingDir, null, true)) + using (var formProcess = new FormProcess(UICommands, outputControl: null, rebaseCmd, Module.WorkingDir, input: null, useDialogSettings: true)) { formProcess.ProcessEnvVariables.Add("GIT_SEQUENCE_EDITOR", string.Format("sed -i -re '0,/pick/s//{0}/'", command)); formProcess.ShowDialog(this);