Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
            }
        }
Пример #4
0
 private SessionImpl()
 {
     responses_ = new ResponsesHandler();
 }