Skip to content

Commit

Permalink
Initial Coding to facilitate alternative keyboard layouts.
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-widrick committed Aug 29, 2018
1 parent ac03db0 commit fe54115
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 16 deletions.
46 changes: 40 additions & 6 deletions UltimateFishBot/Forms/frmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,49 @@ public void ReloadHotkeys() {

foreach (HotKey hotKey in (HotKey[])Enum.GetValues(typeof(HotKey))) {
Keys key = Keys.None;
String tempString;
KeyModifier keyModifier;
KeysConverter keyConverter = new KeysConverter();



switch (hotKey) {
case HotKey.StartStop: key = Properties.Settings.Default.StartStopHotKey; break;
case HotKey.CursorCapture: key = Properties.Settings.Default.CursorCaptureHotKey; break;
default: continue;
}
case HotKey.StartStop:
tempString = Properties.Settings.Default.StartStopHotKey;
keyModifier = new KeyModifier();
if (tempString.Contains("Ctrl"))
{
keyModifier |= (KeyModifier)Keys.ControlKey;
tempString = tempString.Replace("Ctrl+", "");
}

if (tempString.Contains("Shift"))
{
keyModifier |= (KeyModifier)Keys.ShiftKey;
tempString = tempString.Replace("Shift+", "");
}
key |= (Keys)keyConverter.ConvertFromString(tempString);
break;
case HotKey.CursorCapture:
tempString = Properties.Settings.Default.CursorCaptureHotKey;
keyModifier = new KeyModifier();
if (tempString.Contains("Ctrl"))
{
keyModifier |= (KeyModifier)Keys.ControlKey;
tempString = tempString.Replace("Ctrl+", "");
}

KeyModifier modifiers = RemoveAndReturnModifiers(ref key);
Win32.RegisterHotKey(this.Handle, (int)hotKey, (int)modifiers, (int)key);
if (tempString.Contains("Shift"))
{
keyModifier |= (KeyModifier)Keys.ShiftKey;
tempString = tempString.Replace("Shift+", "");
}

key |= (Keys)keyConverter.ConvertFromString(tempString);
break;
default: continue;
}
Win32.RegisterHotKey(this.Handle, (int)hotKey, (int)keyModifier, (int)key);
}
}

Expand Down
6 changes: 3 additions & 3 deletions UltimateFishBot/Forms/frmSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ private void buttonSave_Click(object sender, EventArgs e)
Properties.Settings.Default.CheckCursor = cmbCompareIcon.Checked;
Properties.Settings.Default.AlternativeRoute = cmbAlternativeRoute.Checked;
Properties.Settings.Default.customScanArea = customAreaCheckbox.Checked;
Properties.Settings.Default.CursorCaptureHotKey = (Keys)new KeysConverter().ConvertFromString(ccHotKey.Text);
Properties.Settings.Default.CursorCaptureHotKey = ccHotKey.Text;


/// Hearing the Fish
Expand Down Expand Up @@ -409,14 +409,14 @@ private void cmbAudio_SelectedIndexChanged(object sender, EventArgs e)

private void LoadHotKeys()
{
m_hotkey = Properties.Settings.Default.StartStopHotKey;
m_hotkey = (Keys)new KeysConverter().ConvertFromString(Properties.Settings.Default.StartStopHotKey);
txtHotKey.Text = new KeysConverter().ConvertToString(m_hotkey);
m_mainForm.UnregisterHotKeys();
}

private void SaveHotKeys()
{
Properties.Settings.Default.StartStopHotKey = m_hotkey;
Properties.Settings.Default.StartStopHotKey = new KeysConverter().ConvertToString(m_hotkey);
m_mainForm.ReloadHotkeys();
}

Expand Down
10 changes: 5 additions & 5 deletions UltimateFishBot/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions UltimateFishBot/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
<Setting Name="customScanArea" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="StartStopHotKey" Type="System.Windows.Forms.Keys" Scope="User">
<Setting Name="StartStopHotKey" Type="System.String" Scope="User">
<Value Profile="(Default)">Ctrl+Shift+S</Value>
</Setting>
<Setting Name="Txt2speech" Type="System.Boolean" Scope="User">
Expand All @@ -152,7 +152,7 @@
<Setting Name="AverageSound" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="CursorCaptureHotKey" Type="System.Windows.Forms.Keys" Scope="User">
<Setting Name="CursorCaptureHotKey" Type="System.String" Scope="User">
<Value Profile="(Default)">Ctrl+Shift+C</Value>
</Setting>
<Setting Name="RightClickCast" Type="System.Boolean" Scope="User">
Expand Down

0 comments on commit fe54115

Please sign in to comment.