Ejemplo n.º 1
0
 public void Navigate(IScreen item)
 {
     if (conductor.ActiveItem != null)
     {
         navigationStack.Add(conductor.ActiveItem);
     }
     conductor.ActivateItem(item);
 }
Ejemplo n.º 2
0
        public void can_open_an_item()
        {
            bool wasOpened = false;

            CallProc(ScreenConductor, "Activate");
            activeScreen.Activated += (s, e) => wasOpened = e.WasInitialized;

            ScreenConductor.ActivateItem(activeScreen);

            wasOpened.ShouldBeTrue();
        }
Ejemplo n.º 3
0
 public void Edit(TDocument child)
 {
     Conductor.ActivateItem(this);
     State       = DocumentWorkspaceState.Detail;
     DisplayName = child.DisplayName;
     ActivateItem(child);
 }
        public void Do_not_duplicate_result_subscriptions()
        {
            var shell = new Conductor <IScreen>();
            var model = new TestScreen();

            Init(model);

            WpfTestHelper.WithWindow2(async w => {
                var view = (FrameworkElement)ViewLocator.LocateForModel(shell, null, null);
                ViewModelBinder.Bind(shell, view, null);

                w.Content        = view;
                shell.ActiveItem = model;
                await view.WaitLoaded();

                shell.DeactivateItem(model, false);
                await w.WaitIdle();

                shell.ActivateItem(model);
                await w.WaitIdle();

                model.Raise();
                await w.WaitIdle();
            });

            Assert.AreEqual(1, model.ProcessedCount);
        }
        public void MoveToNextSetupState()
        {
            if (wizardViewState == WizardViewState.NumberOfTasks)
            {
                List <TaskViewModel> tasks = new List <TaskViewModel>();
                int averageSeconds         = totalTimeInfo.TotalSeconds / numberOfTasks;
                int leftoverSeconds        = totalTimeInfo.TotalSeconds % numberOfTasks;

                for (int i = 1; i <= numberOfTasks; ++i)
                {
                    var task = new TaskViewModel(String.Format("Task {0}", i.ToString()), ColorInfo.GetRandomColor(), new TimeInfoViewModel(averageSeconds));
                    tasks.Add(task);
                }

                //Add the remaining seconds
                for (int i = 0; i < leftoverSeconds; ++i)
                {
                    tasks[i].OriginalTime.TotalSeconds++;
                }

                parent.ActivateItem(new SetupViewModel(parent, totalTimeInfo, tasks, windowManager));
            }

            WizardViewState++;
        }
Ejemplo n.º 6
0
        public void StartTasks()
        {
            TimedTasksViewModel timedTasks = new TimedTasksViewModel(parent, TotalTimeInfo, tasks.ToList(), this, windowManager);

            parent.ActivateItem(timedTasks);
            parent.DeactivateItem(this, true);
        }
 public void ChildrenAreNotActivatedIfConductorIsNotActive() {
     var conductor = new Conductor<IScreen>.Collection.OneActive();
     var conducted = new Screen();
     conductor.Items.Add(conducted);
     conductor.ActivateItem(conducted);
     Assert.False(conducted.IsActive);
     Assert.NotEqual(conducted, conductor.ActiveItem);
 }
 public void ChildrenAreActivatedIfConductorIsActive() {
     var conductor = new Conductor<IScreen>.Collection.OneActive();
     var conducted = new Screen();
     conductor.Items.Add(conducted);
     ((IActivate)conductor).Activate();
     conductor.ActivateItem(conducted);
     Assert.True(conducted.IsActive);
     Assert.Equal(conducted, conductor.ActiveItem);
 }
 public void Edit(TDocument child)
 {
     if (child == null)
     {
         return;
     }
     Conductor.ActivateItem(this);
     State = DocumentWorkspaceState.CarbonFootprintDetailView;
     ActivateItem(child);
 }
