Support closing windows with "Escape" key

This commit is contained in:
Jaex 2024-01-17 10:12:48 +03:00
parent f1635a44ac
commit 10c6f5e8a7
26 changed files with 38 additions and 37 deletions

View File

@ -55,7 +55,7 @@ namespace ShareX.HelpersLib
btnOpenLogFile.Enabled = !string.IsNullOrEmpty(Logger.LogFilePath);
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, true);
string startupPath = AppDomain.CurrentDomain.BaseDirectory;
llRunningFrom.Text = startupPath;

View File

@ -33,7 +33,7 @@ namespace ShareX.HistoryLib
public HistoryItemInfoForm(HistoryItem hi)
{
InitializeComponent();
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, true);
pgHistoryItem.SelectedObject = hi;
}
}

View File

@ -37,7 +37,7 @@ namespace ShareX.HistoryLib
public ImageHistorySettingsForm(ImageHistorySettings settings)
{
InitializeComponent();
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, true);
Settings = settings;
nudThumbnailSize.SetValue(Settings.ThumbnailSize.Width);

View File

@ -46,7 +46,7 @@ namespace ShareX.ImageEffectsLib
ShareXImageEffectsFolderPath = imageEffectsFolderPath;
InitializeComponent();
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, true);
AssetsFolderPath = Path.Combine(ShareXImageEffectsFolderPath, ImageEffectName);
txtAssetsFolderPath.Text = AssetsFolderPath;

View File

@ -46,7 +46,7 @@ namespace ShareX.ScreenCaptureLib
Options = options;
InitializeComponent();
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, true);
cbVideoCodec.Items.AddRange(Helpers.GetEnumDescriptions<FFmpegVideoCodec>());
cbAudioCodec.Items.AddRange(Helpers.GetEnumDescriptions<FFmpegAudioCodec>());

View File

@ -50,7 +50,7 @@ namespace ShareX.ScreenCaptureLib
Options = options;
InitializeComponent();
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, true);
manager = new ScrollingCaptureManager(Options);
}

View File

@ -38,7 +38,7 @@ namespace ShareX.ScreenCaptureLib
Options = options;
InitializeComponent();
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, true);
LoadOptions();
}

View File

@ -47,7 +47,7 @@ namespace ShareX.ScreenCaptureLib
public ScrollingCaptureRegionForm(Rectangle regionRectangle)
{
InitializeComponent();
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, false, false);
borderRectangle = regionRectangle.Offset(1);
borderRectangle0Based = new Rectangle(0, 0, borderRectangle.Width, borderRectangle.Height);

View File

@ -50,7 +50,7 @@ namespace ShareX.ScreenCaptureLib
InitializeComponent();
tsMain.Renderer = new ToolStripRoundedEdgeRenderer();
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, true);
tsnudSize.NumericUpDownControl.Minimum = 16;
tsnudSize.NumericUpDownControl.Maximum = 256;

View File

@ -39,7 +39,7 @@ namespace ShareX.ScreenCaptureLib
Stickers = stickers;
InitializeComponent();
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, true);
foreach (StickerPackInfo stickerPackInfo in Stickers)
{

View File

@ -102,7 +102,7 @@ namespace ShareX.UploadersLib
cbRequestMethod.Items.AddRange(Enum.GetNames(typeof(HttpMethod)));
cbBody.Items.AddRange(Helpers.GetEnumDescriptions<CustomUploaderBody>());
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, true);
CustomUploaderLoadTab();
}

View File

@ -84,7 +84,7 @@ namespace ShareX.UploadersLib
rtbURLSyntax.AddContextMenu();
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, true);
CustomUploaderSyntaxHighlight(rtbURLSyntax);
UpdatePreview();

View File

@ -82,7 +82,7 @@ namespace ShareX.UploadersLib
ResumeLayout();
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, true);
}
private void ParserSelectForm_Shown(object sender, EventArgs e)

View File

@ -48,7 +48,7 @@ namespace ShareX.UploadersLib
rtbResponseInfo.AddContextMenu();
rtbResponseText.AddContextMenu();
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, true);
UpdateResult(result);
}

View File

@ -53,7 +53,7 @@ namespace ShareX.UploadersLib
Config = config;
InitializeComponent();
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, true);
InitializeControls();
}

View File

