Add global hotkey support (#724)
Design: Use the plain string for both config and hotkey parsing and make use of KeyConverter, ModifierKeysConverter to make it more rubust. Find corresponding label (to display operation result) and callback (to do the real work) based on textbox name. In this case, they should be named as `<Feature-Name><Control-Name>`. ShowLogsTextBox, ShowLogsLabel, ShowLogsCallback. If this requirement doesn't meet, throw an exception at runtime. Logic: How to input keys: 1. put focus in the corresponding textbox 2. press the key combination you want to use 3. when you think it is ready, release all keys 4. the textbox shows your input How to change keys: 1. put focus in the corresponding textbox 2. press BackSpace to clear content 3. re-input new one How to deactivate: 1. clear content in the textbox 2. press OK button Meaning of label color: - Green: this combination is not occupied by other programs and register successfully - Yellow: this combination is occupied by other programs and you have to change to another one - Transparent without color: initial status Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
This commit is contained in:
@@ -374,6 +374,16 @@ namespace Shadowsocks.Controller
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveHotkeyConfig(HotkeyConfig newConfig)
|
||||
{
|
||||
_config.hotkey = newConfig;
|
||||
SaveConfig(_config);
|
||||
if (ConfigChanged != null)
|
||||
{
|
||||
ConfigChanged(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateLatency(Server server, TimeSpan latency)
|
||||
{
|
||||
if (_config.availabilityStatistics)
|
||||
@@ -565,6 +575,8 @@ namespace Shadowsocks.Controller
|
||||
File.WriteAllText(PACServer.PAC_FILE, abpContent, Encoding.UTF8);
|
||||
}
|
||||
|
||||
#region Memory Management
|
||||
|
||||
private void StartReleasingMemory()
|
||||
{
|
||||
_ramThread = new Thread(new ThreadStart(ReleaseMemory));
|
||||
@@ -581,6 +593,10 @@ namespace Shadowsocks.Controller
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Traffic Statistics
|
||||
|
||||
private void StartTrafficStatistics(int queueMaxSize)
|
||||
{
|
||||
traffic = new QueueLast<TrafficPerSecond>();
|
||||
@@ -615,5 +631,7 @@ namespace Shadowsocks.Controller
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user