Exemple #1
0
        public void ExtractText(string html_string,
                                AppendTextCallback append_text_cb,
                                AddPropertyCallback add_prop_cb,
                                AppendSpaceCallback append_white_cb,
                                AppendSpaceCallback append_break_cb,
                                HotCallback hot_up_cb,
                                HotCallback hot_down_cb)
        {
            AppendText            = append_text_cb;
            AppendWord            = append_text_cb;
            AddProperty           = add_prop_cb;
            AppendWhiteSpace      = append_white_cb;
            AppendStructuralBreak = append_break_cb;
            HotUp   = hot_up_cb;
            HotDown = hot_down_cb;

            HtmlDocument doc = new HtmlDocument();

            doc.ReportNode += HandleNodeEvent;

            doc.StreamMode = true;

            try {
                doc.LoadHtml(html_string);
            } catch (Exception e) {
                Log.Debug(e, "Exception while filtering html string [{0}]", html_string);
            }
        }
Exemple #2
0
 private void AppendText(string text)
 {
     // Since threading is involved for watching the avatar information, check to see if the textbox is writeable, and either write to it if it is or invoke the textbox on the other thread to write to it.
     if (this.textBox1.InvokeRequired)
     {
         AppendTextCallback d = new AppendTextCallback(AppendText);
         this.Invoke(d, new object[] { text });
     }
     else
     {
         this.textBox1.AppendText(text);
     }
 }
Exemple #3
0
        private void appendText(string text)
        {
            if (this.textBoxServer.InvokeRequired)
            {
                AppendTextCallback d = new AppendTextCallback(appendText);
                this.Invoke(d, new object[] { text });
            }
            else
            {
                this.textBoxServer.Text += text + Environment.NewLine;
            }

            //this.textBoxServer.Text += text + Environment.NewLine;
        }
        /// <summary>
        /// Appends text to a textbox in a multi-threaded environment.  This method does not append a linefeed at the end of the text.
        /// </summary>
        /// <param name="tb">The NAME of the textbox to be written to.</param>
        /// <param name="text">The TEXT to be appeneded to the textbox (without linefeed).</param>
        public static void appendText(TextBox tb, String text)
        {
            // Stop if TextBox reference is null
            if (tb == null) return;

            // Stop if the text reference is null
            if (text == null) return;

            if (tb.InvokeRequired)
            {
                AppendTextCallback a = new AppendTextCallback(appendText);
                tb.Invoke(a, new object[] { tb, text });
            }
            else
            {
                tb.AppendText(text);
            }
        }
 private void AppendConsoleOutput(string textToAdd)
 {
     if (this.txtConsoleOutput.InvokeRequired)
     {
         AppendTextCallback d = new AppendTextCallback(AppendConsoleOutput);
         this.Invoke(d, new object[] { textToAdd });
     }
     else
     {
         if(textToAdd.StartsWith("UPLOADING:"))
         {
             this.txtConsoleProgressBar.Text = (textToAdd + Environment.NewLine).Replace("UPLOADING: ", "");
         }
         else
         {
             this.txtConsoleOutput.AppendText(textToAdd + Environment.NewLine);
         }
     }
 }
        public LoggedTextBox(TextBox textBox)
        {
            string outputDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\BenchmarkApplication\";
            var df = new DirectoryInfo(outputDir);
            if (! df.Exists)
            {
                df = Directory.CreateDirectory(df.FullName);
            }

            string fileName = string.Format(df.FullName + "BenchmarkApplication{0}.log", DateTime.Now.ToFileTime());
            var logFile = new FileStream(fileName, FileMode.Append, FileAccess.Write, FileShare.None);
            this.streamWriter = new StreamWriter(logFile);
            this.textBox = textBox;

            this.appendText = delegate(string text)
            {
                textBox.AppendText(text);
                textBox.ScrollToEnd();
                textBox.Focus();
            };
        }
 private void AppendStatusText(string text)
 {
     try
     {
         // InvokeRequired required compares the thread ID of the
         // calling thread to the thread ID of the creating thread.
         // If these threads are different, it returns true.
         if (this.statusbox.InvokeRequired)
         {
             AppendTextCallback d = new AppendTextCallback(AppendStatusText);
             this.Invoke(d, new object[] { text });
         }
         else
         {
             //this.statusbox.SelectionColor = text_color;
             this.statusbox.AppendText(text);
             this.statusbox.ScrollToCaret();
         }
     }
     catch { }
 }
