Наследование: ICoreCursor
Пример #1
0
        public MouseService()
        {
            _cursorTimer = new DispatcherTimer();
            _cursorTimer.Interval = TimeSpan.FromSeconds(CursorHiddenAfterSeconds);
            _cursorTimer.Tick += HideCursor;

            if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                _oldCursor = Window.Current.CoreWindow.PointerCursor;
                Windows.Devices.Input.MouseDevice.GetForCurrentView().MouseMoved += MouseMoved;
            }
        }
Пример #2
0
        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
            }
        }
Пример #3
0
 protected override async void OnLaunched(LaunchActivatedEventArgs args) {
     Frame rootFrame = Window.Current.Content as Frame;
     if(rootFrame == null) {
         rootFrame = new Frame();
         SuspensionManager.RegisterFrame(rootFrame, "AppFrame");
         if(args.PreviousExecutionState == ApplicationExecutionState.Terminated) {
             try {
                 await SuspensionManager.RestoreAsync(); }
             catch (SuspensionManagerException) {} }
         Window.Current.Content = rootFrame; }
     if(rootFrame.Content == null) {
         if(!rootFrame.Navigate(typeof(MainPage))) {
             throw new Exception("Failed to create initial page"); } }
     Window.Current.Activate();
     cursor = Window.Current.CoreWindow.PointerCursor;
     PopulateRecentlyUsed();
     PopulateLibrary();
     SettingsPane.GetForCurrentView().CommandsRequested += CommandsRequested; }
Пример #4
0
        public PlayPage()
        {
            this.InitializeComponent();

            _dispatcher = Window.Current.CoreWindow.Dispatcher;
            _playToManager = PlayToManager.GetForCurrentView();
            _displayRequest = new DisplayRequest();
            _coreCursor = Window.Current.CoreWindow.PointerCursor;
            _timerOfDAC = ThreadPoolTimer.CreatePeriodicTimer(_timerOfDAC_Tick, TimeSpan.FromSeconds(1));

            _timer = new DispatcherTimer();
            _timer.Tick += _timer_Tick;
            _timer.Interval = TimeSpan.FromSeconds(1);

            _timerOfControler = new DispatcherTimer();
            _timerOfControler.Tick += _timerOfControler_Tick;
            _timerOfControler.Interval = TimeSpan.FromSeconds(3);

            xMediaPlayer.BufferingProgressChanged += xMediaPlayer_BufferingProgressChanged;
            xMediaPlayer.CurrentStateChanged += xMediaPlayer_CurrentStateChanged;
            xMediaPlayer.MediaEnded += xMediaPlayer_MediaEnded;
            xMediaPlayer.MediaFailed += xMediaPlayer_MediaFailed;
            xMediaPlayer.MediaOpened += xMediaPlayer_MediaOpened;

            xPlayerControler.Seeking += xPlayerControler_Seeking;
            xPlayerControler.Seeked += xPlayerControler_Seeked;
            xPlayerControler.VolumeChanged += xPlayerControler_VolumeChanged;
            xPlayerControler.MediaElementStatusChanged += xPlayerControler_MediaElementStatusChanged;
            xPlayerControler.NextProgramSelected += xPlayerControler_NextProgramSelected;
            xPlayerControler.PreviousProgramSelected += xPlayerControler_PreviousProgramSelected;
            xPlayerControler.BitrateChanged += xPlayerControler_BitrateChanged;

            var volume = DataStoreUtils.GetLocalSettingValue(Utils.Constants.VolumeSettingKey);
            if (volume != null)
            {
                var value = (double)volume;
                xMediaPlayer.Volume = value;
                xPlayerControler.SetVolumeValue(value);
            }
        }
