Ejemplo n.º 1
0
        public override async Task Render(MessageResult message)
        {
            if (this.Value == null)
            {
                if (this.ShowBackButton)
                {
                    ButtonForm bf = new ButtonForm();
                    bf.AddButtonRow(new ButtonBase(BackLabel, "back"));
                    await this.Device.Send(this.Message, (ReplyMarkupBase)bf);

                    return;
                }

                await this.Device.Send(this.Message);

                return;
            }


            message.Handled = true;

            OnCompleted(new PromptDialogCompletedEventArgs()
            {
                Tag = this.Tag, Value = this.Value
            });

            await this.CloseForm();
        }
Ejemplo n.º 2
0
        public override async Task Render(MessageResult message)
        {
            ButtonForm btn = new ButtonForm();

            var buttons = this.Buttons.Select(a => new ButtonBase(a.Text, CallbackData.Create("action", a.Value))).ToList();

            btn.AddButtonRow(buttons);

            await this.Device.Send(this.Message, btn);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns an inline Button
        /// </summary>
        /// <param name="form"></param>
        /// <returns></returns>
        public InlineKeyboardButton ToInlineButton(ButtonForm form)
        {
            String id = (form.DependencyControl != null ? form.DependencyControl.ControlID + "_" : "");

            if (this.Url == null)
            {
                return(InlineKeyboardButton.WithCallbackData(this.Text, id + this.Value));
            }

            var ikb = new InlineKeyboardButton();

            ikb.Text = this.Text;
            ikb.Url  = this.Url;

            return(ikb);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a copy of this form and filters by the parameter.
        /// </summary>
        /// <returns></returns>
        public ButtonForm TagDuplicate(List <String> tags, bool ByRow = false)
        {
            var bf = new ButtonForm()
            {
                Markup            = this.Markup,
                DependencyControl = this.DependencyControl
            };

            foreach (var b in Buttons)
            {
                var lst = new List <ButtonBase>();
                foreach (var b2 in b)
                {
                    if (!(b2 is TagButtonBase tb))
                    {
                        continue;
                    }

                    if (!tags.Contains(tb.Tag))
                    {
                        continue;
                    }

                    //Copy full row, when at least one match has found.
                    if (ByRow)
                    {
                        lst.AddRange(b);
                        break;
                    }
                    else
                    {
                        lst.Add(b2);
                    }
                }

                if (lst.Count > 0)
                {
                    bf.Buttons.Add(lst);
                }
            }

            return(bf);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a copy of this form.
        /// </summary>
        /// <returns></returns>
        public ButtonForm Duplicate()
        {
            var bf = new ButtonForm()
            {
                Markup            = this.Markup,
                DependencyControl = this.DependencyControl
            };

            foreach (var b in Buttons)
            {
                var lst = new List <ButtonBase>();
                foreach (var b2 in b)
                {
                    lst.Add(b2);
                }
                bf.Buttons.Add(lst);
            }

            return(bf);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates a copy of this form and filters by the parameter.
        /// </summary>
        /// <returns></returns>
        public ButtonForm FilterDuplicate(String filter, bool ByRow = false)
        {
            var bf = new ButtonForm()
            {
                Markup            = this.Markup,
                DependencyControl = this.DependencyControl
            };

            foreach (var b in Buttons)
            {
                var lst = new List <ButtonBase>();
                foreach (var b2 in b)
                {
                    if (b2.Text.IndexOf(filter, StringComparison.InvariantCultureIgnoreCase) == -1)
                    {
                        continue;
                    }

                    //Copy full row, when at least one match has found.
                    if (ByRow)
                    {
                        lst.AddRange(b);
                        break;
                    }
                    else
                    {
                        lst.Add(b2);
                    }
                }

                if (lst.Count > 0)
                {
                    bf.Buttons.Add(lst);
                }
            }

            return(bf);
        }
Ejemplo n.º 7
0
        public override async Task Render(MessageResult message)
        {
            if (this.Value == null)
            {
                if (this.ShowBackButton)
                {
                    ButtonForm bf = new ButtonForm();
                    bf.AddButtonRow(new ButtonBase(BackLabel, "back"));
                    await this.Device.Send(this.Message, (ReplyMarkupBase)bf);

                    return;
                }

                await this.Device.Send(this.Message);

                return;
            }


            OnCompleted(new EventArgs());

            await this.CloseForm();
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Returns a KeyBoardButton
 /// </summary>
 /// <param name="form"></param>
 /// <returns></returns>
 public KeyboardButton ToKeyboardButton(ButtonForm form)
 {
     return(new KeyboardButton(this.Text));
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Returns an inline Button
        /// </summary>
        /// <param name="form"></param>
        /// <returns></returns>
        public override InlineKeyboardButton ToInlineButton(ButtonForm form)
        {
            String id = (form.DependencyControl != null ? form.DependencyControl.ControlID + "_" : "");

            return(InlineKeyboardButton.WithCallbackData(this.Text, id + this.Value));
        }