Ejemplo n.º 1
0
 /// <summary>
 /// Removes the currently selected folder from the grid
 /// </summary>
 private void RemoveCurrentlySelectedFolder()
 {
     if (string.IsNullOrEmpty(CurrentlySelectedFolder) == false)
     {
         SelectedFolders.Remove(CurrentlySelectedFolder);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds a folder to the grid using the default folder browser dialog
 /// </summary>
 private void AddFolder()
 {
     using (var folderBrowser = new FolderBrowserDialog())
     {
         folderBrowser.Description = Resources.SelectMediaLibraryFolder;
         DialogResult dialogResult = folderBrowser.ShowDialog();
         if (dialogResult == DialogResult.OK)
         {
             SelectedFolders.Add(folderBrowser.SelectedPath);
         }
     }
 }
Ejemplo n.º 3
0
        public void UseStorage()
        {
            if (SelectedFolders.Count == 0 && DeselectedFolders.Count == 0)
            {
                Engine.IsBluetooth = false;
                var paths       = new List <string>(_searchPaths);
                var sourcePaths = new List <string>();
                while (paths.Count > 0)
                {
                    string path = paths[0];
                    paths.RemoveAt(0);

                    if (Directory.Exists(path))
                    {
                        SelectedFolders.Add(path);
                        var dirInfo = new DirectoryInfo(path);
                        try
                        {
                            foreach (DirectoryInfo subdirInfo in dirInfo.GetDirectories())
                            {
                                paths.Add(subdirInfo.FullName);
                            }
                        }
                        catch (System.Exception e)
                        {
                            ExecutionEngine.EventLogger.WriteExceptionInfo(e);
                        }
                    }
                }

                if (!ExecutionEngine.Config.EnableFolderSelection.Value || SelectedFolders.Count == 1)
                {
                    Engine.IsShowFolders = false;
                    SwitchToProcessScreen();
                }
                else
                {
                    Engine.IsShowFolders = true;
                    SwitchToSelectFoldersScreen();
                }
            }
            else if (Engine.IsShowFolders)
            {
                SwitchToSelectFoldersScreen();
            }
            else
            {
                SwitchToProcessScreen();
            }
        }
Ejemplo n.º 4
0
 private void BtnAddFolder_OnClick(object sender, RoutedEventArgs e)
 {
     using (var dialog = new System.Windows.Forms.FolderBrowserDialog())
     {
         System.Windows.Forms.DialogResult result = dialog.ShowDialog();
         if (result == System.Windows.Forms.DialogResult.OK)
         {
             string path = dialog.SelectedPath;
             if (Directory.Exists(path) && !SelectedFolders.Any(x => NormalizePath(x.Folder) == NormalizePath(path)))
             {
                 SelectedFolders.Add(new FolderModel(path));
             }
         }
     }
 }
Ejemplo n.º 5
0
        internal bool ShouldFileSync(string localFile)
        {
            if (SelectedFolders == null)
            {
                return(true);
            }

            var dir = Path.GetDirectoryName(localFile).ToLowerInvariant();

            dir = dir.Replace(LocalFolder.ToLowerInvariant(), string.Empty).TrimStart('\\') + "\\";

            if (SelectedFolders.Count(p => !string.IsNullOrEmpty(p) && dir.StartsWith(p, StringComparison.OrdinalIgnoreCase)) > 0)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 6
0
 private void Delete(FolderModel result)
 {
     SelectedFolders.Remove(result);
 }
Ejemplo n.º 7
0
        private void FindPhotos()
        {
            ExecutionEngine.EventLogger.Write("FindingPhotosStage:FindPhotos");

            _isThreadAlive = true;

            if (ExecutionEngine.Context.Contains(Constants.PhotosToRemove))
            {
                _photosToRemove = (List <string>)ExecutionEngine.Context[Constants.PhotosToRemove];
            }
            else
            {
                _photosToRemove.Clear();
            }

            if (_isThreadAlive)
            {
                if (DeselectedFolders != null)
                {
                    DeselectedFolders.ForEach(item =>
                    {
                        if (LastSelectedFolders.Contains(item) &&
                            (SelectedFolders == null || SelectedFolders.Contains(item))
                            )
                        {
                            LastSelectedFolders.Remove(item);
                        }
                    });

                    var folders = SelectedFolders == null ? DeselectedFolders : DeselectedFolders.Where(f => !SelectedFolders.Contains(f)).ToList();
                    foreach (string folder in folders)
                    {
                        var dirInfo = new DirectoryInfo(folder);
                        try
                        {
                            foreach (FileInfo fileInfo in dirInfo.GetFiles())
                            {
                                if (IsExtensionOk(fileInfo.Extension))
                                {
                                    if (_files.Contains(fileInfo.FullName))
                                    {
                                        _files.Remove(fileInfo.FullName);
                                    }
                                    _photosToRemove.Add(fileInfo.FullName);
                                }
                            }
                        }
                        catch (System.Exception e)
                        {
                            ExecutionEngine.EventLogger.WriteExceptionInfo(e);
                        }
                    }
                }

                if (SelectedFolders != null)
                {
                    foreach (string path in SelectedFolders)
                    {
                        int index   = _files.Count;
                        int count   = 0;
                        var dirInfo = new DirectoryInfo(path);

                        try
                        {
                            foreach (FileInfo fileInfo in dirInfo.GetFiles())
                            {
                                if (IsExtensionOk(fileInfo.Extension) && !_files.Contains(fileInfo.FullName))
                                {
                                    _files.Add(fileInfo.FullName);
                                    count++;
                                }
                            }
                            _files.Sort(index, count, null);
                        }
                        catch (System.Exception e)
                        {
                            ExecutionEngine.EventLogger.WriteExceptionInfo(e);
                        }
                    }
                    var newFiles = _files.Where(file => !_photoItems.Any(item => file.Equals(item.SourceFileName)));

                    _photoItems.Clear();
                    foreach (string fileName in newFiles)
                    {
                        _photoItems.Add(new PhotoItem(fileName));
                    }
                }
            }

            _photosFound = true;

            try
            {
                foreach (PhotoItem item in _photoItems)
                {
                    Bitmap exif = null;

                    try
                    {
                        exif = item.LoadExifThumbnail();
                    }
                    catch (Aurigma.GraphicsMill.Exception ex)
                    {
                        ExecutionEngine.EventLogger.WriteExceptionInfo(ex);
                    }
                    catch (IOException ex)
                    {
                        ExecutionEngine.EventLogger.WriteExceptionInfo(ex);
                    }

                    if (!_isThreadAlive || !IsMainThreadAlive())
                    {
                        break;
                    }

                    if (exif != null && !exif.IsEmpty)
                    {
                        lock (_exifSources)
                        {
                            _exifSources.Add(exif);
                        }
                    }
                }
            }
            catch (System.Exception)
            {
                _photoItems.Clear();
            }

            SelectedFolders.ForEach(item =>
            {
                if (!LastSelectedFolders.Contains(item))
                {
                    LastSelectedFolders.Add(item);
                }
            });

            _isThreadAlive = false;
        }