forked from gitextensions/gitextensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGitExtensionsDialog.cs
78 lines (66 loc) · 3.21 KB
/
GitExtensionsDialog.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using GitExtUtils.GitUI.Theming;
namespace GitUI
{
// NOTE do not make this class abstract as it breaks the WinForms designer in VS
/// <summary>Base class for a Git Extensions <see cref="Form"/>.</summary>
/// <remarks>Includes support for font, hotkey, icon, translation, and position restore.</remarks>
public partial class GitExtensionsDialog : GitModuleForm
{
private static readonly Pen FooterDividerPen = new(KnownColor.ControlLight.MakeBackgroundDarkerBy(0.04));
/// <summary>Creates a new <see cref="GitExtensionsForm"/> without position restore.</summary>
[Obsolete("For VS designer and translation test only. Do not remove.")]
protected GitExtensionsDialog()
: base()
{
InitializeComponent();
}
/// <summary>Creates a new <see cref="GitExtensionsForm"/> indicating position restore.</summary>
/// <param name="enablePositionRestore">Indicates whether the <see cref="Form"/>'s position
/// will be restored upon being re-opened.</param>
protected GitExtensionsDialog(GitUICommands? commands, bool enablePositionRestore)
: base(commands, enablePositionRestore)
{
InitializeComponent();
// Lighten up the control panel
ControlsPanel.BackColor = KnownColor.ControlLight.MakeBackgroundDarkerBy(-0.04);
// Draw a separator line at the top of the footer panel, similar to what Task Dialog does
ControlsPanel.Paint += (s, e)
=> e.Graphics.DrawLine(FooterDividerPen, new Point(e.ClipRectangle.Left, 0), new Point(e.ClipRectangle.Right, 0));
}
/// <summary>
/// Gets or sets the anchor pointing to a section in the manual pertaining to this dialog.
/// </summary>
/// <remarks>
/// The URL structure:
/// https://git-extensions-documentation.readthedocs.io/{ManualSectionSubfolder}.html#{ManualSectionAnchorName}.
/// </remarks>
public string? ManualSectionAnchorName { get; set; }
/// <summary>
/// Gets or sets the name of a document pertaining to this dialog.
/// </summary>
/// <remarks>
/// The URL structure:
/// https://git-extensions-documentation.readthedocs.io/{ManualSectionSubfolder}.html#{ManualSectionAnchorName}.
/// </remarks>
public string? ManualSectionSubfolder { get; set; }
protected override void OnHelpButtonClicked(CancelEventArgs e)
{
// If we show the Help button but we have failed to specify where the docs are -> hide the button, and exit
if (string.IsNullOrWhiteSpace(ManualSectionAnchorName) || string.IsNullOrWhiteSpace(ManualSectionSubfolder))
{
HelpButton = false;
e.Cancel = true;
return;
}
base.OnHelpButtonClicked(e);
string url = UserManual.UserManual.UrlFor(ManualSectionSubfolder, ManualSectionAnchorName);
OsShellUtil.OpenUrlInDefaultBrowser(url);
// We've handled the event
e.Cancel = true;
}
}
}