Exemplo n.º 1
0
        /// <summary>
        /// Set the level of tutorial for a group
        /// </summary>
        /// <param name="group">The group name</param>
        /// <param name="level">The desired level</param>

        public void SetLevel(string group, InteractiveLevel level)
        {
            if (!iGuide.ContainsKey(group))
            {
                return;
            }
            InteractiveHelp ih = iGuide[group];

            ih.level      = level;
            iGuide[group] = ih;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a group for interactive help running the user through the process of a command, action
        /// </summary>
        /// <param name="group">The grouping name for the guide</param>
        /// <param name="level">The help level of the guide</param>

        public void CreateInteractive(string group, string explanation, InteractiveLevel level = InteractiveLevel.Normal)
        {
            if (iGuide.ContainsKey(group))
            {
                return;
            }
            InteractiveHelp ih = new InteractiveHelp
            {
                level       = level,
                messages    = new List <string>(),
                idle        = new List <int>(),
                triggerNext = new List <Func <bool> >()
            };

            iGuide.Add(group, ih);
            exp.Add(explanation);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Add when to move to the next message/step
        /// </summary>
        /// <param name="group">The group name</param>
        /// <param name="triggers">A condition, which is when true the next step come's</param>

        public void AddTrigger(string group, params Func <bool>[] triggers)
        {
            if (!iGuide.ContainsKey(group))
            {
                return;
            }

            InteractiveHelp     ih = iGuide[group];
            List <Func <bool> > f  = new List <Func <bool> >();

            foreach (Func <bool> condition in ih.triggerNext)
            {
                f.Add(condition);
            }

            foreach (Func <bool> condition in triggers)
            {
                f.Add(condition);
            }

            ih.triggerNext = f;
            iGuide[group]  = ih;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Add idle time between messages
        /// </summary>
        /// <param name="group">The group name</param>
        /// <param name="times">The idle time in seconds</param>

        public void AddIdle(string group, params int[] times)
        {
            if (!iGuide.ContainsKey(group))
            {
                return;
            }

            InteractiveHelp ih = iGuide[group];
            List <int>      f  = new List <int>();

            foreach (int time in ih.idle)
            {
                f.Add(time);
            }

            foreach (int time in times)
            {
                f.Add(time);
            }

            ih.idle       = f;
            iGuide[group] = ih;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Add one or multiple message/step to a guide
        /// </summary>
        /// <param name="group">The name of the earlier created group</param>
        /// <param name="messages">One or more string message/step</param>

        public void AddMessage(string group, params string[] messages)
        {
            if (!iGuide.ContainsKey(group))
            {
                return;
            }

            InteractiveHelp ih = iGuide[group];
            List <string>   f  = new List <string>();

            foreach (string msg in ih.messages)
            {
                f.Add(msg);
            }

            foreach (string msg in messages)
            {
                f.Add(msg);
            }

            ih.messages   = f;
            iGuide[group] = ih;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Callback for checking progress of  the walkthrough
        /// </summary>
        /// <param name="cmd">String command</param>

        public void OnCommand(string cmd)
        {
            InteractiveHelp ih               = iGuide[currentHelp];
            int             currentIdle      = ih.idle[currentHelpIndex - 1];
            Func <bool>     currentCondition = ih.triggerNext[currentHelpIndex - 1];

            if (currentHelpIndex >= ih.messages.Count)
            {
                Thread.Sleep(currentIdle * 1000);
                WriteLine("Tutorial completed!");
                GetCommandUpdates = false;
                currentHelp       = "";
                currentHelpIndex  = 0;
                return;
            }
            string currentMessage = ih.messages[currentHelpIndex];

            if (currentCondition())
            {
                Thread.Sleep(currentIdle * 1000);
                WriteLine(currentMessage);
                currentHelpIndex++;
            }
        }