/// <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();
        }
        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>
        /// 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);
        }
Exemplo n.º 6
0
        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);
        }