예제 #1
0
 public MediaPlayerElementContentHeightGetter()
 {
     _Timer             = DispatcherQueue.GetForCurrentThread().CreateTimer();
     _Timer.IsRepeating = true;
     _Timer.Interval    = TimeSpan.FromMilliseconds(100);
     _Timer.Tick       += _Timer_Tick;
 }
예제 #2
0
        private void DeferUpdateVisualStateForPointer()
        {
            // Note: As we use only one timer for both pressed and over state, we stop this timer only if cancelled / capture lost
            //		 Other cases will be handle the "normal" way using the m_isPointerOver and m_isPressed flags.

            if (_uno_isDefferingOverState || _uno_isDefferingPressedState)
            {
                if (_uno_pointerDeferring is null)
                {
                    _uno_pointerDeferring             = Windows.System.DispatcherQueue.GetForCurrentThread().CreateTimer();
                    _uno_pointerDeferring.Interval    = TimeSpan.FromMilliseconds(200);
                    _uno_pointerDeferring.IsRepeating = false;
                    _uno_pointerDeferring.Tick       += (snd, e) =>
                    {
                        if (_uno_isDefferingOverState || _uno_isDefferingPressedState)
                        {
                            _uno_isDefferingOverState    = false;
                            _uno_isDefferingPressedState = false;
                            UpdateVisualStateForPointer();
                        }
                    };
                }

                if (!_uno_pointerDeferring.IsRunning)
                {
                    _uno_pointerDeferring.Start();
                }
            }
        }
예제 #3
0
                public InertiaProcessor(Manipulation owner, Point position, ManipulationDelta cumulative, ManipulationVelocities velocities)
                {
                    _owner       = owner;
                    _position0   = position;
                    _cumulative0 = cumulative;
                    _velocities0 = velocities;

                    _isTranslateInertiaXEnabled = _owner._isTranslateXEnabled &&
                                                  _owner._settings.HasFlag(Input.GestureSettings.ManipulationTranslateInertia) &&
                                                  Abs(velocities.Linear.X) > _owner._inertiaThresholds.TranslateX;
                    _isTranslateInertiaYEnabled = _owner._isTranslateYEnabled &&
                                                  _owner._settings.HasFlag(Input.GestureSettings.ManipulationTranslateInertia) &&
                                                  Abs(velocities.Linear.Y) > _owner._inertiaThresholds.TranslateY;
                    _isRotateInertiaEnabled = _owner._isRotateEnabled &&
                                              _owner._settings.HasFlag(Input.GestureSettings.ManipulationRotateInertia) &&
                                              Abs(velocities.Angular) > _owner._inertiaThresholds.Rotate;
                    _isScaleInertiaEnabled = _owner._isScaleEnabled &&
                                             _owner._settings.HasFlag(Input.GestureSettings.ManipulationScaleInertia) &&
                                             Abs(velocities.Expansion) > _owner._inertiaThresholds.Expansion;

                    global::System.Diagnostics.Debug.Assert(_isTranslateInertiaXEnabled || _isTranslateInertiaYEnabled || _isRotateInertiaEnabled || _isScaleInertiaEnabled);

                    // For better experience, as soon inertia kicked-in on an axis, we bypass threshold on the second axis.
                    _isTranslateInertiaXEnabled |= _isTranslateInertiaYEnabled && _owner._isTranslateXEnabled;
                    _isTranslateInertiaYEnabled |= _isTranslateInertiaXEnabled && _owner._isTranslateYEnabled;

                    _timer             = DispatcherQueue.GetForCurrentThread().CreateTimer();
                    _timer.Interval    = TimeSpan.FromMilliseconds(1000d / _framesPerSecond);
                    _timer.IsRepeating = true;
                    _timer.Tick       += (snd, e) => Process(snd.LastTickElapsed.TotalMilliseconds);
                }
        /// <summary>
        /// <para>Used to debounce (rate-limit) an event.  The action will be postponed and executed after the interval has elapsed.  At the end of the interval, the function will be called with the arguments that were passed most recently to the debounced function.</para>
        /// <para>Use this method to control the timer instead of calling Start/Interval/Stop manually.</para>
        /// <para>A scheduled debounce can still be stopped by calling the stop method on the timer instance.</para>
        /// <para>Each timer can only have one debounced function limited at a time.</para>
        /// </summary>
        /// <param name="timer">Timer instance, only one debounced function can be used per timer.</param>
        /// <param name="action">Action to execute at the end of the interval.</param>
        /// <param name="interval">Interval to wait before executing the action.</param>
        /// <param name="immediate">Determines if the action execute on the leading edge instead of trailing edge.</param>
        /// <example>
        /// <code>
        /// private DispatcherQueueTimer _typeTimer = DispatcherQueue.GetForCurrentThread().CreateTimer();
        ///
        /// _typeTimer.Debounce(async () =>
        ///     {
        ///         // Only executes this code after 0.3 seconds have elapsed since last trigger.
        ///     }, TimeSpan.FromSeconds(0.3));
        /// </code>
        /// </example>
        public static void Debounce(this DispatcherQueueTimer timer, Action action, TimeSpan interval, bool immediate = false)
        {
            // Check and stop any existing timer
            var timeout = timer.IsRunning;

            if (timeout)
            {
                timer.Stop();
            }

            // Reset timer parameters
            timer.Tick    -= Timer_Tick;
            timer.Interval = interval;

            if (immediate)
            {
                // If we're in immediate mode then we only execute if the timer wasn't running beforehand
                if (!timeout)
                {
                    action.Invoke();
                }
            }
            else
            {
                // If we're not in immediate mode, then we'll execute when the current timer expires.
                timer.Tick += Timer_Tick;

                // Store/Update function
                _debounceInstances.AddOrUpdate(timer, action, (k, v) => action);
            }

            // Start the timer to keep track of the last call here.
            timer.Start();
        }
