当前位置: 首页>>代码示例>>C#>>正文


C# RichTextBox.Invoke方法代码示例

本文整理汇总了C#中System.Windows.Forms.RichTextBox.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# RichTextBox.Invoke方法的具体用法?C# RichTextBox.Invoke怎么用?C# RichTextBox.Invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.RichTextBox的用法示例。


在下文中一共展示了RichTextBox.Invoke方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AppendText

 private void AppendText(string text, RichTextBox rtb)
 {
     if(rtb.InvokeRequired)
     {
         rtb.Invoke(new AppendTextDelegate(AppendText), text, rtb);
     }
     else
     {
         rtb.AppendText(text + Environment.NewLine);
     }
 }
开发者ID:gunnerwolf,项目名称:Quot,代码行数:11,代码来源:MainForm.cs

示例2: SetSelectionColor

 public static void SetSelectionColor(RichTextBox control, System.Drawing.Color color)
 {
     if (control.InvokeRequired)
         control.Invoke(new SetSelectionColorDelegate(SetSelectionColor), control, color);
     else
         control.SelectionColor = color;
 }
开发者ID:greeduomacro,项目名称:phoenix,代码行数:7,代码来源:Safe.cs

示例3: AppendMessage

        /// <summary>
        /// Writes a message to the specified RichTextBox.
        /// </summary>
        /// <param name="textBox"></param>
        /// <param name="message">The <see cref="string">message</see> to be written.</param>
        /// <param name="col"></param>
        private static void AppendMessage(RichTextBox textBox, string message, Color col)
        {
            try
            {
                if (!textBox.IsDisposed)
                {
                    if (textBox.InvokeRequired)
                    {
                        textBox.Invoke(new Action<RichTextBox, string, Color>(AppendMessage), textBox, message, col);
                        return;
                    }

                    Color oldColor = textBox.SelectionColor;
                    textBox.SelectionColor = col;
                    textBox.AppendText(message);
                    textBox.SelectionColor = oldColor;
                    textBox.AppendText(Environment.NewLine);
                    textBox.ScrollToCaret();
                }
            }
            catch (Exception ex)
            {
                Logging.WriteException(ex);
            }
        }
开发者ID:RaptorFactor,项目名称:devmaximus,代码行数:31,代码来源:Log.cs

示例4: AddLine

 private void AddLine(RichTextBox RTB, string line)
 {
     if (RTB.InvokeRequired)
         RTB.Invoke(new Action(() => RTB.AppendText(line + Environment.NewLine)));
     else
         RTB.AppendText(line + Environment.NewLine);
 }
开发者ID:DatKami,项目名称:FEAT,代码行数:7,代码来源:Form1.cs

示例5: AddText

 private void AddText(RichTextBox RTB, string msg)
 {
     if (RTB.InvokeRequired)
         RTB.Invoke(new Action(() => RTB.AppendText(msg)));
     else
         RTB.AppendText(msg);
 }
开发者ID:DatKami,项目名称:FEAT,代码行数:7,代码来源:Form1.cs

示例6: UpdateRtfText

 public static void UpdateRtfText(RichTextBox i_RichTextBox, string i_Text)
 {
     if (i_RichTextBox.InvokeRequired)
     {
         i_RichTextBox.Invoke(new Action<RichTextBox, string>(UpdateRtfText), i_RichTextBox, i_Text);
     }
     else
     {
         i_RichTextBox.Rtf = i_Text;
     }
 }
开发者ID:rajeshwarn,项目名称:dp_ex4,代码行数:11,代码来源:Utils.cs

示例7: AppendText

 private void AppendText(RichTextBox ctrl, string text)
 {
     if (ctrl.InvokeRequired)
     {
         AppendText_Callback call = new AppendText_Callback(AppendText);
         ctrl.Invoke(call, ctrl, text);
     }
     else
     {
         ctrl.AppendText(text);
         ctrl.ScrollToCaret();
     }
 }
开发者ID:HaKDMoDz,项目名称:geff,代码行数:13,代码来源:FrmParallelAStar.cs

示例8: push

 protected void push(RichTextBox box, string message)
 {
     // box.InvokeRequired may does not check properly
     try {
         box.Text += message;
     }
     catch
     {
         box.Invoke((MethodInvoker)delegate {
             box.Text += message;
         });
     }
 }
开发者ID:hilbertdu,项目名称:vsSolutionBuildEvent,代码行数:13,代码来源:StatusFrm.cs

示例9: SetText

        public static void SetText(string text, RichTextBox tb)
        {
            if (tb.InvokeRequired)
            {
                SetTextCallback d = new SetTextCallback(SetText);
                tb.Invoke(d, new object[] { text, tb });

            }
            else
            {
                tb.AppendText(text);
                tb.AppendText("\r\n");
            }
        }
开发者ID:Kentarre,项目名称:XmppClient,代码行数:14,代码来源:chatMain.cs

示例10: AddMessageToControlInvoke

 private void AddMessageToControlInvoke(RichTextBox sender, String message)
 {
     if (sender.InvokeRequired)
     {
         sender.Invoke(addMessage, message);
     }
     else
     {
         if (!String.IsNullOrEmpty(message))
         {
             sender.Text += String.Format("[{0}]{1}\r\n", DateTime.Now.ToString("yyMMdd HH:mm:ss"), message);
             sender.SelectionStart = richTextBoxReceiver.TextLength;
             sender.ScrollToCaret();
         }
     }
 }
