Example #1
0
        public static string FormatAsRtf(string buffer, ConsoleColorTheme theme)
        {
            StringBuilder           builder = new StringBuilder();
            Stack <ConsoleColorExt> stack   = new Stack <ConsoleColorExt>();

            foreach (Match match in FormatRegex.Matches(buffer))
            {
                if (match.Groups["Tag"].Success)
                {
                    ConsoleColorExt item = ParseColour(match.Groups["Inner"].Value, theme);
                    stack.Push(item);
                    builder.Append(@"\cf" + ((((int)item) + 1)).ToString() + @"\ulnone ");
                }
                else if (match.Groups["EndTag"].Success)
                {
                    if (stack.Count < 0)
                    {
                        throw new Exception(string.Format(Strings.ConsoleInterpreter_UnexpectedEndTag, match.Index));
                    }
                    builder.Append(@"\cf" + ((int)(((ConsoleColorExt)stack.Pop()) + (int)ConsoleColorExt.DarkBlue)).ToString() + @"\ulnone ");
                }
                else if (match.Groups["Text"].Success)
                {
                    string str = UnescapeString(match.Value);
                    builder.Append(ReplaceLineEnds(str));
                }
            }
            return(builder.ToString());
        }
Example #2
0
        static void Main(string[] args)
        {
            RC.Theme = ConsoleColorTheme.Load((ConsoleColor)RC.ForegroundColor, (ConsoleColor)RC.BackgroundColor, ConsoleColorDefaultThemes.Colorful);

            RpxInterface.RunCommand(args);

            RC.ResetColor();
        }
Example #3
0
        public MainForm()
        {
            RC.Verbosity       = ConsoleVerbosity.Normal;
            RC.BackgroundColor = ConsoleColorExt.Black;
            RC.Theme           = ConsoleColorTheme.Load(ConsoleColorDefaultThemes.Colorful);

            InitializeComponent();

            title = typeof(MainForm).Assembly.GetName().Name + " v" + typeof(MainForm).Assembly.GetName().Version.Major + "." + typeof(MainForm).Assembly.GetName().Version.Minor;

            SetTitle();

            icons.Add(null);
            icons.Add(GetImage(SystemIcons.Question));
            icons.Add(GetImage(SystemIcons.Asterisk));
            icons.Add(GetImage(SystemIcons.Exclamation));
            icons.Add(GetImage(SystemIcons.Error));
            icons.Add(GetImage(SystemIcons.Information));
            icons.Add(GetImage(SystemIcons.Warning));

            List <ToolStripMenuItem> commandItems = new List <ToolStripMenuItem>();

            foreach (CommandMetaData command in Commands.GetCommands())
            {
                if (command.IsVisible == false)
                {
                    continue;
                }

                if (command.OscAddress == "/time")
                {
                    continue;
                }

                ToolStripMenuItem menuItem = new ToolStripMenuItem(command.Text)
                {
                    Tag = command,
                };

                menuItem.Click += delegate(object menuSender, EventArgs args)
                {
                    ToolStripMenuItem item = menuSender as ToolStripMenuItem;

                    this.SendCommand(connectionsRows, true, item.Tag as CommandMetaData);
                };

                commandItems.Add(menuItem);
            }

            sendCommandToolStripMenuItem.DropDownItems.AddRange(commandItems.ToArray());
        }
Example #4
0
        private void Terminal_Load(object sender, EventArgs e)
        {
            m_Console.Theme = ConsoleColorTheme.Load(ConsoleColor.White, ConsoleColor.Black, ConsoleColorDefaultThemes.Colorful);

            m_BackupFont = m_SendMessageBox.Font;

            m_SendMessageBox.Text            = m_HelpText;
            m_SendMessageBox.DropDown       += SendMessageBox_DropDown;
            m_SendMessageBox.DropDownClosed += SendMessageBox_DropDownClosed;

            this.AllowDrop  = true;
            this.DragEnter += new DragEventHandler(Terminal_DragEnter);
            this.DragDrop  += new DragEventHandler(Terminal_DragDrop);
        }
