private void ApplicationStartup(object sender, StartupEventArgs e) { // This is required (just before the main window starts), in order to be able to display any dialog before the main window, // without closing the Application on this dialog close. Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown; // If there is any splash screen or login screen we could display it here. // Here we should instantiate SettingsModel singleton (and therefore read settings from file). RSSettingsModel ProgramSettings = RSSettingsModel.Instance; // Here we can instantiate the rest of the models which needs to stay on during App lifetime. // Instantiate FolderListingModels for Processed and Raw files folders FolderListingModel MyProcessedFolderListing = new FolderListingModel(ProgramSettings.ProcessedFolderSetting, ProgramSettings.ProcessedExtensionSetting); FolderListingModel MyRawFolderListing = new FolderListingModel(ProgramSettings.RawFolderSetting, ProgramSettings.RawExtensionSetting); // Here we sdould instantiate the ShellViewModel, which will stay on during App lifetime. ShellViewModel ShellVM = new ShellViewModel(MyProcessedFolderListing, MyRawFolderListing); // Create the ShellViewModel's View - i.e. MainWindow MainWindow wnd = new MainWindow(); // Here we may optionally configure the Main Window or do some other stuff... wnd.DataContext = ShellVM; Application.Current.MainWindow = wnd; Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose; //Show the Main Window and proceed... wnd.Show(); }
public DeltaViewModel(FolderListingModel rawListingModel) { // Instantiate the main collection in this view model MyDeltaFiles = new ObservableCollection <FileDescriptorModel>(); // Build the Delta Files collection (candidate files for deletion), based on BelongsToDelta information: QualifiedRawNo = 0; foreach (FileDescriptorModel fd1 in rawListingModel.FileList) { if (fd1.IsQualified) { QualifiedRawNo++; } if (fd1.BelongsToDelta) { MyDeltaFiles.Add(fd1); } } // Build Views of the above collections, so that we can manipulate it better MyDeltaFilesView = new ListCollectionView(MyDeltaFiles); MyDeltaFilesView.MoveCurrentTo(null); SessionDeletedFiles = new List <FileDescriptorModel>(); // Initiate commands RemoveDeltaListItemCommand = new RelayCommand(RemoveDeleteListItem, RemoveDeleteListItemCanUse); DeleteDeltaFilesCommand = new RelayCommand(DeleteDeltaFiles, DeleteDeltaFilesCanUse); CancelDeletionCommand = new RelayCommand(CancelDeletion, CancelDeletionCanUse); CloseDeltaCommand = new RelayCommand(CloseDelta, CloseDeltaCanUse); }
public ShellViewModel(FolderListingModel pfl, FolderListingModel rfl) { MyProcessedFolderListing = pfl; MyRawFolderListing = rfl; ProcessedFolder = MyProcessedFolderListing.FolderPath; RawFolder = MyRawFolderListing.FolderPath; // Build observable collections of file descriptors in view model MyProcessedFolderFiles = new ObservableCollection <FileDescriptorModel>(); foreach (FileDescriptorModel fd in MyProcessedFolderListing.FileList) { MyProcessedFolderFiles.Add(fd); } MyRawFolderFiles = new ObservableCollection <FileDescriptorModel>(); foreach (FileDescriptorModel fd in MyRawFolderListing.FileList) { MyRawFolderFiles.Add(fd); } // Build Views of the above collections, which can then be filtered ListCollectionView MyProcessedFolderFilesView = new ListCollectionView(MyProcessedFolderFiles); MyProcessedFolderFilesView.Filter = new Predicate <object>(ProcessedQualifyFilter); MyProcessedGridView = MyProcessedFolderFilesView; MyProcessedGridView.MoveCurrentTo(null); ListCollectionView MyRawFolderFilesView = new ListCollectionView(MyRawFolderFiles); MyRawFolderFilesView.Filter = new Predicate <object>(RawQualifyFilter); MyRawGridView = MyRawFolderFilesView; MyRawGridView.MoveCurrentTo(null); // Initiate button commands SelectProcessedFolderCommand = new RelayCommand(SelectProcessedFolder); SelectRawFolderCommand = new RelayCommand(SelectRawFolder); RefreshProcessedFileListCommand = new RelayCommand(RefreshProcessedFileList); RefreshRawFileListCommand = new RelayCommand(RefreshRawFileList); RemoveProcessedItemCommand = new RelayCommand(RemoveProcessedItem, RemoveProcessedItemCanUse); RemoveRawItemCommand = new RelayCommand(RemoveRawItem, RemoveRawItemCanUse); GetDeltaCommand = new RelayCommand(GetDelta, GetDeltaCanUse); OpenSettingsCommand = new RelayCommand(OpenSettings); ProgramExitCommand = new RelayCommand(ProgramExit); ProgramHelpCommand = new RelayCommand(ProgramHelp); }