@ -702,16 +702,18 @@ namespace ShareX.UploadersLib
public UserPassBox SendSpaceRegister()
{
UserPassBox upb = new UserPassBox(Resources.UploadersConfigForm_SendSpaceRegister_SendSpace_Registration___, "John Doe", "john.doe@gmail.com", "JohnDoe", "");
upb.ShowDialog();
if (upb.DialogResult == DialogResult.OK)
if (upb.ShowDialog() == DialogResult.OK)
{
SendSpace sendSpace = new SendSpace(APIKeys.SendSpaceKey);
upb.Success = sendSpace.AuthRegister(upb.UserName, upb.FullName, upb.Email, upb.Password);
if (!upb.Success && sendSpace.Errors.Count > 0)
{
MessageBox.Show(sendSpace.ToErrorString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
return upb;
}

View File

@ -40,25 +40,31 @@ namespace ShareX.UploadersLib
public UserPassBox(string title, string userName, string password)
{
InitializeComponent();
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, true);
Text = title;
txtUserName.Text = userName;
txtPassword.Text = password;
}
public UserPassBox(string q, string fullName, string userName, string password) : this(q, userName, password)
public UserPassBox(string title, string fullName, string userName, string password) : this(title, userName, password)
{
txtFullName.Text = fullName;
txtFullName.Enabled = true;
}
public UserPassBox(string q, string fullName, string email, string userName, string password) : this(q, fullName, userName, password)
public UserPassBox(string title, string fullName, string email, string userName, string password) : this(title, fullName, userName, password)
{
txtEmail.Text = email;
txtEmail.Enabled = true;
}
private void InputBox_Shown(object sender, EventArgs e)
{
txtUserName.Focus();
txtUserName.SelectionLength = txtUserName.Text.Length;
}
private void btnOK_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(txtUserName.Text))
@ -67,8 +73,8 @@ namespace ShareX.UploadersLib
Password = txtPassword.Text;
Email = txtEmail.Text;
FullName = txtFullName.Text;
DialogResult = DialogResult.OK;
Hide();
Close();
}
}
@ -76,14 +82,7 @@ namespace ShareX.UploadersLib
private void btnCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Hide();
Close();
}
private void InputBox_Shown(object sender, EventArgs e)
{
txtUserName.Focus();
txtUserName.SelectionLength = txtUserName.Text.Length;
}
}
}

View File

@ -38,7 +38,7 @@ namespace ShareX.UploadersLib
public YouTubeVideoOptionsForm(string title = "", string description = "", YouTubeVideoPrivacy visibility = YouTubeVideoPrivacy.Private)
{
InitializeComponent();
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, true);
Title = title;
Description = description;

View File

@ -41,7 +41,7 @@ namespace ShareX.UploadersLib
public OAuthListenerForm(IOAuth2Loopback oauth)
{
InitializeComponent();
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, true);
OAuth = oauth;
}

View File

@ -40,7 +40,7 @@ namespace ShareX
public ActionsToolbarEditForm(List<HotkeyType> actions)
{
InitializeComponent();
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, true);
Actions = actions;

View File

@ -42,7 +42,7 @@ namespace ShareX
public ApplicationSettingsForm()
{
InitializeControls();
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, true);
}
private void SettingsForm_Shown(object sender, EventArgs e)

View File

@ -64,7 +64,7 @@ namespace ShareX
private AutoCaptureForm()
{
InitializeComponent();
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, true);
niTray.Icon = Resources.clock.ToIcon();
screenshotTimer = new System.Timers.Timer();

View File

@ -46,7 +46,7 @@ namespace ShareX
public TaskSettingsForm(TaskSettings hotkeySetting, bool isDefault = false)
{
InitializeComponent();
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, true);
tsmiURLShorteners.Image = ShareXResources.IsDarkTheme ? Resources.edit_scale_white : Resources.edit_scale;

View File

@ -36,7 +36,7 @@ namespace ShareX
public BorderlessWindowSettingsForm(BorderlessWindowSettings settings)
{
InitializeComponent();
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, true);
Settings = settings;
cbRememberWindowTitle.Checked = Settings.RememberWindowTitle;

View File

@ -37,7 +37,7 @@ namespace ShareX
public ServiceLinksForm(List<ServiceLink> serviceLinks)
{
InitializeComponent();
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, true);
ServiceLinks = serviceLinks;

View File

@ -39,7 +39,7 @@ namespace ShareX
Options = options;
InitializeComponent();
ShareXResources.ApplyTheme(this);
ShareXResources.ApplyTheme(this, true);
InitOptions();
LoadOptions();