Example #1
0
        public void MoveItems(object param)
        {
            // select folder
            IFolderBrowserDialogService fbd = GetService <IFolderBrowserDialogService>();

            if (fbd != null)
            {
                var result = fbd.Show();
                if (result == DialogResult.OK || result == DialogResult.Yes)
                {
                    string selectedPath = fbd.SelectedPath;
                    if (Directory.Exists(selectedPath))
                    {
                        isMoving = true;
                        Task.Factory.StartNew(
                            () =>
                        {
                            MoveDuplicatesToFolder(selectedPath);
                            isMoving = false;
                            Process.Start("explorer.exe", selectedPath);
                        }).ContinueWith(task => CommandManager.InvalidateRequerySuggested(), TaskScheduler.FromCurrentSynchronizationContext());
                    }
                }
            }
        }
Example #2
0
        public void AddMoreFolders(object param)
        {
            IFolderBrowserDialogService fbg = GetService <IFolderBrowserDialogService>();

            if (fbg != null)
            {
                if (DialogResult.OK == fbg.Show())
                {
                    string selectedPath = fbg.SelectedPath;

                    // Check if such directory exists, and check if such directory wasn't already introduced
                    if (!string.IsNullOrEmpty(selectedPath) && Paths.All(folder => selectedPath != folder.Path))
                    {
                        if (Directory.Exists(selectedPath))
                        {
                            Paths.Add(new Item {
                                Path = selectedPath, Count = -1, IsFolder = true
                            });
                        }
                        else if (File.Exists(selectedPath))
                        {
                            Paths.Add(new Item {
                                Path = selectedPath, Count = 1, IsFolder = false
                            });
                            return;
                        }
                        else
                        {
                            return;
                        }

                        // count the number of available music files asynchronously
                        Task.Factory.StartNew(
                            () =>
                        {
                            int count = Helper.CountNumberOfMusicFiles(selectedPath, musicFileFilters);

                            lock (LockObject)
                            {
                                int index = -1;
                                foreach (Item path in Paths)
                                {
                                    index++;
                                    if (path.Path == selectedPath)
                                    {
                                        break;
                                    }
                                }

                                if (Paths != null && Paths.Count >= index && index >= 0)
                                {
                                    totalMusicItems   += count;
                                    Paths[index].Count = count;
                                }
                            }
                        }).ContinueWith(
                            task => CommandManager.InvalidateRequerySuggested(), TaskScheduler);
                    }
                }
            }
        }