private void AssociatedObject_Unloaded(object sender, RoutedEventArgs e) { _AutoHideTimer.Stop(); MouseDevice.GetForCurrentView().MouseMoved -= CursorSetter_MouseMoved; Window.Current.CoreWindow.PointerCursor = _DefaultCursor; }
/// <summary> /// /// </summary> public DeviceGestureService() { IsHardwareBackButtonPresent = ApiInformation.IsEventPresent("Windows.Phone.UI.Input.HardwareButtons", "BackPressed"); IsHardwareCameraButtonPresent = ApiInformation.IsEventPresent("Windows.Phone.UI.Input.HardwareButtons", "CameraPressed"); IsKeyboardPresent = new KeyboardCapabilities().KeyboardPresent != 0; IsMousePresent = new MouseCapabilities().MousePresent != 0; IsTouchPresent = new TouchCapabilities().TouchPresent != 0; if (IsHardwareBackButtonPresent) { HardwareButtons.BackPressed += OnHardwareButtonsBackPressed; } if (IsHardwareCameraButtonPresent) { HardwareButtons.CameraHalfPressed += OnHardwareButtonCameraHalfPressed; HardwareButtons.CameraPressed += OnHardwareButtonCameraPressed; HardwareButtons.CameraReleased += OnHardwareButtonCameraReleased; } if (IsMousePresent) { MouseDevice.GetForCurrentView().MouseMoved += OnMouseMoved; } SystemNavigationManager.GetForCurrentView().BackRequested += OnSystemNavigationManagerBackRequested; Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += OnAcceleratorKeyActivated; Window.Current.CoreWindow.PointerPressed += OnPointerPressed; }
/// <summary> /// /// </summary> public virtual void InitializeEventHandlers() { if (IsHardwareBackButtonPresent) { HardwareButtons.BackPressed += OnHardwareButtonsBackPressed; } if (IsHardwareCameraButtonPresent) { HardwareButtons.CameraHalfPressed += OnHardwareButtonCameraHalfPressed; HardwareButtons.CameraPressed += OnHardwareButtonCameraPressed; HardwareButtons.CameraReleased += OnHardwareButtonCameraReleased; } if (IsMousePresent) { MouseDevice.GetForCurrentView().MouseMoved += OnMouseMoved; } SystemNavigationManager.GetForCurrentView().BackRequested += OnSystemNavigationManagerBackRequested; Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += OnAcceleratorKeyActivated; Window.Current.CoreWindow.PointerPressed += OnPointerPressed; }
private async void AssociatedObject_Loaded(object sender, RoutedEventArgs e) { using (var releaser = await _CursorDisplayUpdateLock.LockAsync()) { _DefaultCursor = Window.Current.CoreWindow.PointerCursor; try { _MouseDevice = MouseDevice.GetForCurrentView(); _MouseDevice.MouseMoved += CursorSetter_MouseMoved; } catch { } Window.Current.Activated += Current_Activated; _AutoHideTimer.Tick += AutoHideTimer_Tick; _IsCursorInsideAssociatedObject = IsCursorInWindow(); if (Window.Current.Visible) { ResetAutoHideTimer(); } } }
protected override void OnAttached() { _LastCursorPosition = GetPointerPosition(); _AutoHideTimer.Interval = AutoHideDelay; _IsCursorInsideAssociatedObject = IsCursorInWindow(); _prevIsVisible = true; ResetAutoHideTimer(); AssociatedObject.PointerEntered -= AssociatedObject_PointerEntered; AssociatedObject.PointerExited -= AssociatedObject_PointerExited; AssociatedObject.PointerEntered += AssociatedObject_PointerEntered; AssociatedObject.PointerExited += AssociatedObject_PointerExited; Window.Current.Activated -= Current_Activated; Window.Current.Activated += Current_Activated; MouseDevice.GetForCurrentView().MouseMoved -= CursorSetter_MouseMoved; MouseDevice.GetForCurrentView().MouseMoved += CursorSetter_MouseMoved; AssociatedObject.Unloaded -= AssociatedObject_Unloaded; AssociatedObject.Unloaded += AssociatedObject_Unloaded; base.OnAttached(); }
private void OnDragOverlayPointerPressed(object sender, PointerRoutedEventArgs e) #endif { #if UWP #if MIGRATION _dragOverlay.CaptureMouse(); #else _dragOverlay.CapturePointer(e.Pointer); #endif #endif _totalDeltaX = 0; _totalDeltaY = 0; #if UWP if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse) { _isDraggingWithMouse = true; _mouseDevice = MouseDevice.GetForCurrentView(); _mouseDevice.MouseMoved += this.OnMouseDragged; Window.Current.CoreWindow.PointerCursor = null; } else { _dragOverlay.ManipulationDelta += this.OnDragOverlayManipulationDelta; } #endif }
public override void Initialize() { base.Initialize(); var windowHandle = Game.Window.NativeWindow; switch (windowHandle.Context) { case AppContextType.WindowsRuntime: InitializeFromFrameworkElement((FrameworkElement)windowHandle.NativeHandle); break; default: throw new ArgumentException(string.Format("WindowContext [{0}] not supported", Game.Context.ContextType)); } // Scan all registered inputs Scan(); // get sensor default instances windowsAccelerometer = WindowsAccelerometer.GetDefault(); windowsCompass = WindowsCompass.GetDefault(); windowsGyroscope = WindowsGyroscope.GetDefault(); windowsOrientation = WindowsOrientation.GetDefault(); // determine which sensors are available Accelerometer.IsSupported = windowsAccelerometer != null; Compass.IsSupported = windowsCompass != null; Gyroscope.IsSupported = windowsGyroscope != null; Orientation.IsSupported = windowsOrientation != null; Gravity.IsSupported = Orientation.IsSupported && Accelerometer.IsSupported; UserAcceleration.IsSupported = Gravity.IsSupported; MouseDevice.GetForCurrentView().MouseMoved += (_, y) => HandleRelativeOnMouseMoved(y); }
public Video() { this.InitializeComponent(); this.NavigationCacheMode = NavigationCacheMode.Disabled; isInited = true; this.DataContext = this; timer.Interval = TimeSpan.FromSeconds(1); timer_danmaku.Interval = TimeSpan.FromSeconds(1); timer.Tick += Timer_Tick; timer_repeat.Tick += Timer_repeat_Tick; timer_danmaku.Tick += Timer_danmaku_Tick; timer.Start(); // 横向屏幕 DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape; if (!WebStatusHelper.IsOnline()) { txt_mydanmu.PlaceholderText = "没有联网哦,不能发弹幕"; txt_mydanmu.IsEnabled = false; } // 保持屏幕常亮 displayRq.RequestActive(); if (SettingHelper.DeviceType == DeviceType.PC) { menu_full.Visibility = Visibility.Visible; MouseDevice.GetForCurrentView().MouseMoved += Video_MouseMoved; CoreWindow.GetForCurrentThread().KeyDown += Video_KeyDown; } SettingInit(); }
public void UnlockPosition() { if (isPositionLocked) { MouseDevice.GetForCurrentView().MouseMoved -= OnRelativeMouseMoved; UIControl.PointerCursor = previousCursor; previousCursor = null; isPositionLocked = false; } }
/// <summary> /// Initialize a new instance of the <see cref="GestureService"/> /// </summary> public GestureService() { if (IsMousePresent) { MouseDevice.GetForCurrentView().MouseMoved += OnMouseMoved; } SystemNavigationManager.GetForCurrentView().BackRequested += OnSystemNavigationManagerBackRequested; Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += OnAcceleratorKeyActivated; Window.Current.CoreWindow.PointerPressed += OnPointerPressed; }
public void Stop() { _cursorTimer.Tick -= CursorDisappearanceTimer; _cursorTimer.Stop(); var mouse = MouseDevice.GetForCurrentView(); if (mouse != null) { mouse.MouseMoved -= MouseMoved; } }
/// <summary> /// Get the computer information passed from the previous page /// </summary> protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); // We only want to stream in landscape DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape; context = (StreamContext)e.Parameter; Window.Current.CoreWindow.KeyDown += WindowKeyDownHandler; Window.Current.CoreWindow.KeyUp += WindowKeyUpHandler; // Add a callback for relative mouse movements MouseDevice.GetForCurrentView().MouseMoved += RelativeMouseMoved; }
private void AssociatedObject_Loaded(object sender, RoutedEventArgs e) { MouseDevice.GetForCurrentView().MouseMoved += CursorSetter_MouseMoved; AssociatedObject.PointerEntered += AssociatedObject_PointerEntered; AssociatedObject.PointerExited += AssociatedObject_PointerExited; _AutoHideTimer.Tick += AutoHideTimer_Tick; _AutoHideTimer.Interval = AutoHideDelay; _IsCursorInsideAssociatedObject = IsCursorInWindow(); ResetAutoHideTimer(); }
/// <summary> /// </summary> /// <param name="disposing"></param> protected virtual void Dispose(bool disposing) { if (disposing) { if (IsMousePresent) { MouseDevice.GetForCurrentView().MouseMoved -= OnMouseMoved; } SystemNavigationManager.GetForCurrentView().BackRequested -= OnSystemNavigationManagerBackRequested; Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -= OnAcceleratorKeyActivated; Window.Current.CoreWindow.PointerPressed -= OnPointerPressed; } }
public void Start() { _cursorTimer = new DispatcherTimer(); _cursorTimer.Interval = TimeSpan.FromSeconds(CursorHiddenAfterSeconds); _cursorTimer.Tick += CursorDisappearanceTimer; if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled) { var mouse = MouseDevice.GetForCurrentView(); if (mouse != null) { mouse.MouseMoved += MouseMoved; } } }
private void OnDragOverlayPointerPressed(object sender, PointerRoutedEventArgs e) { _dragOverlay.CapturePointer(e.Pointer); if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse) { _isDraggingWithMouse = true; _mouseDevice = MouseDevice.GetForCurrentView(); _mouseDevice.MouseMoved += OnMouseDragged; Window.Current.CoreWindow.PointerCursor = null; } else { _dragOverlay.ManipulationDelta += OnDragOverlayManipulationDelta; } }
public void LockPosition(bool forceCenter = false) { if (!isPositionLocked) { MouseDevice.GetForCurrentView().MouseMoved += OnRelativeMouseMoved; previousCursor = UIControl.PointerCursor; UIControl.PointerCursor = null; if (forceCenter) { var capturedPosition = new PointUWP(UIControl.Bounds.Left, UIControl.Bounds.Top); capturedPosition.X += UIControl.Bounds.Width / 2; capturedPosition.Y += UIControl.Bounds.Height / 2; UIControl.PointerPosition = capturedPosition; } isPositionLocked = true; } }
private DetailViewModel() { Items = new ObservableCollection <ComposedItemViewModel>(); ShowInfo = true; IsRestoreScreenButtonVisible = false; ZoomMode = ZoomMode.Enabled; if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled) { FullScreenService.FullScreenModeChanged += FullScreenModeChanged; FullScreenService.FullScreenPlayActionsChanged += FullScreenPlayActionsChanged; if (HasMouseConnected) { MouseDevice.GetForCurrentView().MouseMoved += MouseMoved; } } }
public DetailViewModel(SectionConfigBase <TConfig, TSchema> sectionConfig) : base(sectionConfig) { Items = new ObservableCollection <ComposedItemViewModel>(); _sectionConfig = sectionConfig; ShowInfo = true; IsRestoreScreenButtonVisible = false; Title = _sectionConfig.DetailPage.Title; if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled) { FullScreenService.FullScreenModeChanged += FullScreenModeChanged; FullScreenService.FullScreenPlayActionsChanged += FullScreenPlayActionsChanged; if (HasMouseConnected) { MouseDevice.GetForCurrentView().MouseMoved += MouseMoved; } } }
public MouseService() { _cursorTimer = new DispatcherTimer(); _cursorTimer.Interval = TimeSpan.FromSeconds(CursorHiddenAfterSeconds); _cursorTimer.Tick += HideCursor; if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled) { #if WINDOWS_APP if (Window.Current.CoreWindow.PointerCursor != null) { _oldCursor = Window.Current.CoreWindow.PointerCursor; } var mouse = MouseDevice.GetForCurrentView(); if (mouse != null) { mouse.MouseMoved += MouseMoved; } #else #endif } }
public AutoHideCursor() { _MouseDevice = MouseDevice.GetForCurrentView(); _DefaultCursor = Window.Current.CoreWindow.PointerCursor; }