示例#1
0
        /// <summary>
        /// Initializes the surface input system. This should be called after any window
        /// initialization is done, and should only be called once.
        /// </summary>
        private void InitializeSurfaceInput()
        {
            System.Diagnostics.Debug.Assert(Window.Handle != System.IntPtr.Zero,
                                            "Window initialization must be complete before InitializeSurfaceInput is called");
            if (Window.Handle == System.IntPtr.Zero)
            {
                return;
            }
            //System.Diagnostics.Debug.Assert(contactTarget == null,
            //                                "Surface input already initialized");

            if (contactTarget != null)
            {
                return;
            }

            // Create a target for surface input.
            // Use an IntPtr.Zero as the handle, but still have a Window(!!) as an ivar
            // to get contacts globaly.
            contactTarget = new ContactTarget(IntPtr.Zero, EventThreadChoice.OnCurrentThread, true);

            // Enable the Surface input on this target:
            //bHasImage = contactTarget.EnableImage(ImageType.Normalized);
            //if (bHasImage) contactTarget.FrameReceived += new EventHandler<FrameReceivedEventArgs>(contactTarget_FrameReceived);

            contactTarget.EnableInput();
        }
示例#2
0
 private void InitializeSurfaceInput()
 {
     hwnd          = new System.Windows.Interop.WindowInteropHelper(this).Handle;
     contactTarget = new Microsoft.Surface.Core.ContactTarget(hwnd);
     contactTarget.EnableInput();
     EnableRawImage();
 }
示例#3
0
        private void InitializeSurfaceInput()
        {
            hwnd          = new System.Windows.Interop.WindowInteropHelper(this).Handle;
            contactTarget = new Microsoft.Surface.Core.ContactTarget(hwnd);
            contactTarget.EnableInput();

            tracker                = new Tracker();
            tracker.DeviceAdded   += tracker_DeviceAdded;
            tracker.DeviceRemoved += tracker_DeviceRemoved;
            tracker.DeviceUpdated += tracker_DeviceUpdated;

            EnableRawImage();
        }
        public InputContext(InputProvider provider)
        {
            inputProvider = provider;

            window      = EventDispatchingNativeWindow.Instance;
            oldContacts = new List <Contact>();

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());

            contactTarget = new ContactTarget(IntPtr.Zero, true);
            contactTarget.EnableInput();

            timer          = new System.Windows.Forms.Timer();
            timer.Interval = 1000 / 60;
            timer.Tick    += timer_Tick;
            timer.Start();
        }
示例#5
0
        /// <summary>
        /// Initializes the surface input system. This should be called after any window
        /// initialization is done, and should only be called once.
        /// </summary>
        private void InitializeSurfaceInput()
        {
            Debug.Assert(Window.Handle != IntPtr.Zero,
                         "Window initialization must be complete before InitializeSurfaceInput is called");
            if (Window.Handle == IntPtr.Zero)
            {
                return;
            }
            Debug.Assert(contactTarget == null,
                         "Surface input already initialized");
            if (contactTarget != null)
            {
                return;
            }

            // Create a target for surface input.
            contactTarget = new ContactTarget(IntPtr.Zero, true);
            contactTarget.EnableInput();
        }
示例#6
0
        /// <summary>
        /// Initializes the surface input system. This should be called after any window
        /// initialization is done, and should only be called once.
        /// </summary>
        private void InitializeSurfaceInput()
        {
            System.Diagnostics.Debug.Assert(Window.Handle != System.IntPtr.Zero,
                                            "Window initialization must be complete before InitializeSurfaceInput is called");
            if (Window.Handle == System.IntPtr.Zero)
            {
                return;
            }
            System.Diagnostics.Debug.Assert(contactTarget == null,
                                            "Surface input already initialized");
            if (contactTarget != null)
            {
                return;
            }

            // Create a target for surface input.
            contactTarget = new ContactTarget(Window.Handle, EventThreadChoice.OnBackgroundThread);
            contactTarget.EnableInput();
        }
        private void InitializeSurfaceInput()
        {
            hwnd = new System.Windows.Interop.WindowInteropHelper(this).Handle;
            contactTarget = new Microsoft.Surface.Core.ContactTarget(hwnd);
            contactTarget.EnableInput();

            EnableRawImage();
        }
