private void _openContainingFolderClick(object sender, EventArgs e) { TailForm tailForm = GetSelectedTabForm <TailForm>(sender); if (tailForm != null) { tailForm.OpenExplorer(); } }
private void _copyFolderPathClick(object sender, EventArgs e) { TailForm tailForm = GetSelectedTabForm <TailForm>(sender); if (tailForm != null) { tailForm.CopyPath(); } }
private int OpenFileSelection(string[] filenames) { if (_defaultTailConfig == null) { TailConfig tailConfig = null; string defaultPath = GetDefaultConfigPath(); if (!string.IsNullOrEmpty(defaultPath)) { tailConfig = LoadSessionFile(defaultPath); } if (tailConfig != null && tailConfig.TailFiles.Count > 0) { _defaultTailConfig = tailConfig.TailFiles[0]; _defaultTailConfig.Title = null; } else { _defaultTailConfig = new TailFileConfig(); } } int filesOpened = 0; foreach (string filename in filenames) { string configPath = ""; try { if (string.IsNullOrEmpty(Path.GetDirectoryName(filename))) { configPath = Directory.GetCurrentDirectory(); } } catch { } TailForm mdiForm = new TailForm(); TailFileConfig tailConfig = _defaultTailConfig; tailConfig.FilePath = filename; mdiForm.LoadConfig(tailConfig, configPath); if (mdiForm.IsDisposed) { continue; } _mruMenu.AddFile(filename); mdiForm.MdiParent = this; mdiForm.Show(); ++filesOpened; Application.DoEvents(); } return(filesOpened); }
private int OpenFileSelection(string[] filenames) { if (_defaultTailConfig == null) { TailConfig tailConfig = null; string defaultPath = GetDefaultConfigPath(); if (!string.IsNullOrEmpty(defaultPath)) tailConfig = LoadSessionFile(defaultPath); if (tailConfig != null && tailConfig.TailFiles.Count > 0) { _defaultTailConfig = tailConfig.TailFiles[0]; _defaultTailConfig.Title = null; } else { _defaultTailConfig = new TailFileConfig(); } } int filesOpened = 0; foreach (string filename in filenames) { string configPath = ""; try { if (string.IsNullOrEmpty(Path.GetDirectoryName(filename))) configPath = Directory.GetCurrentDirectory(); } catch { } TailForm mdiForm = new TailForm(); TailFileConfig tailConfig = _defaultTailConfig; tailConfig.FilePath = filename; mdiForm.LoadConfig(tailConfig, configPath); if (mdiForm.IsDisposed) continue; _mruMenu.AddFile(filename); mdiForm.MdiParent = this; mdiForm.Show(); ++filesOpened; Application.DoEvents(); } return filesOpened; }
private bool LoadSession(string filepath) { TailConfig tailConfig = LoadSessionFile(filepath); if (tailConfig == null) return false; _mruMenu.AddFile(filepath); if (!tailConfig.MinimizedToTray) { Size = tailConfig.WindowSize; DesktopLocation = tailConfig.WindowPosition; } UpdateTitle(); List<string> eventLogFiles = EventLogForm.GetEventLogFiles(); Application.DoEvents(); foreach (TailFileConfig tailFile in tailConfig.TailFiles) { Form mdiForm = null; int index = eventLogFiles.FindIndex(delegate(string arrItem) { return arrItem.Equals(tailFile.FilePath); }); if (index >= 0) mdiForm = new EventLogForm(); else mdiForm = new TailForm(); if (mdiForm != null) { ITailForm tailForm = mdiForm as ITailForm; string tailConfigPath = Path.GetDirectoryName(filepath); mdiForm.Text = tailFile.Title; if (!tailFile.Modeless) { mdiForm.MdiParent = this; mdiForm.ShowInTaskbar = false; AddMdiChildTab(mdiForm); if (tailForm != null) tailForm.LoadConfig(tailFile, tailConfigPath); if (mdiForm.IsDisposed) { _MDITabControl.TabPages.Remove(mdiForm.Tag as TabPage); continue; } } mdiForm.Show(); if (tailConfig.SelectedTab == -1 || tailFile.Modeless) { if (tailFile.WindowState != FormWindowState.Maximized) { mdiForm.DesktopLocation = tailFile.WindowPosition; mdiForm.Size = tailFile.WindowSize; } if (mdiForm.WindowState != tailFile.WindowState) mdiForm.WindowState = tailFile.WindowState; } if (tailFile.Modeless) { if (tailForm != null) tailForm.LoadConfig(tailFile, tailConfigPath); } } Application.DoEvents(); } if (tailConfig.SelectedTab != -1 && _MDITabControl.TabPages.Count > 0) { foreach (Form childForm in MdiChildren) childForm.WindowState = FormWindowState.Minimized; _MDITabControl.SelectedIndex = tailConfig.SelectedTab; _MDITabControl.Visible = true; (_MDITabControl.SelectedTab.Tag as Form).WindowState = FormWindowState.Maximized; } if (tailConfig.MinimizedToTray) { _trayIcon.Visible = true; WindowState = FormWindowState.Minimized; Visible = false; } else if (tailConfig.AlwaysOnTop) { alwaysOnTopToolStripMenuItem.Checked = true; TopMost = true; } return true; }
private void switchToModelessToolStripMenuItem_Click(object sender, EventArgs e) { TailForm newform = new TailForm(); TailFileConfig tailConfig = new TailFileConfig(); SaveConfig(tailConfig); if (this.MdiParent == null) { newform.MdiParent = MainForm.Instance; newform.ShowInTaskbar = false; } else newform.ShowInTaskbar = true; Close(); newform.Show(); newform._logFileCache = _logFileCache; newform._logFileStream = _logFileStream; newform._logTailStream = _logTailStream; newform._tailListView.VirtualListSize = _tailListView.VirtualListSize; newform.LoadConfig(tailConfig, _configPath); newform.BringToFront(); }
private bool LoadSession(string filepath) { TailConfig tailConfig = LoadSessionFile(filepath); if (tailConfig == null) { return(false); } _mruMenu.AddFile(filepath); if (!tailConfig.MinimizedToTray) { Size = tailConfig.WindowSize; DesktopLocation = tailConfig.WindowPosition; } UpdateTitle(); List <string> eventLogFiles = EventLogForm.GetEventLogFiles(); Application.DoEvents(); foreach (TailFileConfig tailFile in tailConfig.TailFiles) { Form mdiForm = null; int index = eventLogFiles.FindIndex(delegate(string arrItem) { return(arrItem.Equals(tailFile.FilePath)); }); if (index >= 0) { mdiForm = new EventLogForm(); } else { mdiForm = new TailForm(); } if (mdiForm != null) { ITailForm tailForm = mdiForm as ITailForm; string tailConfigPath = Path.GetDirectoryName(filepath); mdiForm.Text = tailFile.Title; if (!tailFile.Modeless) { mdiForm.MdiParent = this; mdiForm.ShowInTaskbar = false; AddMdiChildTab(mdiForm); if (tailForm != null) { tailForm.LoadConfig(tailFile, tailConfigPath); } if (mdiForm.IsDisposed) { _MDITabControl.TabPages.Remove(mdiForm.Tag as TabPage); continue; } } mdiForm.Show(); if (tailConfig.SelectedTab == -1 || tailFile.Modeless) { if (tailFile.WindowState != FormWindowState.Maximized) { mdiForm.DesktopLocation = tailFile.WindowPosition; mdiForm.Size = tailFile.WindowSize; } if (mdiForm.WindowState != tailFile.WindowState) { mdiForm.WindowState = tailFile.WindowState; } } if (tailFile.Modeless) { if (tailForm != null) { tailForm.LoadConfig(tailFile, tailConfigPath); } } } Application.DoEvents(); } if (tailConfig.SelectedTab != -1 && _MDITabControl.TabPages.Count > 0) { foreach (Form childForm in MdiChildren) { childForm.WindowState = FormWindowState.Minimized; } _MDITabControl.SelectedIndex = tailConfig.SelectedTab; _MDITabControl.Visible = true; (_MDITabControl.SelectedTab.Tag as Form).WindowState = FormWindowState.Maximized; } if (tailConfig.MinimizedToTray) { _trayIcon.Visible = true; WindowState = FormWindowState.Minimized; Visible = false; } else if (tailConfig.AlwaysOnTop) { alwaysOnTopToolStripMenuItem.Checked = true; TopMost = true; } return(true); }