コード例 #1
0
 public FlipperNode(string name, List <T> elements, string description,
                    Func <ISession, T, string> btnNameFunc = null, Func <T, string> btnCallbackFunc = null,
                    byte pageSize = 6, bool needBack = true, FlipperArrowsType flipperArrows = FlipperArrowsType.Double, bool useGlobalCallbacks = true)
     : this(name, elements, btnNameFunc, btnCallbackFunc, description == null ? null : new MetaDoubleKeyboardedMessage(description),
            pageSize, needBack, flipperArrows, useGlobalCallbacks)
 {
 }
コード例 #2
0
        public SelectManyInputNode(string name, string varName, List <T> options,
                                   IMetaMessage <MetaInlineKeyboardMarkup> metaMessage = null,
                                   string checkedSymbol = defaultChecked, string uncheckedSymbol = defaultUnchecked, Func <T, string> btnCallbackFunc = null,
                                   byte pageSize        = 6, FlipperArrowsType flipperArrows     = FlipperArrowsType.Double, bool needBack = true, bool useGlobalCallbacks = false)
            : base(name, options,
                   (session, element) => (session.Vars.GetVar <List <T> >(varName)?.Contains(element) ?? false ? // если элемент есть,
                                          checkedSymbol : uncheckedSymbol) + element.ToString(session),          // то добавляем checkedSymbol, иначе uncheckedSymbol
                   btnCallbackFunc, metaMessage ?? new MetaDoubleKeyboardedMessage(name),
                   pageSize, needBack, flipperArrows, useGlobalCallbacks)
        {
            VarName  = varName ?? throw new ArgumentNullException(nameof(varName));
            Children = new List <ITreeNode>(1);
            if (collection.Count == 0)
            {
                throw new ArgumentException(nameof(options));
            }

            Dictionary <string, T> callbackToValue = new Dictionary <string, T>(collection.Count);

            foreach (T element in collection)
            {
                callbackToValue.Add(callbackFunc(element), element);
            }

            Converter = (string text, out T variable) => callbackToValue.TryGetValue(text, out variable);
        }
コード例 #3
0
 public MetaValuedContainerInputNode(string name, string varName, List <MetaValued <T> > options, string description,
                                     Action <ISession, MetaValuedContainer <T> > endAction = null, Func <ISession, MetaValued <T>, string> btnNameFunc = null, Func <MetaValued <T>, string> btnCallbackFunc = null,
                                     byte pageSize = 6, FlipperArrowsType flipperArrows = FlipperArrowsType.Double, bool needBack = true, bool useGlobalCallbacks = false)
     : this(name, varName, options, new MetaDoubleKeyboardedMessage(description ?? name), endAction, btnNameFunc,
            btnCallbackFunc, pageSize, flipperArrows, needBack, useGlobalCallbacks)
 {
 }
コード例 #4
0
 public SelectManyInputNode(string name, string varName, List <T> options, string description,
                            string checkedSymbol = defaultChecked, string uncheckedSymbol = defaultUnchecked, Func <T, string> btnCallbackFunc = null,
                            byte pageSize        = 6, FlipperArrowsType flipperArrows     = FlipperArrowsType.Double,
                            bool needBack        = true, bool useGlobalCallbacks = false)
     : this(name, varName, options, new MetaDoubleKeyboardedMessage(description ?? name), checkedSymbol, uncheckedSymbol,
            btnCallbackFunc, pageSize, flipperArrows, needBack, useGlobalCallbacks)
 {
 }
コード例 #5
0
 public SelectSingleInputNode(string name, string varName, List <T> options, string description = null,
                              byte pageSize = 6, Func <ISession, T, string> btnNameFunc = null, Func <T, string> btnCallbackFunc = null,
                              bool required = true, FlipperArrowsType flipperArrows     = FlipperArrowsType.Double,
                              bool needBack = true, bool useGlobalCallbacks             = false)
     : this(name, varName, options, new MetaDoubleKeyboardedMessage(description ?? name), pageSize,
            btnNameFunc, btnCallbackFunc, required, flipperArrows, needBack, useGlobalCallbacks)
 {
 }
コード例 #6
0
 public FlipperNode(string name, List <T> elements, Func <ISession, T, string> btnNameFunc = null, Func <T, string> btnCallbackFunc = null,
                    IMetaMessage <MetaInlineKeyboardMarkup> metaMessage = null, byte pageSize           = 6, bool needBack = true,
                    FlipperArrowsType flipperArrows = FlipperArrowsType.Double, bool useGlobalCallbacks = true)
     : base(name, pageSize, metaMessage ?? new MetaDoubleKeyboardedMessage(name), elements, needBack)
 {
     nameFunc        = btnNameFunc ?? ((session, element) => element.ToString(session));
     callbackFunc    = btnCallbackFunc ?? ((element) => element.ToString());
     arrowsType      = flipperArrows;
     GlobalCallbacks = useGlobalCallbacks;
 }
