Exemplo n.º 1
0
        /// <summary>
        /// Extends mouseMoved to inject mouse position into tray manager, and checks
        /// for mouse wheel movements to slide the carousel, because we can.
        /// </summary>
        /// <param name="evt"></param>
        /// <returns></returns>
        public override bool MouseMoved(SIS.MouseEventArgs evt)
        {
            if (this.TrayManager.InjectMouseMove(evt))
            {
                return(true);
            }

            if (!(CurrentSample != null && !IsSamplePaused) && this.TitleLabel.TrayLocation != TrayLocation.None &&
                evt.State.Z.Relative != 0 && this.SampleMenu.ItemsCount != 0)
            {
                var newIndex = (int)(this.SampleMenu.SelectionIndex - evt.State.Z.Relative / Utility.Abs(evt.State.Z.Relative));
                this.SampleMenu.SelectItem(Utility.Clamp <int>(newIndex, this.SampleMenu.ItemsCount - 1, 0));
            }
            try
            {
                return(base.MouseMoved(evt));
            }
            catch (Exception ex) // show error and fall back to menu
            {
                RunSample(null);
                string msg = ex.Message + "\nSource: " + ex.InnerException;
                LogManager.Instance.Write("[Samples] Error! " + msg);
                this.TrayManager.ShowOkDialog("Error!", msg);
            }

            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="evt"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public override bool MousePressed(SIS.MouseEventArgs evt, SIS.MouseButtonID id)
        {
            if (this.TrayManager.InjectMouseDown(evt, id))
            {
                return(true);
            }

            if (this.TitleLabel.TrayLocation != TrayLocation.None)
            {
                for (int i = 0; i < this.Thumbs.Count; i++)
                {
                    if (this.Thumbs[i].IsVisible &&
                        Widget.IsCursorOver(this.Thumbs[i],
                                            new Vector2(this.TrayManager.CursorContainer.Left, this.TrayManager.CursorContainer.Top),
                                            0))
                    {
                        this.SampleMenu.SelectItem(i);
                        break;
                    }
                }
            }
            try
            {
                return(base.MousePressed(evt, id));
            }
            catch (Exception ex)
            {
                RunSample(null);
                string msg = ex.Message + "\nSource: " + ex.InnerException;
                LogManager.Instance.Write("[Samples] Error! " + msg);
                this.TrayManager.ShowOkDialog("Error!", msg);
            }
            return(true);
        }
Exemplo n.º 3
0
        /*-----------------------------------------------------------------------------
        | Processes mouse movement differently for each style.
        |  -----------------------------------------------------------------------------*/

        public virtual void injectMouseMove(SIS.MouseEventArgs evt)
        {
            if (this.mStyle == CameraStyle.Orbit)
            {
                Real dist = (this.mCamera.Position - this.mTarget.DerivedPosition).Length;

                if (this.mOrbiting)                   // yaw around the target, and pitch locally
                {
                    this.mCamera.Position = this.mTarget.DerivedPosition;

                    this.mCamera.Yaw((Real)(new Degree((Real)(-evt.State.X.Relative * 0.25f))));
                    this.mCamera.Pitch((Real)(new Degree((Real)(-evt.State.Y.Relative * 0.25f))));

                    this.mCamera.MoveRelative(new Vector3(0, 0, dist));

                    // don't let the camera go over the top or around the bottom of the target
                }
                else if (this.mZooming)                   // move the camera toward or away from the target
                {
                    // the further the camera is, the faster it moves
                    this.mCamera.MoveRelative(new Vector3(0, 0, evt.State.Y.Relative * 0.004f * dist));
                }
                else if (evt.State.Z.Relative != 0)                   // move the camera toward or away from the target
                {
                    // the further the camera is, the faster it moves
                    this.mCamera.MoveRelative(new Vector3(0, 0, -evt.State.Z.Relative * 0.0008f * dist));
                }
            }
            else if (this.mStyle == CameraStyle.FreeLook)
            {
                this.mCamera.Yaw((Real)(new Degree((Real)(-evt.State.X.Relative * 0.15f))));
                this.mCamera.Pitch((Real)(new Degree((Real)(-evt.State.Y.Relative * 0.15f))));
            }
        }
Exemplo n.º 4
0
 public virtual bool MouseReleased(SIS.MouseEventArgs evt, SIS.MouseButtonID id)
 {
     if (CurrentSample != null && !this.IsSamplePaused)
     {
         return(CurrentSample.MouseReleased(evt, id));
     }
     return(true);
 }
Exemplo n.º 5
0
 public virtual bool MouseMoved(SIS.MouseEventArgs evt)
 {
     if (CurrentSample != null && !this.IsSamplePaused)
     {
         return(CurrentSample.MouseMoved(evt));
     }
     return(true);
 }
Exemplo n.º 6
0
        public override bool MouseMoved(SIS.MouseEventArgs evt)
        {
            if (this.TrayManager.InjectMouseMove(evt))
            {
                return(true);
            }

            this.CameraManager.injectMouseMove(evt);

            return(true);
        }
Exemplo n.º 7
0
        /*-----------------------------------------------------------------------------
        | Processes mouse releases. Only applies for orbit style.
        | Left button is for orbiting, and right button is for zooming.
        |  -----------------------------------------------------------------------------*/

        public virtual void injectMouseUp(SIS.MouseEventArgs evt, SIS.MouseButtonID id)
        {
            if (this.mStyle == CameraStyle.Orbit)
            {
                if (id == SIS.MouseButtonID.Left)
                {
                    this.mOrbiting = false;
                }
                else if (id == SIS.MouseButtonID.Right)
                {
                    this.mZooming = false;
                }
            }
        }
Exemplo n.º 8
0
        public override bool MouseReleased(SIS.MouseEventArgs evt, SIS.MouseButtonID id)
        {
            if (this.TrayManager.InjectMouseUp(evt, id))
            {
                return(true);
            }

            if (this.dragLook && id == SIS.MouseButtonID.Left)
            {
                this.CameraManager.setStyle(CameraStyle.Manual);
                this.TrayManager.ShowCursor();
            }

            this.CameraManager.injectMouseUp(evt, id);

            return(true);
        }
Exemplo n.º 9
0
        public override bool MousePressed(SIS.MouseEventArgs evt, SIS.MouseButtonID id)
        {
            if (this.TrayManager.InjectMouseDown(evt, id))
            {
                return(true);
            }

            if (this.dragLook && id == SIS.MouseButtonID.Left)
            {
                this.CameraManager.setStyle(CameraStyle.FreeLook);
                this.TrayManager.HideCursor();
            }

            this.CameraManager.injectMouseDown(evt, id);

            return(true);
        }
Exemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="evt"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public override bool MouseReleased(SIS.MouseEventArgs evt, SIS.MouseButtonID id)
        {
            if (this.TrayManager.InjectMouseUp(evt, id))
            {
                return(true);
            }

            try
            {
                return(base.MouseReleased(evt, id));
            }
            catch (Exception ex)
            {
                RunSample(null);
                string msg = ex.Message + "\nSource: " + ex.InnerException;
                LogManager.Instance.Write("[Samples] Error! " + msg);
                this.TrayManager.ShowOkDialog("Error!", msg);
            }
            return(true);
        }
Exemplo n.º 11
0
 public virtual bool MouseReleased(SIS.MouseEventArgs evt, SIS.MouseButtonID id)
 {
     return(true);
 }
Exemplo n.º 12
0
 public virtual bool MouseMoved(SIS.MouseEventArgs evt)
 {
     return(true);
 }