private StackLayout ConstructRadioButtons(cSurveyQuestions Question) { IResponsesHandler Responses = new ResponsesHandler(); List <cResponses> AllResponses = new List <cResponses>(); if (Online == true) { string _ResponsesRadio = Responses.GetAllResponses(Question.QuestionId); if (!(_ResponsesRadio == "NoContent")) { AllResponses = JsonConvert.DeserializeObject <List <cResponses> >(_ResponsesRadio.ToString()); } } else { AllResponses = dbHandler.GetAllResponsesByQuestionId(Question.QuestionId); } StackLayout RadioButtonsStackLayout = new StackLayout(); foreach (cResponses Response in AllResponses) { RadioButton radioButton = new RadioButton { Text = Response.Response.ToString(), BorderColor = Color.FromHex("#005eb8"), TextColor = Color.FromHex("#005eb8"), FontAttributes = FontAttributes.Bold }; RadioButtonsStackLayout.Children.Add(radioButton); } return(RadioButtonsStackLayout); }
private View ConstructControl(cSurveyQuestions Question) { View Control; switch (Question.Control) { case 1: Control = ContructSingleTextBox(); break; case 2: Control = ConstructCommentBox(); break; case 3: Control = ConstructSlider(Question); break; case 4: Control = ConstructMultipleCheckBoxes(Question); break; case 5: Control = ConstructRadioButtons(Question); break; default: Control = new Editor(); break; } return(Control); }
private StackLayout CreateQuestionlayout(cSurveyQuestions Question) { StackLayout MainStackLayout = new StackLayout() { Padding = 5 }; Frame MainFramelayout = new Frame() { HasShadow = true, CornerRadius = 0, Padding = 7 }; StackLayout WrapperQuestionLayout = new StackLayout(); StackLayout QuestionAndNumberlayout = CreateBasicQuestionLayout(Question); StackLayout QuestionControlsLayout = CreateQuestionControls(Question); WrapperQuestionLayout.Children.Add(QuestionAndNumberlayout); WrapperQuestionLayout.Children.Add(QuestionControlsLayout); MainFramelayout.Content = WrapperQuestionLayout; MainStackLayout.Children.Add(MainFramelayout); return(MainStackLayout); }
private StackLayout CreateQuestionControls(cSurveyQuestions Question) { StackLayout QuestionControlLayout = new StackLayout(); View Control = ConstructControl(Question); QuestionControlLayout.Children.Add(Control); return(QuestionControlLayout); }
private StackLayout ConstructMultipleCheckBoxes(cSurveyQuestions Question) { IResponsesHandler Responses = new ResponsesHandler(); List <cResponses> AllResponses = new List <cResponses>(); if (Online == true) { string _Responses = Responses.GetAllResponses(Question.QuestionId); if (!(_Responses == "NoContent")) { AllResponses = JsonConvert.DeserializeObject <List <cResponses> >(_Responses.ToString()); } } else { AllResponses = dbHandler.GetAllResponsesByQuestionId(Question.QuestionId); } StackLayout MainCheckBoxesStackLayout = new StackLayout() { Spacing = 0 }; for (int i = 0; i < AllResponses.Count - 1; i++) { StackLayout LabelCheckBoxesStackLayout = new StackLayout() { Spacing = 0, Orientation = StackOrientation.Horizontal, Margin = 0, Padding = 0 }; Label CheckBoxLabel = new Label { TextColor = Color.FromHex("#005eb8"), Text = AllResponses[i].Response, Margin = new Thickness(-8, 0, 0, 0), FontSize = 15, VerticalTextAlignment = TextAlignment.Center, FontAttributes = FontAttributes.Bold }; CheckBox _CheckBox = new CheckBox() { Margin = new Thickness(-8, 0, 0, 0), Visual = VisualMarker.Material, Color = Color.FromHex("#005eb8") }; LabelCheckBoxesStackLayout.Children.Add(_CheckBox); LabelCheckBoxesStackLayout.Children.Add(CheckBoxLabel); MainCheckBoxesStackLayout.Children.Add(LabelCheckBoxesStackLayout); } return(MainCheckBoxesStackLayout); }
private StackLayout CreateBasicQuestionLayout(cSurveyQuestions Question) { StackLayout QuestionAndNumberlayout = new StackLayout() { Margin = new Thickness { Bottom = 5 } }; Label QuestionLabel = new Label(); FormattedString QuestionFormattedString = new FormattedString(); Span QuestionAndNumber = new Span() { Text = string.Format("Q{0}. {1}", Question.DisplayId, Question.Question), CharacterSpacing = 0.3 }; QuestionFormattedString.Spans.Add(QuestionAndNumber); if (!string.IsNullOrEmpty(Question.QuestionDescription)) { Span QuestionDescription = new Span() { Text = string.Format("\n{0}", Question.QuestionDescription), CharacterSpacing = 0.3, FontAttributes = FontAttributes.Italic }; QuestionFormattedString.Spans.Add(QuestionDescription); } if (Question.Mandatory == true) { Span QuestionMandatory = new Span() { Text = " *", TextColor = Color.Red }; QuestionFormattedString.Spans.Add(QuestionMandatory); } QuestionLabel.FormattedText = QuestionFormattedString; QuestionAndNumberlayout.Children.Add(QuestionLabel); return(QuestionAndNumberlayout); }
public void InsertSurveyQuestionToDevice(cSurveyQuestions SurveyQuestion) { mConnection.Insert(SurveyQuestion); }
private StackLayout ConstructSlider(cSurveyQuestions Question) { IResponsesHandler Responses = new ResponsesHandler(); List <cResponses> AllResponses = new List <cResponses>(); bool DoeSliderHasNumber = false; if (Online == true) { string _ResponsesSlider = Responses.GetAllResponses(Question.QuestionId); if (!(_ResponsesSlider == "NoContent")) { AllResponses = JsonConvert.DeserializeObject <List <cResponses> >(_ResponsesSlider.ToString()); } else { DoeSliderHasNumber = true; } } else { AllResponses = dbHandler.GetAllResponsesByQuestionId(Question.QuestionId); if (!(AllResponses.Count > 0)) { DoeSliderHasNumber = true; } } if (DoeSliderHasNumber == false) { StackLayout SliderAndLabelsStack = new StackLayout() { VerticalOptions = new LayoutOptions(LayoutAlignment.Fill, true), HorizontalOptions = new LayoutOptions(LayoutAlignment.Fill, true) }; Grid LabelsGrid = new Grid() { VerticalOptions = new LayoutOptions(LayoutAlignment.Fill, true), HorizontalOptions = new LayoutOptions(LayoutAlignment.Fill, true) }; int NumberOfColumns = AllResponses.Count; int ColumnWidth = 100 / AllResponses.Count; for (int i = 0; i < NumberOfColumns; i++) { ColumnDefinition LabelColumn = new ColumnDefinition() { Width = new GridLength(ColumnWidth, GridUnitType.Star) }; LabelsGrid.ColumnDefinitions.Add(LabelColumn); } for (int i = 0; i < AllResponses.Count; i++) { Label SliderItemLabel = new Label() { VerticalOptions = new LayoutOptions(LayoutAlignment.Fill, true), HorizontalOptions = new LayoutOptions(LayoutAlignment.Fill, true), Text = AllResponses[i].Response }; if (i == 0 || AllResponses.Count - 1 == i) { if (i == 0) { SliderItemLabel.HorizontalTextAlignment = TextAlignment.Start; } else { SliderItemLabel.HorizontalTextAlignment = TextAlignment.End; } } else { SliderItemLabel.HorizontalTextAlignment = TextAlignment.Center; } LabelsGrid.Children.Add(SliderItemLabel, i, LabelsGrid.RowDefinitions.Count); } Slider _Slider = new Slider() { Minimum = 0, Maximum = AllResponses.Count - 1, VerticalOptions = new LayoutOptions(LayoutAlignment.Fill, true), HorizontalOptions = new LayoutOptions(LayoutAlignment.Fill, true), MaximumTrackColor = Color.FromHex("#005eb8") }; _Slider.ValueChanged += new SurveyPage()._Slider_ValueChanged; SliderAndLabelsStack.Children.Add(LabelsGrid); SliderAndLabelsStack.Children.Add(_Slider); return(SliderAndLabelsStack); } else { cSliderNumbersRange SliderProperties = new cSliderNumbersRange(); if (Online == true) { ISliderNumbersRange _SliderProperties = new SliderNumbersRangeHandler(); string SliderResponses = _SliderProperties.GetPropertiesForSlider(Question.QuestionId); SliderProperties = JsonConvert.DeserializeObject <cSliderNumbersRange>(SliderResponses.ToString()); } else { var ListSliderNumbers = dbHandler.GetSliderProperties(Question.QuestionId); if (ListSliderNumbers.Count > 0) { SliderProperties = ListSliderNumbers[0]; } } StackLayout SliderAndValueLayout = new StackLayout(); Slider _Slider = new Slider() { Maximum = SliderProperties.EndRange, Minimum = SliderProperties.StartRange, VerticalOptions = new LayoutOptions(LayoutAlignment.Fill, true), HorizontalOptions = new LayoutOptions(LayoutAlignment.Fill, true), MaximumTrackColor = Color.FromHex("#005eb8") }; _Slider.ValueChanged += new SurveyPage()._Slider_ValueChanged; Label SliderStepLabel = new Label { Text = SliderProperties.StepRange.ToString(), IsVisible = false }; SliderAndValueLayout.Children.Add(SliderStepLabel); SliderAndValueLayout.Children.Add(_Slider); if (SliderProperties.NumericalTextBox) { Label NumericalTextBox = new Label() { BindingContext = _Slider }; NumericalTextBox.SetBinding(Label.TextProperty, "Value"); SliderAndValueLayout.Children.Add(NumericalTextBox); } return(SliderAndValueLayout); } }
private async void HighLightAndFocus(cSurveyQuestions Question) { await DisplayAlert("Message", string.Format("Question {0} is mandatory", Question.DisplayId), "OK"); }