Skip to content

Commit 703a455

Browse files
committedNov 4, 2018
gitextensions#5665 override CommitInfo.OnLayout instead of Layout event subscription
1 parent 2d01204 commit 703a455

File tree

3 files changed

+21
-26
lines changed

3 files changed

+21
-26
lines changed
 

‎GitUI/CommitInfo/CommitInfo.Designer.cs

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎GitUI/CommitInfo/CommitInfo.cs

+2-10
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ IDisposable subscribeToContentsResized(RichTextBox richTextBox, Action<ContentsR
120120
.Throttle(TimeSpan.FromMilliseconds(100))
121121
.ObserveOn(MainThreadScheduler.Instance)
122122
.Subscribe(_ => handler(_.EventArgs));
123-
124-
Layout += layout;
125123
}
126124

127125
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
@@ -480,11 +478,9 @@ private void UpdateRevisionInfo()
480478
new[] { _annotatedTagsInfo, _linksInfo, _branchInfo, _tagInfo, _gitDescribeInfo }
481479
.Where(_ => !string.IsNullOrEmpty(_)));
482480

483-
RevisionInfo.SuspendLayout();
484481
RevisionInfo.SetXHTMLText(body);
485482
RevisionInfo.SelectionStart = 0; // scroll up
486483
RevisionInfo.ScrollToCaret(); // scroll up
487-
RevisionInfo.ResumeLayout();
488484

489485
return;
490486

@@ -655,7 +651,7 @@ private void CommitMessage_ContentsResized(ContentsResizedEventArgs e)
655651
PerformLayout();
656652
}
657653

658-
private void layout(object sender, LayoutEventArgs e)
654+
protected override void OnLayout(LayoutEventArgs e)
659655
{
660656
tableLayout.SuspendLayout();
661657

@@ -680,16 +676,12 @@ private void layout(object sender, LayoutEventArgs e)
680676
column.SizeType = SizeType.Absolute;
681677
column.Width = width;
682678

683-
pnlCommitMessage.Size = new Size(width - pnlCommitMessage.Margin.Horizontal, _commitMessageHeight + rtbxCommitMessage.Margin.Vertical);
684-
RevisionInfo.Size = new Size(width - RevisionInfo.Margin.Horizontal, _revisionInfoHeight);
685-
686679
tableLayout.Size = new Size(width, heights.Sum());
687680

688681
tableLayout.ResumeLayout(false);
689682
tableLayout.PerformLayout();
690683

691-
rtbxCommitMessage.Refresh();
692-
RevisionInfo.Refresh();
684+
base.OnLayout(e);
693685
}
694686

695687
private void RichTextBox_KeyDown(object sender, KeyEventArgs e)

‎ResourceManager/GitExtensionsControlInitialiser.cs

+13-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.ComponentModel;
3+
using System.Windows.Forms;
34
using GitCommands;
45
using GitUI;
56

@@ -15,31 +16,25 @@ internal sealed class GitExtensionsControlInitialiser
1516
public GitExtensionsControlInitialiser(GitExtensionsFormBase form)
1617
{
1718
ThreadHelper.ThrowIfNotOnUIThread();
18-
form.Font = AppSettings.Font;
19-
form.Load += delegate
20-
{
21-
if (!_initialiseCompleteCalled && !IsDesignModeActive)
22-
{
23-
throw new Exception($"{form.GetType().Name} must call {nameof(InitializeComplete)} in its constructor, ideally as the final statement.");
24-
}
25-
};
19+
form.Load += LoadHandler;
2620
_translate = form;
2721
}
2822

2923
public GitExtensionsControlInitialiser(GitExtensionsControl control)
3024
{
3125
ThreadHelper.ThrowIfNotOnUIThread();
32-
control.Font = AppSettings.Font;
33-
control.Load += delegate
34-
{
35-
if (!_initialiseCompleteCalled && !IsDesignModeActive)
36-
{
37-
throw new Exception($"{control.GetType().Name} must call {nameof(InitializeComplete)} in its constructor, ideally as the final statement.");
38-
}
39-
};
26+
control.Load += LoadHandler;
4027
_translate = control;
4128
}
4229

30+
private void LoadHandler(object control, EventArgs e)
31+
{
32+
if (!_initialiseCompleteCalled && !IsDesignModeActive)
33+
{
34+
throw new Exception($"{control.GetType().Name} must call {nameof(InitializeComplete)} in its constructor, ideally as the final statement.");
35+
}
36+
}
37+
4338
/// <summary>Indicates whether code is running as part of an IDE designer, such as the WinForms designer.</summary>
4439
public bool IsDesignModeActive => LicenseManager.UsageMode == LicenseUsageMode.Designtime;
4540

@@ -51,6 +46,8 @@ public void InitializeComplete()
5146
}
5247

5348
_initialiseCompleteCalled = true;
49+
50+
((Control)_translate).Font = AppSettings.Font;
5451
Translator.Translate(_translate, AppSettings.CurrentTranslation);
5552
}
5653
}

0 commit comments

Comments
 (0)
Please sign in to comment.