private void buttonRead_Click(object sender, EventArgs e) { WriteMessage("Searching eve-chat folder for " + textChannelName.Text + " channel."); LogFileMonitor monitor = ReadChannel(textChannelName.Text); if (monitor == null) { string readLogsAferMinutes = (this.Monitor.ReadLogsAferSeconds / 60).ToString(); WriteMessage("Channel \"" + textChannelName.Text + "\" is not found or is not active.\n"); MessageBox.Show(this, "Channel \"" + textChannelName.Text + "\" is not found or is not active.\n" + "Is the game currently running?\n" + "Is the channel window open in the game?\n" + "Has the channel been updated in the past " + readLogsAferMinutes + " minutes?\n\n" + "If you answered 'yes' to any question above, this is normal behavior.\n" + "Otherwise, try replacing non-alphanumeric characters with \nunderscores ( _ )", "Channel not found or is not active", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (Properties.Settings.Default.ReadFolderAutoLoadFirstChannel) { if (LoadLogFileMonitor(monitor)) { WriteMessage("Channel is automatically loaded. See UI settings to disable this feature."); } } else { WriteMessage("Channel file(s) are identified on the left, please select a channel to start monitoring."); } }
public Log(string title, string fileName) { InitializeComponent(); this.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location); this.Text = title; var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); var sr = new StreamReader(fs); LogReader = new StreamReader(sr.BaseStream); txtLog.LoadFile(LogReader.BaseStream, RichTextBoxStreamType.PlainText); txtLog.SelectionStart = txtLog.Text.Length; txtLog.ScrollToCaret(); var monitor = new LogFileMonitor(fileName, "\n"); monitor.OnLine += (s, e) => { if (this.IsDisposed) { return; } txtLog.AppendText(e.Line); }; monitor.Start(); }
private void buttonUnloadChannel_Click(object sender, EventArgs e) { if (listLoadedChannels.SelectedIndex > -1) { LogFileMonitor monitor = (LogFileMonitor)listLoadedChannels.SelectedItem; logReaderUI.Remove(monitor); listLoadedChannels.Items.Remove(monitor); Analyzer.Remove(monitor); } }
public frmMain() { InitializeComponent(); hideSubMenu(); var monitor = new LogFileMonitor(rustlocation, "\r\n"); monitor.OnLine += (s, e) => { pullfile(); }; monitor.Start(); }
private void LoadStartupChannels() { foreach (string channel in Properties.Settings.Default.StartupChannels) { LogFileMonitor fileMonitor = ReadChannel(channel); if (fileMonitor != null) { LoadLogFileMonitor(fileMonitor); } } }
private bool LoadLogFileMonitor(LogFileMonitor monitor) { if (!listLoadedChannels.Items.Contains(monitor)) { logReaderUI.Add(monitor); listLoadedChannels.Items.Add(monitor); Analyzer.Add(monitor); return(true); } else { return(false); } }
public void Remove(LogFileMonitor monitor) { if (monitor != null) { if (monitors.Remove(monitor)) { monitor.ChangedLogMessage -= SetLogMessage; monitor.ChangedLogChannel -= SetLogChannel; } if (monitors.Count == 0 && refreshTimer.Enabled) { Stop(); } } }
public void Add(LogFileMonitor monitor) { if (monitor != null) { monitors.Add(monitor); monitor.ChangedLogMessage += SetLogMessage; monitor.ChangedLogChannel += SetLogChannel; FileChannel fileChannel = monitor.FileChannel; SetLogChannel(fileChannel.Channel); if (!refreshTimer.Enabled) { Start(); } } }
public void Remove(LogFileMonitor monitor) { monitor.ChangedLogMessage -= NotifyLogMessage; }
public void Add(LogFileMonitor monitor) { // first remove the event listener just in case monitor.ChangedLogMessage -= NotifyLogMessage; monitor.ChangedLogMessage += NotifyLogMessage; }