コード例 #1
0
ファイル: ConnShow.xaml.cs プロジェクト: Zousdie/E-Serial
        private async void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            await txt_Data.Dispatcher.InvokeAsync(() =>
            {
                if (dataQue.Count + txt_Data.LineCount >= app.AutoClearLines)
                {
                    txt_Data.Clear();
                }
                StringBuilder sbuf = new StringBuilder(dataQue.Count);
                while (dataQue.Count > 0)
                {
                    Core.DataReceivedEventArgs de = dataQue.Dequeue();
                    if (app.Timestamp && de.Time != null)
                    {
                        sbuf.AppendFormat("[{0}] ", ((DateTime)de.Time).ToString("MM/dd HH:mm:ss.ffff"));
                    }
                    sbuf.Append(de.Data);
                }
                txt_Data.AppendText(sbuf.ToString());
                if (app.AutoScroll)
                {
                    this.txt_Data.ScrollToEnd();
                }
            }, System.Windows.Threading.DispatcherPriority.Background);

            icc.DataReceived += dataReceived;
            icc.DataReceived -= unDataReceived;
            this.txt_Write.Focus();
            if (!isRun)
            {
                icc.Open();
                isRun = true;
            }
        }
コード例 #2
0
ファイル: ConnShow.xaml.cs プロジェクト: Zousdie/E-Serial
        private async void dataReceived(object sendor, Core.DataReceivedEventArgs ea)
        {
            try
            {
                await txt_Data.Dispatcher.InvokeAsync(() =>
                {
                    if (IsPause)
                    {
                        return;
                    }

                    if (app.AutoClear && txt_Data.LineCount >= app.AutoClearLines)
                    {
                        StringBuilder lines = new StringBuilder();
                        for (int i = txt_Data.LineCount - app.AutoClearLines / 3; i < txt_Data.LineCount; i++)
                        {
                            lines.Append(txt_Data.GetLineText(i));
                        }
                        txt_Data.Clear();
                        txt_Data.AppendText(lines.ToString());
                        Debug.WriteLine("CLEAR TextBox");
                    }
                    if (app.Timestamp && ea.Time != null)
                    {
                        txt_Data.AppendText(string.Format("[{0}] ", ((DateTime)ea.Time).ToString("MM/dd HH:mm:ss.ffff")));
                    }
                    txt_Data.AppendText(ea.Data);
                    if (app.AutoScroll)
                    {
                        this.txt_Data.ScrollToEnd();
                    }
                }, System.Windows.Threading.DispatcherPriority.Background);
            }
            catch { }
        }
コード例 #3
0
ファイル: ConnShow.xaml.cs プロジェクト: Zousdie/E-Serial
        private void unDataReceived(object sendor, Core.DataReceivedEventArgs ea)
        {
            if (IsPause)
            {
                return;
            }

            if (dataQue.Count < app.AutoClearLines)
            {
                dataQue.Enqueue(ea);
            }
            else
            {
                for (int i = 0; i < dataQue.Count - app.AutoClearLines + 1; i++)
                {
                    dataQue.Dequeue();
                }
                dataQue.Enqueue(ea);
            }
        }
コード例 #4
0
ファイル: ConnShow.xaml.cs プロジェクト: Zousdie/E-Serial
 private async void rDataReceived(object sendor, Core.DataReceivedEventArgs ea)
 {
     byte[] buf = Encoding.UTF8.GetBytes(ea.Data);
     try { await rFS.WriteAsync(buf, 0, buf.Length); }
     catch { }
 }