示例#8
0
        /// <summary>
        /// Initializes the surface input system. This should be called after any window
        /// initialization is done, and should only be called once.
        /// </summary>
        private void InitializeSurfaceInput()
        {
            System.Diagnostics.Debug.Assert(Window.Handle != System.IntPtr.Zero,
                "Window initialization must be complete before InitializeSurfaceInput is called");
            if (Window.Handle == System.IntPtr.Zero)
                return;
            System.Diagnostics.Debug.Assert(contactTarget == null,
                "Surface input already initialized");
            if (contactTarget != null)
                return;

            capture = new SurfaceCapture();

            // Create a target for surface input.
            contactTarget = new ContactTarget(Window.Handle, EventThreadChoice.OnBackgroundThread);
            contactTarget.EnableInput();
            contactTarget.EnableImage(ImageType.Normalized);

            // Register events
            contactTarget.ContactAdded += OnContactStartRecord;
            contactTarget.FrameReceived += OnContactRecordGesture;
            contactTarget.ContactRemoved += OffContactStopRecord;
        }
示例#9
0
    /// <summary>
    /// Initializes the surface input system. This should be called after any window
    /// initialization is done, and should only be called once.
    /// </summary>
    private void InitializeSurfaceInput()
    {
      System.Diagnostics.Debug.Assert(Window.Handle != System.IntPtr.Zero,
          "Window initialization must be complete before InitializeSurfaceInput is called");
      if (Window.Handle == System.IntPtr.Zero)
        return;
      System.Diagnostics.Debug.Assert(contactTarget == null,
          "Surface input already initialized");
      if (contactTarget != null)
        return;

      // Create a target for surface input.
      contactTarget = new ContactTarget(Window.Handle, EventThreadChoice.OnBackgroundThread);
      contactTarget.EnableInput();
    }
        /// <summary>
        /// Initializes the surface input system. This should be called after any window
        /// initialization is done, and should only be called once.
        /// </summary>
        public override void Initialize()
        {
            surfaceComp = Game.Components.OfType<SurfaceComponent>().First();

            System.Diagnostics.Debug.Assert(Game.Window.Handle != System.IntPtr.Zero,
                "Window initialization must be complete before InitializeSurfaceInput is called");
            if (Game.Window.Handle == System.IntPtr.Zero)
                return;
            System.Diagnostics.Debug.Assert(contactTarget == null,
                "Surface input already initialized");
            if (contactTarget != null)
                return;

            // Create a target for surface input.
            contactTarget = new ContactTarget(Game.Window.Handle, EventThreadChoice.OnBackgroundThread);
            contactTarget.EnableInput();

            contactTarget.EnableImage(ImageType.Normalized);
            contactTarget.FrameReceived += new EventHandler<FrameReceivedEventArgs>(contactTarget_FrameReceived);

            CurrentContacts = contactTarget.GetState();

            manipulationProcessor = new Affine2DManipulationProcessor(Affine2DManipulations.TranslateX | Affine2DManipulations.TranslateY
                | Affine2DManipulations.Rotate | Affine2DManipulations.Scale);
            manipulationProcessor.Affine2DManipulationDelta += new EventHandler<Affine2DOperationDeltaEventArgs>(manipulationDelta);
            manipulationProcessor.Affine2DManipulationStarted += (s, e) => IsManipulating = true;
            manipulationProcessor.Affine2DManipulationCompleted += (s, e) => IsManipulating = false;

            base.Initialize();
        }
示例#11
0
        /// <summary>
        /// Initializes the surface input system. This should be called after any window
        /// initialization is done, and should only be called once.
        /// </summary>
        private void InitializeSurfaceInput()
        {
            System.Diagnostics.Debug.Assert(Window.Handle != System.IntPtr.Zero,
                                            "Window initialization must be complete before InitializeSurfaceInput is called");
            if (Window.Handle == System.IntPtr.Zero)
                return;
            //System.Diagnostics.Debug.Assert(contactTarget == null,
            //                                "Surface input already initialized");

            if (contactTarget != null)
                return;

            // Create a target for surface input.
            // Use an IntPtr.Zero as the handle, but still have a Window(!!) as an ivar
            // to get contacts globaly.
            contactTarget = new ContactTarget(IntPtr.Zero,EventThreadChoice.OnCurrentThread,true);

            // Enable the Surface input on this target:
            //bHasImage = contactTarget.EnableImage(ImageType.Normalized);
            //if (bHasImage) contactTarget.FrameReceived += new EventHandler<FrameReceivedEventArgs>(contactTarget_FrameReceived);

            contactTarget.EnableInput();
        }
        /// <summary>
        /// Starts the listening for raw input.
        /// </summary>
        /// <param name="window">The window.</param>
        private static void StartListeningForRawInput(SurfaceWindow window)
        {
            // Get the hWnd for the SurfaceWindow object after it has been loaded.
            IntPtr hwnd = new WindowInteropHelper(window).Handle;
            contactTarget = new ContactTarget(hwnd);

            // Set up the ContactTarget object for the entire SurfaceWindow object.
            contactTarget.EnableInput();

            // Start listening to the FrameReceived event
            EnableRawImage(contactTarget);
        }