示例#1
0
        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)}]";
        }
示例#2
0
        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;
            }
        }
示例#3
0
文件: Log.cs 项目: Soldie/greendot1
        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)}]";
        }
示例#4
0
        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}]";
        }
示例#5
0
        private void TriggerWrapText()
        {
            wrapTextTriggerLock = true;

            wrapTextTrigger            = !wrapTextTrigger;
            LogMessageTextBox.WordWrap = wrapTextTrigger;
            LogMessageTextBox.ScrollToCaret();
            WrapTextMenuItem.Checked = WrapTextCheckBox.Checked = wrapTextTrigger;

            wrapTextTriggerLock = false;
        }
示例#6
0
        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;
            }
        }
示例#7
0
        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)
            {
            }
        }
示例#8
0
        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;
            }
        }
示例#9
0
 private void LogForm_Shown(object sender, EventArgs e)
 {
     LogMessageTextBox.ScrollToCaret();
 }
示例#10
0
 private void WrapTextCheckBox_CheckedChanged(object sender, EventArgs e)
 {
     LogMessageTextBox.WordWrap = WrapTextCheckBox.Checked;
     LogMessageTextBox.ScrollToCaret();
 }