コード例 #1
0
ファイル: Tools.cs プロジェクト: XBLHammer/ame3.3
 public static void AppendText(RichTextBoxEx rtb, string str, Color color)
 {
     try
     {
         if (rtb.InvokeRequired)
         {
             rtb.Invoke(new MethodInvoker(delegate
             {
                 rtb.SelectionStart  = rtb.TextLength;
                 rtb.SelectionLength = 0;
                 rtb.SelectionColor  = color;
                 string time         = string.Format("{0:hh:mm:ss tt}", DateTime.Now.ToLocalTime());
                 rtb.AppendText(string.Concat(new object[] { "[", time, "] ", str, "\n" }));
                 rtb.SelectionColor = rtb.ForeColor;
                 rtb.SelectionStart = rtb.Text.Length;
                 rtb.ScrollToCaret();
             }));
         }
         else
         {
             rtb.SelectionStart  = rtb.TextLength;
             rtb.SelectionLength = 0;
             rtb.SelectionColor  = color;
             string time = string.Format("{0:hh:mm:ss tt}", DateTime.Now.ToLocalTime());
             rtb.AppendText(string.Concat(new object[] { "[", time, "] ", str, "\n" }));
             rtb.SelectionColor = rtb.ForeColor;
             rtb.SelectionStart = rtb.Text.Length;
             rtb.ScrollToCaret();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Server", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #2
0
 private void AddTextRightAligned(RichTextBoxEx textbox, Font font, string str, Color color)
 {
     textbox.SelectionFont      = font;
     textbox.SelectionColor     = color;
     textbox.SelectionAlignment = TextAlign.Right;
     textbox.AppendText(str);
 }
コード例 #3
0
ファイル: Util.cs プロジェクト: luan999/RoinCableTester_QR
        public static void AppendText(this RichTextBoxEx box, string text, Color color)
        {
            box.SelectionStart  = box.TextLength;
            box.SelectionLength = 0;

            box.SelectionColor = color;
            box.AppendText(text);
            box.SelectionColor = box.ForeColor;
        }
コード例 #4
0
 public void RenderChapterELS50(bool isGrouped = false)
 {
     RenderText(EditChapterELS50, false, isGrouped, () =>
     {
         using var box = new RichTextBoxEx();
         foreach (var chapter in CurrentReference.Book.Chapters)
         {
             AddTextRightAligned(box, HebrewFont12, chapter.ELS50);
             AddTextRightAligned(box, LatinFont10, $" :{chapter.NumberFormatted}");
             box.AppendText(Globals.NL);
         }
         EditChapterELS50.Rtf = box.Rtf;
     });
 }
コード例 #5
0
 public void RenderChapterOriginal(bool isGrouped = false)
 {
     RenderText(EditChapterOriginal, false, isGrouped, () =>
     {
         using var box = new RichTextBoxEx();
         foreach (VerseRow verse in CurrentReference.Chapter.Verses)
         {
             AddTextRightAligned(box, HebrewFont12, verse.InHebrew);
             AddTextRightAligned(box, LatinFont10, $" :{verse.NumberFormatted}");
             box.AppendText(Globals.NL2);
         }
         EditChapterOriginal.Rtf = box.Rtf;
     });
 }
コード例 #6
0
        public static void AppendText(RichTextBoxEx box, string text, Color color, FontStyle fontStyle, bool AddNewLine = false)
        {
            if (AddNewLine)
            {
                text += Environment.NewLine;
            }

            box.SelectionStart  = box.TextLength;
            box.SelectionLength = 0;
            box.SelectionColor  = color;
            box.SelectionFont   = new Font(box.SelectionFont, fontStyle);
            box.AppendText(text);
            box.SelectionColor = box.ForeColor;
        }
コード例 #7
0
        /// <summary>
        /// 输出运行信息
        /// </summary>
        /// <param name="text"></param>
        /// <param name="type"></param>
        public void Output(string text, eOutputType outputType = eOutputType.Normal)
        {
            lock (lockObject)
            {
                try
                {
                    rTxtOutputer.Invoke((Action)(() =>
                    {
                        if (rTxtOutputer.TextLength > 5000)
                        {
                            rTxtOutputer.Clear();
                        }

                        text = string.Format("{0} - {1}", DateTime.Now.ToString("HH:mm:ss"), text);

                        rTxtOutputer.SelectionStart = rTxtOutputer.TextLength;

                        if (outputType == eOutputType.Normal)
                        {
                            rTxtOutputer.SelectionColor = ColorTranslator.FromHtml("#53A654");
                        }
                        else if (outputType == eOutputType.Important)
                        {
                            rTxtOutputer.SelectionColor = ColorTranslator.FromHtml("#ff91c5");
                        }
                        else if (outputType == eOutputType.Warn)
                        {
                            rTxtOutputer.SelectionColor = ColorTranslator.FromHtml("#ec7967");
                        }
                        else if (outputType == eOutputType.Error)
                        {
                            rTxtOutputer.SelectionColor = ColorTranslator.FromHtml("#f11030");
                        }

                        rTxtOutputer.AppendText(string.Format("{0}\r", text));

                        rTxtOutputer.ScrollToCaret();
                    }));
                }
                catch { }
            }
        }
コード例 #8
0
        /// <summary>
        /// 输出运行信息
        /// </summary>
        /// <param name="richTextBox"></param>
        /// <param name="text"></param>
        /// <param name="outputType"></param>
        private void OutputRunInfo(RichTextBoxEx richTextBox, string text, eOutputType outputType = eOutputType.Normal)
        {
            this.Invoke((EventHandler)(delegate
            {
                if (richTextBox.TextLength > 100000)
                {
                    richTextBox.Clear();
                }

                text = string.Format("{0}  {1}", DateTime.Now.ToString("HH:mm:ss"), text);

                richTextBox.SelectionStart = richTextBox.TextLength;

                switch (outputType)
                {
                case eOutputType.Normal:
                    richTextBox.SelectionColor = ColorTranslator.FromHtml("#BD86FA");
                    break;

                case eOutputType.Important:
                    richTextBox.SelectionColor = ColorTranslator.FromHtml("#A50081");
                    break;

                case eOutputType.Warn:
                    richTextBox.SelectionColor = ColorTranslator.FromHtml("#F9C916");
                    break;

                case eOutputType.Error:
                    richTextBox.SelectionColor = ColorTranslator.FromHtml("#DB2606");
                    break;

                default:
                    richTextBox.SelectionColor = Color.White;
                    break;
                }

                richTextBox.AppendText(string.Format("{0}\r", text));

                richTextBox.ScrollToCaret();
            }));
        }
コード例 #9
0
        private void DisassemblyLines(int numberOfLines)
        {
            _output.Visible = false;
            var instructionBytes = Config.Stream.ReadRam(_lastAddress, 4 * numberOfLines, EndiannessType.Little);

            for (int i = 0; i < numberOfLines; i++, _lastAddress += 4)
            {
                // Get next bytes
                var nextBytes = new byte[4];
                Array.Copy(instructionBytes, i * 4, nextBytes, 0, 4);

                // Write Address
                _output.AppendText(HexUtilities.FormatValue(_lastAddress | 0x80000000, 8) + ": ", Color.Blue);

                // Write byte-code
                _output.AppendText(BitConverter.ToString(nextBytes.Reverse().ToArray()).Replace('-', ' '), Color.DarkGray);

                // Write Disassembly
                uint   instruction = BitConverter.ToUInt32(nextBytes, 0);
                uint   address     = (uint)(((uint)_lastAddress) & 0x0FFFFFFF);
                string disassembly = "\t" + N64Disassembler.DisassembleInstruction(address, instruction);
                _output.AppendText(disassembly, Color.Red);

                // Replace "span's"
                string searchText = "<span class='dis-reg-";
                int    findIndex  = _output.Text.IndexOf(searchText);;
                while (findIndex >= 0)
                {
                    _output.ReadOnly = false;
                    _output.Select(findIndex, _output.Text.IndexOf('>', findIndex) - findIndex + 1);
                    _output.SelectedText = "";
                    _output.Select(findIndex, _output.Text.IndexOf('<', findIndex) - findIndex);
                    _output.SelectionColor = Color.Green;
                    _output.Select(_output.Text.IndexOf('<', findIndex), "</span>".Length);
                    _output.SelectedText = "";
                    _output.ReadOnly     = true;

                    findIndex = _output.Text.IndexOf(searchText);
                }

                searchText = "<span class='dis-address-jump'>";
                findIndex  = _output.Text.IndexOf(searchText);;
                while (findIndex >= 0)
                {
                    _output.ReadOnly = false;
                    _output.Select(findIndex, searchText.Length);
                    _output.SelectedText = "";
                    _output.Select(findIndex, _output.Text.IndexOf('<', findIndex) - findIndex);
                    _output.SelectionColor = Color.Blue;
                    _output.SetSelectionLink(true);
                    _output.Select(_output.Text.IndexOf('<', findIndex), "</span>".Length);
                    _output.SelectedText = "";
                    _output.ReadOnly     = true;

                    findIndex = _output.Text.IndexOf(searchText);
                }

                // Finish line (no pun intended)
                _output.AppendText(Environment.NewLine);
            }
            _output.Visible = true;
        }