Example #1
0
        /// <summary>
        /// The start action
        /// </summary>
        private void Start()
        {
            this.Information = "Fotos werden gesucht...";

            var handler = new ExifFileHandler();

            // The progress object is passed to the worker thread. It updates the Information property
            // and thus raises a propertyChanged event which is used to display the background worker progress.
            IProgress<TransferProgress> progress = new Progress<TransferProgress>(this.ProgressHandler);

            // The background task uses the Task library instead of the BackgroundWorker (this would be old-school).
            // The progress handler is passed down to the method executed in the background thread of the task.
            // By a miracle the progress information is tunneled through the threads and triggers an update of the
            // information text in the GUI.
            this.fileHandlerTask = Task.Factory.StartNew(() => handler.FindAndCopyFiles(this.sourcePath, this.targetPath, this.startDate, this.endDate, this.KeepOriginalFileName, progress));
        }
Example #2
0
        /// <summary>
        /// The drag-and-drop handler
        /// </summary>
        /// <param name="droppedFiles">The files to copy.</param>
        public void DropFiles(IEnumerable<string> droppedFiles)
        {
            var exifHandler = new ExifFileHandler();
            int numFiles = 0;

            this.Information = "Kopiere Drag-and-drop Dateien";

            foreach(string source in droppedFiles)
            {
                string[] sourceFiles;

                if (Directory.Exists(source))
                {
                    sourceFiles = Directory.GetFiles(source, "*.jpg", SearchOption.AllDirectories);
                }
                else
                {
                    // a single file
                    sourceFiles = new string[1];
                    sourceFiles[0] = source;
                }

                foreach(string sourceFile in sourceFiles)
                {
                    if (exifHandler.CopySingleFile(sourceFile, this.targetPath, this.KeepOriginalFileName))
                    {
                        numFiles++;
                    }

                    this.Information = string.Format("{0} Datei{1} wurden kopiert", numFiles, numFiles == 1 ? string.Empty : "en");
                }
            }
        }