Пример #1
0
        static void OnMacroKeyPressed(Keyboard kb, EMacroKey key)
        {
            if (settings.keymap.TryGetValue(key, out var kc))
            {
                Input.SendKeyPress(kc);
            }
            if (key == EMacroKey.MR)
            {
                TimeSpan voltageNotificatinCooldown = TimeSpan.FromSeconds(5);

                if (DateTime.Now - lastVoltageNotification < voltageNotificatinCooldown)
                {
                    return;
                }

                if (lastPowerState != 0)
                {
                    var template  = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);
                    var textNodes = template.GetElementsByTagName("text");
                    textNodes.Item(0).InnerText = $"Mouse battery voltage: {lastVoltage}mV ~{lastPercent:0.#}% ({lastPowerState})";
                    var notification = new ToastNotification(template);
                    toastNotifier.Show(notification);
                    lastVoltageNotification = DateTime.Now;
                }
            }
        }
Пример #2
0
        protected void MacroKeyUpdate(bool isDown, EMacroKey key)
        {
            int index = (int)key;

            if (index < 0 || index >= macroKeysDown.Length)
            {
                return;
            }

            if (isDown && !macroKeysDown[index])
            {
                OnMacroKeyPressed?.Invoke(this, key);
            }

            if (!isDown && macroKeysDown[index])
            {
                OnMacroKeyReleased?.Invoke(this, key);
            }

            macroKeysDown[index] = isDown;
        }