Пример #1
0
        void displayCurrentPoll(Poll poll)
        {
            //Displaying the current details of the poll
            pollQuestionInput.Text = poll.pollQuestion;

            var optionNumberList = new List <string>();

            for (var i = 2; i < 21; i++)
            {
                optionNumberList.Add(i.ToString());
            }

            //Display number of option
            pollOptionNoPicker.ItemsSource = optionNumberList;

            int numberOfOption = poll.pollOptions.Count;

            currentOptionCount = numberOfOption;

            //Display all current options
            for (var i = 1; i <= numberOfOption; i++)
            {
                StackLayout stackLayout = new StackLayout();

                //Create label
                Label label = new Label();
                label.Text           = "Option " + i.ToString() + ": ";
                label.FontAttributes = FontAttributes.Bold;

                //Create input field
                Frame frame = new Frame();
                frame.CornerRadius    = 5;
                frame.BackgroundColor = Color.FromHex("#E5E7E8");
                frame.Padding         = 2;
                frame.HasShadow       = false;

                Entry entry = new Entry();
                entry.Text = poll.pollOptions[i - 1].optionTitle;

                frame.Content = entry;

                Button deleteButton = new Button();
                deleteButton.Text            = "Delete";
                deleteButton.BackgroundColor = Color.FromHex("#EC7063");
                deleteButton.TextColor       = Color.White;
                deleteButton.StyleId         = poll.pollOptions[i - 1].optionID;
                deleteButton.Clicked        += OnDeleteButtonClicked;

                stackLayout.Children.Add(label);
                stackLayout.Children.Add(frame);
                stackLayout.Children.Add(deleteButton);
                optionListLayout.Children.Add(stackLayout);
            }

            foreach (string optionNo in pollOptionNoPicker.ItemsSource)
            {
                if (optionNo == numberOfOption.ToString())
                {
                    pollOptionNoPicker.SelectedItem = optionNo;
                    break;
                }
            }
            currentOptionCount++;
        }
Пример #2
0
 public editPoll(Poll poll)
 {
     InitializeComponent();
     currentPoll = poll;
     displayCurrentPoll(poll);
 }