2020-07-07 09:37:55 +12:00
// <copyright file="SettingsForm.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
2020-07-07 07:15:45 +12:00
// </copyright>
2020-05-05 05:43:47 +12:00
namespace SystemTrayMenu.UserInterface
{
2020-07-07 07:15:45 +12:00
using System ;
using System.Collections.Generic ;
using System.Drawing ;
2021-05-09 19:52:37 +12:00
using System.IO ;
2020-07-07 07:15:45 +12:00
using System.Reflection ;
using System.Text ;
using System.Windows.Forms ;
2020-07-08 03:05:19 +12:00
using Microsoft.Win32 ;
2021-05-05 02:18:19 +12:00
using SystemTrayMenu.Properties ;
2020-07-07 07:15:45 +12:00
using SystemTrayMenu.Utilities ;
2020-07-08 03:05:19 +12:00
using static SystemTrayMenu . UserInterface . HotkeyTextboxControl . HotkeyControl ;
2020-07-07 07:15:45 +12:00
2020-05-05 05:43:47 +12:00
public partial class SettingsForm : Form
{
2021-05-09 23:14:37 +12:00
private static readonly Icon SystemTrayMenu = Resources . SystemTrayMenu ;
2020-05-14 05:14:51 +12:00
private readonly string newHotKey = string . Empty ;
2021-04-17 12:39:48 +12:00
private bool inHotkey ;
2021-05-05 02:18:19 +12:00
private ColorConverter colorConverter = new ColorConverter ( ) ;
2020-05-05 05:43:47 +12:00
public SettingsForm ( )
{
InitializeComponent ( ) ;
2021-05-09 23:14:37 +12:00
Icon = SystemTrayMenu ;
2020-05-05 05:43:47 +12:00
2021-04-26 02:22:53 +12:00
// Initialize and replace here here, because designer always removes it
InitializeTextBoxHotkeyAndReplacetextBoxHotkeyPlaceholder ( ) ;
void InitializeTextBoxHotkeyAndReplacetextBoxHotkeyPlaceholder ( )
{
2021-04-26 06:40:11 +12:00
textBoxHotkey = new HotkeyTextboxControl . HotkeyControl
{
Hotkey = Keys . None ,
HotkeyModifiers = Keys . None ,
Name = "textBoxHotkey" ,
Size = new Size ( 200 , 20 ) ,
Text = "None" ,
} ;
2021-04-26 02:22:53 +12:00
textBoxHotkey . Enter + = new EventHandler ( this . TextBoxHotkeyEnter ) ;
textBoxHotkey . Leave + = new EventHandler ( this . TextBoxHotkey_Leave ) ;
tableLayoutPanelHotkey . Controls . Remove ( textBoxHotkeyPlaceholder ) ;
tableLayoutPanelHotkey . Controls . Add ( textBoxHotkey , 0 , 0 ) ;
}
// designer always resets it to 1
this . tabControl . SelectedIndex = 0 ;
2020-05-05 05:43:47 +12:00
Translate ( ) ;
void Translate ( )
{
Text = Translator . GetText ( "Settings" ) ;
tabPageGeneral . Text = Translator . GetText ( "General" ) ;
2021-04-26 02:22:53 +12:00
tabPageAdvanced . Text = Translator . GetText ( "Advanced" ) ;
tabPageCustomize . Text = Translator . GetText ( "Customize" ) ;
groupBoxFolder . Text = Translator . GetText ( "Folder" ) ;
2021-05-05 07:59:55 +12:00
buttonChangeFolder . Text = Translator . GetText ( "Change folder" ) ;
2021-05-09 19:52:37 +12:00
groupBoxUSB . Text = Translator . GetText ( "USB" ) ;
buttonChangeRelativeFolder . Text = Translator . GetText ( "Change to relative folder" ) ;
2021-05-17 07:45:24 +12:00
checkBoxStoreConfigAtAssemblyLocation . Text = Translator . GetText ( "Store config at the assembly location" ) ;
buttonOpenAssemblyLocation . Text = Translator . GetText ( "Open the assembly location" ) ;
2021-04-26 02:22:53 +12:00
groupBoxAutostart . Text = Translator . GetText ( "Autostart" ) ;
2020-05-05 05:43:47 +12:00
checkBoxAutostart . Text = Translator . GetText ( "Launch on startup" ) ;
2021-04-26 02:22:53 +12:00
groupBoxHotkey . Text = Translator . GetText ( "Hotkey" ) ;
buttonHotkeyDefault . Text = Translator . GetText ( "Default" ) ;
groupBoxLanguage . Text = Translator . GetText ( "Language" ) ;
groupBoxClick . Text = Translator . GetText ( "Click" ) ;
2020-08-06 01:33:45 +12:00
checkBoxOpenItemWithOneClick . Text = Translator . GetText ( "Single click to start item" ) ;
2021-04-26 02:22:53 +12:00
groupBoxSizeAndLocation . Text = Translator . GetText ( "Size and location" ) ;
checkBoxAppearAtMouseLocation . Text = Translator . GetText ( "Appear at mouse location" ) ;
labelMaxMenuWidth . Text = Translator . GetText ( "Pixels maximum menu width" ) ;
groupBoxStaysOpen . Text = Translator . GetText ( "Stays open" ) ;
2021-05-02 23:12:18 +12:00
checkBoxStayOpenWhenItemClicked . Text = Translator . GetText ( "If an item was clicked" ) ;
2021-04-26 02:22:53 +12:00
checkBoxStayOpenWhenFocusLost . Text = Translator . GetText ( "If the focus is lost and if the mouse is still on the menu" ) ;
labelTimeUntilCloses . Text = Translator . GetText ( "Milliseconds until the menu closes if in this case the mouse then leaves the menu" ) ;
2021-04-27 07:05:15 +12:00
groupBoxOpenSubmenus . Text = Translator . GetText ( "Time until a menu opens" ) ;
2021-04-26 02:22:53 +12:00
labelTimeUntilOpen . Text = Translator . GetText ( "Milliseconds until a menu opens when the mouse is on it" ) ;
buttonAdvancedDefault . Text = Translator . GetText ( "Default" ) ;
2021-05-05 07:59:55 +12:00
groupBoxColors . Text = Translator . GetText ( "Colors Light Mode and Dark Mode" ) ;
2021-05-05 02:58:12 +12:00
buttonDefaultColors . Text = Translator . GetText ( "Default" ) ;
2021-04-26 02:22:53 +12:00
groupBoxDarkMode . Text = Translator . GetText ( "Dark Mode" ) ;
2020-08-08 01:24:25 +12:00
checkBoxDarkModeAlwaysOn . Text = Translator . GetText ( "Dark Mode always active" ) ;
2021-05-05 07:59:55 +12:00
labelPasteHtmlColorCodeOrDoubleClickIntoField . Text = Translator . GetText ( "To change a color paste a HTML Color Code or double click into a field." ) ;
labelTitle . Text = Translator . GetText ( "Title" ) ;
labelBackground . Text = Translator . GetText ( "Background" ) ;
labelSearchField . Text = Translator . GetText ( "Search field" ) ;
2021-05-17 07:45:24 +12:00
labelOpenFolder . Text = Translator . GetText ( "Opened folder" ) ;
labelOpenFolderBorder . Text = Translator . GetText ( "Border of opened folder" ) ;
2021-05-05 07:59:55 +12:00
labelSelectedItem . Text = Translator . GetText ( "Selected item" ) ;
2021-05-17 07:45:24 +12:00
labelSelectedItemBorder . Text = Translator . GetText ( "Border of selected item" ) ;
2021-05-05 07:59:55 +12:00
labelWarning . Text = Translator . GetText ( "Warning" ) ;
buttonDefaultColors . Text = Translator . GetText ( "Default Light Mode" ) ;
buttonDefaultColorsDark . Text = Translator . GetText ( "Default Dark Mode" ) ;
2020-05-05 05:43:47 +12:00
buttonOk . Text = Translator . GetText ( "buttonOk" ) ;
buttonCancel . Text = Translator . GetText ( "buttonCancel" ) ;
}
InitializeFolder ( ) ;
void InitializeFolder ( )
{
textBoxFolder . Text = Config . Path ;
}
InitializeAutostart ( ) ;
void InitializeAutostart ( )
{
2020-05-14 05:14:51 +12:00
checkBoxAutostart . Checked =
2021-05-05 02:18:19 +12:00
Settings . Default . IsAutostartActivated ;
2020-05-05 05:43:47 +12:00
}
InitializeHotkey ( ) ;
void InitializeHotkey ( )
{
2021-05-05 02:18:19 +12:00
textBoxHotkey . SetHotkey ( Settings . Default . HotKey ) ;
2020-05-05 05:43:47 +12:00
}
InitializeLanguage ( ) ;
void InitializeLanguage ( )
{
2020-05-14 05:14:51 +12:00
List < Language > dataSource = new List < Language >
{
2021-05-03 00:51:16 +12:00
new Language ( ) { Name = "čeština" , Value = "cs" } ,
2020-07-07 07:15:45 +12:00
new Language ( ) { Name = "Deutsch" , Value = "de" } ,
2021-05-03 00:51:16 +12:00
new Language ( ) { Name = "English" , Value = "en" } ,
2021-04-16 05:01:23 +12:00
new Language ( ) { Name = "Español" , Value = "es" } ,
2021-05-03 00:51:16 +12:00
new Language ( ) { Name = "Français" , Value = "fr" } ,
2021-04-25 09:03:24 +12:00
new Language ( ) { Name = "Italiano" , Value = "it" } ,
2021-04-29 09:41:21 +12:00
new Language ( ) { Name = "Nederlands" , Value = "nl" } ,
2021-05-03 00:51:16 +12:00
new Language ( ) { Name = "Português (Brasil)" , Value = "pt-BR" } ,
2021-05-03 01:21:07 +12:00
2021-05-03 00:51:16 +12:00
// new Language() { Name = "русский", Value = "ru" },
2020-05-14 05:14:51 +12:00
} ;
2020-05-05 05:43:47 +12:00
comboBoxLanguage . DataSource = dataSource ;
comboBoxLanguage . DisplayMember = "Name" ;
comboBoxLanguage . ValueMember = "Value" ;
2020-05-14 05:14:51 +12:00
comboBoxLanguage . SelectedValue =
2021-05-05 02:18:19 +12:00
Settings . Default . CurrentCultureInfoName ;
2020-05-05 05:43:47 +12:00
if ( comboBoxLanguage . SelectedValue = = null )
{
comboBoxLanguage . SelectedValue = "en" ;
}
}
2020-08-06 01:33:45 +12:00
2021-05-09 19:52:37 +12:00
checkBoxStoreConfigAtAssemblyLocation . Checked = CustomSettingsProvider . IsActivatedConfigPathAssembly ( ) ;
2021-05-05 02:18:19 +12:00
checkBoxOpenItemWithOneClick . Checked = Settings . Default . OpenItemWithOneClick ;
checkBoxAppearAtMouseLocation . Checked = Settings . Default . AppearAtMouseLocation ;
2021-04-26 06:40:11 +12:00
numericUpDownMenuWidth . Minimum = 50 ;
numericUpDownMenuWidth . Maximum = 500 ;
numericUpDownMenuWidth . Increment = 10 ;
2021-05-05 02:18:19 +12:00
numericUpDownMenuWidth . Value = Settings . Default . MaximumMenuWidth ;
2021-04-26 06:40:11 +12:00
2021-05-05 02:18:19 +12:00
checkBoxStayOpenWhenItemClicked . Checked = Settings . Default . StaysOpenWhenItemClicked ;
checkBoxStayOpenWhenFocusLost . Checked = Settings . Default . StaysOpenWhenFocusLost ;
2021-04-26 06:40:11 +12:00
numericUpDownTimeUntilClose . Minimum = 200 ;
numericUpDownTimeUntilClose . Maximum = 5000 ;
numericUpDownTimeUntilClose . Increment = 100 ;
2021-05-05 02:18:19 +12:00
numericUpDownTimeUntilClose . Value = Settings . Default . TimeUntilCloses ;
2021-04-26 06:40:11 +12:00
numericUpDownTimeUntilOpens . Minimum = 20 ;
numericUpDownTimeUntilOpens . Maximum = 1000 ;
numericUpDownTimeUntilOpens . Increment = 10 ;
2021-05-05 02:18:19 +12:00
numericUpDownTimeUntilOpens . Value = Settings . Default . TimeUntilOpens ;
checkBoxDarkModeAlwaysOn . Checked = Settings . Default . IsDarkModeAlwaysOn ;
2021-05-05 07:59:55 +12:00
textBoxColorSelectedItem . Text = Settings . Default . ColorSelectedItem ;
textBoxColorDarkModeSelecetedItem . Text = Settings . Default . ColorDarkModeSelecetedItem ;
textBoxColorSelectedItemBorder . Text = Settings . Default . ColorSelectedItemBorder ;
textBoxColorDarkModeSelectedItemBorder . Text = Settings . Default . ColorDarkModeSelectedItemBorder ;
textBoxColorOpenFolder . Text = Settings . Default . ColorOpenFolder ;
textBoxColorDarkModeOpenFolder . Text = Settings . Default . ColorDarkModeOpenFolder ;
textBoxColorOpenFolderBorder . Text = Settings . Default . ColorOpenFolderBorder ;
textBoxColorDarkModeOpenFolderBorder . Text = Settings . Default . ColorDarkModeOpenFolderBorder ;
2021-05-05 02:58:12 +12:00
textBoxColorWarning . Text = Settings . Default . ColorWarning ;
textBoxColorDarkModeWarning . Text = Settings . Default . ColorDarkModeWarning ;
textBoxColorTitle . Text = Settings . Default . ColorTitle ;
textBoxColorDarkModeTitle . Text = Settings . Default . ColorDarkModeTitle ;
2021-05-05 07:59:55 +12:00
textBoxColorBackground . Text = Settings . Default . ColorBackground ;
textBoxColorDarkModeBackground . Text = Settings . Default . ColorDarkModeBackground ;
textBoxColorSearchField . Text = Settings . Default . ColorSearchField ;
textBoxColorDarkModeSearchField . Text = Settings . Default . ColorDarkModeSearchField ;
2020-05-05 05:43:47 +12:00
}
2020-07-08 03:05:19 +12:00
public string NewHotKey = > newHotKey ;
2020-05-05 05:43:47 +12:00
2020-07-08 03:05:19 +12:00
/// <summary>
/// Registers all hotkeys as configured, displaying a dialog in case of hotkey conflicts with other tools.
/// </summary>
/// <returns>Whether the hotkeys could be registered to the users content. This also applies if conflicts arise and the user decides to ignore these (i.e. not to register the conflicting hotkey).</returns>
public static bool RegisterHotkeys ( )
2020-05-05 05:43:47 +12:00
{
2020-07-08 03:05:19 +12:00
return RegisterHotkeys ( false ) ;
2020-05-05 05:43:47 +12:00
}
protected override bool ProcessCmdKey ( ref Message msg , Keys keyData )
{
switch ( keyData )
{
case Keys . Escape :
2020-07-07 09:37:55 +12:00
if ( ! inHotkey )
2020-05-05 05:43:47 +12:00
{
DialogResult = DialogResult . Cancel ;
}
else
{
return base . ProcessCmdKey ( ref msg , keyData ) ;
}
2020-07-07 07:15:45 +12:00
2020-05-05 05:43:47 +12:00
break ;
default :
return base . ProcessCmdKey ( ref msg , keyData ) ;
}
2020-07-07 07:15:45 +12:00
2020-05-05 05:43:47 +12:00
return true ;
}
/// <summary>
2020-07-07 09:37:55 +12:00
/// Helper method to cleanly register a hotkey.
2020-05-05 05:43:47 +12:00
/// </summary>
2020-07-07 09:37:55 +12:00
/// <param name="failedKeys">failedKeys.</param>
/// <param name="hotkeyString">hotkeyString.</param>
/// <param name="handler">handler.</param>
/// <returns>bool success.</returns>
2020-05-05 05:43:47 +12:00
private static bool RegisterHotkey ( StringBuilder failedKeys , string hotkeyString , HotKeyHandler handler )
{
2021-04-23 05:18:03 +12:00
Keys modifierKeyCode = HotkeyModifiersFromString ( hotkeyString ) ;
Keys virtualKeyCode = HotkeyFromString ( hotkeyString ) ;
2020-05-05 05:43:47 +12:00
if ( ! Keys . None . Equals ( virtualKeyCode ) )
{
2021-04-23 05:18:03 +12:00
if ( RegisterHotKey ( modifierKeyCode , virtualKeyCode , handler ) < 0 )
2020-05-05 05:43:47 +12:00
{
if ( failedKeys . Length > 0 )
{
failedKeys . Append ( ", " ) ;
}
2020-07-07 07:15:45 +12:00
2020-05-05 05:43:47 +12:00
failedKeys . Append ( hotkeyString ) ;
return false ;
}
}
2020-07-07 07:15:45 +12:00
2020-05-05 05:43:47 +12:00
return true ;
}
2020-07-04 08:02:16 +12:00
private static bool RegisterWrapper ( StringBuilder failedKeys , HotKeyHandler handler )
2020-05-05 05:43:47 +12:00
{
2020-07-07 09:37:55 +12:00
bool success = RegisterHotkey (
failedKeys ,
2021-05-05 02:18:19 +12:00
Settings . Default . HotKey ,
2020-07-07 02:46:47 +12:00
handler ) ;
return success ;
2020-05-05 05:43:47 +12:00
}
/// <summary>
/// Registers all hotkeys as configured, displaying a dialog in case of hotkey conflicts with other tools.
/// </summary>
2020-07-07 09:37:55 +12:00
/// <param name="ignoreFailedRegistration">if true, a failed hotkey registration will not be reported to the user - the hotkey will simply not be registered.</param>
2020-05-05 05:43:47 +12:00
/// <returns>Whether the hotkeys could be registered to the users content. This also applies if conflicts arise and the user decides to ignore these (i.e. not to register the conflicting hotkey).</returns>
private static bool RegisterHotkeys ( bool ignoreFailedRegistration )
{
bool success = true ;
StringBuilder failedKeys = new StringBuilder ( ) ;
2020-07-07 02:46:47 +12:00
if ( ! RegisterWrapper ( failedKeys , Handler ) )
2020-05-05 05:43:47 +12:00
{
success = false ;
}
if ( ! success )
{
if ( ! ignoreFailedRegistration )
{
success = HandleFailedHotkeyRegistration ( failedKeys . ToString ( ) ) ;
}
}
2020-07-07 07:15:45 +12:00
2020-05-05 05:43:47 +12:00
return success | | ignoreFailedRegistration ;
}
2020-07-07 02:46:47 +12:00
private static void Handler ( )
2020-05-14 05:14:51 +12:00
{
}
2020-05-05 05:43:47 +12:00
/// <summary>
2020-07-07 07:15:45 +12:00
/// Displays a dialog for the user to choose how to handle hotkey registration failures:
2020-05-05 05:43:47 +12:00
/// retry (allowing to shut down the conflicting application before),
/// ignore (not registering the conflicting hotkey and resetting the respective config to "None", i.e. not trying to register it again on next startup)
2020-07-07 09:37:55 +12:00
/// abort (do nothing about it).
2020-05-05 05:43:47 +12:00
/// </summary>
2020-07-07 09:37:55 +12:00
/// <param name="failedKeys">comma separated list of the hotkeys that could not be registered, for display in dialog text.</param>
/// <returns>bool success.</returns>
2020-05-05 05:43:47 +12:00
private static bool HandleFailedHotkeyRegistration ( string failedKeys )
{
bool success = false ;
2020-07-04 08:02:16 +12:00
string warningTitle = Translator . GetText ( "Warning" ) ;
string message = Translator . GetText ( "Could not register the hot key." ) + failedKeys ;
2020-05-05 05:43:47 +12:00
DialogResult dr = MessageBox . Show ( message , warningTitle , MessageBoxButtons . AbortRetryIgnore , MessageBoxIcon . Exclamation ) ;
if ( dr = = DialogResult . Retry )
{
2021-04-23 05:18:03 +12:00
UnregisterHotkeys ( ) ;
2020-05-05 05:43:47 +12:00
success = RegisterHotkeys ( false ) ;
}
else if ( dr = = DialogResult . Ignore )
{
2021-04-23 05:18:03 +12:00
UnregisterHotkeys ( ) ;
2020-05-05 05:43:47 +12:00
success = RegisterHotkeys ( true ) ;
}
2020-07-07 07:15:45 +12:00
2020-05-05 05:43:47 +12:00
return success ;
}
2021-05-05 07:59:55 +12:00
private void SettingsForm_Load ( object sender , EventArgs e )
{
tabControl . Size = new Size (
tabControl . Size . Width ,
tableLayoutPanelCustomize . Size . Height + 50 ) ;
}
2020-07-08 03:05:19 +12:00
private void ButtonOk_Click ( object sender , EventArgs e )
{
2021-04-26 02:22:53 +12:00
SaveAutostart ( ) ;
void SaveAutostart ( )
{
if ( checkBoxAutostart . Checked )
{
RegistryKey key = Registry . CurrentUser . OpenSubKey (
@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run" , true ) ;
key . SetValue (
Assembly . GetExecutingAssembly ( ) . GetName ( ) . Name ,
System . Diagnostics . Process . GetCurrentProcess ( ) . MainModule . FileName ) ;
2021-05-05 02:18:19 +12:00
Settings . Default . IsAutostartActivated = true ;
2021-04-26 02:22:53 +12:00
}
else
{
RegistryKey key = Registry . CurrentUser . OpenSubKey (
@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run" , true ) ;
key . DeleteValue ( "SystemTrayMenu" , false ) ;
2021-05-05 02:18:19 +12:00
Settings . Default . IsAutostartActivated = false ;
2021-04-26 02:22:53 +12:00
}
}
2020-07-08 03:05:19 +12:00
2021-04-26 02:22:53 +12:00
SaveHotkey ( ) ;
void SaveHotkey ( )
2020-07-08 03:05:19 +12:00
{
2021-05-05 02:18:19 +12:00
Settings . Default . HotKey =
2021-04-26 02:22:53 +12:00
new KeysConverter ( ) . ConvertToInvariantString (
textBoxHotkey . Hotkey | textBoxHotkey . HotkeyModifiers ) ;
2020-07-08 03:05:19 +12:00
}
2021-04-26 02:22:53 +12:00
SaveLanguage ( ) ;
void SaveLanguage ( )
2020-07-08 03:05:19 +12:00
{
2021-05-05 02:18:19 +12:00
Settings . Default . CurrentCultureInfoName =
2021-04-26 02:22:53 +12:00
comboBoxLanguage . SelectedValue . ToString ( ) ;
2020-07-08 03:05:19 +12:00
}
2021-05-05 02:18:19 +12:00
Settings . Default . OpenItemWithOneClick = checkBoxOpenItemWithOneClick . Checked ;
Settings . Default . AppearAtMouseLocation = checkBoxAppearAtMouseLocation . Checked ;
Settings . Default . MaximumMenuWidth = ( int ) numericUpDownMenuWidth . Value ;
Settings . Default . StaysOpenWhenItemClicked = checkBoxStayOpenWhenItemClicked . Checked ;
Settings . Default . StaysOpenWhenFocusLost = checkBoxStayOpenWhenFocusLost . Checked ;
Settings . Default . TimeUntilCloses = ( int ) numericUpDownTimeUntilClose . Value ;
Settings . Default . TimeUntilOpens = ( int ) numericUpDownTimeUntilOpens . Value ;
Settings . Default . IsDarkModeAlwaysOn = checkBoxDarkModeAlwaysOn . Checked ;
2021-05-05 07:59:55 +12:00
Settings . Default . ColorSelectedItem = textBoxColorSelectedItem . Text ;
Settings . Default . ColorDarkModeSelecetedItem = textBoxColorDarkModeSelecetedItem . Text ;
Settings . Default . ColorSelectedItemBorder = textBoxColorSelectedItemBorder . Text ;
Settings . Default . ColorDarkModeSelectedItemBorder = textBoxColorDarkModeSelectedItemBorder . Text ;
Settings . Default . ColorOpenFolder = textBoxColorOpenFolder . Text ;
Settings . Default . ColorDarkModeOpenFolder = textBoxColorDarkModeOpenFolder . Text ;
Settings . Default . ColorOpenFolderBorder = textBoxColorOpenFolderBorder . Text ;
Settings . Default . ColorDarkModeOpenFolderBorder = textBoxColorDarkModeOpenFolderBorder . Text ;
2021-05-05 02:58:12 +12:00
Settings . Default . ColorWarning = textBoxColorWarning . Text ;
Settings . Default . ColorDarkModeWarning = textBoxColorDarkModeWarning . Text ;
Settings . Default . ColorTitle = textBoxColorTitle . Text ;
Settings . Default . ColorDarkModeTitle = textBoxColorDarkModeTitle . Text ;
2021-05-05 07:59:55 +12:00
Settings . Default . ColorBackground = textBoxColorBackground . Text ;
Settings . Default . ColorDarkModeBackground = textBoxColorDarkModeBackground . Text ;
Settings . Default . ColorSearchField = textBoxColorSearchField . Text ;
Settings . Default . ColorDarkModeSearchField = textBoxColorDarkModeSearchField . Text ;
2021-05-09 19:52:37 +12:00
if ( checkBoxStoreConfigAtAssemblyLocation . Checked )
{
CustomSettingsProvider . ActivateConfigPathAssembly ( ) ;
Settings . Default . Save ( ) ;
}
else
{
Settings . Default . Save ( ) ;
CustomSettingsProvider . DeactivateConfigPathAssembly ( ) ;
}
2021-04-26 02:22:53 +12:00
DialogResult = DialogResult . OK ;
Close ( ) ;
2020-07-08 03:05:19 +12:00
}
2021-04-26 02:22:53 +12:00
private void ButtonHotkeyDefault_Click ( object sender , EventArgs e )
2020-07-08 03:05:19 +12:00
{
2021-04-26 02:22:53 +12:00
textBoxHotkey . SetHotkey ( "Ctrl+LWin" ) ;
2020-07-08 03:05:19 +12:00
}
2020-07-07 09:37:55 +12:00
2021-04-26 02:22:53 +12:00
private void ButtonAdvancedDefault_Click ( object sender , EventArgs e )
2020-08-06 01:33:45 +12:00
{
2021-04-26 02:22:53 +12:00
checkBoxOpenItemWithOneClick . Checked = true ;
checkBoxAppearAtMouseLocation . Checked = false ;
2021-04-26 06:40:11 +12:00
numericUpDownMenuWidth . Value = 300 ;
2021-05-02 23:12:18 +12:00
checkBoxStayOpenWhenItemClicked . Checked = true ;
2021-04-26 02:22:53 +12:00
checkBoxStayOpenWhenFocusLost . Checked = true ;
2021-04-26 06:40:11 +12:00
numericUpDownTimeUntilClose . Value = 1000 ;
2021-04-27 04:09:56 +12:00
numericUpDownTimeUntilOpens . Value = 100 ;
2020-08-06 01:33:45 +12:00
}
2020-07-08 03:05:19 +12:00
private void ButtonCancel_Click ( object sender , EventArgs e )
{
2021-05-05 02:18:19 +12:00
Settings . Default . Reload ( ) ;
2020-07-08 03:05:19 +12:00
DialogResult = DialogResult . Cancel ;
Close ( ) ;
}
private void ButtonChange_Click ( object sender , EventArgs e )
{
Config . SetFolderByUser ( false ) ;
textBoxFolder . Text = Config . Path ;
}
2021-05-09 19:52:37 +12:00
private void ButtonChangeRelativeFolder_Click ( object sender , EventArgs e )
{
Settings . Default . PathDirectory = Path . GetRelativePath (
Directory . GetParent ( Assembly . GetEntryAssembly ( ) . Location ) . FullName ,
Config . Path ) ;
textBoxFolder . Text = Config . Path ;
}
private void ButtonOpenAssemblyLocation_Click ( object sender , EventArgs e )
{
Log . ProcessStart ( Directory . GetParent ( Assembly . GetEntryAssembly ( ) . Location ) . FullName ) ;
}
2020-07-08 03:05:19 +12:00
private void TextBoxHotkeyEnter ( object sender , EventArgs e )
{
2021-04-23 05:18:03 +12:00
UnregisterHotkeys ( ) ;
2020-07-08 03:05:19 +12:00
inHotkey = true ;
}
private void TextBoxHotkey_Leave ( object sender , EventArgs e )
{
2021-05-05 02:18:19 +12:00
Settings . Default . HotKey =
2020-07-08 03:05:19 +12:00
new KeysConverter ( ) . ConvertToInvariantString (
textBoxHotkey . Hotkey | textBoxHotkey . HotkeyModifiers ) ;
RegisterHotkeys ( ) ;
inHotkey = false ;
}
2021-05-03 01:21:07 +12:00
private void CheckBoxStayOpenWhenFocusLost_CheckedChanged ( object sender , EventArgs e )
{
numericUpDownTimeUntilClose . Enabled = checkBoxStayOpenWhenFocusLost . Checked ;
}
2021-05-05 02:18:19 +12:00
private void TextBoxColorsChanged ( object sender , EventArgs e )
{
TextBox textBox = ( TextBox ) sender ;
textBox . Text = textBox . Text . Trim ( ) ;
2021-05-05 02:58:12 +12:00
try
2021-05-05 02:18:19 +12:00
{
2021-05-05 02:58:12 +12:00
Color color = ( Color ) colorConverter . ConvertFromString ( textBox . Text ) ;
textBox . BackColor = color ;
2021-05-05 02:18:19 +12:00
}
2021-05-05 02:58:12 +12:00
catch
2021-05-05 02:18:19 +12:00
{
2021-05-05 02:58:12 +12:00
textBox . Text = "#ffffff" ;
2021-05-05 02:18:19 +12:00
textBox . BackColor = Color . White ;
}
}
private void TextBoxColorsDoubleClick ( object sender , EventArgs e )
{
TextBox textBox = ( TextBox ) sender ;
2021-05-05 02:58:12 +12:00
colorDialog . Color = textBox . BackColor ;
if ( colorDialog . ShowDialog ( ) = = DialogResult . OK )
2021-05-05 02:18:19 +12:00
{
2021-05-05 02:58:12 +12:00
textBox . Text = ColorTranslator . ToHtml ( colorDialog . Color ) ;
textBox . BackColor = colorDialog . Color ;
2021-05-05 02:18:19 +12:00
}
}
private void ButtonDefaultColors_Click ( object sender , EventArgs e )
{
2021-05-05 02:58:12 +12:00
textBoxColorTitle . Text = "#f0ffff" ;
2021-05-05 07:59:55 +12:00
textBoxColorOpenFolder . Text = "#C2F5DE" ;
textBoxColorOpenFolderBorder . Text = "#99FFA5" ;
textBoxColorBackground . Text = "#ffffff" ;
textBoxColorSearchField . Text = "#ffffff" ;
textBoxColorSelectedItem . Text = "#CCE8FF" ;
textBoxColorSelectedItemBorder . Text = "#99D1FF" ;
2021-05-05 02:58:12 +12:00
textBoxColorWarning . Text = "#FFCCE8" ;
2021-05-05 02:18:19 +12:00
}
private void ButtonDefaultColorsDark_Click ( object sender , EventArgs e )
{
2021-05-05 02:58:12 +12:00
textBoxColorDarkModeTitle . Text = "#2B2B2B" ;
2021-05-05 07:59:55 +12:00
textBoxColorDarkModeOpenFolder . Text = "#14412A" ;
textBoxColorDarkModeOpenFolderBorder . Text = "#144B55" ;
textBoxColorDarkModeBackground . Text = "#202020" ;
textBoxColorDarkModeSearchField . Text = "#191919" ;
textBoxColorDarkModeSelecetedItem . Text = "#333333" ;
textBoxColorDarkModeSelectedItemBorder . Text = "#141D4B" ;
2021-05-05 02:58:12 +12:00
textBoxColorDarkModeWarning . Text = "#4B1834" ;
2021-05-05 02:18:19 +12:00
}
2020-05-05 05:43:47 +12:00
}
}