public void RaiseCanExecuteChanged() { if (CanExecuteChanged != null) { SmartDispatcher.BeginInvoke(() => CanExecuteChanged(this, new EventArgs())); } }
private void ItemClicked(object s, EventArgs ea) { SystemMessageItemControl c = s as SystemMessageItemControl; currentSelectedNumber = (int)c.Tag; SmartDispatcher.BeginInvoke(UpdateCurrentMessageText); }
private void ViewModelOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs) { if (propertyChangedEventArgs.PropertyName == "IsSearchBoxVisible") { Scheduler.Default.Schedule(TimeSpan.FromMilliseconds(200), () => SmartDispatcher.BeginInvoke(SetFocus)); } }
private void UpdateAppBar() { SmartDispatcher.BeginInvoke(() => { switch (FavoritedState) { case FavoritedState.Unknown: break; case FavoritedState.Me: AppbarButtons.Remove(_favoriteAppbarButton); AppbarButtons.Remove(_unfavoriteAppbarButton); break; case FavoritedState.Favorited: AppbarButtons.Remove(_favoriteAppbarButton); AppbarButtons.Add(_unfavoriteAppbarButton); break; case FavoritedState.NotFavorited: AppbarButtons.Remove(_unfavoriteAppbarButton); AppbarButtons.Add(_favoriteAppbarButton); break; default: throw new ArgumentOutOfRangeException(); } }); }
protected override void OnNavigatedTo(NavigationEventArgs e) { SmartDispatcher.BeginInvoke(() => { if (ApplicationBar == null) { BuildApplicationBar(); } else { ApplicationBar.IsVisible = true; } }); SmartDispatcher.BeginInvoke(() => { var postalCode = NavigationContext.TryGetKey("PostalCode"); var country = NavigationContext.TryGetStringKey("Country"); if (postalCode.HasValue && string.IsNullOrEmpty(country) == false) { ViewModel.LoadCity(postalCode.Value, country); } }); base.OnNavigatedTo(e); }
private void Save(object arg) { if (Template.IsChanged) { IsBusy = true; try { var service = serviceLocator.GetInstance <ITrainingSetTemplateService>(); service.TrainingSetTemplateSaved += (sender, e) => { switch (e.Value.Status) { case SaveTemplateStatus.Success: if (ApplicationUser.CurrentUser.Templates.Contains(e.Value.SavedTemplate)) { SmartDispatcher.BeginInvoke(() => { var list = ApplicationUser.CurrentUser.Templates as ObservableCollection <TrainingSetTemplate>; var index = list.IndexOf(e.Value.SavedTemplate); list.RemoveAt(index); list.Insert(index, e.Value.SavedTemplate); shell.RemoveFromLayoutRoot(View as UIElement); }); } else { SmartDispatcher.BeginInvoke(() => { ApplicationUser.CurrentUser.Templates.Add(e.Value.SavedTemplate); shell.RemoveFromLayoutRoot(View as UIElement); }); } break; case SaveTemplateStatus.Error: dialogFacade.Alert(MyLibraryResources.ErrorSavingTemplate); break; default: break; } IsBusy = false; }; service.TrainingSetTemplateSaveError += (sender, e) => { IsBusy = false; }; service.SaveTemplate(Template); } catch (Exception ex) { dialogFacade.Alert(MyLibraryResources.ErrorSavingTemplate); IsBusy = false; } } else { shell.RemoveFromLayoutRoot(View as UIElement); } }
private void mnuAbout_Click(object sender, EventArgs e) { SmartDispatcher.BeginInvoke(() => { NavigationService.Navigate(new Uri("/YourLastAboutDialog;component/AboutPage.xaml", UriKind.Relative)); }); }
public void LoadTelemetry(ICollection <Telemetry> telemetry) { SmartDispatcher.BeginInvoke(() => { this.profileChart.LoadTelemetry(telemetry); }); }
private void LoadTextAnimation(FrameworkElement animation, TimeSpan duration) { Grid.SetColumnSpan(animation, 3); Grid.SetRowSpan(animation, 3); animation.HorizontalAlignment = HorizontalAlignment.Center; animation.VerticalAlignment = VerticalAlignment.Center; animation.Visibility = Visibility.Visible; playerGrid.Children.Add(animation); var startAnimation = animation.Resources["InTransition"] as Storyboard; if (startAnimation != null) { startAnimation.Begin(); ThreadPool.QueueUserWorkItem((_animation) => { Thread.Sleep(Convert.ToInt32(duration.TotalMilliseconds)); SmartDispatcher.BeginInvoke(() => { var stopAnimation = animation.Resources["OutTransition"] as Storyboard; stopAnimation.Begin(); playerGrid.Children.Remove(animation); }); }, animation); } }
/// <summary> /// Notify any listeners that the property value has changed. /// </summary> /// <param name="propertyName">The property name.</param> protected void NotifyPropertyChanged(string propertyName) { if (string.IsNullOrEmpty(propertyName)) { throw new ArgumentException("PropertyName cannot be empty or null."); } PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { PropertyChangedEventArgs args; if (!_argumentInstances.TryGetValue(propertyName, out args)) { args = new PropertyChangedEventArgs(propertyName); _argumentInstances[propertyName] = args; } // Fire the change event. The smart dispatcher will directly // invoke the handler if this change happened on the UI thread, // otherwise it is sent to the proper dispatcher. SmartDispatcher.BeginInvoke(delegate { handler(this, args); }); } }
void ReadCallback(IAsyncResult asynchronousResult) { try { HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState; HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult); ImageCacheService.SaveImage(response.GetResponseStream()); } catch (Exception e) { SmartDispatcher.BeginInvoke(delegate { if (ReadError != null) { ReadError(this, null); } }); } SmartDispatcher.BeginInvoke(delegate { if (ReadFinished != null) { ReadFinished(this, null); } }); }
private void DisplayEmptyView() { SmartDispatcher.BeginInvoke(() => { stackPanelMessageItems.Children.Clear(); textBlockMessageText.Text = String.Empty; }); }
private void NavigateInternal(Uri path) { SmartDispatcher.BeginInvoke(() => { Debug.WriteLine("NavigationService::Navigating to {0}", path); PlatformNavigationService.Navigate(path); }); }
protected virtual void RaisePropertyChanged(string propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { SmartDispatcher.BeginInvoke(() => handler(this, new PropertyChangedEventArgs(propertyName))); } }
private void UpdateTelemetryAt(object arg) { SmartDispatcher.BeginInvoke(() => { if (queue.Any() && queue.Peek().TimePosition <= PlayerPosition) { CurrentTelemetry = queue.Dequeue(); } }); }
private void PivotLayout_SelectionChanged(object sender, SelectionChangedEventArgs e) { SmartDispatcher.BeginInvoke(() => { if (ApplicationBar != null && (this.Orientation & PageOrientation.Landscape) != PageOrientation.Landscape) { ApplicationBar.IsVisible = (PivotLayout.SelectedItem == WeatherPivotItem); } }); }
internal void NotifyPropertyChanged(String propertyName) { SmartDispatcher.BeginInvoke(() => { PropertyChangedEventHandler handler = _PropertyChanged; if (null != handler) { handler(this, new PropertyChangedEventArgs(propertyName)); } }); }
private void CheckForTextToDisplayAt(object arg) { SmartDispatcher.BeginInvoke(() => { if (textQueue.Count > 0 && textQueue.Peek().StartTime <= PlayerPosition) { LoadVideoText(textQueue.Dequeue()); //SmartDispatcher.BeginInvoke(() => LoadVideoText(textQueue.Dequeue())); } }); }
void ReadCallback(IAsyncResult asynchronousResult) { try { HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState; HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult); using (StreamReader streamReader1 = new StreamReader(response.GetResponseStream())) { string resultString = streamReader1.ReadToEnd(); System.Xml.Linq.XElement MyXElement = System.Xml.Linq.XElement.Parse(resultString); DataModel = new RijksDataModel { Exension = MyXElement.Element("config").Elements("image").Attributes("extension").First().Value, Path = MyXElement.Element("config").Elements("image").Attributes("path").First().Value, ArtistId = MyXElement.Element("artobject").Elements("artist").Attributes("id").First().Value, ArtistName = MyXElement.Element("artobject").Elements("artist").First().Value, CreationDate = MyXElement.Element("artobject").Elements("creationdate").Attributes("value").First().Value, Description = MyXElement.Element("artobject").Elements("description").First().Value, Link = MyXElement.Element("artobject").Elements("link").Attributes("href").First().Value, ObjectId = MyXElement.Element("artobject").Attributes("id").First().Value, Title = MyXElement.Element("artobject").Elements("title").First().Value.ToLower(), ReadDate = DateTime.Now }; DataModel.Description = DataModel.Description.Replace("\r", string.Empty).Replace("\n", string.Empty); } } catch (Exception e) { SmartDispatcher.BeginInvoke(delegate { if (ReadError != null) { ReadError(this, null); } }); } SmartDispatcher.BeginInvoke(delegate { if (ReadFinished != null) { ReadFinished(this.DataModel); } }); }
protected virtual void RaisePropertyChanged(string propertyName) { PropertyChangedEventHandler handler = this.PropertyChanged; if (handler != null) { // Fire the change event. The smart dispatcher will directly // invoke the handler if this change happened on the UI thread, // otherwise it is sent to the proper dispatcher. SmartDispatcher.BeginInvoke(delegate { handler(this, new PropertyChangedEventArgs(propertyName)); }); } }
public virtual void FirePropertyChanged(string propertyName) { PropertyChangedEventHandler handler = this.PropertyChanged; if (handler != null) { try { SmartDispatcher.BeginInvoke(() => handler(this, new PropertyChangedEventArgs(propertyName))); } catch { } } }
private void RemoveTemplate(object arg) { dialogFacade.Confirm(MyLibraryResources.RemoveTemplateConfirmation, result => { if (result) { var service = serviceLocator.GetInstance <ITrainingSetTemplateService>(); service.TrainingSetTemplateRemoved += (sender, e) => { switch (e.Value.Status) { case RemoveTemplateStatus.Success: SmartDispatcher.BeginInvoke(() => { ApplicationUser.CurrentUser.Templates.Remove(Template); this.Template = null; this.IsBusy = false; OnTemplateRemoved(); }); break; case RemoveTemplateStatus.Error: this.IsBusy = false; dialogFacade.Alert(MyLibraryResources.ErrorRemovingTemplate); break; default: break; } }; service.TrainingSetTemplateRemoveError += (sender, e) => { throw e.Value; }; this.IsBusy = true; try { service.RemoveTemplate(Template); } catch { IsBusy = false; throw; } } }); }
public void ShowToast(string title, string message) { SmartDispatcher.BeginInvoke(() => { var toast = new ToastPrompt { Title = title, Message = message, TextWrapping = TextWrapping.Wrap, Background = new SolidColorBrush(Color.FromArgb(255, 76, 109, 167)), TextOrientation = System.Windows.Controls.Orientation.Vertical, ImageSource = new BitmapImage(new Uri("/Resources/Images/notification_logo.png", UriKind.Relative)) }; toast.Show(); }); }
private void Stop(object arg) { SmartDispatcher.BeginInvoke(View.Pause); DialogFacade.Confirm(Resources.PlayerResources.ConfirmStopVideo, (result) => { if (result) { eventAggregator.GetEvent <VideoStoppedEvent>().Publish(Video); Stop(); } else { View.Play(); } }); }
public void OnCancelled(Action cancelled) { if (Interval.IsChanged) { dialogFacade.Confirm(MyLibraryResources.IntervalChangedCancelConfirmation, (result) => { if (result) { Interval.CancelEdit(); SmartDispatcher.BeginInvoke(cancelled); } }); } else { Interval.CancelEdit(); SmartDispatcher.BeginInvoke(cancelled); } }
private void Countdown(object arg) { counter++; if (counter > 5 || paused) { paused = false; var play = arg as Action; counter = 0; timer.Change(Timeout.Infinite, Timeout.Infinite); SmartDispatcher.BeginInvoke(() => play()); } else { SmartDispatcher.BeginInvoke(() => View.AddTextAnimation(new VideoText() { MainText = (countFrom - counter).ToString(), Duration = TimeSpan.FromSeconds(1), Animation = Infrastructure.Enums.VideoTextAnimations.ZoomCenter })); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { var previousPage = NavigationService.BackStack.LastOrDefault(); if (previousPage != null && previousPage.Source.OriginalString == AppSettings.MainPageBaseAddress) { NavigationService.RemoveBackEntry(); } SmartDispatcher.BeginInvoke(() => { if (DataContext == null) { DataContext = new MainPageViewModel(); } if (ViewModel != null && ViewModel.IsInitialized == false) { ViewModel.Initialize(); } if (ApplicationBar == null) { BuildApplicationBar(); } }); SmartDispatcher.BeginInvoke(() => { var postalCode = NavigationContext.TryGetStringKey("PostalCode"); var country = NavigationContext.TryGetStringKey("Country"); if (string.IsNullOrEmpty(postalCode) == false && string.IsNullOrEmpty(country) == false) { ViewModel.ResolveLocation(postalCode, country); } }); base.OnNavigatedTo(e); }
private void ProcessUploadedFile(object sender, DoWorkEventArgs doWorkEventArgs) { FileStream stream = doWorkEventArgs.Argument as FileStream; try { PortableDataFactory factory = new PortableDataFactory(stream); importedData = factory.Create(); PortableDataImporter importer = new PortableDataImporter( OnSuccessfullyImported, OnError); importer.UnsupportedVinsFound += OnUnsupportedVinsFound; importer.CheckAndImport(importedData); } catch (Exception) { stream.Close(); SmartDispatcher.BeginInvoke(NotifyAboutFailure); } }
private void LoadData() { string id; if (NavigationContext.QueryString.TryGetValue("id", out id)) { SystemTray.ProgressIndicator.IsVisible = true; CurrentVenue = MainPage.Venues[Convert.ToInt32(id)]; SmartDispatcher.BeginInvoke(() => { this.txtName.Text = CurrentVenue.venue.name.ToUpper(); isLoaded = true; ToggleLoadingText(); ToggleEmptyText(); SystemTray.ProgressIndicator.IsVisible = false; }); } }
private void LoadNewsFeed() { NewsProvider.GetVideos((videos, exception) => { SmartDispatcher.BeginInvoke(() => { NewsItems.Clear(); if (videos.Count >= 2) { NewsItems.Add(new NewsItem() { Title = Properties.Resources.WebTV_DMI, WebTVItem = videos.FirstOrDefault(v => v.Category == "DMI"), }); NewsItems.Add(new NewsItem() { Title = Properties.Resources.WebTV_3D, WebTVItem = videos.FirstOrDefault(v => v.Category == "3D"), }); } NewsProvider.GetNewsItems((items, e) => { SmartDispatcher.BeginInvoke(() => { foreach (var item in items) { NewsItems.Add(item); } }); }); }); }); }