Exemple #1
0
        private void HandlePropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            DataDrive drive = (DataDrive)sender;

            if (e.PropertyName == "Status")
            {
                if (drive.Status != "")
                {
                    Status = drive.Status;
                }
                else
                {
                    UpdateStatus();
                }
            }
            else if (e.PropertyName == "Progress")
            {
                Progress = drive.Progress;
            }
            else if (e.PropertyName == "DriveStatus")
            {
                UpdateStatus();
            }
            else if (e.PropertyName == "FileCount")
            {
                UpdateFileCount();
            }
        }
Exemple #2
0
        private DataDriveViewModel AddDrive(DataDrive drive)
        {
            DataDriveViewModel vm = new DataDriveViewModel(drive, config);

            drives.Add(vm);
            drive.PropertyChanged += HandleDateDrivePropertyChanged;
            drive.ScanCompleted   += HandleScanCompleted;
            return(vm);
        }
Exemple #3
0
        private const int AUTO_SCAN_DELAY = 5; // time in seconds between changes detected and automatic scan

        public DataDriveViewModel(DataDrive dataDrive, Config config)
        {
            this.config = config;
            DataDrive   = dataDrive;
            DataDrive.PropertyChanged += HandlePropertyChanged;
            DataDrive.ChangesDetected += HandleChangesDetected;
            UpdateStatus();
            UpdateFileCount();
            UpdateAdditionalInfo();

            autoScanTimer           = new System.Timers.Timer(1000);
            autoScanTimer.AutoReset = true;
            autoScanTimer.Elapsed  += HandleAutoScanTimer;
        }
Exemple #4
0
 public void Scan(bool auto)
 {
     if (DataDrive.Scanning)
     {
         return;
     }
     autoScanTimer.Stop();
     Task.Factory.StartNew(() =>
     {
         try {
             DataDrive.Scan(auto);
             UpdateAdditionalInfo();
         }
         catch (Exception e) {
             LogFile.Log("Error occurred during scan of {0}: {1}", DataDrive.Root, e.Message);
         }
         finally {
             UpdateStatus();
             Progress = 0;
         }
     }
                           );
 }