//================================================================================= // Constructor //================================================================================= public Controller() { InitializeComponent(); InitializeLanguage(); //defines a list of built-in action handlers that may be bound to at run time m_actions = new Actions<Keys>(); m_actions.RegisterAction("hk_center", Program.GetLang("hotkey_center"), HK_CenterView, Keys.Control | Keys.Alt | Keys.C); m_actions.RegisterAction("hk_snap", Program.GetLang("hotkey_snap"), HK_SnapRange, Keys.Control | Keys.Alt | Keys.S); m_actions.RegisterAction("hk_zoom_increase", Program.GetLang("hotkey_zoom_increase"), HK_ZoomIncrease, Keys.Control | Keys.Alt | Keys.OemPeriod); m_actions.RegisterAction("hk_zoom_decrease", Program.GetLang("hotkey_zoom_decrease"), HK_ZoomDecrease, Keys.Control | Keys.Alt | Keys.Oemcomma); m_actions.RegisterAction("hk_togglegrid", Program.GetLang("hotkey_togglegrid"), HK_ToggleGrid, Keys.Control | Keys.Alt | Keys.G); m_actions.RegisterAction("hk_togglelines", Program.GetLang("hotkey_togglelines"), HK_ToggleLines, Keys.Control | Keys.Alt | Keys.M); m_actions.RegisterAction("hk_togglelabels", Program.GetLang("hotkey_togglelabels"), HK_ToggleLabels, Keys.Control | Keys.Alt | Keys.L); m_actions.RegisterAction("hk_togglehidden", Program.GetLang("hotkey_togglehidden"), HK_ToggleHidden, Keys.Control | Keys.Alt | Keys.H); m_actions.RegisterAction("hk_toggleclickthru", Program.GetLang("hotkey_toggleclickthru"), HK_ToggleClickThrough, Keys.Control | Keys.Alt | Keys.T); m_actions.RegisterAction("hk_togglemapimage", Program.GetLang("hotkey_togglemapimage"), HK_ToggleMapImage, Keys.Control | Keys.Alt | Keys.I); m_actions.RegisterAction("hk_openprefs", Program.GetLang("hotkey_openprefs"), HK_OpenPreferences, Keys.Control | Keys.Alt | Keys.P); m_actions.RegisterAction("hk_exit", Program.GetLang("hotkey_exit"), HK_Exit, Keys.Control | Keys.Alt | Keys.Shift | Keys.X); m_actions.RegisterAction("hk_edit_start", Program.GetLang("hotkey_edit_start"), HK_EditStartLine, Keys.Alt | Keys.Shift | Keys.S); m_actions.RegisterAction("hk_edit_cancel", Program.GetLang("hotkey_edit_cancel"), HK_EditCancelLine, Keys.Alt | Keys.Shift | Keys.C); m_actions.RegisterAction("hk_edit_add", Program.GetLang("hotkey_edit_add"), HK_EditAddPoint, Keys.Alt | Keys.Shift | Keys.A); m_actions.RegisterAction("hk_edit_remove", Program.GetLang("hotkey_edit_remove"), HK_EditRemovePoint, Keys.Alt | Keys.Shift | Keys.R); //Set the initial editor. This must be available before form events begin to fire. m_editors = new MapEditors(); m_editors.RegisterEditor(new MapNavigator()); m_editors.RegisterEditor(new FFXIMapImageEditor()); m_gamelist = new Dictionary<int, ProcessItem>(); m_config = new RegistryConfig(Program.ConfigKey); //bind actions from the config foreach (KeyValuePair<string, Actions<Keys>.Action> pair in m_actions) { pair.Value.Trigger = m_config.GetValue<Keys>(pair.Key, pair.Value.Trigger); } TrayIcon.MouseDoubleClick += new MouseEventHandler(TrayIcon_MouseDoubleClick); TrayMenu.Opening += new CancelEventHandler(TrayMenu_Opening); miTrayExit.Click += new EventHandler(miTrayExit_Click); miInstance.SelectedIndexChanged += new EventHandler(miInstance_SelectedIndexChanged); miRefresh.Click += new EventHandler(miRefresh_Click); miSaveDefault.Click += new EventHandler(miSaveDefault_Click); miClearDefault.Click += new EventHandler(miClearDefault_Click); miActiveOnTop.CheckedChanged += new EventHandler(miActiveOnTop_CheckedChanged); miActiveClickthru.CheckedChanged += new EventHandler(miActiveClickthru_CheckedChanged); miActiveResizable.CheckedChanged += new EventHandler(miActiveResizable_CheckedChanged); miActiveDraggable.CheckedChanged += new EventHandler(miActiveDraggable_CheckedChanged); miActiveShowSpawns.CheckedChanged += new EventHandler(miActiveShowSpawns_CheckedChanged); miActiveShowHidden.CheckedChanged += new EventHandler(miActiveShowHidden_CheckedChanged); miActiveShowLines.CheckedChanged += new EventHandler(miActiveShowLines_CheckedChanged); miActiveShowLabels.CheckedChanged += new EventHandler(miActiveShowLabels_CheckedChanged); miActiveShowMapImage.CheckedChanged += new EventHandler(miActiveShowMapImage_CheckedChanged); miActiveCenter.Click += new EventHandler(miActiveCenter_Click); miActiveSnapRange.Click += new EventHandler(miActiveSnapRange_Click); miAbout.Click += new EventHandler(miAbout_Click); miOptions.Click += new EventHandler(miOptions_Click); SetIcon(MapRes.MappyIcon); RefreshInstances(); m_hook = new Hook(Hook.HookType.Keyboard | Hook.HookType.Mouse); m_hook.AllowCancel = m_config.Get("HotkeysConsume", false); m_hook.KeyDown += new Hook.HookKeyEventHandler(m_hook_KeyDown); m_hook.KeyUp += new Hook.HookKeyEventHandler(m_hook_KeyUp); m_hook.MouseWheel += new Hook.HookMouseEventHandler(m_hook_MouseWheel); m_hook.Enabled = m_config.Get("UseGlobalHotkeys", false); bool dns = m_config.Get("DNS_UseGlobalHotkeys", false); if(!m_hook.Enabled && !dns) { int button = MessageBoxEx.Show(Program.GetLang("msg_hotkey_enable_text"), Program.GetLang("msg_hotkey_enable_title"), new string[] { Program.GetLang("button_enable"), Program.GetLang("button_decline") }, MessageBoxIcon.Question, out dns); m_config["DNS_UseGlobalHotkeys"] = dns; if(button == 0) { m_hook.Enabled = true; } } m_actionkey = m_config.GetValue<Keys>("HotkeyModifier", m_actionkey); m_actionkeyState = false; }
//================================================================================= // Constructor //================================================================================= public Controller() { InitializeComponent(); InitializeLanguage(); //defines a list of built-in action handlers that may be bound to at run time m_actions = new Actions <Keys>(); m_actions.RegisterAction("hk_center", Program.GetLang("hotkey_center"), HK_CenterView, Keys.Control | Keys.Alt | Keys.C); m_actions.RegisterAction("hk_snap", Program.GetLang("hotkey_snap"), HK_SnapRange, Keys.Control | Keys.Alt | Keys.S); m_actions.RegisterAction("hk_zoom_increase", Program.GetLang("hotkey_zoom_increase"), HK_ZoomIncrease, Keys.Control | Keys.Alt | Keys.OemPeriod); m_actions.RegisterAction("hk_zoom_decrease", Program.GetLang("hotkey_zoom_decrease"), HK_ZoomDecrease, Keys.Control | Keys.Alt | Keys.Oemcomma); m_actions.RegisterAction("hk_togglegrid", Program.GetLang("hotkey_togglegrid"), HK_ToggleGrid, Keys.Control | Keys.Alt | Keys.G); m_actions.RegisterAction("hk_togglelines", Program.GetLang("hotkey_togglelines"), HK_ToggleLines, Keys.Control | Keys.Alt | Keys.M); m_actions.RegisterAction("hk_togglelabels", Program.GetLang("hotkey_togglelabels"), HK_ToggleLabels, Keys.Control | Keys.Alt | Keys.L); m_actions.RegisterAction("hk_togglehidden", Program.GetLang("hotkey_togglehidden"), HK_ToggleHidden, Keys.Control | Keys.Alt | Keys.H); m_actions.RegisterAction("hk_toggleclickthru", Program.GetLang("hotkey_toggleclickthru"), HK_ToggleClickThrough, Keys.Control | Keys.Alt | Keys.T); m_actions.RegisterAction("hk_togglemapimage", Program.GetLang("hotkey_togglemapimage"), HK_ToggleMapImage, Keys.Control | Keys.Alt | Keys.I); m_actions.RegisterAction("hk_openprefs", Program.GetLang("hotkey_openprefs"), HK_OpenPreferences, Keys.Control | Keys.Alt | Keys.P); m_actions.RegisterAction("hk_exit", Program.GetLang("hotkey_exit"), HK_Exit, Keys.Control | Keys.Alt | Keys.Shift | Keys.X); m_actions.RegisterAction("hk_edit_start", Program.GetLang("hotkey_edit_start"), HK_EditStartLine, Keys.Alt | Keys.Shift | Keys.S); m_actions.RegisterAction("hk_edit_cancel", Program.GetLang("hotkey_edit_cancel"), HK_EditCancelLine, Keys.Alt | Keys.Shift | Keys.C); m_actions.RegisterAction("hk_edit_add", Program.GetLang("hotkey_edit_add"), HK_EditAddPoint, Keys.Alt | Keys.Shift | Keys.A); m_actions.RegisterAction("hk_edit_remove", Program.GetLang("hotkey_edit_remove"), HK_EditRemovePoint, Keys.Alt | Keys.Shift | Keys.R); //Set the initial editor. This must be available before form events begin to fire. m_editors = new MapEditors(); m_editors.RegisterEditor(new MapNavigator()); m_editors.RegisterEditor(new FFXIMapImageEditor()); m_gamelist = new Dictionary <int, ProcessItem>(); m_config = new RegistryConfig(Program.ConfigKey); //bind actions from the config foreach (KeyValuePair <string, Actions <Keys> .Action> pair in m_actions) { pair.Value.Trigger = m_config.GetValue <Keys>(pair.Key, pair.Value.Trigger); } TrayIcon.MouseDoubleClick += new MouseEventHandler(TrayIcon_MouseDoubleClick); TrayMenu.Opening += new CancelEventHandler(TrayMenu_Opening); miTrayExit.Click += new EventHandler(miTrayExit_Click); miInstance.SelectedIndexChanged += new EventHandler(miInstance_SelectedIndexChanged); miRefresh.Click += new EventHandler(miRefresh_Click); miSaveDefault.Click += new EventHandler(miSaveDefault_Click); miClearDefault.Click += new EventHandler(miClearDefault_Click); miActiveOnTop.CheckedChanged += new EventHandler(miActiveOnTop_CheckedChanged); miActiveClickthru.CheckedChanged += new EventHandler(miActiveClickthru_CheckedChanged); miActiveResizable.CheckedChanged += new EventHandler(miActiveResizable_CheckedChanged); miActiveDraggable.CheckedChanged += new EventHandler(miActiveDraggable_CheckedChanged); miActiveShowSpawns.CheckedChanged += new EventHandler(miActiveShowSpawns_CheckedChanged); miActiveShowHidden.CheckedChanged += new EventHandler(miActiveShowHidden_CheckedChanged); miActiveShowLines.CheckedChanged += new EventHandler(miActiveShowLines_CheckedChanged); miActiveShowLabels.CheckedChanged += new EventHandler(miActiveShowLabels_CheckedChanged); miActiveShowMapImage.CheckedChanged += new EventHandler(miActiveShowMapImage_CheckedChanged); miActiveCenter.Click += new EventHandler(miActiveCenter_Click); miActiveSnapRange.Click += new EventHandler(miActiveSnapRange_Click); miAbout.Click += new EventHandler(miAbout_Click); miOptions.Click += new EventHandler(miOptions_Click); SetIcon(MapRes.MappyIcon); RefreshInstances(); m_hook = new Hook(Hook.HookType.Keyboard | Hook.HookType.Mouse); m_hook.AllowCancel = m_config.Get("HotkeysConsume", false); m_hook.KeyDown += new Hook.HookKeyEventHandler(m_hook_KeyDown); m_hook.KeyUp += new Hook.HookKeyEventHandler(m_hook_KeyUp); m_hook.MouseWheel += new Hook.HookMouseEventHandler(m_hook_MouseWheel); m_hook.Enabled = m_config.Get("UseGlobalHotkeys", false); bool dns = m_config.Get("DNS_UseGlobalHotkeys", false); if (!m_hook.Enabled && !dns) { int button = MessageBoxEx.Show(Program.GetLang("msg_hotkey_enable_text"), Program.GetLang("msg_hotkey_enable_title"), new string[] { Program.GetLang("button_enable"), Program.GetLang("button_decline") }, MessageBoxIcon.Question, out dns); m_config["DNS_UseGlobalHotkeys"] = dns; if (button == 0) { m_hook.Enabled = true; } } m_actionkey = m_config.GetValue <Keys>("HotkeyModifier", m_actionkey); m_actionkeyState = false; }