public override async void OnNavigatedTo(string parameter, NavigationMode mode, Dictionary <string, object> state) { LoadCommand.Execute(null); // register background tasks await BackgroundHelper.Register <MyUpdateTileTask>(new SystemTrigger(SystemTriggerType.TimeZoneChange, false)); }
public override void OnNavigatedTo(NavigationParameters parameters) { base.OnNavigatedTo(parameters); if (parameters.GetNavigationMode() == NavigationMode.Back) { return; } if (parameters["place"] is GeofencePlace place) { Place.ID = place.ID; Place.Radius = place.Radius; Place.Latitude = place.Latitude; Place.Longitude = place.Longitude; Edit = true; } else { Place.Radius = 300; } Title = Edit ? $"Edit {Place.ID}" : $"Add"; LoadCommand.Execute(); }
public void Init(NavObject navObject) { _path = navObject.Path; HtmlUrl = navObject.HtmlUrl; _name = navObject.Name; _gitUrl = navObject.GitUrl; _forceBinary = navObject.ForceBinary; Username = navObject.Username; Repository = navObject.Repository; Branch = navObject.Branch; TrueBranch = navObject.TrueBranch; //Create the filename var fileName = System.IO.Path.GetFileName(_path); if (fileName == null) { fileName = _path.Substring(_path.LastIndexOf('/') + 1); } //Create the temp file path Title = fileName; _editToken = Messenger.SubscribeOnMainThread <SourceEditMessage>(x => { if (x.OldSha == null || x.Update == null) { return; } _gitUrl = x.Update.Content.GitUrl; LoadCommand.Execute(true); }); }
private void UserControl_Loaded(object sender, System.Windows.RoutedEventArgs e) { if (LoadCommand != null) { LoadCommand.Execute(null); } }
public SourceViewModel(IApplicationService applicationService) { GoToSourceCommand = new ReactiveCommand(); Tags = new ReactiveList <Tag>(); Branches = new ReactiveList <Branch>(); LoadCommand.RegisterAsyncTask(_ => Load(applicationService)); this.WhenAnyValue(x => x.SelectedView).Skip(1).Subscribe(_ => LoadCommand.Execute(null)); GoToSourceCommand.OfType <Tag>().Subscribe(x => { var vm = CreateViewModel <FilesViewModel>(); vm.ProjectKey = ProjectKey; vm.RepositorySlug = RepositorySlug; vm.Branch = x.LatestChangeset; vm.Folder = x.DisplayId; ShowViewModel(vm); }); GoToSourceCommand.OfType <Branch>().Subscribe(x => { var vm = CreateViewModel <FilesViewModel>(); vm.ProjectKey = ProjectKey; vm.RepositorySlug = RepositorySlug; vm.Branch = x.LatestChangeset; vm.Folder = x.DisplayId; ShowViewModel(vm); }); }
public NotificationsViewModel() { _notifications = new FilterableCollectionViewModel <NotificationModel, NotificationsFilterModel>("Notifications"); _notifications.GroupingFunction = (n) => n.GroupBy(x => x.Repository.FullName); _notifications.Bind(x => x.Filter, () => LoadCommand.Execute(false)); this.Bind(x => x.ShownIndex, x => { if (x == 0) { _notifications.Filter = NotificationsFilterModel.CreateUnreadFilter(); } else if (x == 1) { _notifications.Filter = NotificationsFilterModel.CreateParticipatingFilter(); } else { _notifications.Filter = NotificationsFilterModel.CreateAllFilter(); } ((IMvxCommand)ReadAllCommand).RaiseCanExecuteChanged(); }); this.Bind(x => x.IsLoading, ((IMvxCommand)ReadAllCommand).RaiseCanExecuteChanged); if (_notifications.Filter.Equals(NotificationsFilterModel.CreateUnreadFilter())) { _shownIndex = 0; } else if (_notifications.Filter.Equals(NotificationsFilterModel.CreateParticipatingFilter())) { _shownIndex = 1; } else { _shownIndex = 2; } }
void scrollViewer_ScrollChanged(object sender, ScrollChangedEventArgs e) { if (!IsLazyLoad) { return; } if (LoadCommand == null) { return; } var scrollViewer = sender as ScrollViewer; if (scrollViewer == null) { return; } if (IsLoadingUp != true && scrollViewer.ScrollableHeight != 0 && scrollViewer.ScrollableHeight == scrollViewer.VerticalOffset) { LoadCommand.Execute(null); //this.UpdateLayout(); //foreach (var VARIABLE in ItemsSource) //{ //} //this.ScrollIntoView(item); } if (IsLoadingUp && scrollViewer.VerticalOffset == 0) { LoadCommand.Execute(null); } }
public void OnAppearing() { if (LoadCommand.CanExecute(null)) { LoadCommand.Execute(null); } }
public void Init() { SelectedTime = Times[0]; SelectedLanguage = _defaultLanguage; GetLanguages().FireAndForget(); this.Bind(x => x.SelectedTime, () => LoadCommand.Execute(null)); this.Bind(x => x.SelectedLanguage, () => LoadCommand.Execute(null)); }
public void RecieveInternetMessage(HasInternetMessageType empty) { HasInternet = true; if (isLoggedin == false) { LoadCommand.Execute(null); } }
public HomeViewModel() { IsBusy = true; MessagingCenter.Subscribe <LoginViewModel>( this, LoginViewModel.LogInFinishedMessage, _ => LoadCommand.Execute(null)); }
public void Init(NavObject nav) { Username = nav.Username; Repository = nav.Repository; Simple = nav.Simple; _issues = new FilterableCollectionViewModel <IssueModel, IssuesFilterModel>("IssuesViewModel:" + Username + "/" + Repository); _issues.GroupingFunction = Group; _issues.Bind(x => x.Filter).Subscribe(_ => LoadCommand.Execute(true)); _addToken = Messenger.SubscribeOnMainThread <IssueAddMessage>(x => { if (x.Issue == null || !DoesIssueBelong(x.Issue)) { return; } Issues.Items.Insert(0, x.Issue); }); _editToken = Messenger.SubscribeOnMainThread <IssueEditMessage>(x => { if (x.Issue == null || !DoesIssueBelong(x.Issue)) { return; } var item = Issues.Items.FirstOrDefault(y => y.LocalId == x.Issue.LocalId); if (item == null) { return; } var index = Issues.Items.IndexOf(item); using (Issues.DeferRefresh()) { Issues.Items.RemoveAt(index); Issues.Items.Insert(index, x.Issue); } }); _deleteToken = Messenger.SubscribeOnMainThread <IssueDeleteMessage>(x => { var find = Issues.Items.FirstOrDefault(i => i.LocalId == x.Issue.LocalId); if (find != null) { Issues.Items.Remove(find); } }); _filterToken = Messenger.SubscribeOnMainThread <IssuesFilterMessage>(x => { _issues.Filter = x.Filter; }); }
public async Task SetFragmentOpened(bool isOpened) { if (isOpened && !_isOpened && !_wasLoadedOnce) { if (_applicationSettingsService.IsFragmentAutoLoadEnabled) { LoadCommand?.Execute(null); } } _isOpened = isOpened; }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { try { if (LoadCommand != null) { LoadCommand.Execute(null); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
protected override void OnTextChanged(string oldValue, string newValue) { base.OnTextChanged(oldValue, newValue); if (IsFocused || string.IsNullOrEmpty(newValue)) { // Cancels the current execution try { cancellationTokenSource?.Cancel(); } catch (ObjectDisposedException) { Debug.WriteLine($"[{AppInfo.Name}] an error occurred while canceling the CancellationTokenSource of an LoadEditor. This is expected to occur occasionally"); } // Creates a new instance for the cancellation token cancellationTokenSource = new CancellationTokenSource(); // Executes a background operation IsBusy = true; Task.Run(async() => { // Takes the token reference that will be cancelled after the next character inserted var source = cancellationTokenSource; // Await a certain time before executing the search await Task.Delay(LoadDelay); // If the token wasn't cancelled (when another character is inserted), do the search if (!source.Token.IsCancellationRequested) { source.Dispose(); Dispatcher.BeginInvokeOnMainThread(() => { if (LoadCommandParameter == null) { LoadCommand?.Execute(newValue); } else { LoadCommand?.Execute(LoadCommandParameter); } IsBusy = false; }); } else { source.Dispose(); } }, cancellationTokenSource.Token); } }
public SourceViewModel() { _editToken = Messenger.SubscribeOnMainThread <SourceEditMessage>(x => { if (x.OldSha == null || x.Update == null) { return; } _gitUrl = x.Update.Content.GitUrl; if (LoadCommand.CanExecute(null)) { LoadCommand.Execute(true); } }); }
public SourceViewModel(IMessageService messageService) { _editToken = messageService.Listen <SourceEditMessage>(x => { if (x.OldSha == null || x.Update == null) { return; } _gitUrl = x.Update.Content.GitUrl; if (LoadCommand.CanExecute(null)) { LoadCommand.Execute(true); } }); }
public async Task <IHttpActionResult> Get(Guid id) { if (id == null) { return(NotFound()); } var command = new LoadCommand() { Id = id }; await command.Execute(); return(Ok(command.Book)); }
public void ExecuteWithOkTest() { FakeOpenFileDialogService fakeOpenFileDialogService = new FakeOpenFileDialogService(); LoadCommand loadCommand = new LoadCommand(fakeOpenFileDialogService); MainWindowViewModel mainWindowViewModel = new MainWindowViewModel(); loadCommand.MainWindowViewModel = mainWindowViewModel; fakeOpenFileDialogService.ShowDialogResult = true; loadCommand.Execute(null); Assert.AreEqual(fakeOpenFileDialogService.FileName, loadCommand.MainWindowViewModel.Filename); Assert.AreEqual(fakeOpenFileDialogService.FileContent, loadCommand.MainWindowViewModel.LogText); Assert.AreEqual(fakeOpenFileDialogService.FileContent, loadCommand.MainWindowViewModel.LastSavedText); }
public MainWindowViewModel() { DBHelper = new PostgreSQLDBHelper(); // PostgreSQL の方がつながっていなければオフラインの sqlite に切り替え。 if (!DBHelper.Connected) { DBHelper = new DatabaseHelper("Diarydb"); SwitchDBCommand.Execute(DBType.Local); } LoadCommand.Execute(); UIColors.ChangeTheme((ColorTheme)Enum.ToObject(typeof(ColorTheme), Properties.Settings.Default.ColorTheme)); }
public HomeViewModel() { IsBusy = true; // subscribe any domain here MessagingCenter.Subscribe <LogInViewModel>( this, LogInViewModel.LogInFinishedMessage, _ => LoadCommand.Execute(null)); MessagingCenter.Subscribe <SignUpViewModel>( this, SignUpViewModel.SignUpFinishedMessage, _ => LoadCommand.Execute(null)); }
public MainViewModel() { var searchPredicate = _searchSubject .Throttle(TimeSpan.FromMilliseconds(100)) .StartWith(string.Empty) .Select(GetSearchFunction); var filteredList = _dataSource.ToObservable() .Filter(searchPredicate) .Sort(SortExpressionComparer <Foo> .Ascending(f => f.Title)) .ObserveOn(Xam.Reactive.Concurrency.XamarinDispatcherScheduler.Current) .Bind(Items) .Subscribe(); LoadCommand.Execute(null); }
public LazyLoadListView() { ItemSelected += OnItemSelected; ItemAppearing += (object sender, ItemVisibilityEventArgs e) => { var items = ItemsSource as IList; if (items != null && e.Item == items[items.Count - 1]) { if (LoadCommand != null && LoadCommand.CanExecute(null)) { LoadCommand.Execute(null); } } }; }
private async void DeletePayment(Payment payment) { if (!await dialogService.ShowConfirmMessage(Strings.DeleteTitle, Strings.DeletePaymentConfirmationMessage)) { return; } if (await paymentManager.CheckForRecurringPayment(payment)) { paymentRepository.DeleteRecurring(payment); } accountRepository.RemovePaymentAmount(payment); paymentRepository.Delete(payment); LoadCommand.Execute(); }
protected virtual void OnMenuClick(MenuItem menuItem) { string filepath = GetFilepath(menuItem); if (String.IsNullOrEmpty(filepath)) { return; } if (LoadCommand == null) { return; } if (LoadCommand.CanExecute(filepath)) { LoadCommand.Execute(filepath); } }
public MyIssuesViewModel(IMessageService messageService = null) { messageService = messageService ?? GetService <IMessageService>(); _issues = new FilterableCollectionViewModel <IssueModel, MyIssuesFilterModel>("MyIssues"); _issues.GroupingFunction = Group; _issues.Bind(x => x.Filter).Subscribe(_ => LoadCommand.Execute(false)); this.Bind(x => x.SelectedFilter).Subscribe(x => { if (x == 0) { _issues.Filter = MyIssuesFilterModel.CreateOpenFilter(); } else if (x == 1) { _issues.Filter = MyIssuesFilterModel.CreateClosedFilter(); } }); _editToken = messageService.Listen <IssueEditMessage>(x => { if (x.Issue == null) { return; } var item = Issues.Items.FirstOrDefault(y => y.Number == x.Issue.Number); if (item == null) { return; } var index = Issues.Items.IndexOf(item); using (Issues.DeferRefresh()) { Issues.Items.RemoveAt(index); Issues.Items.Insert(index, x.Issue); } }); }
private async void DeletePayment(PaymentViewModel payment) { if (!await dialogService .ShowConfirmMessage(Strings.DeleteTitle, Strings.DeletePaymentConfirmationMessage)) { return; } var deletePaymentSucceded = await paymentManager.DeletePayment(payment); var deleteAccountSucceded = paymentManager.RemovePaymentAmount(payment); if (deletePaymentSucceded && deleteAccountSucceded) { settingsManager.LastDatabaseUpdate = DateTime.Now; #pragma warning disable 4014 backupManager.EnqueueBackupTask(); #pragma warning restore 4014 } LoadCommand.Execute(); }
void OnDeleteCommandExecuted(GeofencePlace place) { try { CrossGeofencing.Current.StopMonitoring( new GeofenceRegion(place.ID, new Position(place.Latitude, place.Longitude), Distance.FromMeters(place.Radius))); if (!CrossGeofencing.Current.MonitoredRegions.Any()) { MessagingCenter.Send("", "StopGeofencingService", ""); } LoadCommand.Execute(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"Error deleting geofence place: {ex.Message}"); } }
public NotificationsViewModel( IMessageService messageService = null, IApplicationService applicationService = null) { _messageService = messageService ?? GetService <IMessageService>(); _applicationService = applicationService ?? GetService <IApplicationService>(); _notifications = new FilterableCollectionViewModel <Octokit.Notification, NotificationsFilterModel>("Notifications"); _notifications.GroupingFunction = (n) => n.GroupBy(x => x.Repository.FullName); _notifications.Bind(x => x.Filter).Subscribe(_ => LoadCommand.Execute(false)); this.Bind(x => x.ShownIndex).Subscribe(x => { if (x == 0) { _notifications.Filter = NotificationsFilterModel.CreateUnreadFilter(); } else if (x == 1) { _notifications.Filter = NotificationsFilterModel.CreateParticipatingFilter(); } else { _notifications.Filter = NotificationsFilterModel.CreateAllFilter(); } ((IMvxCommand)ReadAllCommand).RaiseCanExecuteChanged(); }); this.Bind(x => x.IsLoading).Subscribe(_ => ((IMvxCommand)ReadAllCommand).RaiseCanExecuteChanged()); if (_notifications.Filter.Equals(NotificationsFilterModel.CreateUnreadFilter())) { _shownIndex = 0; } else if (_notifications.Filter.Equals(NotificationsFilterModel.CreateParticipatingFilter())) { _shownIndex = 1; } else { _shownIndex = 2; } }
private async void DeletePayment(Payment payment) { if (!await dialogService.ShowConfirmMessage(Strings.DeleteTitle, Strings.DeletePaymentConfirmationMessage)) { return; } if (await paymentManager.CheckForRecurringPayment(payment)) { paymentRepository.DeleteRecurring(payment); } bool accountSucceded = accountRepository.RemovePaymentAmount(payment); bool paymentSucceded = paymentRepository.Delete(payment); if (accountSucceded && paymentSucceded) { SettingsHelper.LastDatabaseUpdate = DateTime.Now; } LoadCommand.Execute(); }
public void Init(NavObject nav) { Username = nav.Username; Repository = nav.Repository; _issues = new FilterableCollectionViewModel <IssueModel, IssuesFilterModel>("IssuesViewModel:" + Username + "/" + Repository); _issues.GroupingFunction = Group; _issues.Bind(x => x.Filter).Subscribe(_ => LoadCommand.Execute(true)); _addToken = _messageService.Listen <IssueAddMessage>(x => { if (x.Issue == null || !DoesIssueBelong(x.Issue)) { return; } Issues.Items.Insert(0, x.Issue); }); _editToken = _messageService.Listen <IssueEditMessage>(x => { if (x.Issue == null || !DoesIssueBelong(x.Issue)) { return; } var item = Issues.Items.FirstOrDefault(y => y.Number == x.Issue.Number); if (item == null) { return; } var index = Issues.Items.IndexOf(item); using (Issues.DeferRefresh()) { Issues.Items.RemoveAt(index); Issues.Items.Insert(index, x.Issue); } }); }