public InputEvents(CoreWindow window, UIElement inputElement, TouchQueue touchQueue) { _touchQueue = touchQueue; // The key events are always tied to the window as those will // only arrive here if some other control hasn't gotten it. window.KeyDown += CoreWindow_KeyDown; window.KeyUp += CoreWindow_KeyUp; window.VisibilityChanged += CoreWindow_VisibilityChanged; window.Activated += CoreWindow_Activated; window.SizeChanged += CoreWindow_SizeChanged; if (inputElement != null) { // If we have an input UIElement then we bind input events // to it else we'll get events for overlapping XAML controls. inputElement.PointerPressed += UIElement_PointerPressed; inputElement.PointerReleased += UIElement_PointerReleased; inputElement.PointerCanceled += UIElement_PointerReleased; inputElement.PointerMoved += UIElement_PointerMoved; inputElement.PointerWheelChanged += UIElement_PointerWheelChanged; } else { // If we only have a CoreWindow then use it for input events. window.PointerPressed += CoreWindow_PointerPressed; window.PointerReleased += CoreWindow_PointerReleased; window.PointerMoved += CoreWindow_PointerMoved; window.PointerWheelChanged += CoreWindow_PointerWheelChanged; } }
public void Initialize(CoreWindow coreWindow, UIElement inputElement, TouchQueue touchQueue) { _coreWindow = coreWindow; _windowEvents = new InputEvents(_coreWindow, inputElement, touchQueue); _dinfo = DisplayInformation.GetForCurrentView(); _appView = ApplicationView.GetForCurrentView(); // Set a min size that is reasonable knowing someone might try // to use some old school resolution like 640x480. var minSize = new Windows.Foundation.Size(640 / _dinfo.RawPixelsPerViewPixel, 480 / _dinfo.RawPixelsPerViewPixel); _appView.SetPreferredMinSize(minSize); _orientation = ToOrientation(_dinfo.CurrentOrientation); _dinfo.OrientationChanged += DisplayProperties_OrientationChanged; _swapChainPanel = inputElement as SwapChainPanel; _swapChainPanel.SizeChanged += SwapChain_SizeChanged; _coreWindow.Closed += Window_Closed; _coreWindow.Activated += Window_FocusChanged; _coreWindow.CharacterReceived += Window_CharacterReceived; SetViewBounds(_appView.VisibleBounds.Width, _appView.VisibleBounds.Height); SetCursor(false); }
public bool TryAddTouchQueueChanging(TouchQueue queue, TouchQueueChangingMode changingMode, long time) { TouchQueueInfomation info = FindQueueInfomation(queue); if (info.IsEmpty()) { if (changingMode == TouchQueueChangingMode.TQC_PRESS) { TouchQueueInfomation tqcInfo = new TouchQueueInfomation(queue, changingMode, time); mChangedTouchQueues.AddLast(tqcInfo); return(true); } return(false); } else { if (changingMode == TouchQueueChangingMode.TQC_RELEASE) { Debug.Assert((info.lastChangingMode == TouchQueueChangingMode.TQC_PRESS) || (info.lastChangingMode == TouchQueueChangingMode.TQC_MOVE)); info.releaseTime = time; info.repeatTimes++; } bool changed = (info.lastChangingMode == changingMode); info.lastChangingMode = changingMode; return(changed); } }
public void Initialize(CoreWindow coreWindow, UIElement inputElement, TouchQueue touchQueue) { _coreWindow = coreWindow; _inputEvents = new InputEvents(_coreWindow, inputElement, touchQueue); _dinfo = DisplayInformation.GetForCurrentView(); _appView = ApplicationView.GetForCurrentView(); _orientation = ToOrientation(_dinfo.CurrentOrientation); _dinfo.OrientationChanged += DisplayProperties_OrientationChanged; _coreWindow.SizeChanged += Window_SizeChanged; _coreWindow.Closed += Window_Closed; _coreWindow.Activated += Window_FocusChanged; if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) { Windows.Phone.UI.Input.HardwareButtons.BackPressed += this.HardwareButtons_BackPressed; } SetViewBounds(_appView.VisibleBounds.Width, _appView.VisibleBounds.Height); SetCursor(false); }
public void Initialize(CoreWindow coreWindow, UIElement inputElement, TouchQueue touchQueue) { _coreWindow = coreWindow; _inputEvents = new InputEvents(_coreWindow, inputElement, touchQueue); _dinfo = DisplayInformation.GetForCurrentView(); _appView = ApplicationView.GetForCurrentView(); // Set a min size that is reasonable knowing someone might try // to use some old school resolution like 640x480. var minSize = new Windows.Foundation.Size(640 / _dinfo.RawPixelsPerViewPixel, 480 / _dinfo.RawPixelsPerViewPixel); _appView.SetPreferredMinSize(minSize); _orientation = ToOrientation(_dinfo.CurrentOrientation); _dinfo.OrientationChanged += DisplayProperties_OrientationChanged; _coreWindow.SizeChanged += Window_SizeChanged; _coreWindow.Closed += Window_Closed; _coreWindow.Activated += Window_FocusChanged; if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) { Windows.Phone.UI.Input.HardwareButtons.BackPressed += this.HardwareButtons_BackPressed; } SetViewBounds(_appView.VisibleBounds.Width, _appView.VisibleBounds.Height); SetCursor(false); }
public InputEvents(CoreWindow window, UIElement inputElement, TouchQueue touchQueue) { _touchQueue = touchQueue; // The key events are always tied to the window as those will // only arrive here if some other control hasn't gotten it. window.KeyDown += CoreWindow_KeyDown; window.KeyUp += CoreWindow_KeyUp; window.VisibilityChanged += CoreWindow_VisibilityChanged; window.Activated += CoreWindow_Activated; window.SizeChanged += CoreWindow_SizeChanged; DisplayInformation.GetForCurrentView().DpiChanged += InputEvents_DpiChanged; _currentDipFactor = DisplayInformation.GetForCurrentView().LogicalDpi / 96.0f; if (inputElement is SwapChainPanel || inputElement is SwapChainBackgroundPanel) { // Create a thread to precess input events. var workItemHandler = new WorkItemHandler((action) => { var inputDevices = CoreInputDeviceTypes.Mouse | CoreInputDeviceTypes.Pen | CoreInputDeviceTypes.Touch; CoreIndependentInputSource coreIndependentInputSource; if (inputElement is SwapChainBackgroundPanel) { coreIndependentInputSource = ((SwapChainBackgroundPanel)inputElement).CreateCoreIndependentInputSource(inputDevices); } else { coreIndependentInputSource = ((SwapChainPanel)inputElement).CreateCoreIndependentInputSource(inputDevices); } coreIndependentInputSource.PointerPressed += CoreWindow_PointerPressed; coreIndependentInputSource.PointerMoved += CoreWindow_PointerMoved; coreIndependentInputSource.PointerReleased += CoreWindow_PointerReleased; coreIndependentInputSource.Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessUntilQuit); }); var inputWorker = ThreadPool.RunAsync(workItemHandler, WorkItemPriority.High, WorkItemOptions.TimeSliced); } if (inputElement != null) { // If we have an input UIElement then we bind input events // to it else we'll get events for overlapping XAML controls. inputElement.PointerPressed += UIElement_PointerPressed; inputElement.PointerReleased += UIElement_PointerReleased; inputElement.PointerCanceled += UIElement_PointerReleased; inputElement.PointerMoved += UIElement_PointerMoved; inputElement.PointerWheelChanged += UIElement_PointerWheelChanged; } else { // If we only have a CoreWindow then use it for input events. window.PointerPressed += CoreWindow_PointerPressed; window.PointerReleased += CoreWindow_PointerReleased; window.PointerMoved += CoreWindow_PointerMoved; window.PointerWheelChanged += CoreWindow_PointerWheelChanged; } }
public TouchQueueInfomation() { touchQueue = null; releaseTime = 0; lastChangingMode = TouchQueueChangingMode.TQC_NONE; repeatTimes = 0; curState = TouchState.STATE_NONE; }
protected TouchQueueInfomation FindQueueInfomation(TouchQueue queue) { for (int i = 0; i < mChangedTouchQueues.Count; i++) { if (mChangedTouchQueues.ElementAt(i).touchQueue == queue) { return(mChangedTouchQueues.ElementAt(i)); } } return(_empty_infomation); }
public TouchQueueInfomation(TouchQueue queue, TouchQueueChangingMode changingMode, long time) { curState = TouchState.STATE_NONE; touchQueue = queue; releaseTime = time; lastChangingMode = changingMode; repeatTimes = 0; if (touchQueue.IsActived()) { curState = TouchState.STATE_TAP; } }
protected void TryRemoveTouchQueueInfomation(TouchQueue queue) { for (int i = 0; i < mChangedTouchQueues.Count; i++) { TouchQueueInfomation info = mChangedTouchQueues.ElementAt(i); if (info.touchQueue == queue) { mChangedTouchQueues.Remove(info); queue.Clear(); break; } } }
public void Initialize(CoreWindow coreWindow, UIElement inputElement, TouchQueue touchQueue) { _coreWindow = coreWindow; _windowEvents = new InputEvents(_coreWindow, inputElement, touchQueue); _orientation = ToOrientation(DisplayProperties.CurrentOrientation); DisplayProperties.OrientationChanged += DisplayProperties_OrientationChanged; _coreWindow.SizeChanged += Window_SizeChanged; _coreWindow.Closed += Window_Closed; _coreWindow.Activated += Window_FocusChanged; #if !WINDOWS_PHONE81 _currentViewState = ApplicationView.Value; #endif var bounds = _coreWindow.Bounds; SetClientBounds(bounds.Width, bounds.Height); SetCursor(false); }
public SurfaceTouchHandler(TouchQueue touchQueue) { _touchQueue = touchQueue; }