Esempio n. 1
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(Color.FromArgb(Opacity, KeystrokesSettings.BackgroundColor),
                                 rect,
                                 KeystrokesSettings.CornerRadius);

            Editor.DrawString(Text,
                              Font,
                              Color.FromArgb(Opacity, KeystrokesSettings.FontColor),
                              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(Color.FromArgb(Opacity, KeystrokesSettings.BorderColor), border,
                                     rect,
                                     KeystrokesSettings.CornerRadius);
            }
        }
Esempio n. 2
0
        public virtual void Draw(IEditableFrame editor, Func <Point, Point> pointTransform = null)
        {
            if (!_overlaySettings.Display)
            {
                return;
            }

            var text = GetText();

            if (string.IsNullOrWhiteSpace(text))
            {
                return;
            }

            var fontSize = _overlaySettings.FontSize;

            var size = editor.MeasureString(text, fontSize);

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

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

            editor.FillRectangle(_overlaySettings.BackgroundColor,
                                 rect,
                                 _overlaySettings.CornerRadius);

            editor.DrawString(text,
                              fontSize,
                              _overlaySettings.FontColor,
                              new RectangleF(rect.Left + paddingX, rect.Top + paddingY, size.Width, size.Height));

            var border = _overlaySettings.BorderThickness;

            if (border <= 0)
            {
                return;
            }

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

            editor.DrawRectangle(_overlaySettings.BorderColor, border,
                                 rect,
                                 _overlaySettings.CornerRadius);
        }
Esempio n. 3
0
        public void Draw(IEditableFrame Editor, Func <Point, Point> PointTransform = null)
        {
            if (!_settings.Display)
            {
                return;
            }

            if (_records?.Last == null)
            {
                return;
            }

            var  offsetY  = 0f;
            var  fontSize = _settings.FontSize;
            byte opacity  = 255;

            var index = 0;

            foreach (var keyRecord in _records)
            {
                ++index;

                if ((DateTime.Now - keyRecord.TimeStamp).TotalSeconds > _records.Size * _settings.Timeout)
                {
                    continue;
                }

                using (var font = Editor.GetFont(_settings.FontFamily, Math.Max(1, fontSize)))
                {
                    DrawKeys(_settings, Editor, keyRecord.Display, font, opacity, offsetY);

                    var height = Editor.MeasureString("A", font).Height;

                    offsetY += height + _settings.HistorySpacing;

                    offsetY += _settings.VerticalPadding * 2 + _settings.BorderThickness * 2;
                }

                if (index == 1)
                {
                    fontSize -= 5;
                    opacity   = 200;
                }
            }
        }
Esempio n. 4
0
        public static void DrawString(IEditableFrame Editor, string Text, KeystrokesSettings Settings)
        {
            if (string.IsNullOrWhiteSpace(Text))
            {
                return;
            }

            using (var font = Editor.GetFont(Settings.FontFamily, Settings.FontSize))
            {
                var size = Editor.MeasureString(Text, font);

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

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

                Editor.FillRectangle(Settings.BackgroundColor,
                                     rect,
                                     Settings.CornerRadius);

                Editor.DrawString(Text,
                                  font,
                                  Settings.FontColor,
                                  new RectangleF(rect.Left + paddingX, rect.Top + paddingY, size.Width, size.Height));

                var border = Settings.BorderThickness;

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

                    Editor.DrawRectangle(Settings.BorderColor,
                                         border,
                                         rect,
                                         Settings.CornerRadius);
                }
            }
        }