private void TextBox_KeyDown(object sender, KeyEventArgs e) { MetroTextBox textBox = (MetroTextBox)sender; if (e.KeyCode != Keys.ControlKey && e.KeyCode != Keys.ShiftKey && e.KeyCode != Keys.Menu) { KeyExt key = new KeyExt(e.KeyCode, e.Alt, e.Shift, e.Control); textBox.Text = key.ToString(); string name = "Plugin_" + ((IPlugin3)textBox.Tag).Name; HotkeyManager.RemoveKeys(name); if (e.KeyCode == Keys.None) { AxTools.Helpers.Settings2.Instance.PluginHotkeys.Remove(((IPlugin3)textBox.Tag).Name); } else { AxTools.Helpers.Settings2.Instance.PluginHotkeys[((IPlugin3)textBox.Tag).Name] = key; Task.Run(() => { Thread.Sleep(1000); HotkeyManager.AddKeys(name, key); }); } AxTools.Helpers.Settings2.Instance.InvokePluginHotkeysChanged(); e.Handled = true; e.SuppressKeyPress = true; } }
public LuaConsole(GameInterface info) { InitializeComponent(); Icon = Resources.PluginIcon; luaConsoleSettings = this.LoadSettingsJSON <LuaConsoleSettings>(); pictureBoxOpenLuaFile.Image = Resources.OpenFile; pictureBoxSaveLuaFile.Image = Resources.SaveFile; StyleManager.Style = Utilities.MetroColorStyle; this.info = info; luaEngine = new NLua.Lua(); SetLuaEnv(); textBoxLuaCode.SetHighlighting("Lua"); textBoxLuaCode.Font = Utils.FontIsInstalled("Consolas") ? new Font("Consolas", 8) : new Font("Courier New", 8); textBoxLuaCode.Visible = true; textBoxLuaCode.Encoding = Encoding.Unicode; textBoxTimerHotkey.Text = luaConsoleSettings.TimerHotkey.ToString(); textBoxTimerHotkey.KeyDown += TextBoxTimerHotkey_KeyDown; metroToolTip1.SetToolTip(textBoxTimerHotkey, "Press 'Esc' to clear"); metroPanelTimerOptions.Visible = false; Size = luaConsoleSettings.WindowSize; metroLinkEnableCyclicExecution.Text = MetroLinkEnableCyclicExecutionTextEnable; metroCheckBoxRandomize.Checked = luaConsoleSettings.TimerRnd; metroCheckBoxIgnoreGameState.Checked = luaConsoleSettings.IgnoreGameState; metroTextBoxTimerInterval.Text = luaConsoleSettings.TimerInterval.ToString(); metroToolTip1.SetToolTip(metroLinkRunScriptOnce, "Execute script once"); metroToolTip1.SetToolTip(metroLinkSettings, "Open settings"); textBoxLuaCode.Text = string.Join("\r\n", luaConsoleSettings.Code); luaConsoleSettings.TimerHotkeyChanged += LuaTimerHotkeyChanged; LuaTimerHotkeyChanged(luaConsoleSettings.TimerHotkey); HotkeyManager.AddKeys(typeof(LuaConsole).ToString(), luaConsoleSettings.TimerHotkey); HotkeyManager.KeyPressed += KeyboardListener2_KeyPressed; textBoxLuaCode.TextChanged += TextBoxLuaCode_TextChanged; this.LogPrint("Loaded"); }
private void TextBoxClickerHotkey_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode != Keys.ControlKey && e.KeyCode != Keys.ShiftKey && e.KeyCode != Keys.Menu) { KeyExt key = new KeyExt(e.KeyCode, e.Alt, e.Shift, e.Control); textBoxClickerHotkey.Text = key.ToString(); HotkeyManager.RemoveKeys(typeof(Clicker).ToString()); HotkeyManager.AddKeys(typeof(Clicker).ToString(), key); settings.ClickerHotkey = key; e.Handled = true; e.SuppressKeyPress = true; } }
internal static Task LoadPluginsAsync() { return(Task.Run(delegate { if (UpdateIsActive && Settings2.Instance.UpdatePlugins) { UpdatePluginsFromWeb(); Settings2.Instance.PluginsLastTimeUpdated = DateTime.UtcNow; UpdateIsActive = false; } LoadPluginsFromDisk(); CheckDependencies(); ClearOldAssemblies(); foreach (var i in Settings2.Instance.PluginHotkeys.Where(l => LoadedPlugins.Select(k => k.Name).Contains(l.Key))) { HotkeyManager.AddKeys("Plugin_" + i.Key, i.Value); } AllPluginsLoaded?.Invoke(); })); }
private void TextBoxTimerHotkey_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode != Keys.ControlKey && e.KeyCode != Keys.ShiftKey && e.KeyCode != Keys.Menu) { if (e.KeyCode == Keys.Escape) { TextBoxTimerHotkey_KeyDown(sender, new KeyEventArgs(Keys.None)); } else { var key = new KeyExt(e.KeyCode, e.Alt, e.Shift, e.Control); textBoxTimerHotkey.Text = key.ToString(); HotkeyManager.RemoveKeys(typeof(LuaConsole).ToString()); luaConsoleSettings.TimerHotkey = key; Task.Run(() => { Thread.Sleep(1000); HotkeyManager.AddKeys(typeof(LuaConsole).ToString(), key); }); } e.Handled = true; e.SuppressKeyPress = true; } }