Ejemplo n.º 10
0
        private void ActivateItem(T item)
        {
            if (item == null)
            {
                return;
            }

            _conductor.ActivateItem(item);

            (_conductor.Items as ObservableCollection <T>)?.Move(_conductor.Items.IndexOf(item), _conductor.Items.Count - 1);
        }
Ejemplo n.º 11
0
        public void OnViewLoaded(object view, Action <object> onViewLoadedBase)
        {
            onViewLoadedBase(view);

            _readyToActivate = true;
            if (_toActivate != null && !_doneReactivating)
            {
                _conductor.ActivateItem(_toActivate);
                _doneReactivating = true;
            }
        }
Ejemplo n.º 12
0
        public ShellViewModel(IEventAggregator agg)
        {
            _eventAgg = agg;

            _conductor = new Conductor <IScreen> {
                Parent = this
            };
            _conductor.ConductWith(this);
            _conductor.AttachToPropertyChanged(() => _conductor.ActiveItem, () => NotifyOfPropertyChange(() => MainActiveItem));
            _conductor.ActivateItem(new MainViewModel());
        }
        public void ChildrenAreNotActivatedIfConductorIsNotActive()
        {
            var conductor = new Conductor <IScreen> .Collection.OneActive();

            var conducted = new Screen();

            conductor.Items.Add(conducted);
            conductor.ActivateItem(conducted);
            Assert.False(conducted.IsActive);
            Assert.NotEqual(conducted, conductor.ActiveItem);
        }
        public void ChildrenAreActivatedIfConductorIsActive()
        {
            var conductor = new Conductor <IScreen> .Collection.OneActive();

            var conducted = new Screen();

            conductor.Items.Add(conducted);
            ((IActivate)conductor).Activate();
            conductor.ActivateItem(conducted);
            Assert.True(conducted.IsActive);
            Assert.Equal(conducted, conductor.ActiveItem);
        }
        public void Show()
        {
            var haveActive = Parent as IHaveActiveItem;

            if (haveActive != null &&
                haveActive.ActiveItem == this)
            {
                State = DocumentWorkspaceState.CarbonFootprintOverView;
            }
            else
            {
                Conductor.ActivateItem(this);
            }
        }
Ejemplo n.º 16
0
        public void Show()
        {
            var haveActive = Parent as IHaveActiveItem;

            if (haveActive != null && haveActive.ActiveItem == this)
            {
                DisplayName = IconName;
                State       = DocumentWorkspaceState.Master;
            }
            else
            {
                Conductor.ActivateItem(this);
            }
        }
Ejemplo n.º 17
0
        public static T ActivateViewModelOf <T>(
            [NotNull] this Conductor <IMessageDetailItem> .Collection.OneActive conductor)
        {
            if (conductor == null)
            {
                throw new ArgumentNullException(nameof(conductor));
            }

            var item = conductor?.Items.FirstOrDefault(s => s.GetType() == typeof(T));

            if (item != null)
            {
                conductor.ActivateItem(item);
                return((T)item);
            }

            return(default(T));
        }
Ejemplo n.º 18
0
        public async Task <TReturn> ShowDialog <TViewModel, TReturn>(TViewModel rootModel)
            where TViewModel : class, IScreen
        {
            var viewType = ViewLocator.LocateTypeForModelType(typeof(TViewModel), null, null);
            var view     = (FrameworkElement)Activator.CreateInstance(viewType);

            ViewModelBinder.Bind(rootModel, view, null);
            view.DataContext = rootModel;

            conductor.ActivateItem(rootModel);
            var returnValue = await DialogHost.Show(view, OnDialogClosing);

            if (returnValue == null)
            {
                return(default(TReturn));
            }

            return((TReturn)returnValue);
        }
Ejemplo n.º 19
0
 public void StartWizard()
 {
     parent.ActivateItem(new SetupWizardViewModel(parent, windowManager));
 }
Ejemplo n.º 20
0
 public void Navigate(IScreen item)
 {
     conductor.ActivateItem(item);
 }