public void InsertSliderToDevice(cSliderNumbersRange SliderNumber) { mConnection.Insert(SliderNumber); }
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); } }