public MatchingQuestionPage(Test test, int currentQuestion, Models.TestSolving.TestResults testResults) { this.testResults = testResults; this.test = test; this.curQ = currentQuestion; startTime = DateTime.Now; answered = false; InitializeComponent(); MatchingQuestion question = (MatchingQuestion)test[curQ]; BindingContext = vm = new ViewModels.TestSolving.MatchingQSolveViewModel { Lefts = new ObservableCollection <QPart>( question.Lefts.Select((text) => new QPart { Text = text }) ), Rights = new ObservableCollection <QPart>( question.Rights.Select((text) => new QPart { Text = text }) ), Relation = new ObservableCollection <int?>( question.Relation ) }; QuestionLabel.Text = string.Join("", (curQ + 1).ToString(), ". ", test[curQ].Text ); limit = test.TimeLimit.Value; if (test.Mode == Models.TimeMode.limitForQuestion) { TimeLeftBar.Progress = 1; Device.StartTimer( TimeSpan.FromSeconds(0.1), () => { if (answered) { return(false); } if (PassedTime() >= limit) { TimeExpired(); return(false); } TimeLeftBar.Progress = (limit - PassedTime()).TotalSeconds / limit.TotalSeconds; return(true); } ); } else { TimeLeftBar.Progress = (limit - testResults.UsedTime).TotalSeconds / limit.TotalSeconds; Device.StartTimer( TimeSpan.FromSeconds(0.1), () => { if (answered) { return(false); } if (PassedTime() + testResults.UsedTime >= limit) { TestTimeExpired(); return(false); } TimeLeftBar.Progress = (limit - testResults.UsedTime - PassedTime()).TotalSeconds / limit.TotalSeconds; return(true); } ); } }
protected bool Equals(MatchingQuestion other) { return(Equals(Terms, other.Terms) && Equals(Definitions, other.Definitions)); }