コード例 #7
0
 public ChildrenFlipperNode(string name, IMetaMessage <MetaInlineKeyboardMarkup> metaMessage = null, byte pageSize = 6,
                            bool needBack = true, FlipperArrowsType flipperArrows = FlipperArrowsType.Double, bool useGlobalCallbacks = true)
     : base(name, null,
            (session, child) => session.Translate(child.Name),
            (child) => ButtonIdManager.GetInlineButtonId(child),
            metaMessage ?? new MetaDoubleKeyboardedMessage(name),
            pageSize, needBack, flipperArrows, useGlobalCallbacks)
 {
     Children = collection;
 }
コード例 #8
0
 public ProductMultiNode(string name, List <List <string> > elements, string itemsContainer, List <int> productsIds, List <MetaText> foldersNames,
                         string sessionContainer, string addedPrefix = DefaultStrings.Plus, string addBtnName = DefaultStrings.Add, MetaDoubleKeyboardedMessage metaMessage = null,
                         byte pageSize = 6, bool needBack = true, FlipperArrowsType flipperArrowsType = FlipperArrowsType.Double, bool useGlobalCallbacks = false) :
     base(
         new MultiNode(name, elements, metaMessage, pageSize, needBack, flipperArrowsType, useGlobalCallbacks, foldersNames),
         CreateItemNodes(name, itemsContainer, elements, productsIds,
                         sessionContainer, addedPrefix, true, addBtnName)
         )
 {
     foreach (var itemNode in TailNodes)
     {
         itemNode.SetParent(HeadNode);
     }
 }
コード例 #9
0
        public MetaValuedContainerInputNode(string name, string varName, List <MetaValued <T> > options, IMetaMessage <MetaInlineKeyboardMarkup> metaMessage = null,
                                            Action <ISession, MetaValuedContainer <T> > endAction = null, Func <ISession, MetaValued <T>, string> btnNameFunc = null, Func <MetaValued <T>, string> btnCallbackFunc = null,
                                            byte pageSize = 6, FlipperArrowsType flipperArrows = FlipperArrowsType.Double, bool needBack = true, bool useGlobalCallbacks = false)
            : base(name, options, btnNameFunc, btnCallbackFunc ?? ((element) => DefaultStrings.DoNothing), metaMessage ?? new MetaDoubleKeyboardedMessage(name),
                   pageSize, needBack, flipperArrows, useGlobalCallbacks)
        {
            VarName  = varName ?? throw new ArgumentNullException(nameof(varName));
            Children = new List <ITreeNode>(1);
            if (collection.Count == 0)
            {
                throw new ArgumentException(nameof(options));
            }

            Dictionary <string, MetaValued <T> > callbackToValue = new Dictionary <string, MetaValued <T> >(collection.Count);

            foreach (MetaValued <T> element in collection)
            {
                callbackToValue.Add(element.ToString(), element);
            }

            Converter   = (string text, out MetaValued <T> variable) => callbackToValue.TryGetValue(text, out variable);
            finalisator = endAction;
        }
コード例 #10
0
        public SelectSingleInputNode(string name, string varName, List <T> options,
                                     IMetaMessage <MetaInlineKeyboardMarkup> metaMessage = null, byte pageSize        = 6,
                                     Func <ISession, T, string> btnNameFunc = null, Func <T, string> btnCallbackFunc  = null, bool required           = true,
                                     FlipperArrowsType flipperArrows        = FlipperArrowsType.Double, bool needBack = true, bool useGlobalCallbacks = false)
            : base(name, options, btnNameFunc, btnCallbackFunc, metaMessage ?? new MetaDoubleKeyboardedMessage(name),
                   pageSize, needBack, flipperArrows, useGlobalCallbacks)
        {
            VarName  = varName ?? throw new ArgumentNullException(nameof(varName));
            Children = new List <ITreeNode>(1);
            Required = required;
            if (collection.Count == 0)
            {
                throw new ArgumentException(nameof(options));
            }

            Dictionary <string, T> callbackToValue = new Dictionary <string, T>(collection.Count);

            foreach (T element in collection)
            {
                callbackToValue.Add(callbackFunc(element), element);
            }

            Converter = (string text, out T variable) => callbackToValue.TryGetValue(text, out variable);
        }
コード例 #11
0
 public ChildrenFlipperNode(string name, string description, byte pageSize = 6,
                            bool needBack = true, FlipperArrowsType flipperArrows = FlipperArrowsType.Double, bool useGlobalCallbacks = true)
     : this(name, new MetaDoubleKeyboardedMessage(description), pageSize, needBack, flipperArrows, useGlobalCallbacks)
 {
 }