/// <summary>
        /// Append text to a RichTextBox with font customization
        /// </summary>
        /// <param name="box">Target RichTextBox</param>
        /// <param name="text">Text to add</param>
        /// <param name="color">Color of the text</param>
        /// <param name="style">Font style of the text</param>

        private void AppendTextBox(RichTextBox box, string text, Color color, FontStyle style)
        {
            BotBox.log.Add(text);
            AwaitingEngine.SendString(text, Convert.ToInt32(box.Parent.Parent.Text.Remove(0, 4)));
            if (InvokeRequired)
            {
                this.Invoke(new Action <RichTextBox, string, Color, FontStyle>(AppendTextBox), new object[] { box, text, color, style });
            }
            else
            {
                if (box.Text.Length > 10000)
                {
                    box.Text = box.Text.Remove(0, 500);
                }

                box.SelectionStart  = box.TextLength;
                box.SelectionLength = 0;
                box.SelectionColor  = color;
                box.SelectionFont   = new Font(box.Font, style);
                box.AppendText(text);
                box.SelectionColor = box.ForeColor;
                box.SelectionStart = box.Text.Length;
                box.ScrollToCaret();
            }
        }
Beispiel #2
0
        void RUNinAsync(object output)
        {
            var outputinclass = (OutputWriter)output;
            var cmds          = commands;

            regions = new List <Region>();
            vars    = new List <Variable>();
            for (int i = 0; i < cmds.Count; i++)
            {
                if (cmds[i] == "")
                {
                    cmds[i] = "null";
                }
            }
            foreach (var item in cmds)
            {
                List <string> parts = item.Split(' ').ToList();
                if (parts[0] == "$new")
                {
                    vars.Add(new Variable(parts[1], "null"));
                }
            }
            for (int i = 0; i < cmds.Count + 1; i++)
            {
                List <string> compiledcommands = Variable.ReplaceVars(vars, cmds);
                compiledcommands.Insert(0, "#begin");
                Thread.Sleep(5);
                var           item  = compiledcommands[i];
                List <string> parts = item.Split(' ').ToList();
                switch (item[0])
                {
                case '/':
                {
                    try
                    {
                        outputinclass.Write(item);
                        break;
                    }
                    catch { return; }
                }

                case '@':
                {
                    switch (parts[0])
                    {
                    case "@delay": { Thread.Sleep(Convert.ToInt32(parts[1])); break; }

                    case "@goto": { i = Region.RecoRegions(regions, parts[1]); break; }

                    case "@await":
                    {
                        string txt = item.Remove(0, 6);
                        txt = txt.Trim();
                        if (!testmode)
                        {
                            AwaitingEngine engine = new AwaitingEngine(txt, outputinclass.MCCClient.ID);
                            while (true && !BotBox.exited && !engine.IsSucces)
                            {
                                Thread.Sleep(100);
                            }
                        }
                        break;
                    }
                    }
                    break;
                }

                case '#':
                {
                    regions.Add(new Region(parts[0].Remove(0, 1), i));
                    break;
                }

                case '$':
                {
                    if (parts[0] == "$set")
                    {
                        Variable.SetValue(vars, parts[1], parts[2]);
                    }
                    break;
                }

                case '%':
                {
                    if (Variable.RecoVars(vars, parts[1]) == parts[2])
                    {
                        i = Region.RecoRegions(regions, parts[3]);
                    }
                    break;
                }
                }
            }
        }