Exemple #8
0
		public FilterHtml (bool register_filter)
		{
			if (register_filter) {
				base.SetVersion (version);
				SnippetMode = true;
				SetFileType ("document");

				AppendText = new AppendTextCallback (base.AppendText);
				AppendWord = new AppendTextCallback (base.AppendWord);
				AddProperty = new AddPropertyCallback (base.AddProperty);
				AppendWhiteSpace = new AppendSpaceCallback (base.AppendWhiteSpace);
				AppendStructuralBreak = new AppendSpaceCallback (base.AppendStructuralBreak);
				HotUp = new HotCallback (base.HotUp);
				HotDown = new HotCallback (base.HotDown);
#if ENABLE_RDF_ADAPTER
				AddLink = new AddLinkCallback (base.AddLink);
#endif
			}

			ignore_level = 0;
			building_text = false;
			builder = new StringBuilder ();
		}
Exemple #9
0
		public void ExtractText (string html_string,
					 AppendTextCallback append_text_cb,
					 AddPropertyCallback add_prop_cb,
					 AppendSpaceCallback append_white_cb,
					 AppendSpaceCallback append_break_cb,
					 HotCallback hot_up_cb,
					 HotCallback hot_down_cb)
		{
			AppendText = append_text_cb;
			AppendWord = append_text_cb;
			AddProperty = add_prop_cb;
			AppendWhiteSpace = append_white_cb;
			AppendStructuralBreak = append_break_cb;
			HotUp = hot_up_cb;
			HotDown = hot_down_cb;

			HtmlDocument doc = new HtmlDocument ();
			doc.ReportNode += HandleNodeEvent;

			doc.StreamMode = true;
	
			try {
				doc.LoadHtml (html_string);
			} catch (Exception e) {
				Log.Debug (e, "Exception while filtering html string [{0}]", html_string);
			}

		}
Exemple #10
0
        /// <summary>
        /// Append text to list.
        /// </summary>
        /// <param name="text">Text.</param>
        /// <param name="color">Text color.</param>
        private void AppendText(string text, Color color)
        {
            if (rtbFiles.InvokeRequired)
            {
                try
                {
                    AppendTextCallback callback = new AppendTextCallback(AppendText);
                    Invoke(callback, new Object[] { text, color });
                }
                catch { }
            }
            else
            {
                rtbFiles.SelectionStart = rtbFiles.TextLength;
                rtbFiles.SelectionLength = 0;

                rtbFiles.SelectionColor = color;
                rtbFiles.AppendText(text);
                rtbFiles.SelectionColor = rtbFiles.ForeColor;
                rtbFiles.AppendText(Environment.NewLine);

                rtbFiles.SelectionStart = rtbFiles.Text.Length;
                rtbFiles.ScrollToCaret();
            }
        }
Exemple #11
0
 private void AppendText(string text)
 {
     // InvokeRequired required compares the thread ID of the
       // calling thread to the thread ID of the creating thread.
       // If these threads are different, it returns true.
       if (this.textBox1.InvokeRequired) {
     var d = new AppendTextCallback(AppendText);
     this.Invoke(d, new object[] { text });
       } else {
     this.textBox1.Text += text;
       }
 }