Example #5
0
        public static ConsoleColorExt ParseColour(string tagInner, ConsoleColorTheme theme)
        {
            string str   = tagInner.Trim();
            int    index = str.IndexOf(':');

            if ((index == 1) && (str[0] == 'c'))
            {
                string s      = str.Substring(2);
                int    result = 0;
                if (int.TryParse(s, out result))
                {
                    return((ConsoleColorExt)result);
                }
                try
                {
                    return((ConsoleColorExt)Enum.Parse(typeof(ConsoleColorExt), s, true));
                }
                catch (Exception exception)
                {
                    throw new Exception(string.Format(Strings.ConsoleInterpreter_ParseColour_Error, str), exception);
                }
            }
            if ((index == 1) && (str[0] == 't'))
            {
                string str3 = str.Substring(2);
                int    num3 = 0;
                if (int.TryParse(str3, out num3))
                {
                    return(theme[(ConsoleThemeColor)num3]);
                }
                try
                {
                    return(theme[(ConsoleThemeColor)Enum.Parse(typeof(ConsoleThemeColor), str3, true)]);
                }
                catch (Exception exception2)
                {
                    throw new Exception(string.Format(Strings.ConsoleInterpreter_ParseColour_Error, str), exception2);
                }
            }
            throw new Exception(string.Format(Strings.ConsoleInterpreter_ParseColour_Error, str));
        }
        static void Main(string[] args)
        {
            ConsoleColorState state = RC.ColorState;

            // create the argument parser
            ArgumentParser parser = new ArgumentParser("SettingsObjectModelCodeGenerator", "Generates settings object model code for the ImuApi project");

            StringArgument XmlArg           = new StringArgument("XML", "The path of the settings XML file", "The path of the settings XML file");
            StringArgument CodeArg          = new StringArgument("Code", "The destination code .cs file", "The destination code .cs file");
            StringArgument DocumentationArg = new StringArgument("Documentation", "The documentation .XML file", "The documentation .XML file");

            // add the arguments to the parser
            parser.Add("/", "XML", XmlArg);
            parser.Add("/", "Code", CodeArg);
            parser.Add("/", "Documentation", DocumentationArg);

            try
            {
                RC.IsBuildMode = true;
                RC.Verbosity   = ConsoleVerbosity.Debug;
                RC.ApplicationBuildReportPrefix = "SGEN";

                RC.Theme = ConsoleColorTheme.Load(ConsoleColorDefaultThemes.Colorful);

                RC.WriteLine(ConsoleThemeColor.TitleText, "Settings Object Model Code Generator");

                // parse arguemnts
                parser.Parse(args);

                // did the parser detect a /? arguemnt
                if (parser.HelpMode == true)
                {
                    return;
                }

                if (XmlArg.Defined == false)
                {
                    RC.WriteError(001, "No settings XML file supplied.");
                    return;
                }

                if (CodeArg.Defined == false)
                {
                    RC.WriteError(001, "No destination file supplied.");
                    return;
                }

                if (DocumentationArg.Defined == false)
                {
                    RC.WriteError(001, "No documentation file supplied.");
                    return;
                }

                string xmlFilePath = XmlArg.Value;

                if (File.Exists(xmlFilePath) == false)
                {
                    RC.WriteError(002, "Settings XML file does not exist.");
                    return;
                }

                string codeFilePath = CodeArg.Value;

                try
                {
                    FileInfo info = new FileInfo(codeFilePath);
                }
                catch
                {
                    RC.WriteError(002, "Settings destination file is not valid.");
                    return;
                }

                string documentationFilePath = DocumentationArg.Value;

                try
                {
                    FileInfo info = new FileInfo(documentationFilePath);
                }
                catch
                {
                    RC.WriteError(002, "Settings documentation file is not valid.");
                    return;
                }

                Generate(xmlFilePath, codeFilePath, documentationFilePath);
            }
            catch (Exception ex)
            {
                RC.WriteException(04, System.Reflection.Assembly.GetExecutingAssembly().Location, 0, 0, ex);
            }
            finally
            {
                //RC.PromptForKey("Press any key to exit..", true, false);

                RC.ColorState = state;
            }
        }