Ejemplo n.º 1
0
        public bool ClearOutputText()
        {
            if (RtxResult.InvokeRequired)
            {
                //// 解决窗体关闭时出现“访问已释放句柄”异常
                //while (RtxResult.IsHandleCreated == false)
                //{
                //    if (RtxResult.Disposing || RtxResult.IsDisposed) return false;
                //}

                //BeginInvoke(new Action(() =>
                //{
                //    RtxResult.SelectionColor = color;
                //    //_lastTextColor = color;

                //    if (type != OutputType.Sql && type != OutputType.None)
                //        RtxResult.AppendText("-- ");

                //    RtxResult.AppendText(text);
                //    RtxResult.Focus();
                //    RtxResult.ScrollToCaret();
                //    RtxResult.Refresh();
                //}));
                ClearTextHander d = new ClearTextHander(ClearOutputText);
                this.Invoke(d, new object[] { });
                Application.DoEvents();
            }
            else
            {
                RtxResult.Clear();
                RtxResult.Refresh();
            }
            //RtxResult.SelectionColor = color;
            ////_lastTextColor = color;

            //if (type != OutputType.Sql && type != OutputType.None)
            //    RtxResult.AppendText("-- ");

            //RtxResult.AppendText(text);
            //RtxResult.Focus();
            //RtxResult.ScrollToCaret();
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 替换最后一行的文本
        /// </summary>
        /// <param name="content"></param>
        public bool ReplaceLastLineText(string content, OutputType type = OutputType.Comment)
        {
            try
            {
                if (RtxResult.InvokeRequired)
                {
                    //// 解决窗体关闭时出现“访问已释放句柄”异常
                    //while (RtxResult.IsHandleCreated == false)
                    //{
                    //    if (RtxResult.Disposing || RtxResult.IsDisposed) return false;
                    //}
                    //BeginInvoke(new Action(() =>
                    //{
                    //    ////RtxResult.Text = content;
                    //    //System.Threading.Thread.Sleep(10);
                    //    //File.AppendAllText(Environment.CurrentDirectory + "/1.txt", "ReplaceLastLineText Start" + "\r\n");
                    //    if (type != OutputType.Sql && type != OutputType.None)
                    //        content = content.Insert(0, "-- ");
                    //    RtxResult.Select(RtxResult.Text.LastIndexOf("\n") + 1, RtxResult.Text.Length - RtxResult.Text.LastIndexOf("\n"));
                    //    RtxResult.SelectedText = content;
                    //    RtxResult.Focus();
                    //    //System.Threading.Thread.Sleep(10);
                    //    //File.AppendAllText(Environment.CurrentDirectory + "/1.txt", "ReplaceLastLineText END" + "\r\n");
                    //    RtxResult.ScrollToCaret();
                    //    RtxResult.Refresh();
                    //}));
                    SetTextCallback d = new SetTextCallback(ReplaceLastLineText);
                    this.Invoke(d, new object[] { content, type });
                    Application.DoEvents();
                }
                else
                {
                    ////RtxResult.Text = content;
                    //System.Threading.Thread.Sleep(10);
                    //File.AppendAllText(Environment.CurrentDirectory + "/1.txt", "ReplaceLastLineText Start" + "\r\n");
                    if (type != OutputType.Sql && type != OutputType.None)
                    {
                        content = content.Insert(0, "-- ");
                    }
                    RtxResult.Select(RtxResult.Text.LastIndexOf("\n") + 1, RtxResult.Text.Length - RtxResult.Text.LastIndexOf("\n"));
                    RtxResult.SelectedText = content;
                    RtxResult.Focus();
                    //System.Threading.Thread.Sleep(10);
                    //File.AppendAllText(Environment.CurrentDirectory + "/1.txt", "ReplaceLastLineText END" + "\r\n");
                    RtxResult.ScrollToCaret();
                    RtxResult.Refresh();
                }
                ////System.Threading.Thread.Sleep(10);
                ////File.AppendAllText(Environment.CurrentDirectory + "/1.txt", "ReplaceLastLineText Start" + "\r\n");
                //if (type != OutputType.Sql && type != OutputType.None)
                //    content = content.Insert(0, "-- ");
                //RtxResult.Select(RtxResult.Text.LastIndexOf("\n") + 1, RtxResult.Text.Length - RtxResult.Text.LastIndexOf("\n"));
                //RtxResult.SelectedText = content;
                //RtxResult.Focus();
                ////System.Threading.Thread.Sleep(10);
                ////File.AppendAllText(Environment.CurrentDirectory + "/1.txt", "ReplaceLastLineText END" + "\r\n");
                //RtxResult.ScrollToCaret();
                return(true);

                return(false);
            }
            catch (Exception e)
            {
                //File.AppendAllText(Environment.CurrentDirectory + "/1.txt", "2/" + e.Message);
                return(false);
            }
        }
Ejemplo n.º 3
0
        public bool AppendOutputText(string text, OutputType type)
        {
            Color color = Color.Black;

            if (type == OutputType.Comment)
            {
                color = Color.DarkGray;
            }
            else if (type == OutputType.Warning)
            {
                color = Color.Orange;
            }
            else if (type == OutputType.Error)
            {
                color = Color.Red;
            }
            else if (type == OutputType.Sql)
            {
                color = Color.Black;
            }
            //else
            //    color = _lastTextColor;


            if (RtxResult.InvokeRequired)
            {
                //// 解决窗体关闭时出现“访问已释放句柄”异常
                //while (RtxResult.IsHandleCreated == false)
                //{
                //    if (RtxResult.Disposing || RtxResult.IsDisposed) return false;
                //}

                //BeginInvoke(new Action(() =>
                //{
                //    RtxResult.SelectionColor = color;
                //    //_lastTextColor = color;

                //    if (type != OutputType.Sql && type != OutputType.None)
                //        RtxResult.AppendText("-- ");

                //    RtxResult.AppendText(text);
                //    RtxResult.Focus();
                //    RtxResult.ScrollToCaret();
                //    RtxResult.Refresh();
                //}));
                SetTextCallback d = new SetTextCallback(AppendOutputText);
                this.Invoke(d, new object[] { text, type });
                Application.DoEvents();
            }
            else
            {
                RtxResult.SelectionColor = color;
                //_lastTextColor = color;

                if (type != OutputType.Sql && type != OutputType.None)
                {
                    RtxResult.AppendText("-- ");
                }

                RtxResult.AppendText(text);
                RtxResult.Focus();
                RtxResult.ScrollToCaret();
                RtxResult.Refresh();
            }
            //RtxResult.SelectionColor = color;
            ////_lastTextColor = color;

            //if (type != OutputType.Sql && type != OutputType.None)
            //    RtxResult.AppendText("-- ");

            //RtxResult.AppendText(text);
            //RtxResult.Focus();
            //RtxResult.ScrollToCaret();
            return(true);
        }