// 最低限度需要重写的方法
 public override void Write(string value)
 {
     if (textBox.InvokeRequired)
     {
         textBox.BeginInvoke(write, value);
     }
     else
     {
         textBox.AppendText(value);
     }
 }
示例#2
0
 /// <summary>
 /// Internal implementation of Write; bypasses \n checking for the prefix
 /// </summary>
 /// <param name="data">The text to write</param>
 /// <remarks>
 /// This method exists so it can be called when we need to write the prefix.
 /// </remarks>
 protected virtual void _innerWrite(string data)
 {
     data = AddMissingCRs(data);
     if (tb.InvokeRequired)
     {
         if (this.SyncInvoke)
         {
             tb.Invoke(asyncWriteSync, new object[] { data });
         }
         else
         {
             // Okay, an async invocation is needed
             _writeBuffer.QueueWrite(data);
             if (!_writeQueued)
             {
                 _writeQueued = true;
                 tb.BeginInvoke(asyncWriteAsync);
             }
         }
         return;
     }
     // Okay, no invoke required. That means we're executing on the main thread.
     // If there are any queued writes, write them *right now*.
     _asyncWriteAsync();
     tb.AppendText(data);
 }
示例#3
0
        public override void Clear()
        {
            base.Clear();

            lock (_textBox)
            {
                if (_textBox.InvokeRequired)
                {
                    _textBox.BeginInvoke(new Action(_textBox.Clear));
                }
                else
                {
                    _textBox.Clear();
                }
            }
        }
示例#4
0
	}// -----------------------------------------
	public override void Write(string message)
	{
		if (box.InvokeRequired) {
			box.BeginInvoke(writeFunction, message);
		} else {
			writeFunction(message);
		}
	}// -----------------------------------------
    public override void Write(string message)
    {
        Action append = delegate()
        {
            output.AppendText(string.Format("[{0}] ", DateTime.Now.ToString()));
            output.AppendText(message);
            output.AppendText(Environment.NewLine);
        };

        if (output.InvokeRequired)
        {
            output.BeginInvoke(append);
        }
        else
        {
            append();
        }
    }
示例#6
0
 public override void Write(string message)
 {
     message = message.Replace("\r\n", "\n");
     message = message.Replace("\n", "\r\n");
     _textBox.BeginInvoke((Action) delegate {
         _textBox.AppendText(message);
         _textBox.ScrollToCaret();
     });
 }
示例#7
0
 /// <summary>
 /// Write a string to the trace window
 /// </summary>
 /// <param name="message">The string to write</param>
 public override void Write(string message)
 {
     if (textBox.InvokeRequired)
     {
         textBox.BeginInvoke(new AppendTextDelegate(textBox.AppendText), new object[] { message });
     }
     else
     {
         textBox.AppendText(message);
     }
 }
示例#8
0
 /// <summary>
 /// Sets the border style.
 /// </summary>
 /// <param name="textBoxBase">The text box base.</param>
 /// <param name="value">The value.</param>
 public static void SetBorderStyle(this TextBoxBase textBoxBase, BorderStyle value)
 {
     if (textBoxBase.InvokeRequired)
     {
         textBoxBase.BeginInvoke(new MethodInvoker(() => textBoxBase.SetBorderStyle(value)));
     }
     else
     {
         textBoxBase.BorderStyle = value;
         textBoxBase.Refresh();
     }
 }
示例#9
0
 /// <summary>
 /// Sets the background image layout.
 /// </summary>
 /// <param name="textBoxBase">The text box base.</param>
 /// <param name="value">The value.</param>
 public static void SetBackgroundImageLayout(this TextBoxBase textBoxBase, ImageLayout value)
 {
     if (textBoxBase.InvokeRequired)
     {
         textBoxBase.BeginInvoke(new MethodInvoker(() => textBoxBase.SetBackgroundImageLayout(value)));
     }
     else
     {
         textBoxBase.BackgroundImageLayout = value;
         textBoxBase.Refresh();
     }
 }
示例#10
0
 /// <summary>
 /// Sets the color of the back.
 /// </summary>
 /// <param name="textBoxBase">The text box base.</param>
 /// <param name="value">The value.</param>
 public static void SetBackColor(this TextBoxBase textBoxBase, Color value)
 {
     if (textBoxBase.InvokeRequired)
     {
         textBoxBase.BeginInvoke(new MethodInvoker(() => textBoxBase.SetBackColor(value)));
     }
     else
     {
         textBoxBase.BackColor = value;
         textBoxBase.Refresh();
     }
 }