Exemple #12
0
        private void AppendText(string text)
        {


            if (this.textBox1.InvokeRequired)
            {
                AppendTextCallback d = new AppendTextCallback(AppendText);
                //IAsyncResult result = this.textBox1.BeginInvoke(d, new object[] { text });
                try
                {
                    //d.EndInvoke(result);
                    textBox1.Invoke(d, new object[] { text });
                    //this.Invoke(d, new object[] {text });
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                //this.textBox1.Refresh();
                //string temp = textBox1.Text;
                //this.textBox1.Text = temp + text;
                //this.textBox1.Refresh();
                int lines = textBox1.GetLineFromCharIndex(textBox1.Text.Length) + 1;
                if (lines > 1000)
                {
                    textBox1.Text = textBox1.Text.Remove(0, textBox1.Text.IndexOf('\r') + 1);
                }


                textBox1.AppendText(text);

            }



        }
Exemple #13
0
        private void WriteLog(object sender, LogInfoArgs e)
        {
            if (e.level < LogLevel.FormLog)
                return;

            if (rbLog.InvokeRequired)
            {
                AppendTextCallback d = new AppendTextCallback(WriteLog);
                rbLog.Invoke(d, new object[] { sender, e });
            }
            else
            {
                if (e.level == LogLevel.Error)
                {
                    rbLog.SelectionColor = System.Drawing.Color.Red;
                }
                else if (e.level == LogLevel.Warning)
                {
                    rbLog.SelectionColor = System.Drawing.Color.DarkViolet;
                }

                if (e.level == LogLevel.SqlExe)
                {
                    rbLog.AppendText(e.info + Environment.NewLine);
                }
                else
                {
                    rbLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "  " + e.title + e.info + Environment.NewLine);
                }
            }
        }
Exemple #14
0
        public void UpdateLog(string message, LogType type, LogSource src)
        {
            Color clr = consoleLogTextbox.ForeColor;
            try
            {
                if ((LogType.Warning & type) == type)
                    clr = Color.Yellow;
                else if ((LogType.OpChat & type) == type || (LogType.GlobalChat & type) == type || (LogType.IRCChat & type) == type || (LogType.GlobalChat & type) == type)
                    clr = Color.White;
                else if ((LogType.Error & type) == type || (LogType.FatalError & type) == type || (LogType.ErrorMessage & type) == type)
                    clr = Color.Red;

                message = Environment.NewLine + "[" + DateTime.Now.ToString("hh:mm:ss tt") + "]"
                               + "[" + Enum.GetName(typeof(LogType), type).Substring(0, 1) + "]"
                               + " - " + message;

                if ((LogTypes & type) == type || ((LogType.Debug & type) == type && MCSharp.Properties.DebugEnabled))
                {
                    if (this.consoleLogTextbox.InvokeRequired)
                    {
                        AppendTextCallback d = new AppendTextCallback(Log);
                        this.Invoke(d, new object[] { message, clr });
                    }
                    else
                    {
                        Log(message, clr);
                    }
                }
            }
            catch (Exception) {  }
        }
 /// <summary>
 /// Appends text to main textbox Async
 /// </summary>
 /// <param name="text">Value to append to textbox</param>
 private void appendText(string text)
 {
     if (this.tbxMain.InvokeRequired)
     {
         AppendTextCallback d = new AppendTextCallback(appendText);
         this.Invoke(d, new object[] { text });
     }
     else
     {
         this.tbxMain.AppendText(text);
     }
 }
Exemple #16
0
 public FormExport()
 {
     InitializeComponent();
     _AppendTextCallback = new AppendTextCallback(AppendText);
 }
