コード例 #1
0
 private void ViewLoaded(object sender, RoutedEventArgs r)
 {
     myViewModel = this.DataContext as ExplorerWindowViewModel;
     (DirectoryTree.Items[0] as DirInfo).IsSelected = true;
 }
コード例 #2
0
        private void startbutton_Click(object sender, RoutedEventArgs e)
        {
            IEnumerable <CollectorNode> _selectedCollectors = FileManager.GetSelectedCollectors(Collectors);

            if (!_selectedCollectors.Any() && !FileManager.Configuration.Options.DisableSearch)
            {
                MessageBox.Show("Please select at least one provider for images.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            GC.Collect();
            //GC.WaitForPendingFinalizers();

            ExplorerWindow          _fileExplorer   = new ExplorerWindow(this);
            ExplorerWindowViewModel _fileExplorerVM = new ExplorerWindowViewModel();

            _fileExplorer.DataContext = _fileExplorerVM;
            _fileExplorerVM.SelectPath(FileManager.Configuration.Options.LastSelectedFolder);

            bool?_res = _fileExplorer.ShowDialog();

            StartActionType _actionType = _fileExplorer.StartActionType;

            if (_res.HasValue && _res.Value)
            {
                switch (_actionType)
                {
                case StartActionType.Process:
                case StartActionType.ProcessAutomatic:
                case StartActionType.ProcessSemiautomatic:
                case StartActionType.ProcessFeelingLucky:
                case StartActionType.GenerateRandomThumbs:

                    switch (_actionType)
                    {
                    case StartActionType.Process:
                        FileManager.Mode = ProcessingMode.Manual;
                        break;

                    case StartActionType.ProcessSemiautomatic:
                        FileManager.Mode = ProcessingMode.SemiAutomatic;
                        break;

                    case StartActionType.ProcessAutomatic:
                        FileManager.Mode = ProcessingMode.Automatic;
                        break;

                    case StartActionType.ProcessFeelingLucky:
                        FileManager.Mode = ProcessingMode.FeelingLucky;
                        break;
                    }

                    dcMovies.IsEnabled  = false;
                    TheRibbon.IsEnabled = false;
                    try
                    {
                        IList <string> list = _fileExplorerVM.CollectSelectedFolders();

                        UpdateConfigurationData();

                        _fileExplorerVM.Dispose();
                        _fileExplorer.Close();
                        _fileExplorer = null;
                        GC.Collect();

                        if (list.Count != 0)
                        {
                            FileManager.ProcessMovies(_selectedCollectors as ObservableCollection <CollectorNode>, this, list, _actionType);
                        }
                        else
                        {
                            System.Windows.MessageBox.Show("Nothing selected, nothing to do...", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                            return;
                        }
                    }
                    finally
                    {
                        dcMovies.IsEnabled  = true;
                        TheRibbon.IsEnabled = true;
                    }
                    break;

                case StartActionType.FixNetworkShares:
                case StartActionType.UnfixNetworkShares:
                case StartActionType.UpdateMoviesheetsTemplate:
                case StartActionType.CreatePlaylist:
                case StartActionType.GenerateDummyFile:

                    _fileExplorer.Close();
                    _fileExplorer = null;
                    GC.Collect();

                    IList <string> list2 = _fileExplorerVM.CollectSelectedFolders();

                    if (list2.Count != 0)
                    {
                        FileManager.ProcessMovies(_selectedCollectors as ObservableCollection <CollectorNode>, this, list2, _actionType);
                    }
                    else
                    {
                        System.Windows.MessageBox.Show("Nothing selected, nothing to do...", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                        return;
                    }
                    break;
                }
            }
        }