Example #1
0
 private void OnConvertOutput(string output)
 {
     ConvertOutputText.Text += output + "\n";
     if (Math.Abs(TextScroll.ScrollableHeight - TextScroll.VerticalOffset) < 0.1)
     {
         TextScroll.ScrollToEnd();
     }
 }
Example #2
0
        /// <summary>
        /// Event handler for clock ticks and related work.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The event arguments</param>
        private void Clock_Tick(object sender, EventArgs e)
        {
            string title = this.FindCurrentWindow();

            if (title == this.lastWindow)
            {
                return;
            }

            DateTime now        = DateTime.Now;
            TimeSpan duration   = now - this.since;
            string   log        = now.ToString("u") + "," + this.lastWindow + "," + duration.ToString() + "\n";
            bool     isAtBottom = false;

            if (Math.Abs(TextScroll.VerticalOffset - TextScroll.ScrollableHeight) < this.epsilon)
            {
                isAtBottom = true;
            }

            WindowLog.Text    += log;
            this.logLength    += 1;
            textLogLength.Text = this.logLength.ToString();
            this.since         = now;
            this.lastWindow    = title;

            uint idle = this.GetIdleTime();

            if (idle > this.minIdle)
            {
                TimeSpan idleTime = new TimeSpan(0, 0, (int)idle);
                log = "Also idle for approximately " + idleTime.ToString() + "\n";
            }

            if (isAtBottom)
            {
                TextScroll.ScrollToEnd();
            }

            this.isDirty = true;
        }