public override void Update(bool swapBuffers) { #if SILVERLIGHT if (Root.InDrawCallback) { base.Update(swapBuffers); } else { ThreadUI.Invoke(DrawingSurface.Invalidate); } #else var rs = (XnaRenderSystem)Root.Instance.RenderSystem; // access device through driver var device = _driver.XnaDevice; switch (device.GraphicsDeviceStatus) { case GraphicsDeviceStatus.Lost: Thread.Sleep(50); return; case GraphicsDeviceStatus.NotReset: break; } base.Update(swapBuffers); #endif }
public async Task SubmitEditor() { await ThreadUI.Invoke(() => { IsBusy = true; }); CurrentEditor.PrepareForSubmit(); //Required!!! var result = await HttpClientHelper.Post(CurrentEditor.SubmitUrl, CurrentEditor.Data); #warning "no feedback on submit" Debug.WriteLine(result); if (result.Length > 0) { await ThreadUI.Invoke(() => { Loc.NavigationService.GoBack(); _isBusy = false; }); await Loc.Thread.RefreshPage(CurrentEditor.Intent); } else { await ThreadUI.Invoke(() => { IsBusy = false; }); } }
public async Task SubmitEditor() { await ThreadUI.Invoke(() => { IsBusy = true; }); CurrentEditor.PrepareForSubmit(); //Required!!! var result = await HttpClientHelper.Post(CurrentEditor.SubmitUrl, CurrentEditor.Data); #warning "no feedback on submit" Debug.WriteLine(result); if (result.Length > 0) { await ThreadUI.Invoke(() => { IsBusy = false; Loc.NavigationService.GoBack(); ApplicationView.GetForCurrentView().SuppressSystemOverlays = false; }); await Loc.Topic.RefreshPage(); } else { await ThreadUI.Invoke(() => { IsBusy = false; }); } }
public override async void Execute(object parameter) { var fileOpenPicker = new FileOpenPicker(); fileOpenPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; fileOpenPicker.ViewMode = PickerViewMode.Thumbnail; fileOpenPicker.FileTypeFilter.Add(".jpg"); fileOpenPicker.FileTypeFilter.Add(".jpeg"); fileOpenPicker.FileTypeFilter.Add(".png"); fileOpenPicker.FileTypeFilter.Add(".gif"); var file = await fileOpenPicker.PickSingleFileAsync(); await Task.Run(async() => { var url = await HfrRehostHelper.Upload(file); if (string.IsNullOrEmpty(url)) { return; } await ThreadUI.Invoke(() => { Loc.Editor.UploadedPicId = url; }); }); }
async Task Initialize() { var accounts = accountDataRepository?.GetAccounts(); if (accounts != null && accounts.Any()) { Accounts = accounts; if (accounts.Count == 1) { CurrentAccount = accounts[0]; #warning "Optimistic: any account/cookies is supposed valid, proper implementation needed (cookies timeout check)" await ThreadUI.Invoke(() => { Loc.NavigationService.Navigate(View.Connect); Loc.Main.AccountManager.CurrentAccount.ConnectionErrorStatus = "Connecting"; Loc.Main.AccountManager.CurrentAccount.IsConnecting = true; }); bool success = await CurrentAccount.BeginAuthentication(false); if (success) { await ThreadUI.Invoke(() => { Loc.Main.AccountManager.CurrentAccount.IsConnected = false; Loc.NavigationService.Navigate(View.Main); }); } else { Debug.WriteLine("Login failed"); } } else { // Handle selection of one of the multi accounts } } else { // navigate to connectpage await ThreadUI.Invoke(() => { CurrentAccount = new Account(); Loc.NavigationService.Navigate(View.Connect); // Trying to detect login and password stored in RoamingSettings if (ApplicationSettingsHelper.Contains(nameof(CurrentAccount.Pseudo), false) && ApplicationSettingsHelper.Contains(nameof(CurrentAccount.Password), false)) { ToastHelper.Simple("Connexion automatique ..."); var pseudo = ApplicationSettingsHelper.ReadSettingsValue(nameof(CurrentAccount.Pseudo), false).ToString(); var password = ApplicationSettingsHelper.ReadSettingsValue(nameof(CurrentAccount.Password), false).ToString(); CurrentAccount.Pseudo = pseudo; CurrentAccount.Password = password; ConnectCommand.Execute(null); } }); } }
public async Task LoadEditor(string url) { await ThreadUI.Invoke(() => IsBusy = true); await Task.Run(async() => await FormFetcher.GetEditor(url)); await ThreadUI.Invoke(() => { IsBusy = false; }); }
public async Task LoadEditor(EditorPackage package) { await ThreadUI.Invoke(() => IsBusy = true); await Task.Run(async() => await FormFetcher.GetEditor(package)); await ThreadUI.Invoke(() => { IsBusy = false; RaisePropertyChanged(nameof(IsEditUIVisible)); }); }
public override Codec.DecodeResult Decode(Stream input) { return(ThreadUI.Invoke( delegate { var wbs = new WriteableBitmap(0, 0); wbs.SetSource(input); wbs.Invalidate(); input.Close(); return Decode(wbs); })); }
public async Task LoadEditor(EditorPackage package) { await ThreadUI.Invoke(() => IsBusy = true); await Task.Run(async() => await FormFetcher.GetEditor(package)); await ThreadUI.Invoke(() => { IsBusy = false; RaisePropertyChanged(nameof(IsEditUIVisible)); if (package.Intent == EditorIntent.MultiQuote) { Loc.NavigationService.GoBack(); } }); }
public async Task OnNavigatedTo(object parameter) { var url = parameter as string; await ThreadUI.Invoke(() => { IsBusy = false; ApplicationView.GetForCurrentView().SuppressSystemOverlays = true; }); Debug.WriteLine("EditorViewModel OnNavigatedTo " + url); if (url == "http://debug") { url = HFRUrl.Dbg_Form_QuoteSingleURL; } await LoadEditor(url); }
public async Task OnNavigatedTo(object parameter) { var editorPackage = parameter as EditorPackage; _isBusy = false; await ThreadUI.Invoke(() => { ApplicationView.GetForCurrentView().SuppressSystemOverlays = true; }); Debug.WriteLine("EditorViewModel OnNavigatedTo " + editorPackage.PostUriForm); if (editorPackage.PostUriForm == "http://debug") { editorPackage.PostUriForm = HFRUrl.Dbg_Form_QuoteSingleURL; } await LoadEditor(editorPackage); }
public async Task RefreshPage(EditorIntent editorIntent) { await ThreadUI.Invoke(() => { switch (editorIntent) { case EditorIntent.New: case EditorIntent.Quote: case EditorIntent.MultiQuote: CurrentTopic.TopicCurrentPage = CurrentTopic.TopicNbPage; break; case EditorIntent.Edit: break; default: break; } }); await Task.Run(async() => await TopicFetcher.GetPosts(CurrentTopic)); }
public async Task GetSmileys() { var smileys = await SmileyFetcher.Fetch(_smileySearch); await ThreadUI.Invoke(() => WikiSmileys = smileys); }
public override async void Execute(object parameter) { /* Connect when ENTER key is pressed */ var keyStroke = parameter as KeyRoutedEventArgs; if (keyStroke != null) { if (keyStroke.Key == Windows.System.VirtualKey.Enter) { keyStroke.Handled = true; } else { return; } } if (Loc.Main.AccountManager.Accounts.FirstOrDefault(x => x.Pseudo == Loc.Main.AccountManager.CurrentAccount.Pseudo) != null) { return; } await ThreadUI.Invoke(() => { Loc.Main.AccountManager.CurrentAccount.ConnectionErrorStatus = "Connecting"; Loc.Main.AccountManager.CurrentAccount.IsConnecting = true; }); bool success = await Loc.Main.AccountManager.CurrentAccount.BeginAuthentication(true); if (success) { Loc.Main.AccountManager.Accounts.Add(Loc.Main.AccountManager.CurrentAccount); Loc.Main.AccountManager.AddCurrentAccountInDB(); var autoConnectFromRoamingSettings = ApplicationSettingsHelper.Contains(nameof(Loc.Main.AccountManager.CurrentAccount.Pseudo), false); var md = new MessageDialog("Voulez-vous être connecté automatiquement à ce compte ?", "Juste une question"); if (!autoConnectFromRoamingSettings) { md.Commands.Add(new UICommand() { Label = "Oui", Invoked = async(command) => { await ThreadUI.Invoke(() => { Loc.Main.AccountManager.AddCurrentAccountInRoamingSettings(); }); }, }); md.Commands.Add(new UICommand() { Label = "Non", Invoked = (command) => { }, }); } await ThreadUI.Invoke(async() => { if (!autoConnectFromRoamingSettings) { await md.ShowAsync(); } Loc.Main.AccountManager.CurrentAccount.IsConnecting = false; Loc.Main.AccountManager.CurrentAccount.ConnectionErrorStatus = "Login succeeded"; Loc.NavigationService.Navigate(View.Main); }); } else { await ThreadUI.Invoke(() => { Loc.Main.AccountManager.CurrentAccount.IsConnecting = false; Loc.Main.AccountManager.CurrentAccount.ConnectionErrorStatus = "Login failed"; ToastHelper.Simple("Echec de la connexion"); }); Debug.WriteLine("Login failed"); } }