private void FileNamesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (UserSettings.Application.RememberOpenFiles) { SystemSettings.OpenFiles = FileNames; } if (FileNames == null) { SelectedTab = null; return; } if (e.Action != NotifyCollectionChangedAction.Add) { return; } using (new CursorManager()) { foreach (var fileName in FileNames) { if (!TabFileItems.Any(tab => tab.FileName == fileName)) { LoadFile(fileName); } } } }
public void OnFileDrop(DragEventArgs e) { var files = (string[])e.Data.GetData(DataFormats.FileDrop, false); files.Apply(FileNames.Add); SelectedTab = TabFileItems.Last(); }
public void ApplyConfiguration() { try { var currentRow = SelectedTab != null ? SelectedTab.CurrentRow : 0; Accent accent = ThemeManager.DefaultAccents.First(a => a.Name == UserSettings.Appearance.AccentColor); ThemeManager.ChangeTheme(Application.Current.MainWindow, accent, UserSettings.Appearance.Theme); TabFileItems.Apply(tab => tab.TailService.ApplyConfiguration(UserSettings)); SetFont(); Reload(force: true); Buffer.Apply(b => b.ApplyConfiguration(UserSettings)); if (SelectedTab != null) { SelectedTab.CurrentRow = currentRow; } Refresh(); } catch (Exception ex) { MessageBox.Show(ex.Message, "LaanTail - Error Updating Settings - please check the XML and try again"); } }
public void CloseOthers(TabFileItem tabItem) { using (new CursorManager()) { TabFileItems .Where(tab => tab != tabItem) .Apply(tab => Close(tab)); } }
public void CloseAll() { using (new CursorManager()) { TabFileItems.Clear(); SelectedTab = null; Buffer.Clear(); } }
private void TailChanged(TailChangedEventArgs e) { var tab = TabFileItems.FirstOrDefault(item => item.FileName == e.FileName); if (tab != null) { tab.ApplyChange(); Reset(); } }
private TabFileItem LoadFile(string fileName) { var service = new TailService(UserSettings, fileName); service.Changed += (sender, e) => Execute.OnUIThread(() => TailChanged(e)); var item = new TabFileItem(this, fileName, Path.GetFileNameWithoutExtension(fileName), service); item.FollowTail = UserSettings.Tail.AutoFollow; TabFileItems.Add(item); return(item); }
public void Open() { OpenFileDialog dialog = new OpenFileDialog(); dialog.Multiselect = true; dialog.Filter = "Log Files (*.log)|*.log|Any File (*.*)|*.*"; if (dialog.ShowDialog() != true) { return; } dialog.FileNames.Apply(FileNames.Add); SelectedTab = TabFileItems.Last(); }
public void Close(TabFileItem tabItem) { int index = TabFileItems.IndexOf(tabItem); FileNames.Remove(tabItem.FileName); TabFileItems.Remove(tabItem); tabItem.TailService.Dispose(); if (TabFileItems.Count == 0) { Buffer.Clear(); } SelectedTab = TabFileItems.Any() ? TabFileItems[Math.Min(index, TabFileItems.Count - 1)] : null; }
private void MoveTab(int delta) { var index = (TabFileItems.IndexOf(SelectedTab) + delta) % TabFileItems.Count; SelectedTab = TabFileItems[index]; }