public void ResetHighlight() { if (!_isHighlighted) { return; } _dispatcherService.BeginInvokeIfRequired(() => { _isHighlighted = false; AssociatedObject.SetCurrentValue(_styleDependencyProperty, _defaultStyle); _defaultStyle = null; }); }
private void OnTimerTick(object e) { _dispatcherService.BeginInvokeIfRequired(() => { _commandManager.InvalidateCommands(); }); }
private async Task SetValueAsync(Func <string> retrievalFunc, Action <string> setter) { var value = string.Empty; await TaskHelper.Run(() => value = retrievalFunc(), true); _dispatcherService.BeginInvokeIfRequired(() => setter(value)); }
public override void OnViewModelCreated(IViewModel viewModel) { base.OnViewModelCreated(viewModel); _dispatcherService.BeginInvokeIfRequired(() => { _commandManager.SubscribeToKeyboardEvents(); }); }
/// <summary> /// Notifies external classes of property changes. /// </summary> protected void NotifyChanges() { Action action = () => { OnPropertyChanged(new PropertyChangedEventArgs("Count")); OnPropertyChanged(new PropertyChangedEventArgs("Item[]")); OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); }; if (AutomaticallyDispatchChangeNotifications) { _dispatcherService.BeginInvokeIfRequired(action); } else { action(); } }
/// <summary> /// Raises the <see cref="ObservableCollection{T}.CollectionChanged" /> event, but also makes sure the event is dispatched to the UI thread. /// </summary> /// <param name="e">The <see cref="NotifyCollectionChangedEventArgs" /> instance containing the event data.</param> protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e) { if (!_suspendChangeNotifications) { if (AutomaticallyDispatchChangeNotifications) { _dispatcherService.BeginInvokeIfRequired(() => base.OnCollectionChanged(e)); } else { base.OnCollectionChanged(e); } return; } IsDirty = true; }
public virtual void Show(string status = "") { if (ShowCounter <= 0) { ShowCounter = 1; } UpdateStatus(status); _dispatcherService.BeginInvokeIfRequired(() => { if (_previousCursor == null) { _previousCursor = Mouse.OverrideCursor; } Mouse.OverrideCursor = Cursors.Wait; }); }
private void AutoDispatchIfRequired(Action action) { if (AutomaticallyDispatchEvents) { _dispatcherService.BeginInvokeIfRequired(action); } else { action(); } }
/// <summary> /// Notifies external classes of property changes. /// </summary> protected void NotifyChanges() { Action action = () => { // Create event args var eventArgsList = new List <ListChangedEventArgs>(); var suspensionContext = _suspensionContext; if (suspensionContext != null) { if (suspensionContext.NewItems.Count != 0) { eventArgsList.Add(new NotifyRangedListChangedEventArgs(NotifyRangedListChangedAction.Add, suspensionContext.NewItems, suspensionContext.NewItemIndices)); } if (suspensionContext.OldItems.Count != 0) { eventArgsList.Add(new NotifyRangedListChangedEventArgs(NotifyRangedListChangedAction.Remove, suspensionContext.OldItems, suspensionContext.OldItemIndices)); } } else { eventArgsList.Add(new NotifyListChangedEventArgs(ListChangedType.Reset)); } // Fire events foreach (var eventArgs in eventArgsList) { OnListChanged(eventArgs); } }; if (AutomaticallyDispatchChangeNotifications) { _dispatcherService.BeginInvokeIfRequired(action); } else { action(); } }
/// <summary> /// Notifies external classes of property changes. /// </summary> protected void NotifyChanges() { Action action = () => { // Create event args ListChangedEventArgs eventArgs = null; if (_suspensionContext != null && _suspensionContext.Mode == SuspensionMode.Adding) { if (_suspensionContext.NewItems.Count != 0) { eventArgs = new NotifyRangedListChangedEventArgs(NotifyRangedListChangedAction.Add, _suspensionContext.NewItems, _suspensionContext.NewItemIndices); } } else if (_suspensionContext != null && _suspensionContext.Mode == SuspensionMode.Removing) { if (_suspensionContext.OldItems.Count != 0) { eventArgs = new NotifyRangedListChangedEventArgs(NotifyRangedListChangedAction.Remove, _suspensionContext.OldItems, _suspensionContext.OldItemIndices); } } else { eventArgs = new NotifyListChangedEventArgs(ListChangedType.Reset); } // Fire events if (eventArgs != null) { OnListChanged(eventArgs); } }; if (AutomaticallyDispatchChangeNotifications) { _dispatcherService.BeginInvokeIfRequired(action); } else { action(); } }
public virtual void Hide() { Log.Debug("Hiding busy indicator"); CurrentItem = -1; ShowCounter = 0; _dispatcherService.BeginInvokeIfRequired(() => { Mouse.OverrideCursor = _previousCursor; _previousCursor = null; }); }
public void Show() { _dispatcherService.BeginInvokeIfRequired(() => { if (IsOpen) { return; } Log.Debug($"[{this}] Showing callout"); if (ShowTime > TimeSpan.Zero) { Log.Debug($"[{this}] Starting callout timer with interval of '{ShowTime}'"); _dispatcherTimer.Interval = ShowTime; _dispatcherTimer.Start(); } HasShown = true; IsOpen = true; }); }
/// <summary> /// Raises the <see cref="ObservableObject.PropertyChanged"/> event. /// <para/> /// This is the one and only method that actually raises the <see cref="ObservableObject.PropertyChanged"/> event. All other /// methods are (and should be) just overloads that eventually call this method. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.ComponentModel.PropertyChangedEventArgs"/> instance containing the event data.</param> protected override void RaisePropertyChanged(object sender, AdvancedPropertyChangedEventArgs e) { _dispatcherService.BeginInvokeIfRequired(() => base.RaisePropertyChanged(sender, e)); }