static void InvokeOnNavigationAwareElements(IEnumerable <object> items, Action <INavigationAware> invocation) { foreach (var item in items) { MVVMHelper.ViewAndViewModelAction(item, invocation); } }
private async Task AppearingCommandExecute() { if (IsBusy) { return; } IsBusy = true; if (string.Empty == GlobalSetting.Instance.CurrentUserId) { await MVVMHelper.CompanyChoiseView(); return; } if (_isFirstLoad) { await LoadPersonalData(); _isFirstLoad = false; } IsBusy = false; }
static bool PersistInHistory(object view) { bool persist = true; MVVMHelper.ViewAndViewModelAction <IJournalAware>(view, ija => { persist &= ija.PersistInHistory(); }); return(persist); }
private async Task LoadSchedule() { if (IsBusy) { return; } IsBusy = true; if (SelectedMonths == DateTime.MinValue) { IsBusy = false; return; } var serviceResult = await service.GetSheduleAsync(DateTime.Now); if (!serviceResult.Contune) { System.Diagnostics.Debug.WriteLine(serviceResult.Exception); await MVVMHelper.DisplayAlert("Сообщение", "Произошла ошибка получчения данных. Попробуйте снова минут через 5"); IsBusy = false; return; } IsBusy = false; }
public WorkPlaceViewModelBase(MainViewModel mainModel, string displayName) { DisplayName = displayName; _mainModel = mainModel; CloseCommand = new RelayCommand(Close); MVVMHelper.SetTargetName(this, "DocumentHost"); }
protected override void OnStart() { if (GlobalSetting.Instance.IsAuthenticated) { MVVMHelper.WorkSpacePage(); } else { MVVMHelper.LoginPage(); } }
/// <summary> /// Configure <see cref="IDialogWindow"/> content. /// </summary> /// <param name="dialogName">The name of the dialog to show.</param> /// <param name="window">The hosting window.</param> /// <param name="parameters">The parameters to pass to the dialog.</param> protected virtual void ConfigureDialogWindowContent(string dialogName, IDialogWindow window, IDictionary <string, object> args) { var content = _containerExtension.Resolve <object>(dialogName); if (!(content is FrameworkElement dialogContent)) { throw new NullReferenceException("A dialog's content must be a FrameworkElement"); } if (!(dialogContent.DataContext is IDialogAware viewModel)) { throw new NullReferenceException("A dialog's ViewModel must implement the IDialogAware interface"); } ConfigureDialogWindowProperties(window, dialogContent, viewModel); MVVMHelper.ViewAndViewModelAction <IDialogAware>(viewModel, d => d.OnDialogOpened(args)); }
private async Task LoginExecuteAsync() { if (!Validate()) { return; } IsBusy = true; var result = await service.Login(UserName.Value, Password.Value); if (result != null) { await MVVMHelper.DisplayAlert("Сообщение", result.Message); IsBusy = false; return; } await GlobalSetting.Instance.SetPropertyAsync("login", userName.Value); #if DEBUG await GlobalSetting.Instance.SetPropertyAsync("pwd", password.Value); #endif await GlobalSetting.Instance.SaveSettingsAsync(); var serviceResult = await service.GetUidAsync(); if (!serviceResult.Contune) { await MVVMHelper.DisplayAlert("Ошибка", "При рабочче сервиса произошла ошибка. Попробуйте еще раз"); IsValid = true; IsLogin = true; IsBusy = false; return; } GlobalSetting.Instance.ClientId = serviceResult.Data; await MVVMHelper.WorkspacePageAsync(); IsValid = true; IsLogin = true; IsBusy = false; }
static bool ShouldKeepAlive(object inactiveView) { var lifetime = MVVMHelper.GetImplementerFromViewOrViewModel <IRegionMemberLifetime>(inactiveView); if (lifetime != null) { return(lifetime.KeepAlive); } var lifetimeAttribute = GetItemOrContextLifetimeAttribute(inactiveView); if (lifetimeAttribute != null) { return(lifetimeAttribute.KeepAlive); } return(true); }
public App() { InitializeComponent(); DependencyService.Register <IdentityService>(); DependencyService.Register <HolidaysService>(); DependencyService.Register <PaySlipService>(); DependencyService.Register <PersonalDataService>(); DependencyService.Register <PrivilegesService>(); DependencyService.Register <ScheduleService>(); DependencyService.Register <DaDataService>(); MVVMHelper.LoginPage(); // MessagingCenter.Unsubscribe<CatalogViewModel, CatalogItem>(this, MessageKeys.AddProduct); // MessagingCenter.Subscribe<CatalogViewModel, CatalogItem>(this, MessageKeys.AddProduct, async (sender, arg) => // { // } }
private async Task ExecuteRegisterCommand() { IsBusy = true; var result = await service.RegisterAsync(FiilRegistredData()); if (result != null) { await MVVMHelper.DisplayAlert("Сообщение", result.Message, "Отмена"); return; } NotRegistred = false;; IsBusy = false; NotRegistred = false; Isregistred = true; }
void ExecuteNavigation(NavigationContext navigationContext, object[] activeViews, Action <NavigationResult> navigationCallback) { try { NotifyActiveViewsNavigatingFrom(navigationContext, activeViews); object view = _regionNavigationContentLoader.LoadContent(Region, navigationContext); // Raise the navigating event just before activing the view. RaiseNavigating(navigationContext); Region.Activate(view); // Update the navigation journal before notifying others of navigaton IRegionNavigationJournalEntry journalEntry = _container.Resolve <IRegionNavigationJournalEntry>(); journalEntry.Uri = navigationContext.Uri; journalEntry.Args = navigationContext.Args; bool persistInHistory = PersistInHistory(view); Journal.RecordNavigation(journalEntry, persistInHistory); // The view can be informed of navigation void action(INavigationAware n) => n.OnNavigatedTo(navigationContext); MVVMHelper.ViewAndViewModelAction(view, (Action <INavigationAware>)action); navigationCallback(new NavigationResult(navigationContext, true)); // Raise the navigated event when navigation is completed. RaiseNavigated(navigationContext); } catch (Exception e) { NotifyNavigationFailed(navigationContext, navigationCallback, e); } }
protected override void OnAttached() { MVVMHelper.SetLayoutAdapter(this.AssociatedObject, this); }
public DocumentViewModel() { MVVMHelper.SetTargetName(this, "DocumentHost"); }
public PanelViewModel() { MVVMHelper.SetTargetName(this, "PanelHost"); }
private async Task ExecuteRestorePasswordAsync() { await MVVMHelper.ForgotPageAsync(); }
private async Task RegisterAsync() { await MVVMHelper.RegisterPageAsync(); }