Exemple #1
0
        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);
                    }
                }
            }
        }
Exemple #2
0
        public void OnFileDrop(DragEventArgs e)
        {
            var files = (string[])e.Data.GetData(DataFormats.FileDrop, false);

            files.Apply(FileNames.Add);
            SelectedTab = TabFileItems.Last();
        }
Exemple #3
0
        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");
            }
        }
Exemple #4
0
 public void CloseOthers(TabFileItem tabItem)
 {
     using (new CursorManager())
     {
         TabFileItems
         .Where(tab => tab != tabItem)
         .Apply(tab => Close(tab));
     }
 }
Exemple #5
0
 public void CloseAll()
 {
     using (new CursorManager())
     {
         TabFileItems.Clear();
         SelectedTab = null;
         Buffer.Clear();
     }
 }
Exemple #6
0
        private void TailChanged(TailChangedEventArgs e)
        {
            var tab = TabFileItems.FirstOrDefault(item => item.FileName == e.FileName);

            if (tab != null)
            {
                tab.ApplyChange();
                Reset();
            }
        }
Exemple #7
0
        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);
        }
Exemple #8
0
        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();
        }
Exemple #9
0
        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;
        }
Exemple #10
0
        private void MoveTab(int delta)
        {
            var index = (TabFileItems.IndexOf(SelectedTab) + delta) % TabFileItems.Count;

            SelectedTab = TabFileItems[index];
        }