public QuestionEditorVM(RootVM root, object owner, Test test, Question question) : base(root, owner)
        {
            if (question == null)
            {
                question = new Question();
            }
            Question = question;
            Test     = test;
            Error    = new ErrorMessageVM();
            _answers = new List <InputAnswerVM>();

            QuestionInpit      = new InputTextVM();
            QuestionInpit.Text = Question.Queston;

            OneAnswer            = new InputAnswerVM(1);
            OneAnswer.Text       = Question.Answers[0];
            OneAnswer.IsCheceked = true;
            _answers.Add(OneAnswer);

            TwoAnswer      = new InputAnswerVM(2);
            TwoAnswer.Text = Question.Answers[1];
            _answers.Add(TwoAnswer);

            ThreeAnswer      = new InputAnswerVM(3);
            ThreeAnswer.Text = Question.Answers[2];
            _answers.Add(ThreeAnswer);

            FourAnswer      = new InputAnswerVM(4);
            FourAnswer.Text = Question.Answers[3];
            _answers.Add(FourAnswer);
        }
示例#2
0
        public void Setup()
        {
            VM = new RootVM {
                LoadedChildSource = new ChildSource {
                    ChildPropertyError = LoadedChildError,
                    Items = new List <GrandchildSource> {
                        new GrandchildSource {
                            GrandchildError = LoadedGrandChildError
                        }
                    }
                },
                UnloadedChildSource = new ChildSource {
                    ChildPropertyError = UnloadedChildError,
                    Items = new List <GrandchildSource> {
                        new GrandchildSource {
                            GrandchildError = UnloadedGrandChildError
                        }
                    }
                },
                ChildWithPropertyValidatorSource = new ChildSource {
                    Items = new List <GrandchildSource>()
                    {
                        new GrandchildSource()
                    }
                }
            };

            VM.Load(x => x.LoadedChild);
            VM.GetValue(x => x.LoadedChild).Load(x => x.Items);

            Assert.IsTrue(VM.IsValid, "Test prerequisite failed");
        }
        public void T004_InitRootData()
        {
            _RootVM = new RootVM();
            var data = new RootData {
                TestObject = new TestData {
                    Number = 1
                }, TestList = new List <TestData> {
                    new TestData {
                        Number = 2
                    }
                }
            };

            _RootVM.Data = data;
            _RootVM.TestList.Metadata.DataProvider.NotifyDataChanged();            //HACK

            Assert.AreEqual(1, data.TestObject.Number);
            Assert.AreEqual(1, data.TestList.Count);
            Assert.AreEqual(2, data.TestList[0].Number);

            Assert.IsNotNull(_RootVM.TestObject.Data);
            Assert.IsNotNull(_RootVM.TestList.MːData);

            Assert.AreEqual(1, _RootVM.TestObject.Number.Value);
            Assert.AreEqual(1, _RootVM.TestList.Count);
            Assert.AreEqual(2, _RootVM.TestList[0].Number.Value);
        }
