Example #1
0
        /// <summary>
        /// Moves and sizes the window to cover the input surface.
        /// </summary>
        private void SetWindowOnSurface()
        {
            Debug.Assert(Window.Handle != IntPtr.Zero,
                         "Window initialization must be complete before SetWindowOnSurface is called");
            if (Window.Handle == IntPtr.Zero)
            {
                return;
            }

            // We don't want to run in full-screen mode because we need
            // overlapped windows, so instead run in windowed mode
            // and resize to take up the whole surface with no border.

            // Make sure the graphics device has the correct back buffer size.
            InteractiveSurface interactiveSurface = InteractiveSurface.DefaultInteractiveSurface;

            if (interactiveSurface != null)
            {
                graphics.PreferredBackBufferWidth  = interactiveSurface.Width;
                graphics.PreferredBackBufferHeight = interactiveSurface.Height;
                graphics.ApplyChanges();

                // Remove the border and position the window.
                Program.RemoveBorder(Window.Handle);
                Program.PositionWindow(Window);
            }
        }
Example #2
0
            public Form1()
            {
                InitializeSurfaceInput();

                Affine2DManipulations supportedManipulations =
                    Affine2DManipulations.TranslateX | Affine2DManipulations.TranslateY | Affine2DManipulations.Scale;

                manipulationProcessor = new Affine2DManipulationProcessor(supportedManipulations);
                manipulationProcessor.Affine2DManipulationStarted   += OnAffine2DManipulationStarted;
                manipulationProcessor.Affine2DManipulationDelta     += OnAffine2DDelta;
                manipulationProcessor.Affine2DManipulationCompleted += OnAffine2DManipulationCompleted;

                inertiaProcessor = new Affine2DInertiaProcessor();
                inertiaProcessor.Affine2DInertiaCompleted += OnAffine2DInertiaCompleted;
                inertiaProcessor.Affine2DInertiaDelta     += OnAffine2DDelta;

                Visible = true;
                InteractiveSurface interactiveSurface = InteractiveSurface.DefaultInteractiveSurface;

                if (interactiveSurface != null)
                {
                    FormBorderStyle = FormBorderStyle.None;
                }
                UpdateWindowPosition();

                // Set the application's orientation based on the current launcher orientation
                //currentOrientation = ApplicationLauncher.Orientation;

                // Subscribe to surface application activation events
                ApplicationLauncher.ApplicationActivated   += OnApplicationActivated;
                ApplicationLauncher.ApplicationPreviewed   += OnApplicationPreviewed;
                ApplicationLauncher.ApplicationDeactivated += OnApplicationDeactivated;
            }
Example #3
0
        /// <summary>
        /// Retrieve the movement velocity of a Contact
        /// The data is taken from a ManipulationProcessor linked to the Contact
        /// The final unit is: SurfaceDimension / Seconds
        /// </summary>
        /// <param name="id">Contact Id</param>
        /// <param name="velocityX">Output parameter</param>
        /// <param name="velocityY">Output parameter</param>
        /// <param name="surface">Object representing the Surface</param>
        public void getVelocity(int id, out float velocityX, out float velocityY, InteractiveSurface surface)
        {
            velocityX = 0.0f;
            velocityY = 0.0f;

            if (_contactManipulationData.ContainsKey(id))
            {
                velocityX = _contactManipulationData[id].VelocityX;
                velocityY = _contactManipulationData[id].VelocityY;

                velocityX = velocityX * 1000.0f;
                velocityY = velocityY * 1000.0f;

                velocityX = velocityX / surface.Width;
                velocityY = velocityY / surface.Height;
            }
        }