예제 #5
0
 public PointerCursolAutoHideBehavior()
 {
     _AutoHideTimer             = DispatcherQueue.GetForCurrentThread().CreateTimer();
     _AutoHideTimer.Tick       += AutoHideTimer_Tick;
     _AutoHideTimer.IsRepeating = false;
     _DefaultCursor             = Window.Current.CoreWindow.PointerCursor;
 }
        private void Start()
        {
            _currentIndex = 0;
            var currentItem = GetCurrent();

            if (_currentElement != null)
            {
                _currentElement.DataContext = currentItem;
            }

            if (_nextElement != null)
            {
                _nextElement.DataContext = GetNext();
            }

            if (currentItem == null)
            {
                _currentIndex = -1;
                _timer?.Stop();
                return;
            }

            if (_timer == null)
            {
                _timer          = DispatcherQueue.GetForCurrentThread().CreateTimer();
                _timer.Interval = GetTileDuration();
                _timer.Tick    += Timer_Tick;
            }

            _timer.Start();
            _suppressFlipOnSet = true;
            CurrentItem        = currentItem;
            _suppressFlipOnSet = false;
        }
예제 #7
0
        public ColumnViewBase() : base()
        {
            this.InitializeComponent();
            CurrentColumn = this;
            var selectionRectangle = RectangleSelection.Create(FileList, SelectionRectangle, FileList_SelectionChanged);

            tapDebounceTimer = DispatcherQueue.GetForCurrentThread().CreateTimer();
        }
 public RectangleSelection_ListViewBase(ListViewBase uiElement, Rectangle selectionRectangle, SelectionChangedEventHandler selectionChanged = null)
 {
     this.uiElement          = uiElement;
     this.selectionRectangle = selectionRectangle;
     this.selectionChanged   = selectionChanged;
     itemsPosition           = new Dictionary <object, System.Drawing.Rectangle>();
     timer = DispatcherQueue.GetForCurrentThread().CreateTimer();
     InitEvents(null, null);
 }
        public MainPage()
        {
            this.InitializeComponent();

            _timer          = DispatcherQueue.GetForCurrentThread().CreateTimer();
            _timer.Interval = TimeSpan.FromSeconds(1);

            _timer.Tick += _timer_Tick;
            _timer.Start();
        }
        private void Start()
        {
            if (updateTimer == null)
            {
                updateTimer       = DispatcherQueue.GetForCurrentThread().CreateTimer();
                updateTimer.Tick += UpdateTimer_Tick;
            }

            updateTimer.Start();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="InAppNotification"/> class.
        /// </summary>
        public InAppNotification()
        {
            DefaultStyleKey = typeof(InAppNotification);

            _dispatcherQueue    = DispatcherQueue.GetForCurrentThread();
            _dismissTimer       = _dispatcherQueue.CreateTimer();
            _dismissTimer.Tick += DismissTimer_Tick;

            _stackedNotificationOptions = new List <NotificationOptions>();
        }
예제 #12
0
 private void StartHoldingTimer()
 {
     if (NeedsHoldingTimer())
     {
         _holdingTimer          = DispatcherQueue.GetForCurrentThread().CreateTimer();
         _holdingTimer.Interval = TimeSpan.FromTicks(HoldMinDelayTicks);
         _holdingTimer.State    = this;
         _holdingTimer.Tick    += OnHoldingTimerTick;
         _holdingTimer.Start();
     }
 }
예제 #13
0
        public GenericFileBrowser2()
            : base()
        {
            InitializeComponent();
            this.DataContext = this;

            var selectionRectangle = RectangleSelection.Create(FileList, SelectionRectangle, FileList_SelectionChanged);

            selectionRectangle.SelectionEnded += SelectionRectangle_SelectionEnded;
            renameDoubleClickTimer             = DispatcherQueue.GetForCurrentThread().CreateTimer();
        }
예제 #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PeoplePicker"/> class.
        /// </summary>
        public PeoplePicker()
        {
            this.DefaultStyleKey = typeof(PeoplePicker);

            SuggestedItemsSource = new ObservableCollection <Person>();

            TextChanged     += TokenBox_TextChanged;
            TokenItemAdding += TokenBox_TokenItemTokenItemAdding;

            _typeTimer = DispatcherQueue.GetForCurrentThread().CreateTimer();
        }
예제 #15
0
        public ColumnViewBrowser() : base()
        {
            this.InitializeComponent();
            ColumnViewBrowser1                      = this;
            ColumnViewBase.ItemInvoked             += ColumnViewBase_ItemInvoked;
            ColumnViewBase.UnFocusPreviousListView += ColumnViewBase_UnFocusPreviousListView;
            ColumnViewBase.DismissColumn           += ColumnViewBase_DismissColumn;
            //this.DataContext = this;
            var selectionRectangle = RectangleSelection.Create(FileList, SelectionRectangle, FileList_SelectionChanged);

            tapDebounceTimer = DispatcherQueue.GetForCurrentThread().CreateTimer();
        }
예제 #16
0
        public static void Run(this DispatcherQueueTimer timer, bool restart = false)
        {
            if (restart)
            {
                timer.Stop();
            }

            if (!timer.IsRunning)
            {
                timer.Start();
            }
        }
예제 #17
0
        public GenericFileBrowser()
            : base()
        {
            InitializeComponent();

            var selectionRectangle = RectangleSelection.Create(AllView, SelectionRectangle, AllView_SelectionChanged);

            selectionRectangle.SelectionStarted += SelectionRectangle_SelectionStarted;
            selectionRectangle.SelectionEnded   += SelectionRectangle_SelectionEnded;
            AllView.PointerCaptureLost          += AllView_ItemPress;

            tapDebounceTimer = DispatcherQueue.GetForCurrentThread().CreateTimer();
        }
예제 #18
0
        private void InitializeAnimation()
        {
            if (_timerAnimation == null)
            {
                _timerAnimation = DispatcherQueue.GetForCurrentThread().CreateTimer();
            }
            else
            {
                _timerAnimation.Stop();
            }

            _timerAnimation.Interval = TimeSpan.FromMilliseconds(AnimationDuration);
            _timerAnimation.Tick    += Timer_Tick;
        }
        private void _timer_Tick(DispatcherQueueTimer sender, object args)
        {
            var now = DateTime.Now;

            txtTime.Text = now.ToString("HH:mm:ss");

            secondRotateTransform.Angle = now.Second * 6;
            minuteRotateTransform.Angle = now.Minute * 6;

            var       currentHoursInMinutes = (now.Hour % 12) * 60 + now.Minute;
            const int minutesPerRound       = 12 * 60;

            hourRotateTransform.Angle = ((double)(currentHoursInMinutes - minutesPerRound) / minutesPerRound) * 360;
        }
예제 #20
0
        public BaseLayout()
        {
            ItemManipulationModel = new ItemManipulationModel();

            HookEvents();

            jumpTimer          = new DispatcherTimer();
            jumpTimer.Interval = TimeSpan.FromSeconds(0.8);
            jumpTimer.Tick    += JumpTimer_Tick;

            SelectedItemsPropertiesViewModel = new SelectedItemsPropertiesViewModel(this);
            DirectoryPropertiesViewModel     = new DirectoryPropertiesViewModel();

            // QuickLook Integration
            ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
            var isQuickLookIntegrationEnabled      = localSettings.Values["quicklook_enabled"];

            if (isQuickLookIntegrationEnabled != null && isQuickLookIntegrationEnabled.Equals(true))
            {
                App.InteractionViewModel.IsQuickLookEnabled = true;
            }

            dragOverTimer = DispatcherQueue.GetForCurrentThread().CreateTimer();
        }
예제 #21
0
 public TickRunnable(DispatcherQueueTimer timer)
 {
     _timer = timer;
 }
예제 #22
0
 private static void OnHoldingTimerTick(DispatcherQueueTimer timer, object _)
 {
     timer.Stop();
     ((Gesture)timer.State).TryUpdateHolding(timeElapsed: true);
 }
예제 #23
0
 public DispatcherTimer(DispatcherQueueTimer timer)
 {
     _timer = timer;
 }
예제 #24
0
 private static void RunNextFrame(DispatcherQueueTimer timer, object state)
 => ((KeyFrameScheduler <TValue>)timer.State).RunNextFrame();
예제 #25
0
 private void StopHoldingTimer()
 {
     _holdingTimer?.Stop();
     _holdingTimer = null;
 }
        public MainPage()
        {
            this.InitializeComponent();

            var textBoxCandidates = this.FindName("candidateBox") as TextBox;

            textBoxCandidates.IsEnabled = false;

            _coreWindow                    = CoreWindow.GetForCurrentThread();
            _coreWindow.KeyDown           += CoreWindow_KeyDown;
            _coreWindow.CharacterReceived += CoreWindow_CharacterReceived;
            _coreWindow.Activated         += _coreWindow_Activated;

            // Create a CoreTextEditContext for our custom edit control.
            CoreTextServicesManager manager = CoreTextServicesManager.GetForCurrentView();

            _editContext = manager.CreateEditContext();

            // Get the Input Pane so we can programmatically hide and show it.
            _inputPane          = InputPane.GetForCurrentView();
            _inputPane.Showing += (o, e) => _virtualKeyboardHeight = (int)e.OccludedRect.Height;
            _inputPane.Hiding  += (o, e) => _virtualKeyboardHeight = 0;

            // For demonstration purposes, this sample sets the Input Pane display policy to Manual
            // so that it can manually show the software keyboard when the control gains focus and
            // dismiss it when the control loses focus. If you leave the policy as Automatic, then
            // the system will hide and show the Input Pane for you. Note that on Desktop, you will
            // need to implement the UIA text pattern to get expected automatic behavior.
            _editContext.InputPaneDisplayPolicy = CoreTextInputPaneDisplayPolicy.Manual;

            // Set the input scope to Text because this text box is for any text.
            // This also informs software keyboards to show their regular
            // text entry layout.  There are many other input scopes and each will
            // inform a keyboard layout and text behavior.
            _editContext.InputScope = CoreTextInputScope.Text;

            // The system raises this event to request a specific range of text.
            _editContext.TextRequested += EditContext_TextRequested;

            // The system raises this event to request the current selection.
            _editContext.SelectionRequested += EditContext_SelectionRequested;

            // The system raises this event when it wants the edit control to remove focus.
            _editContext.FocusRemoved += EditContext_FocusRemoved;

            // The system raises this event to update text in the edit control.
            _editContext.TextUpdating += EditContext_TextUpdating;

            // The system raises this event to change the selection in the edit control.
            _editContext.SelectionUpdating += EditContext_SelectionUpdating;

            // The system raises this event to request layout information.
            // This is used to help choose a position for the IME candidate window.
            _editContext.LayoutRequested += EditContext_LayoutRequested;

            // The system raises this event to notify the edit control
            // that the string composition has started.
            _editContext.CompositionStarted += EditContext_CompositionStarted;

            // The system raises this event to notify the edit control
            // that the string composition is finished.
            _editContext.CompositionCompleted += EditContext_CompositionCompleted;

            // The system raises this event when the NotifyFocusLeave operation has
            // completed. Our sample does not use this event.
            // _editContext.NotifyFocusLeaveCompleted += EditContext_NotifyFocusLeaveCompleted;

            _timer             = _coreWindow.DispatcherQueue.CreateTimer();
            _timer.Interval    = new TimeSpan(0, 0, 0, 0, 10);
            _timer.IsRepeating = false;
            _timer.Tick       += (o, e) =>
            {
                //Debug.WriteLine("Result text: {0}", (object)_lastResultText);
                foreach (var c in _lastResultText)
                {
                    OnTextInput(c);
                }
            };
        }