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);
        }
Esempio n. 4
0
        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;
        }
Esempio n. 5
0
        public WorkPlaceViewModelBase(MainViewModel mainModel, string displayName)
        {
            DisplayName  = displayName;
            _mainModel   = mainModel;
            CloseCommand = new RelayCommand(Close);

            MVVMHelper.SetTargetName(this, "DocumentHost");
        }
Esempio n. 6
0
 protected override void OnStart()
 {
     if (GlobalSetting.Instance.IsAuthenticated)
     {
         MVVMHelper.WorkSpacePage();
     }
     else
     {
         MVVMHelper.LoginPage();
     }
 }
Esempio n. 7
0
        /// <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));
        }
Esempio n. 8
0
        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);
        }
Esempio n. 10
0
        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) =>
            //           {
            //           }
        }
Esempio n. 11
0
        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);
            }
        }
Esempio n. 13
0
 protected override void OnAttached()
 {
     MVVMHelper.SetLayoutAdapter(this.AssociatedObject, this);
 }
Esempio n. 14
0
 public DocumentViewModel()
 {
     MVVMHelper.SetTargetName(this, "DocumentHost");
 }
Esempio n. 15
0
 public PanelViewModel()
 {
     MVVMHelper.SetTargetName(this, "PanelHost");
 }
Esempio n. 16
0
 private async Task ExecuteRestorePasswordAsync()
 {
     await MVVMHelper.ForgotPageAsync();
 }
Esempio n. 17
0
 private async Task RegisterAsync()
 {
     await MVVMHelper.RegisterPageAsync();
 }