コード例 #1
0
        public MainWindow()
        {
            InitializeComponent();

            label = mainLabel;
            image = mainImage;

            batteryReader = new BatteryReader();
            preConfigs    = new PredefinedConfigs();

            displayKeyHook            = new KeyboardHook(this, VirtualKeyCodes.B, ModifierKeyCodes.Control, 0);
            displayKeyHook.Triggered += ToggleVisibility;

            exitKeyHook            = new KeyboardHook(this, VirtualKeyCodes.X, ModifierKeyCodes.Alt, 1);
            exitKeyHook.Triggered += ExitRequested;

            switchModeKeyHook            = new KeyboardHook(this, VirtualKeyCodes.Q, ModifierKeyCodes.Alt, 2);
            switchModeKeyHook.Triggered += ModeSwitchRequested;

            SetupTrayIcon();
            LoadBatteryIcons();
            batteryReader.OnBatteryPercentUpdated += (o, e) =>
            {
                ni.Text = $"{e.BatteryPercent}%";
                ni.Icon = FindIconFor(e.BatteryPercent);
            };
        }
コード例 #2
0
        public MainWindow()
        {
            InitializeComponent();
            RegisterInStartup(true);

            label = mainLabel;
            image = mainImage;

            this.batteryReader = new BatteryReader();
            this.preConfigs    = new PredefinedConfigs();

            displayKeyHook            = new KeyboardHook(this, VirtualKeyCodes.B, ModifierKeyCodes.Control, 0);
            displayKeyHook.Triggered += displayHotkeyEvent;

            exitKeyHook            = new KeyboardHook(this, VirtualKeyCodes.X, ModifierKeyCodes.Alt, 1);
            exitKeyHook.Triggered += exitHotkeyEvent;

            switchModeKeyHook            = new KeyboardHook(this, VirtualKeyCodes.Q, ModifierKeyCodes.Alt, 2);
            switchModeKeyHook.Triggered += switchModeKeyEvent;

            setupTrayIcon();
        }