Пример #5
0
 protected virtual void uiElement_PointerEntered(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
 {
     lastCursor = Window.Current.CoreWindow.PointerCursor;
     Window.Current.CoreWindow.PointerCursor = CursorOver;
 }
Пример #6
0
 /// <summary>
 /// Sets the Cursor property. This dependency property 
 /// indicates the cursor to use when a mouse cursor is moved over the control.
 /// </summary>
 public static void SetCursor(DependencyObject d, CoreCursor value)
 {
     d.SetValue(CursorProperty, value);
 }
Пример #7
0
        internal void UpdateCursor()
        {
            if (defaultCursor == null)
            {
                defaultCursor = Window.Current.CoreWindow.PointerCursor;
            }

            var cursor = ControlExtensions.GetCursor(this.control);

            if (this.isHovering)
            {
                if (cursor != null)
                {
                    Window.Current.CoreWindow.PointerCursor = cursor;
                }
                else
                {
                    Window.Current.CoreWindow.PointerCursor = DefaultCursor;
                }
            }
        }
        internal void UpdateCursor()
        {
            if (_defaultCursor == null)
            {
                _defaultCursor = Window.Current.CoreWindow.PointerCursor;
            }

            var cursor = FrameworkElementExtensions.GetCursor(_control);

            if (_isHovering)
            {
                if (cursor != null)
                {
                    Window.Current.CoreWindow.PointerCursor = cursor;
                }
                else
                {
                    Window.Current.CoreWindow.PointerCursor = DefaultCursor;
                }
            }
        }
        private void CaptureMouse()
        {
            // Hide the cursor
            oldCursor = Window.Current.CoreWindow.PointerCursor;
            Window.Current.CoreWindow.PointerCursor = null;

            capturingMouse = true;
        }
Пример #10
0
        /// <summary>
        /// This is the click handler for the 'Set Lat/Long to current position' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        async private void OnSetPositionToHere(object sender, RoutedEventArgs e)
        {
            // save off current cursor and set cursor to a wait cursor
            Windows.UI.Core.CoreCursor oldCursor = Window.Current.CoreWindow.PointerCursor;
            Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(CoreCursorType.Wait, 0);
            SetPositionToHereButton.IsEnabled       = false;
            Latitude.IsEnabled  = false;
            Longitude.IsEnabled = false;

            try
            {
                // Get cancellation token
                cts = new CancellationTokenSource();
                CancellationToken token = cts.Token;

                // Carry out the operation
                Geoposition pos = await geolocator.GetGeopositionAsync().AsTask(token);

                Latitude.Text  = pos.Coordinate.Point.Position.Latitude.ToString();
                Longitude.Text = pos.Coordinate.Point.Position.Longitude.ToString();

                // clear status
                rootPage.NotifyUser("", NotifyType.StatusMessage);
            }
            catch (UnauthorizedAccessException)
            {
                if (DeviceAccessStatus.DeniedByUser == accessInfo.CurrentStatus)
                {
                    rootPage.NotifyUser("Location has been disabled by the user. Enable access through the settings charm.", NotifyType.StatusMessage);
                }
                else if (DeviceAccessStatus.DeniedBySystem == accessInfo.CurrentStatus)
                {
                    rootPage.NotifyUser("Location has been disabled by the system. The administrator of the device must enable location access through the location control panel.", NotifyType.StatusMessage);
                }
                else if (DeviceAccessStatus.Unspecified == accessInfo.CurrentStatus)
                {
                    rootPage.NotifyUser("Location has been disabled by unspecified source. The administrator of the device may need to enable location access through the location control panel, then enable access through the settings charm.", NotifyType.StatusMessage);
                }
            }
            catch (TaskCanceledException)
            {
                rootPage.NotifyUser("Task canceled", NotifyType.StatusMessage);
            }
            catch (Exception ex)
            {
                // If there are no location sensors GetGeopositionAsync()
                // will timeout -- that is acceptable.
                const int WaitTimeoutHResult = unchecked ((int)0x80070102);

                if (ex.HResult == WaitTimeoutHResult) // WAIT_TIMEOUT
                {
                    rootPage.NotifyUser("Operation accessing location sensors timed out. Possibly there are no location sensors.", NotifyType.StatusMessage);
                }
                else
                {
                    rootPage.NotifyUser(ex.ToString(), NotifyType.ErrorMessage);
                }
            }
            finally
            {
                cts = null;
            }

            // restore cursor and re-enable controls
            Window.Current.CoreWindow.PointerCursor = oldCursor;
            SetPositionToHereButton.IsEnabled       = true;
            Latitude.IsEnabled  = true;
            Longitude.IsEnabled = true;
        }