Пример #1
0
 public void RaiseCanExecuteChanged()
 {
     if (CanExecuteChanged != null)
     {
         SmartDispatcher.BeginInvoke(() => CanExecuteChanged(this, new EventArgs()));
     }
 }
Пример #2
0
        private void ItemClicked(object s, EventArgs ea)
        {
            SystemMessageItemControl c = s as SystemMessageItemControl;

            currentSelectedNumber = (int)c.Tag;
            SmartDispatcher.BeginInvoke(UpdateCurrentMessageText);
        }
Пример #3
0
 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();
                }
            });
        }
Пример #5
0
        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);
        }
Пример #6
0
        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);
            }
        }
Пример #7
0
 private void mnuAbout_Click(object sender, EventArgs e)
 {
     SmartDispatcher.BeginInvoke(() =>
     {
         NavigationService.Navigate(new Uri("/YourLastAboutDialog;component/AboutPage.xaml", UriKind.Relative));
     });
 }
Пример #8
0
 public void LoadTelemetry(ICollection <Telemetry> telemetry)
 {
     SmartDispatcher.BeginInvoke(() =>
     {
         this.profileChart.LoadTelemetry(telemetry);
     });
 }
Пример #9
0
        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);
            }
        }
Пример #10
0
        /// <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);
                }
            });
        }
Пример #12
0
 private void DisplayEmptyView()
 {
     SmartDispatcher.BeginInvoke(() =>
     {
         stackPanelMessageItems.Children.Clear();
         textBlockMessageText.Text = String.Empty;
     });
 }
Пример #13
0
 private void NavigateInternal(Uri path)
 {
     SmartDispatcher.BeginInvoke(() =>
     {
         Debug.WriteLine("NavigationService::Navigating to {0}", path);
         PlatformNavigationService.Navigate(path);
     });
 }
Пример #14
0
        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();
         }
     });
 }
Пример #16
0
 private void PivotLayout_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     SmartDispatcher.BeginInvoke(() =>
     {
         if (ApplicationBar != null && (this.Orientation & PageOrientation.Landscape) != PageOrientation.Landscape)
         {
             ApplicationBar.IsVisible = (PivotLayout.SelectedItem == WeatherPivotItem);
         }
     });
 }
Пример #17
0
 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()));
         }
     });
 }
Пример #19
0
        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);
                }
            });
        }
Пример #20
0
        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));
                });
            }
        }
Пример #21
0
        public virtual void FirePropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = this.PropertyChanged;

            if (handler != null)
            {
                try
                {
                    SmartDispatcher.BeginInvoke(() => handler(this, new PropertyChangedEventArgs(propertyName)));
                }
                catch
                {
                }
            }
        }
Пример #22
0
        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;
                    }
                }
            });
        }
Пример #23
0
        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();
         }
     });
 }
Пример #25
0
 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
         }));
     }
 }
Пример #27
0
        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);
        }
Пример #28
0
        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);
            }
        }
Пример #29
0
        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;
                });
            }
        }
Пример #30
0
        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);
                            }
                        });
                    });
                });
            });
        }