예제 #1
0
 /// <summary>
 /// Handles the mouse wheel.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="args">The <see cref="MouseWheelEventArgs"/> instance containing the event data.</param>
 private void HandleMouseWheel(object sender, MouseWheelEventArgs args)
 {
     if(Moved == null || !isMouseOver) return;
     Moved(this, args);
 }
예제 #2
0
            /// <summary>
            /// Handles the mouse wheel.
            /// </summary>
            /// <param name="sender">The sender.</param>
            /// <param name="args">The <see cref="System.Windows.Browser.HtmlEventArgs"/> instance containing the event data.</param>
            private void HandleMouseWheel(object sender, HtmlEventArgs args)
            {
                double delta = 0;
                ScriptObject eventObj = args.EventObject;

                if(eventObj.GetProperty("wheelDelta") != null)
                {
                    delta = ((double)eventObj.GetProperty("wheelDelta"));

                    if(HtmlPage.Window.GetProperty("opera") != null)
                        delta = -delta;

                    if(HtmlPage.BrowserInformation.UserAgent.Contains("Chrome"))
                        delta /= 140;
                    else
                        delta /= 120;
                }
                else if(eventObj.GetProperty("detail") != null)
                {
                    delta = -((double)eventObj.GetProperty("detail"));

                    if(!HtmlPage.BrowserInformation.UserAgent.Contains("Macintosh"))
                        delta /= 2;
                }

                if(delta == 0 || Moved == null) return;
                var wheelArgs = new MouseWheelEventArgs(delta);
                if(Moved != null) Moved(this, wheelArgs);

                if(wheelArgs.Handled)
                    args.PreventDefault();
            }