Esempio n. 1
0
        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
        }
Esempio n. 2
0
        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;
                });
            }
        }
Esempio n. 3
0
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
            Loc.Init();
#if DEBUG
            if (Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            await WindowsAppInitializer.InitializeAsync("755097ed-7bf6-41a8-81c4-6d072579a7eb", WindowsCollectors.Metadata | WindowsCollectors.PageView | WindowsCollectors.Session | WindowsCollectors.UnhandledException);

            if (AppShell == null)
            {
                AppShell = new Shell();
                App.AppShell.GoToDarkTheme(Loc.Settings.IsApplicationThemeDark);
                Loc.NavigationService.Initialize();
                ThreadUI.setDispatcher(NavigationFrame.Dispatcher);
                AppViewHelper.SetAppView();
                Window.Current.Activate();

                Loc.Main.AccountManager = new AccountManager();

                AppShell.Language = ApplicationLanguages.Languages[0];

                AppShell.NavigationFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }
            }
        }
Esempio n. 4
0
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            Loc.Init();
#if DEBUG
            if (Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            if (AppShell == null)
            {
                AppShell = new Shell();
                Loc.NavigationService.Initialize();
                ThreadUI.setDispatcher(NavigationFrame.Dispatcher);
                AppViewHelper.SetAppView();
                Window.Current.Activate();

                Loc.Main.AccountManager = new AccountManager();

                AppShell.Language = ApplicationLanguages.Languages[0];

                AppShell.NavigationFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }
            }
        }
Esempio n. 5
0
        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;
                });
            }
        }
Esempio n. 6
0
        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;
                });
            });
        }
Esempio n. 7
0
        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);
                    }
                });
            }
        }
Esempio n. 8
0
        public async Task LoadEditor(string url)
        {
            await ThreadUI.Invoke(() => IsBusy = true);

            await Task.Run(async() => await FormFetcher.GetEditor(url));

            await ThreadUI.Invoke(() =>
            {
                IsBusy = false;
            });
        }
Esempio n. 9
0
        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));
            });
        }
Esempio n. 10
0
 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);
     }));
 }
Esempio n. 11
0
        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();
                }
            });
        }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
        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);
        }
Esempio n. 14
0
        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));
        }
Esempio n. 15
0
        public async Task GetSmileys()
        {
            var smileys = await SmileyFetcher.Fetch(_smileySearch);

            await ThreadUI.Invoke(() => WikiSmileys = smileys);
        }
Esempio n. 16
0
        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");
            }
        }