/// <summary> /// Initializes a new instance of the <see cref="T:CGFSMVVM.ViewModels.EmojiRatingViewModel"/> class. /// </summary> /// <param name="iNavigation">I navigation.</param> /// <param name="currQuestionIndex">Curr question index.</param> public EmojiRatingViewModel(INavigation iNavigation, string currQuestionIndex, StackLayout childLayout, ScrollView scrollView) { this._navigation = iNavigation; this._currQuestionindex = currQuestionIndex; this._childLayout = childLayout; this._scrollView = scrollView; this._Questions = QuestionJsonDeserializer.GetQuestion(currQuestionIndex); this.children = QuestionJsonDeserializer.GetChildQuestionSet(_currQuestionindex); LoadEmojis(); SetChildVisibility("All"); LoadChildGlobalList(); TappedCommand = new Command <EmojiIconModel>(async(emojiIconModel) => await EmojiTapped(emojiIconModel).ConfigureAwait(true)); ChildHeatBarTappedCommand = new Command <Heat_ChildModel>(ChildButtonTapped); LoadQuestionCommand = new Command <Label>(LoadData); LoadMessageTextCommand = new Command <Label>(SetMessageText); LoadChildQuestionCommand = new Command(LoadChildData); BackCommand = new Command(BackButtonTapped); NextCommand = new Command(NextButtonTapped); RestoreFeedbackData(); RestoreChildFeedbackData(); }
private async void AccessQuestionAPI() { this.IsBusy = true; _indicator.IsVisible = true; _indicator.IsRunning = true; _startButton.IsEnabled = false; bool isCompletedQ = await QuestionJsonDeserializer.DeserializeQuestions().ConfigureAwait(true); if (isCompletedQ) { _indicator.IsVisible = false; _indicator.IsRunning = false; _startButton.IsEnabled = true; } else { await Navigation.PushAsync(new SystemConfigView()); Navigation.RemovePage(this); } }
public TextCommentViewModel(INavigation iNavigation, string currQuestionIndex) { this._navigation = iNavigation; this._currQuestionindex = currQuestionIndex; this._Questions = QuestionJsonDeserializer.GetQuestion(currQuestionIndex); BackCommand = new Command(BackButtonTapped); NextCommand = new Command(NextButtonTapped); LoadQuestionCommand = new Command <Label>(LoadData); LoadMessageTextCommand = new Command <Label>(SetMessageText); EntryCompletedCommand = new Command <Editor>(SetTempCommentData); RestoreFeedbackData(); }
/// <summary> /// Loads the question views. /// </summary> private void LoadQuestionViews() { GlobalModel.CleanGlobalModel(); QuestionsModel _nextQuestion = QuestionJsonDeserializer.GetFirstQuestion(0); //Set Main Category to cart FeedbackCart._mainCatId = Convert.ToInt32(_nextQuestion.MainCategory); Debug.WriteLine("Main Cat :" + FeedbackCart._mainCatId); // if (_nextQuestion.QType == "") { if (_nextQuestion.UIControl == "sli") { if (_nextQuestion.RatingScale != null) { var ratingScale = _nextQuestion.RatingScale.Count; _navigation.PushAsync(new HeatBarView(_currQuesNo, _nextQuestion.QNo, ratingScale)); } } else { _navigation.PushAsync(new EmojiRatingView(_currQuesNo, _nextQuestion.QNo)); } } else if (_nextQuestion.QType == "Y") { _navigation.PushAsync(new DualOptionView(_currQuesNo, _nextQuestion.QNo)); } else if (_nextQuestion.QType == "O") { if (_nextQuestion.UIControl == "cbl") { _navigation.PushAsync(new MultiSelectionView(_currQuesNo, _nextQuestion.QNo)); } else { _navigation.PushAsync(new MultiOptionView(_currQuesNo, _nextQuestion.QNo)); } } else if (_nextQuestion.QType == "C") { _navigation.PushAsync(new TextCommentView(_currQuesNo, _nextQuestion.QNo)); } _taplocked = false; // unlock name label tap lock }
public StackLayout GetProgressPane() { _baseLayer = new StackLayout() { HorizontalOptions = LayoutOptions.CenterAndExpand, Orientation = StackOrientation.Vertical, HeightRequest = 40 }; _upperLayer = new StackLayout() { HorizontalOptions = LayoutOptions.CenterAndExpand }; _bottomLayer = new StackLayout() { HorizontalOptions = LayoutOptions.CenterAndExpand }; _label = new Label() { Text = QuestionJsonDeserializer.GetCurrentQuestionIndex().ToString() + " of " + QuestionJsonDeserializer.GetQuestionCount().ToString(), TextColor = Color.Green, FontSize = 14, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, }; _progressBar = new ProgressBar() { VerticalOptions = LayoutOptions.Center, Progress = (double)QuestionJsonDeserializer.GetCurrentQuestionIndex() / (double)QuestionJsonDeserializer.GetQuestionCount(), WidthRequest = Application.Current.MainPage.Width - 10 }; _upperLayer.Children.Add(_progressBar); _bottomLayer.Children.Add(_label); _baseLayer.Children.Add(_upperLayer); _baseLayer.Children.Add(_bottomLayer); return(_baseLayer); }
/// <summary> /// Initializes a new instance of the <see cref="T:CGFSMVVM.ViewModels.DualOptionViewModel"/> class. /// </summary> /// <param name="iNavigation">navigation stack reference.</param> /// <param name="currQuestionIndex">Current question index.</param> public DualOptionViewModel(INavigation iNavigation, string currQuestionIndex) { this._navigation = iNavigation; this._currQuestionindex = currQuestionIndex; this._Questions = QuestionJsonDeserializer.GetQuestion(currQuestionIndex); TappedCommand = new Command <DualOptionModel>(async(dualOptionModel) => await IconTapped(dualOptionModel).ConfigureAwait(true)); BackCommand = new Command(BackButtonTapped); NextCommand = new Command(NextButtonTapped); LoadQuestionCommand = new Command <Label>(LoadData); LoadMessageTextCommand = new Command <Label>(SetMessageText); RestoreFeedbackData(); LoadImages(); }
public MultiSelectionsViewModel(INavigation iNavigation, string currQuestionIndex) { this._navigation = iNavigation; this._currQuestionindex = currQuestionIndex; this._Questions = QuestionJsonDeserializer.GetQuestion(currQuestionIndex); LoadLabels(); OptionTappedCommand = new Command <MultiOpsLabelModel>(async(multiOpsModel) => await OptionTapped(multiOpsModel).ConfigureAwait(true)); LoadQuestionCommand = new Command <Label>(LoadData); LoadMessageTextCommand = new Command <Label>(SetMessageText); LoadOptionsDescCommand = new Command(LoadOptionsDesc); BackCommand = new Command(BackButtonTapped); NextCommand = new Command(NextButtonTapped); RestoreFeedbackData(); }
public StackLayout GetMultiOptionsLayout(INavigation iNavigation, string currQuestionIndex) { this._Questions = QuestionJsonDeserializer.GetQuestion(currQuestionIndex); _baseLayer = new StackLayout(); _lableLayer = new StackLayout() { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, Margin = new Thickness(100, 10, 100, 10) }; for (int i = 0; i < _Questions.OtherQuestions.Count; i++) { _optionLabel = new Label() { FontSize = 20, VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center, BackgroundColor = Color.Purple, TextColor = Color.White, HeightRequest = 70, WidthRequest = 500, Margin = new Thickness(0, 5, 0, 5) }; GlobalModel.MultiOptionsLabelList.Add(_optionLabel); TapGestureRecognizer _tapGestureRecognizer = new TapGestureRecognizer(); _tapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandProperty, "OptionTappedCommand"); MultiOpsLabelModel _multiOpsLabelModel = new MultiOpsLabelModel(i.ToString(), _optionLabel); _tapGestureRecognizer.CommandParameter = _multiOpsLabelModel; _optionLabel.GestureRecognizers.Add(_tapGestureRecognizer); _lableLayer.Children.Add(_optionLabel); } _baseLayer.Children.Add(_lableLayer); return(_baseLayer); }
/// <summary> /// Checks the next has feedback. /// </summary> /// <returns><c>true</c>, if next has feedback, <c>false</c> otherwise.</returns> private bool CheckNextHasFeedback() { var nextQuestion = QuestionJsonDeserializer.GetNextQuestion(_currQuestionindex); if (nextQuestion != null) { var nextQId = nextQuestion.QId; var GivenNextFeedback = FeedbackCart.RatingNVC[nextQId]; if (GivenNextFeedback != null) { _nextHasPreviousFeedback = true; return(true); } else { _nextHasPreviousFeedback = false; return(false); } } return(false); }
private static QuestionsModel HandleDependancyQuestions(string currQIndex) { try { QuestionsModel currQuestion = QuestionJsonDeserializer.GetQuestion(currQIndex); QuestionsModel nextQuestion = QuestionJsonDeserializer.GetNextQuestion(currQIndex); var dependancyQNo = nextQuestion.DependantQNo; if (string.IsNullOrEmpty(dependancyQNo)) { return(QuestionJsonDeserializer.GetNextQuestion(currQIndex)); } QuestionsModel dependantParent = QuestionJsonDeserializer.GetQuestion(dependancyQNo); var dependancyQid = dependantParent.QId; var dependancyCriteria = nextQuestion.DependantQValue; var dependancyQType = dependantParent.QType; var dependancyQuestionRating = string.Empty; if (dependancyQType == null) { dependancyQuestionRating = FeedbackCart.RatingNVC[dependancyQid]; } else if (dependancyQType == "O") { dependancyQuestionRating = FeedbackCart.OtherNVC[dependancyQid]; } if (string.IsNullOrEmpty(dependancyQuestionRating) || dependancyQuestionRating == (-1).ToString()) { var afterSkippedQuestion = QuestionJsonDeserializer.SkipDependantQuestion(currQIndex); if (afterSkippedQuestion.DependantQNo != null) { return(HandleDependancyQuestions(nextQuestion.QNo)); } else { return(afterSkippedQuestion); } } if (dependancyCriteria.Contains(dependancyQuestionRating) || dependancyQuestionRating.Contains(dependancyCriteria)) { return(QuestionJsonDeserializer.GetNextQuestion(currQIndex)); } else { var afterSkippedQuestion = QuestionJsonDeserializer.SkipDependantQuestion(currQIndex); if (afterSkippedQuestion.DependantQNo != null) { return(HandleDependancyQuestions(nextQuestion.QNo)); } else { return(afterSkippedQuestion); } } } catch (Exception) { return(QuestionJsonDeserializer.SkipDependantQuestion(currQIndex)); } }
public StackLayout GetMultiSelectionsLayout(string currQuestionIndex) { this._Questions = QuestionJsonDeserializer.GetQuestion(currQuestionIndex); ////remove not applicable facilities //if(_Questions.OtherQuestions != null && _Questions.OtherQValuesNA != null) //{ // foreach (var item in _Questions.OtherQuestions) // { // if(_Questions.OtherQValuesNA.Contains(item.QOId)) // { // _Questions.OtherQuestions.Remove(item); // } // } //} _baseLayer = new StackLayout(); _lableLayer = new StackLayout() { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, Margin = new Thickness(100, 10, 100, 10) }; for (int i = 0; i < _Questions.OtherQuestions.Count; i++) { _checkboxlayer = new StackLayout() { Orientation = StackOrientation.Horizontal, HeightRequest = 70 }; _checkBoxImage = new Image() { Aspect = Aspect.AspectFit, Source = ImageSource.FromFile("Images/unchecked.png"), HeightRequest = 50 }; _optionLabel = new Label() { FontSize = 20, VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center, BackgroundColor = Color.FromRgb(60, 0, 70), TextColor = Color.White, WidthRequest = 500, Margin = new Thickness(0, 5, 0, 5) }; //Hide not Applicable Options if (_Questions.OtherQuestions != null && _Questions.OtherQValuesNA != null) { if (_Questions.OtherQValuesNA.Contains(i.ToString())) { _optionLabel.IsVisible = false; _checkBoxImage.IsVisible = false; } } _checkboxlayer.Children.Add(_checkBoxImage); _checkboxlayer.Children.Add(_optionLabel); GlobalModel.MultiSelectionsLabelList.Add(_optionLabel); GlobalModel.MultiSelectionsIconlList.Add(_checkBoxImage); TapGestureRecognizer _tapGestureRecognizer = new TapGestureRecognizer(); _tapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandProperty, "OptionTappedCommand"); MultiOpsLabelModel _multiOpsLabelModel = new MultiOpsLabelModel(i.ToString(), _optionLabel, _checkBoxImage); _tapGestureRecognizer.CommandParameter = _multiOpsLabelModel; _optionLabel.GestureRecognizers.Add(_tapGestureRecognizer); _checkBoxImage.GestureRecognizers.Add(_tapGestureRecognizer); _lableLayer.Children.Add(_checkboxlayer); } _baseLayer.Children.Add(_lableLayer); return(_baseLayer); }
public StackLayout GetHeatBarListLayout(string currQuestion) { children = QuestionJsonDeserializer.GetChildQuestionSet(currQuestion); var childCount = 0; if (children != null) { childCount = children.Count; foreach (var item in children) { if (item.Value.QType == "L") { childCount -= 1; } } } _baseLayout = new StackLayout() { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.EndAndExpand, Padding = new Thickness(20, 50, 10, 10) }; _titleLabel = new Label() { HorizontalTextAlignment = TextAlignment.Start, FontSize = 24, FontAttributes = FontAttributes.Bold, TextColor = Color.White }; List <StackLayout> hearBarList = new List <StackLayout>(); for (int i = 0; i < childCount; i++) { _heatListLayout = new StackLayout() { Orientation = StackOrientation.Horizontal, HeightRequest = 50, Padding = new Thickness(10, 10, 10, 10), HorizontalOptions = LayoutOptions.EndAndExpand }; _childTitle = new Label() { HorizontalTextAlignment = TextAlignment.Start, VerticalTextAlignment = TextAlignment.Center, FontSize = 20, TextColor = Color.White, WidthRequest = 500 }; _heatListLayout.Children.Add(_childTitle); List <Button> buttonList = new List <Button>(); for (int j = 0; j < 5; j++) { _button = new Button() { BackgroundColor = Color.White, Text = (j + 1).ToString(), TextColor = Color.Black, FontSize = 14, HeightRequest = 50, WidthRequest = 50 }; HeatButtonModel _buttonModel = new HeatButtonModel(j.ToString(), _button); Heat_ChildModel heat_ChildModel = new Heat_ChildModel(i.ToString(), j.ToString(), _buttonModel); _button.CommandParameter = heat_ChildModel; _button.SetBinding(Button.CommandProperty, new Binding("ChildHeatBarTappedCommand")); buttonList.Add(_button); _heatListLayout.Children.Add(_button); } hearBarList.Add(_heatListLayout); ChildHeatListModel _heatListModel = new ChildHeatListModel(i.ToString(), _titleLabel, _childTitle, buttonList); GlobalModel.ChildHeatListCollection.Add(_heatListModel); } if (childCount > 0) { _baseLayout.Children.Add(_titleLabel); } foreach (var item in hearBarList) { _baseLayout.Children.Add(item); } return(_baseLayout); }