示例#11
0
 /// <summary>
 /// Sets the word wrap.
 /// </summary>
 /// <param name="textBoxBase">The text box base.</param>
 /// <param name="value">if set to <c>true</c> [value].</param>
 public static void SetWordWrap(this TextBoxBase textBoxBase, bool value)
 {
     if (textBoxBase.InvokeRequired)
     {
         textBoxBase.BeginInvoke(new MethodInvoker(() => textBoxBase.SetWordWrap(value)));
     }
     else
     {
         textBoxBase.WordWrap = value;
         textBoxBase.Refresh();
     }
 }
示例#12
0
 /// <summary>
 /// Sets the selection start.
 /// </summary>
 /// <param name="textBoxBase">The text box base.</param>
 /// <param name="value">The value.</param>
 public static void SetSelectionStart(this TextBoxBase textBoxBase, int value)
 {
     if (textBoxBase.InvokeRequired)
     {
         textBoxBase.BeginInvoke(new MethodInvoker(() => textBoxBase.SetSelectionStart(value)));
     }
     else
     {
         textBoxBase.SelectionStart = value;
         textBoxBase.Refresh();
     }
 }
示例#13
0
 /// <summary>
 /// Sets the maximum length.
 /// </summary>
 /// <param name="textBoxBase">The text box base.</param>
 /// <param name="value">The value.</param>
 public static void SetMaxLength(this TextBoxBase textBoxBase, int value)
 {
     if (textBoxBase.InvokeRequired)
     {
         textBoxBase.BeginInvoke(new MethodInvoker(() => textBoxBase.SetMaxLength(value)));
     }
     else
     {
         textBoxBase.MaxLength = value;
         textBoxBase.Refresh();
     }
 }
示例#14
0
 /// <summary>
 /// Sets the shortcuts enabled.
 /// </summary>
 /// <param name="textBoxBase">The text box base.</param>
 /// <param name="value">if set to <c>true</c> [value].</param>
 public static void SetShortcutsEnabled(this TextBoxBase textBoxBase, bool value)
 {
     if (textBoxBase.InvokeRequired)
     {
         textBoxBase.BeginInvoke(new MethodInvoker(() => textBoxBase.SetShortcutsEnabled(value)));
     }
     else
     {
         textBoxBase.ShortcutsEnabled = value;
         textBoxBase.Refresh();
     }
 }
示例#15
0
 /// <summary>
 /// Sets the accepts tab.
 /// </summary>
 /// <param name="textBoxBase">The text box base.</param>
 /// <param name="value">if set to <c>true</c> [value].</param>
 public static void SetAcceptsTab(this TextBoxBase textBoxBase, bool value)
 {
     if (textBoxBase.InvokeRequired)
     {
         textBoxBase.BeginInvoke(new MethodInvoker(() => textBoxBase.SetAcceptsTab(value)));
     }
     else
     {
         textBoxBase.AcceptsTab = value;
         textBoxBase.Refresh();
     }
 }
示例#16
0
 /// <summary>
 /// Sets the hide selection.
 /// </summary>
 /// <param name="textBoxBase">The text box base.</param>
 /// <param name="value">if set to <c>true</c> [value].</param>
 public static void SetHideSelection(this TextBoxBase textBoxBase, bool value)
 {
     if (textBoxBase.InvokeRequired)
     {
         textBoxBase.BeginInvoke(new MethodInvoker(() => textBoxBase.SetHideSelection(value)));
     }
     else
     {
         textBoxBase.HideSelection = value;
         textBoxBase.Refresh();
     }
 }
示例#17
0
 /// <summary>
 /// Sets the lines.
 /// </summary>
 /// <param name="textBoxBase">The text box base.</param>
 /// <param name="value">The value.</param>
 public static void SetLines(this TextBoxBase textBoxBase, IEnumerable <string> value)
 {
     if (textBoxBase.InvokeRequired)
     {
         textBoxBase.BeginInvoke(new MethodInvoker(() => textBoxBase.SetLines(value)));
     }
     else
     {
         textBoxBase.Lines = value.ToArray();
         textBoxBase.Refresh();
     }
 }
示例#18
0
 /// <summary>
 /// Sets the text.
 /// </summary>
 /// <param name="textBoxBase">The text box base.</param>
 /// <param name="value">The value.</param>
 public static void SetText(this TextBoxBase textBoxBase, string value)
 {
     if (textBoxBase.InvokeRequired)
     {
         textBoxBase.BeginInvoke(new MethodInvoker(() => textBoxBase.SetText(value)));
     }
     else
     {
         textBoxBase.Text = value;
         textBoxBase.Refresh();
     }
 }
