Esempio n. 1
0
        public MenuNode AddConfirm(string accept = "Yes", string reject = "No", Func <NodeBase, string, Task <HandlerResult> > handler = null, bool acceptAsDefault = false)
        {
            var acceptNode = new MenuNode(accept, (s, d) =>
            {
                if (d == Constants.Select && handler != null)
                {
                    return(handler.Invoke(s, d));
                }

                return(Handle(s, d));
            });

            acceptNode.SetParent(this);

            var rejectNode = new MenuNode(reject, (s, d) =>
            {
                if (d == Constants.Select)
                {
                    return(s.Menu.Back());
                }

                return(Handle(s, d));
            });

            rejectNode.SetParent(this);

            if (acceptAsDefault)
            {
                _nodes.Add(acceptNode);
                _nodes.Add(rejectNode);
            }
            else
            {
                _nodes.Add(rejectNode);
                _nodes.Add(acceptNode);
            }

            return(this as MenuNode);
        }
Esempio n. 2
0
 public MenuNode AddNode(MenuNode menuNode)
 {
     menuNode.SetParent(this);
     _nodes.Add(menuNode);
     return(this as MenuNode);
 }
Esempio n. 3
0
 public void AddNode(MenuNode menuNode)
 {
     _selectedMenu.AddNode(menuNode);
 }