예제 #1
0
        public KneeboardApplication(bool showConfig, AltCodeData altCodes)
        {
            _AltCodes = altCodes;

            _HotkeyManager         = new HotkeyManager();
            _HotkeyManager.Enabled = Settings.Default.HotkeysEnabled;

            _KneeboardManager = new KneeboardManager(_AltCodes);

            var momentaryKC = KeyCombo.FromStorage(Settings.Default.MomentaryShowKeyCombo);
            var toggleKC    = KeyCombo.FromStorage(Settings.Default.ToggleShowKeyCombo);

            _HotkeyManager.AddHook(HK_MOMENTARY, R.Hotkey_Momentary_Name, R.Hotkey_Momentary_Desc, Settings.Default.MomentaryShowEnabled, momentaryKC, _KneeboardManager.ShowKneeboard, _KneeboardManager.HideKneeboard, MomentaryShowHook_PropertyChanged);
            _HotkeyManager.AddHook(HK_TOGGLE, R.Hotkey_Toggle_Name, R.Hotkey_Toggle_Desc, Settings.Default.ToggleShowEnabled, toggleKC, _KneeboardManager.ToggleKneeboard, null, ToggleShowHook_PropertyChanged);

            _TrayIcon                  = new NotifyIcon();
            _TrayIcon.Icon             = R.appicon;
            _TrayIcon.Text             = R.AppTitle;
            _TrayIcon.DoubleClick     += OnShowConfig;
            _TrayIcon.ContextMenuStrip = new ContextMenuStrip();
            _TrayIcon.ContextMenuStrip.Items.Add(new ToolStripMenuItem(R.Configure, FormUtils.RenderSvg(R.keyboard, SystemColors.ControlText, new Size(16, 16)), OnShowConfig));
            _TrayIcon.ContextMenuStrip.Items.Add(new ToolStripSeparator());
            _TrayIcon.ContextMenuStrip.Items.Add(new ToolStripMenuItem(R.ToggleKneeboard, null, (sender, args) => _KneeboardManager.ToggleKneeboard()));
            _TrayIcon.ContextMenuStrip.Items.Add(new ToolStripMenuItem(R.ShowCharMap, null, OnShowCharMap));
            _TrayIcon.ContextMenuStrip.Items.Add(new ToolStripSeparator());
            _TrayIcon.ContextMenuStrip.Items.Add(new ToolStripMenuItem(R.Exit, FormUtils.RenderSvg(R.close, SystemColors.ControlText, new Size(16, 16)), (sender, e) => ExitThread()));
            _TrayIcon.ContextMenuStrip.Items[0].Font = new Font(_TrayIcon.ContextMenuStrip.Items[0].Font, FontStyle.Bold);
            _TrayIcon.Visible = true;

            Settings.Default.PropertyChanged += Settings_PropertyChanged;

            if (showConfig)
            {
                OnShowConfig(this, EventArgs.Empty);
            }
        }