コード例 #1
0
        public bool PreFilterMessage(ref Message m)
        {
            var msg = (WindowsMessage)m.Msg;

            if (msg == WindowsMessage.WM_TIMER)
            {
                return(false);
            }

            var activeForm   = Form.ActiveForm;
            var globalEvents = activeForm as IGlobalEvents ?? this.defaultHandler;

            if (globalEvents == null)
            {
                return(false);
            }
            var ctl = Control.FromHandle(m.HWnd);

            if (ctl == null && activeForm == null)
            {
                return(false);
            }
            if (msg == WindowsMessage.WM_MOUSEMOVE)
            {
                var wp = (MouseWParam)m.WParam;
                var lp = (MouseLParam)m.LParam;

                var e = new GlobalMouseEventArgs(MouseEvents.MouseMove, (MouseButtons)wp, 0, lp.X, lp.Y, 0);
                globalEvents.GlobalMouseMove(ctl ?? activeForm, e);
            }
            else if (msg == WindowsMessage.WM_LBUTTONDOWN)
            {
            }
            else if (msg == WindowsMessage.WM_RBUTTONDOWN)
            {
            }
            else if (msg == WindowsMessage.WM_LBUTTONUP)
            {
            }
            else if (msg == WindowsMessage.WM_RBUTTONUP)
            {
            }
            else if (msg == WindowsMessage.WM_LBUTTONDBLCLK)
            {
            }
            else if (msg == WindowsMessage.WM_RBUTTONDBLCLK)
            {
            }
            else if (msg == WindowsMessage.WM_MOUSEWHEEL)
            {
            }
            else if (msg == WindowsMessage.WM_MOUSEHWHEEL)
            {
            }
            else if (msg == WindowsMessage.WM_MOUSEHOVER)
            {
            }
            else if (msg == WindowsMessage.WM_MOUSELEAVE)
            {
            }
            else if (msg == WindowsMessage.WM_MOUSEACTIVATE)
            {
            }
            else if (msg == WindowsMessage.WM_MOUSEFIRST)
            {
            }
            return(false);
        }
コード例 #2
0
        public void GlobalMouseMove(Control target, GlobalMouseEventArgs args)
        {
            if (args.MouseEvent == MouseEvents.MouseMove)
            {
                // find control under mouse pointer
                Control control = target.GetChildAtPoint(args.Location);
                if (control == this.btnShowCertificate && control?.Enabled == false)
                {
                    var msg = "";
                    if (string.IsNullOrWhiteSpace(this.controller.Model.CurrentCertificate.Value?.IssuerSerialNumber))
                    {
                        msg = Messages.CannotSave_CertInvalid;
                    }
                    else
                    {
                        msg = "First, select a certificate type to show!";
                    }
                    msg += "\n" +
                           "**Note:** You can use the `Certificate View` tab\n" +
                           "to view any issued certificate.";

                    var tt = this.tooltip.ToolTipFor(control, "DISABLED")
                             .ShowMessage(msg, useMarkdown: true, showWhenNotActive: true);
                    string positionPreferences = ">,v,^,<,>v,>^,<v,<^";
                    tt.PositionPreferences = positionPreferences;
                    tt.BorderColor         = Color.OrangeRed;
                    tt.Margin = 1;
                }
                else
                {
                    var tt = this.tooltip.ToolTipFor(this.btnShowCertificate, "DISABLED");
                    if (tt.Visible)
                    {
                        tt.Hide();
                    }
                }

                if (control == this.btnSaveCertificate && control?.Enabled == false)
                {
                    var msg = "";
                    if (string.IsNullOrWhiteSpace(this.controller.Model.CurrentCertificate.Value?.IssuerSerialNumber))
                    {
                        msg = Messages.CannotSave_CertInvalid;
                    }
                    else
                    {
                        msg = "First, select a certificate type to save!";
                    }

                    var tt = this.tooltip.ToolTipFor(control, "DISABLED")
                             .ShowMessage(msg, useMarkdown: true, showWhenNotActive: true);
                    string positionPreferences = ">,v,^,<,>v,>^,<v,<^";
                    tt.PositionPreferences = positionPreferences;
                    tt.BorderColor         = Color.OrangeRed;
                    tt.Margin = 1;
                }
                else
                {
                    var tt = this.tooltip.ToolTipFor(this.btnSaveCertificate, "DISABLED");
                    if (tt.Visible)
                    {
                        tt.Hide();
                    }
                }
            }
        }