开发者ID:raindyi,项目名称:LearningProject,代码行数:16,代码来源:ServerForm.cs

示例11: OutMsg

 /// <summary>
 /// 委托方式输出信息
 /// </summary>
 /// <param name="rtb">文本框实例</param>
 /// <param name="msg">要输出的信息</param>
 /// <param name="color">信息的颜色</param>
 public static void OutMsg(RichTextBox rtb, string msg, Color color)
 {
     try
     {
         rtb.Invoke(new EventHandler(delegate
         {
             rtb.SelectionStart = rtb.Text.Length;
             rtb.SelectionColor = color;
             rtb.AppendText(msg + "\r\n");
             rtb.ScrollToCaret();
             if (rtb.Text.Length > 4000)
             {
                 rtb.Text = string.Empty;
             }
         }));
     }
     catch (Exception)
     {
         Application.Exit();
     }
 }
开发者ID:Rozbo,项目名称:51ctohelper,代码行数:27,代码来源:DoLog.cs

示例12: BuildFile

        // Functions
        public void BuildFile(RichTextBox buildbox, string filename, string directory)
        {
            try
            {
                Process proc = new Process();
                proc.StartInfo.Arguments = filename + " -i=\"" + Directory.GetCurrentDirectory() + "\\includes\"";
                proc.StartInfo.CreateNoWindow = true;
                proc.StartInfo.FileName = "pawncc.exe";
                proc.StartInfo.RedirectStandardError = true;
                proc.StartInfo.RedirectStandardOutput = true;
                proc.StartInfo.UseShellExecute = false;
                proc.StartInfo.WorkingDirectory = directory;
                proc.Start();

                string output = proc.StandardOutput.ReadToEnd();
                string error = proc.StandardError.ReadToEnd();
                proc.WaitForExit();

                buildbox.Invoke(new MethodInvoker(delegate { buildbox.Text = error + "\n" + output.Replace("\r\n\r\n", "\r\n"); }));
            }
            catch (Exception ex) { mainform.Invoke(new MethodInvoker(delegate { mainform.CaughtException(ex); })); }
        }
开发者ID:Byt3-Hub,项目名称:PAWNEdit,代码行数:23,代码来源:Build.cs

示例13: Log

 /// <summary>
 /// Logger to be able to see the events and operations in the server
 /// </summary>
 /// <param name="control"></param>
 /// <param name="message"></param>
 public static void Log(RichTextBox control, string message)
 {
     string formatted = string.Format("\r\n[{0}] {1}", DateTime.Now.ToString("MM-dd-yy hh:mm:ss"), message);
     /// Invoke the message to the controll
     /// http://msdn.microsoft.com/en-us/library/system.windows.forms.methodinvoker.aspx
     if (!control.IsDisposed)
     {
         if (!control.InvokeRequired)
         {
             control.AppendText(formatted);
             control.ScrollToCaret();
         }
         else
         {
             control.Invoke(((MethodInvoker)delegate
             {
                 control.AppendText(formatted);
                 control.ScrollToCaret();
             }));
         }
     }
 }
开发者ID:AaronTrazona,项目名称:BusTerminalApplication,代码行数:27,代码来源:ServerUtility.cs

示例14: updateMessageList

 public void updateMessageList(RichTextBox messageList, ludo_client.dto.Message newIncomingMessage)
 {
     if (messageList.InvokeRequired)
     {
         // We're on a thread other than the GUI thread
         messageList.Invoke(new MethodInvoker(() => updateMessageList(messageList, newIncomingMessage)));
         return;
     }
     String timeStampSecond = newIncomingMessage.TimeStamp.Second.ToString();
     if (timeStampSecond.Length == 1)
     {
         timeStampSecond = "0" + timeStampSecond;
     }
     String timeStamp = "[" + newIncomingMessage.TimeStamp.ToShortTimeString() +
         ":" + timeStampSecond  + "]";
     String sender = newIncomingMessage.Sender.UserName;
     String message = newIncomingMessage.Msg;
     messageList.AppendText(timeStamp + " ", Color.Gray);
     messageList.AppendText(sender + ": " , Color.Blue);
     messageList.AppendText(message + "\n");
     messageList.ScrollToCaret();
 }
开发者ID:Cir0X,项目名称:ludo,代码行数:22,代码来源:ChatHandler.cs

示例15: ConnectLogger

 public Task ConnectLogger(RichTextBox box)
 {
     return Task.Factory.StartNew(() =>
         {
             while (!_source.Token.IsCancellationRequested)
             {
                 string result;
                 var builder = new StringBuilder();
                 while (_log.TryDequeue(out result))
                 {
                     builder.AppendLine(result);
                 }
                 if (builder.Length > 0)
                 {
                     box.Invoke(new Action(() =>
                         {
                             box.AppendText(builder.ToString());
                             box.ScrollToCaret();
                         }));
                 }
                 _source.Token.WaitHandle.WaitOne(TimeSpan.FromMilliseconds(250));
             }
         }, _source.Token);
 }
开发者ID:mojamcpds,项目名称:lokad-cqrs-1,代码行数:24,代码来源:ShellServices.cs


注:本文中的System.Windows.Forms.RichTextBox.Invoke方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。