public ChooseTime()
        {
            InitializeComponent();

            // >> chat-chatpicker-timepicker
            TimePickerContext context = new TimePickerContext
            {
                StartTime = TimeSpan.FromHours(1),
                EndTime   = TimeSpan.FromHours(5),
            };
            PickerItem pickerItem = new PickerItem {
                Context = context
            };

            chat.Items.Add(new TextMessage {
                Text = "Select a time"
            });
            chat.Items.Add(pickerItem);
            context.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == "SelectedValue")
                {
                    if (context.SelectedValue != null)
                    {
                        chat.Items.Remove(pickerItem);
                        chat.Items.Add(new TextMessage {
                            Author = chat.Author, Text = "" + context.SelectedValue
                        });
                    }
                }
            };
            // << chat-chatpicker-timepicker
        }
Example #2
0
        private void CreateTimePickerHeroCard(HeroCard heroCard)
        {
            this.outerChatPicker.HeaderText = heroCard.Text;

            string startTimeText = heroCard.Buttons[0].Value.ToString();
            string endTimeText   = heroCard.Buttons[heroCard.Buttons.Count - 1].Value.ToString();

            TimeSpan startTime = DateTime.Parse(startTimeText).TimeOfDay;
            TimeSpan endTime   = DateTime.Parse(endTimeText).TimeOfDay;

            TimePickerContext timePickerContext = new TimePickerContext
            {
                StartTime = startTime,
                EndTime   = endTime
            };

            this.outerChatPicker.Context   = timePickerContext;
            this.outerChatPicker.IsVisible = true;
        }
Example #3
0
        private void OnChatPickerOkClicked(object sender, EventArgs e)
        {
            TimePickerContext context = this.outerChatPicker.Context as TimePickerContext;
            string            message;

            if (context != null)
            {
                message = context.SelectedValue.Value.ToString();
            }
            else
            {
                var action = ((ItemPickerContext)this.outerChatPicker.Context).SelectedItem;
                message = ((CardAction)action).Value.ToString();
            }

            this.chat.Items.Add(new TextMessage {
                Author = this.chat.Author, Text = message
            });
            this.outerChatPicker.Context   = null;
            this.outerChatPicker.IsVisible = false;
        }