Пример #1
0
        /// <summary>
        /// Creates a new instance of <see cref="MouseKeyHook"/>.
        /// </summary>
        public MouseKeyHook(MouseClickSettings mouseClickSettings,
                            KeystrokesSettings keystrokesSettings,
                            KeymapViewModel keymap,
                            string fileName,
                            Func <TimeSpan> elapsed)
        {
            _mouseClickSettings = mouseClickSettings;
            _keystrokesSettings = keystrokesSettings;
            _keymap             = keymap;

            _hook = Hook.GlobalEvents();

            _hook.MouseDown += (sender, e) =>
            {
                _mouseClicked = true;

                _mouseButtons = e.Button;
            };

            _hook.MouseUp += (sender, e) => _mouseClicked = false;

            if (keystrokesSettings.SeparateTextFile)
            {
                _textWriter = InitKeysToTextFile(fileName, elapsed);
            }
            else
            {
                _records = new KeyRecords(keystrokesSettings.HistoryCount);

                _hook.KeyDown += OnKeyDown;
                _hook.KeyUp   += OnKeyUp;
            }
        }
Пример #2
0
        static void DrawKeys(KeystrokesSettings KeystrokesSettings, IEditableFrame Editor, string Text, IFont Font, byte Opacity, float OffsetY)
        {
            var size = Editor.MeasureString(Text, Font);

            int paddingX = KeystrokesSettings.HorizontalPadding, paddingY = KeystrokesSettings.VerticalPadding;

            var rect = new RectangleF(GetLeft(KeystrokesSettings, Editor.Width, size.Width),
                                      GetTop(KeystrokesSettings, Editor.Height, size.Height, OffsetY),
                                      size.Width + 2 * paddingX,
                                      size.Height + 2 * paddingY);

            Editor.FillRectangle(ApplyOpacity(KeystrokesSettings.BackgroundColor, Opacity),
                                 rect,
                                 KeystrokesSettings.CornerRadius);

            Editor.DrawString(Text,
                              Font,
                              ApplyOpacity(KeystrokesSettings.FontColor, Opacity),
                              new RectangleF(rect.Left + paddingX, rect.Top + paddingY, size.Width, size.Height));

            var border = KeystrokesSettings.BorderThickness;

            if (border > 0)
            {
                rect = new RectangleF(rect.Left - border / 2f, rect.Top - border / 2f, rect.Width + border, rect.Height + border);

                Editor.DrawRectangle(ApplyOpacity(KeystrokesSettings.BorderColor, Opacity), border,
                                     rect,
                                     KeystrokesSettings.CornerRadius);
            }
        }
Пример #3
0
        public RepeatKeyRecord(KeyRecord Repeated, KeystrokesSettings Settings)
        {
            this.Repeated = Repeated;
            _settings     = Settings;

            Increment();
        }
Пример #4
0
        public KeyOverlay(IMouseKeyHook Hook,
                          KeystrokesSettings Settings,
                          KeymapViewModel Keymap)
        {
            _settings = Settings;
            _keymap   = Keymap;

            _records = new KeyRecords(Settings.HistoryCount);

            Hook.KeyDown += OnKeyDown;
            Hook.KeyUp   += OnKeyUp;
        }
Пример #5
0
        /// <summary>
        /// Creates a new instance of <see cref="MouseKeyHook"/>.
        /// </summary>
        public MouseKeyOverlay(IMouseKeyHook Hook,
                               MouseClickSettings MouseClickSettings,
                               KeystrokesSettings KeystrokesSettings,
                               KeymapViewModel Keymap,
                               string FileName,
                               Func <TimeSpan> Elapsed)
        {
            _keystrokesSettings = KeystrokesSettings;
            _keymap             = Keymap;

            _hook = Hook;
            _mouseClickOverlay = new MouseClickOverlay(_hook, MouseClickSettings);

            if (KeystrokesSettings.SeparateTextFile)
            {
                _textWriter = InitKeysToTextFile(FileName, Elapsed);
            }
            else
            {
                _keyOverlay = new KeyOverlay(_hook, KeystrokesSettings, Keymap);
            }
        }