Esempio n. 1
0
        private void Banner_Load(object sender, EventArgs e)
        {
            if (_bannerConfigruation != null)
            {
                lblKeys.Font      = _bannerConfigruation.Font;
                lblKeys.ForeColor = _bannerConfigruation.ForegroundColor;
                BackColor         = _bannerConfigruation.BackgroundColor;
                Height            = _bannerConfigruation.Height;
            }

            var screen = GetScreen();

            Width    = screen.Width;
            Location = new Point(0, screen.Height - (Height + 50));

            // Opacity
            Opacity = 0;
            _timer  = new Timer {
                Interval = 10
            };
            _timer.Tick += ChangeOpacity;
            _timer.Start();

            // opacity End

            lblKeys.Text = string.Empty;

            _resetTimer = new Timer {
                Interval = _bannerConfigruation?.TextClearTimeOut ?? 2000
            };

            _resetTimer.Tick += (o, args) =>
            {
                lblKeys.Text = string.Empty;
                _resetTimer.Stop();
            };

            _closeTimer = new Timer {
                Interval = _bannerConfigruation?.BannerCloseTimeOut ?? 7000
            };

            _closeTimer.Tick += (o, args) =>
            {
                this.Close();
            };

            Updatekey(_args.KeyChar);
            _keyboardListener = new KeyboardListener();

            _keyboardListener.OnKeyReceived += arg =>
            {
                _resetTimer.Stop();
                _closeTimer.Stop();
                Updatekey(arg.KeyChar);
                _resetTimer.Start();
                _closeTimer.Start();
            };

            _keyboardListener.OnSpecialKeyReceived += args =>
            {
                lblKeys.Text += KeysTransformer.GetSpecialKeyAbr(args.KeyData);
            };
        }