Exemple #17
0
        private void AppendStatusText(string text, Color text_color , int channel)
        {
            try
            {
                // InvokeRequired required compares the thread ID of the
                // calling thread to the thread ID of the creating thread.
                // If these threads are different, it returns true.
                switch (channel)
                {
                    case 0:
                        if (this.Motor1_Statusbox.InvokeRequired)
                        {
                            AppendTextCallback d = new AppendTextCallback(AppendStatusText);
                            this.Invoke(d, new object[] { text, text_color ,channel});
                        }
                        else
                        {
                            this.Motor1_Statusbox.SelectionColor = text_color;
                            this.Motor1_Statusbox.AppendText(text);
                            this.Motor1_Statusbox.ScrollToCaret();
                        }
                        break;
                    case 1:
                        if (this.Motor2_Statusbox.InvokeRequired)
                        {
                            AppendTextCallback d = new AppendTextCallback(AppendStatusText);
                            this.Invoke(d, new object[] { text, text_color, channel });
                        }
                        else
                        {
                            this.Motor2_Statusbox.SelectionColor = text_color;
                            this.Motor2_Statusbox.AppendText(text);
                            this.Motor2_Statusbox.ScrollToCaret();
                        }
                        break;
                    case 2:
                        if (this.Motor3_Statusbox.InvokeRequired)
                        {
                            AppendTextCallback d = new AppendTextCallback(AppendStatusText);
                            this.Invoke(d, new object[] { text, text_color, channel });
                        }
                        else
                        {
                            this.Motor3_Statusbox.SelectionColor = text_color;
                            this.Motor3_Statusbox.AppendText(text);
                            this.Motor3_Statusbox.ScrollToCaret();
                        }
                        break;
                    case 3:
                        if (this.Motor4_Statusbox.InvokeRequired)
                        {
                            AppendTextCallback d = new AppendTextCallback(AppendStatusText);
                            this.Invoke(d, new object[] { text, text_color, channel });
                        }
                        else
                        {
                            this.Motor4_Statusbox.SelectionColor = text_color;
                            this.Motor4_Statusbox.AppendText(text);
                            this.Motor4_Statusbox.ScrollToCaret();
                        }
                        break;
                    case 4:
                        if (this.Motor5_Statusbox.InvokeRequired)
                        {
                            AppendTextCallback d = new AppendTextCallback(AppendStatusText);
                            this.Invoke(d, new object[] { text, text_color, channel });
                        }
                        else
                        {
                            this.Motor5_Statusbox.SelectionColor = text_color;
                            this.Motor5_Statusbox.AppendText(text);
                            this.Motor5_Statusbox.ScrollToCaret();
                        }
                        break;
                    case 5:
                        if (this.Motor6_Statusbox.InvokeRequired)
                        {
                            AppendTextCallback d = new AppendTextCallback(AppendStatusText);
                            this.Invoke(d, new object[] { text, text_color, channel });
                        }
                        else
                        {
                            this.Motor6_Statusbox.SelectionColor = text_color;
                            this.Motor6_Statusbox.AppendText(text);
                            this.Motor6_Statusbox.ScrollToCaret();
                        }
                        break;
                    case 6:
                        if (this.Motor7_Statusbox.InvokeRequired)
                        {
                            AppendTextCallback d = new AppendTextCallback(AppendStatusText);
                            this.Invoke(d, new object[] { text, text_color, channel });
                        }
                        else
                        {
                            this.Motor7_Statusbox.SelectionColor = text_color;
                            this.Motor7_Statusbox.AppendText(text);
                            this.Motor7_Statusbox.ScrollToCaret();
                        }
                        break;
                }

            }
            catch { }
        }
 internal void AppendText(string text)
 {
     if (this.BeatLog.InvokeRequired)
     {
         AppendTextCallback d = new AppendTextCallback(this.BeatLog.AppendText);
         this.Invoke(d, new object[] { text });
     }
     else
     {
         this.BeatLog.AppendText(text);
     }
 }
Exemple #19
0
 private void AppendText(string text)
 {
     if (ResultsRTB.InvokeRequired)
     {
         AppendTextCallback d = new AppendTextCallback(AppendText);
         ResultsRTB.BeginInvoke(d, new object[] { text });
     }
     else
     {
         ResultsRTB.AppendText(text);
     }
 }