示例#4
0
        public static RootVM CreateRootVM(
            Action <IVMDependencyBuilder <RootVM, RootVMDescriptor> > dependencyConfigurator
            )
        {
            RootVMDescriptor descriptor = VMDescriptorBuilder
                                          .OfType <RootVMDescriptor>()
                                          .For <RootVM>()
                                          .WithProperties((d, b) => {
                var v = b.GetPropertyBuilder();

                d.Property1 = v.Property.Of <string>();
                d.Property2 = v.Property.Of <string>();

                d.Child1 = v.VM.Of <ChildVM>();
                d.Child2 = v.VM.Of <ChildVM>();
            })
                                          .WithDependencies(dependencyConfigurator)
                                          .WithBehaviors(b => {
                b.Property(x => x.Property1).AppendBehavior(new RefreshSpyBehavior());
                b.Property(x => x.Property2).AppendBehavior(new RefreshSpyBehavior());
            })
                                          .Build();

            var vm = new RootVM(descriptor);

            vm.SetValue(x => x.Child1, new ChildVM());
            vm.SetValue(x => x.Child2, new ChildVM());
            return(vm);
        }
 public PasswordPageVM(RootVM root, object owner, ViewModelBase nextPage, string password) : base(root, owner)
 {
     _password      = password;
     _nextPage      = nextPage;
     Error          = new ErrorMessageVM();
     PasswordIsTrue = false;
 }
        public TestManager(RootVM root, object owner, string mode, Test test) : base(root, owner)
        {
            if (test == null)
            {
                MessageBox.Show("Возникла ошибка при генерации тестов", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                Root.CurrentVM = Owner;
            }

            _test             = test;
            _currentTestIndex = 0;
            _mode             = mode;

            _dataService = DataService.GetInstance();
            _settings    = Settings.GetInstance();
            _tests       = new List <ViewModelBase>();
            _statistic   = new TestSessionInformation();
            _statistic.SetTestTime((int)_settings.TimeToTestEnd);

            _timerToTestEnd          = new DispatcherTimer();
            _timerToTestEnd.Tick    += TimerToTestEnd_Tick;
            _timerToTestEnd.Interval = new TimeSpan(0, 0, 0, 1);

            switch (mode)
            {
            case Settings.GROUP_MODE: GroupMode(); break;

            case Settings.PERSONAL_MODE: PersonalMode(); break;
            }
        }
 public PersonalTestingPageResult(RootVM root, object owner, TestSessionInformation information) : base(root, owner)
 {
     if (information == null)
     {
         Root.CurrentVM = Owner;
     }
     Information = information;
 }
 public TestEditorPageVM(RootVM root, object owner) : base(root, owner)
 {
     Error     = new ErrorMessageVM();
     Info      = new InfoMessageVM();
     TestModes = new List <string>();
     TestModes.Add(Settings.GROUP_MODE);
     TestModes.Add(Settings.PERSONAL_MODE);
     SelectedTestMode = Settings.DEFAULT_SELECTED_MODE;
 }
示例#9
0
        public async Task Update()
        {
            PendingMigrationsCount.Value = ProjectInfo.ToBeRunMigrationsCount;
            HasPendingMigrations.Value   = ProjectInfo.ToBeRunMigrationsCount > 0;

            MigrationsCount.Value = ProjectInfo.Migrations.Count;
            ProfilesCount.Value   = ProjectInfo.Profiles.Count;

            await RootVM.UpdateHasPendingMigrations();
        }
示例#10
0
        public void Drop(ICanBeDragged draggable)
        {
            var childVM = draggable as HierarchicalBaseViewModel;

            if (childVM != null && !Children.Contains(childVM))
            {
                Add(childVM);
            }

            Task.Run(async() => await RootVM.UpdateHasPendingMigrations());
        }
示例#11
0
        public void RefreshDescendants_DoesNotLoadUnloadedProperties()
        {
            var root = new RootVM();

            root.RefreshDescendants(b => {
                b.Descendant(x => x.Children)
                .Properties(x => x.RefreshDetectionProperty);
            });

            ViewModelAssert.IsNotLoaded(root, x => x.Children);
        }
示例#12
0
        public void Clone()
        {
            var configuration = ToConfiguration();

            configuration.Id = Guid.NewGuid();

            var clonedVM = new ProjectViewModel(_log, RootVM, configuration);

            Parent.Add(clonedVM);

            RootVM.SelectActiveEntity(clonedVM);
        }
示例#13
0
    private void UserControl_Loaded(object sender, RoutedEventArgs e)
    {

      // Do not load your data at design time.
      if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
      {
        //Load your data here and assign the result to the CollectionViewSource.
        var rootVM = new RootVM();
        System.Windows.Data.CollectionViewSource myCollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["rootVMViewSource"];
        myCollectionViewSource.Source = new List<object> { rootVM };
      }
    }
 public TestingSettingsVM(RootVM root, object owner) : base(root, owner)
 {
     Error = new ErrorMessageVM();
     GroupAmountQuestions       = _settings.GroupAmountQuestions;
     GroupTimeToNextQuestion    = _settings.GroupTimeToNextQuestion;
     PersonalAmountQuestions    = _settings.PersonalAmountQuestions;
     PersonalTimeToNextQuestion = _settings.PersonalTimeToNextQuestion;
     ImageHeight      = _settings.ImageHeight;
     ImageWidth       = _settings.ImageWidht;
     MaxWrongs        = _settings.MaxTestWrongs;
     PersonalTestTime = _settings.TimeToTestEnd;
     Password         = _settings.Password;
 }
示例#15
0
        public void Refresh_RefresesSelectedDescendants()
        {
            var root  = new RootVM();
            var child = new ChildVM();
            var item1 = new ChildVM();

            root.Child = child;
            root.Children.Add(item1);

            root.RefreshDescendants(b => {
                b.Descendant(x => x.Children)
                .Properties(x => x.RefreshDetectionProperty);
            });

            Assert.IsTrue(item1.WasRefreshed);
            Assert.IsFalse(child.WasRefreshed);
        }
示例#16
0
        public EditQuestionVM(RootVM root, object owner, Question question) : base(root, owner)
        {
            Question           = question;
            OldQuestion        = (Question)question.Clone();
            QuestionInput      = new InputTextVM();
            QuestionInput.Text = Question.Queston;

            Answers = new ObservableCollection <InputAnswerVM>();
            for (int i = 0; i < question.Answers.Count; i++)
            {
                InputAnswerVM answerVM = new InputAnswerVM(i + 1);
                answerVM.Text = question.Answers[i];
                if (question.Answers[i] == question.RightAnswer)
                {
                    answerVM.IsCheceked = true;
                }
                Answers.Add(answerVM);
            }
        }
        public TestEditPageVM(RootVM root, object owner, Test test) : base(root, owner)
        {
            _oldVersion = test;
            if (test == null)
            {
                test = new Test();
            }
            Test = (Test)test.Clone();

            Title = new InputTextVM();
            Title.UseValidation = true;
            Title.Text          = Test.Title;

            Author = new InputTextVM();
            Author.UseValidation = true;
            Author.Text          = Test.Author;

            Description = new InputTextVM();
            Description.UseValidation = true;
            Description.Text          = Test.Description;

            Error = new ErrorMessageVM();
            Info  = new InfoMessageVM();
        }
示例#18
0
 public EmblemsTestSettingsVM(string name, RootVM root) : base(name, root)
 {
     _settings     = root.GetModel("EmblemsTestSettings") as Settings;
     _tempSettings = new Settings("EmblemsTestSettings");
 }
示例#19
0
 public MainWindow(RootVM vm)
 {
     DataContext = vm;
     InitializeComponent();
 }
 public GroupTestingPageResultVM(RootVM root, object owner) : base(root, owner)
 {
 }
 public void Setup()
 {
     VM = new RootVM();
 }
 public StartPageVM(RootVM root, object owner) : base(root, owner)
 {
     System.Windows.Application.Current.Exit += Application_Exit;
 }
示例#23
0
 public void Setup()
 {
     VM = new RootVM();
     VM.Revalidate(ValidationScope.SelfAndLoadedDescendants); // Enable validation
 }
 public LearningPageVM(RootVM root, object owner) : base(root, owner)
 {
     Error = new ErrorMessageVM();
     Info  = new InfoMessageVM();
     SetDefaultSelectedLesson();
 }
示例#25
0
 public StartTestVM(string name, RootVM rootVM) : base(name, rootVM)
 {
 }
示例#26
0
 public RootView()
 {
     InitializeComponent();
     DataContext = new RootVM();
     Closed     += RootView_Closed;
 }
示例#27
0
 public MapPageVM(string name, RootVM root) : base(name, root)
 {
 }
示例#28
0
 public BaseWindow()
 {
     InitializeComponent();
     DataContext = new RootVM();
 }
示例#29
0
 public StartWindow()
 {
     InitializeComponent();
     DataBase.GetInstance();
     DataContext = new RootVM();
 }
示例#30
0
 public ViewModel(string name, RootVM root)
 {
     Name = name;
     Root = root;
 }
    public void SaveVmd()
    {
        RootVM rootObj = JToken.Parse(json).ToObject <RootVM>();

        Console.WriteLine($"Parsed {rootObj.jsnObj.Count} vessel movement objects");
    }