private void UpdateContent() { try { using (StreamReader reader = new StreamReader(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) { reader.BaseStream.Seek(lastOffset, SeekOrigin.Begin); string line = ""; bool changed = false; while ((line = reader.ReadLine()) != null) { changed = true; LogMessageTextBox.AppendText(line + Environment.NewLine); } if (changed) { LogMessageTextBox.ScrollToCaret(); } lastOffset = reader.BaseStream.Position; } } catch (FileNotFoundException) { } this.Text = I18N.GetString("Log Viewer") + $" [in: {Utils.FormatBandwidth(controller.inboundCounter)}, out: {Utils.FormatBandwidth(controller.outboundCounter)}]"; }
private void InitContent() { if (string.IsNullOrEmpty(filename)) { return; } using (StreamReader reader = new StreamReader(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) { if (reader.BaseStream.Length > BACK_OFFSET) { reader.BaseStream.Seek(-BACK_OFFSET, SeekOrigin.End); reader.ReadLine(); } string line = ""; StringBuilder appendText = new StringBuilder(1024); while ((line = reader.ReadLine()) != null) { appendText.AppendLine(line); } LogMessageTextBox.AppendText(appendText.ToString()); LogMessageTextBox.ScrollToCaret(); lastOffset = reader.BaseStream.Position; } }
private void UpdateContent() { try { using (StreamReader reader = new StreamReader(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) { reader.BaseStream.Seek(lastOffset, SeekOrigin.Begin); string line = ""; bool changed = false; StringBuilder appendText = new StringBuilder(128); while ((line = reader.ReadLine()) != null) { changed = true; appendText.Append(line + Environment.NewLine); } if (changed) { LogMessageTextBox.AppendText(appendText.ToString()); LogMessageTextBox.ScrollToCaret(); } lastOffset = reader.BaseStream.Position; } } catch (FileNotFoundException) { } lblWindowTitle.Text = "运行日志" + $" [in: {Utils.FormatBytes(this.mainController.InboundCounter)},out: {Utils.FormatBytes(this.mainController.OutboundCounter)}]"; }
private void UpdateContent() { try { using (StreamReader reader = new StreamReader(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) { reader.BaseStream.Seek(lastOffset, SeekOrigin.Begin); string line = ""; bool changed = false; StringBuilder appendText = new StringBuilder(128); while ((line = reader.ReadLine()) != null) { changed = true; appendText.Append(line + Environment.NewLine); } if (changed) { LogMessageTextBox.AppendText(appendText.ToString()); LogMessageTextBox.ScrollToCaret(); } lastOffset = reader.BaseStream.Position; } } catch (FileNotFoundException) { } this.Text = I18N.GetString("Log Viewer") + $" [in: {Utils.FormatBytes(controller.InboundCounter)}, out: {Utils.FormatBytes(controller.OutboundCounter)}, TCP conn: {controller.TCPConnectionCounter}/{TCPRelay.MAX_HANDLER_NUM}]"; }
private void TriggerWrapText() { wrapTextTriggerLock = true; wrapTextTrigger = !wrapTextTrigger; LogMessageTextBox.WordWrap = wrapTextTrigger; LogMessageTextBox.ScrollToCaret(); WrapTextMenuItem.Checked = WrapTextCheckBox.Checked = wrapTextTrigger; wrapTextTriggerLock = false; }
private void InitContent() { using (StreamReader reader = new StreamReader(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) { if (reader.BaseStream.Length > BACK_OFFSET) { reader.BaseStream.Seek(-BACK_OFFSET, SeekOrigin.End); reader.ReadLine(); } string line = ""; while ((line = reader.ReadLine()) != null) { LogMessageTextBox.AppendText(line + Environment.NewLine); } LogMessageTextBox.ScrollToCaret(); lastOffset = reader.BaseStream.Position; } }
private void UpdateContent() { this.Text = I18N.GetString("Log Viewer") + $" [in: {Utils.FormatBytes(controller.InboundCounter)}, out: {Utils.FormatBytes(controller.OutboundCounter)}]"; if (string.IsNullOrEmpty(filename) || !File.Exists(filename)) { return; } try { using (StreamReader reader = new StreamReader(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) { reader.BaseStream.Seek(lastOffset, SeekOrigin.Begin); string line = ""; bool changed = false; StringBuilder appendText = new StringBuilder(128); while ((line = reader.ReadLine()) != null) { changed = true; appendText.AppendLine(line); } if (changed) { LogMessageTextBox.AppendText(appendText.ToString()); LogMessageTextBox.ScrollToCaret(); } lastOffset = reader.BaseStream.Position; } } catch (FileNotFoundException) { } }
private void UpdateContent() { using (StreamReader reader = new StreamReader(new FileStream(_filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) { reader.BaseStream.Seek(_lastOffset, SeekOrigin.Begin); string line; bool changed = false; while ((line = reader.ReadLine()) != null) { changed = true; LogMessageTextBox.AppendText(line + "\r\n"); } if (changed) { LogMessageTextBox.ScrollToCaret(); } _lastOffset = reader.BaseStream.Position; } }
private void LogForm_Shown(object sender, EventArgs e) { LogMessageTextBox.ScrollToCaret(); }
private void WrapTextCheckBox_CheckedChanged(object sender, EventArgs e) { LogMessageTextBox.WordWrap = WrapTextCheckBox.Checked; LogMessageTextBox.ScrollToCaret(); }