示例#19
0
        public override void Write(string message)
        {
            AppendDelegate append = new AppendDelegate(Append);

            if (output.InvokeRequired)
            {
                output.BeginInvoke(append, new object[] { message });
            }
            else
            {
                append(message);
            }
        }
示例#20
0
        public override void Write(string message)
        {
            Action append = () => textBox.AppendText(message);

            if (textBox.InvokeRequired)
            {
                textBox.BeginInvoke(append);
            }
            else
            {
                append();
            }
        }
示例#21
0
        protected override void Append(LoggingEvent loggingEvent)
        {
            var logInfo = string.Empty;

            if (_textBox == null)
            {
                if (string.IsNullOrEmpty(FormName) || string.IsNullOrEmpty(TextBoxName))
                {
                    return;
                }
                Form form = Application.OpenForms[FormName];
                if (form == null)
                {
                    return;
                }
                TableLayoutPanel layoutPanel = form.Controls[TableLayoutPanelName] as TableLayoutPanel;
                if (layoutPanel == null)
                {
                    return;
                }
                Panel panel = layoutPanel.Controls[PanelName] as Panel;
                if (panel == null)
                {
                    return;
                }
                TabControl tabControl = panel.Controls[TabControlName] as TabControl;
                if (tabControl == null)
                {
                    return;
                }
                TabPage tabPage = tabControl.Controls[TabPageName] as TabPage;
                if (tabPage == null)
                {
                    return;
                }
                _textBox = tabPage.Controls[TextBoxName] as TextBox;
                if (_textBox == null)
                {
                    return;
                }
                form.FormClosed += (s, e) => _textBox = null;
            }

            _textBox.BeginInvoke((MethodInvoker) delegate
            {
                _textBox.AppendText(RenderLoggingEvent(loggingEvent));
                _textBox.Focus();
                _textBox.Select(_textBox.TextLength, 0);
                _textBox.ScrollToCaret();
            });
        }
        public override void Write(string message)
        {
            Action append = delegate()
            {
                output.AppendText(message);
            };

            if (output.InvokeRequired)
            {
                output.BeginInvoke(append);
            }
            else
            {
                append();
            }
        }
示例#23
0
        void AddTextToOutputWindow(string ExeFileName, string Text)
        {
            //if ((DateTime.Now - dt).TotalSeconds >= 1)
            //  Application.DoEvents()
            ExeFileName = Tools.FileNameToLower(ExeFileName);
            if (WorkbenchStorage.SetCurrentTabPageIfWriteToOutputWindow)
            {
                WorkbenchStorage.SetCurrentTabPageIfWriteToOutputWindow = false;
                CurrentCodeFileDocument = WorkbenchServiceFactory.RunService.GetRunTab(ExeFileName) as CodeFileDocumentControl;
            }
            BottomTabsVisible = true;
            if (BottomActiveContent != OutputWindow)
            {
                OutputWindow.Activate();
                CurrentCodeFileDocument.Activate();
                OutputWindow.Activate();
            }
            TextBoxBase textBox = OutputTextBoxs[WorkbenchServiceFactory.RunService.GetRunTab(ExeFileName) as CodeFileDocumentControl];

            textBox.BeginInvoke(new AppendTextInternalAsyncDelegate(AppendTextInternalAsync), textBox, Text);
            if (textBox == OutputWindow.outputTextBox)
            {
                OutputWindow.OutputTextBoxScrolToEnd();
            }
            if (WorkbenchServiceFactory.DebuggerManager.IsRun(ExeFileName))
            {
                for (int i = 0; i < TabStack.Count; i++)
                {
                    TextBoxBase tb = OutputTextBoxs[TabStack[i]];
                    if (textBox != tb)
                    {
                        tb.BeginInvoke(new AppendTextInternalAsyncDelegate(AppendTextInternalAsync), tb, Text);
                    }
                }
            }
            if (!WorkbenchServiceFactory.RunService.IsRun(ExeFileName))
            {
                SetFocusToEditor();
            }
        }
示例#24
0
        public override void Write(string message)
        {
            if (this.output.IsDisposed)
            {
                return;
            }

            Callback append = delegate()
            {
                output.AppendText(string.Format("[{0}] ", DateTime.Now.ToString()));
                output.AppendText(message);
            };

            if (output.InvokeRequired)
            {
                output.BeginInvoke(append);
            }
            else
            {
                append();
            }
        }