コード例 #1
0
        public void AddFileMonitor(string filepath)
        {
            foreach (var fileMonitor in FileMonitors)
            {
                if (!fileMonitor.FilePath.Equals(filepath, StringComparison.InvariantCultureIgnoreCase))
                {
                    continue;
                }

                // Already being monitored
                SelectedFile = fileMonitor;
                return;
            }

            var monitorViewModel = new FileMonitorViewModel
                                   (
                filepath,
                Path.GetFileName(filepath),
                Settings.Default.DefaultEncoding,
                Settings.Default.BufferedRead
                                   );

            monitorViewModel.Renamed += MonitorViewModelOnRenamed;
            monitorViewModel.Updated += MonitorViewModelOnUpdated;

            FileMonitors.Add(monitorViewModel);
            SelectedFile = monitorViewModel;
        }
コード例 #2
0
        private static void MonitorViewModelOnRenamed(FileMonitorViewModel renamedFileMonitor)
        {
            var filepath = renamedFileMonitor.FilePath;

            renamedFileMonitor.FileName = Path.GetFileName(filepath);
        }
コード例 #3
0
 private void MonitorViewModelOnUpdated(FileMonitorViewModel fileMonitorViewModel)
 {
     _lastUpdateDateTime   = DateTime.Now;
     _lastUpdatedViewModel = fileMonitorViewModel;
     RefreshLastUpdatedText();
 }