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()); } } } }
/// <summary> /// Initializes a new instance of the <see cref="BaseViewModel" /> class. /// </summary> /// <param name="settingsService">The settings service.</param> /// <param name="folderBrowserDialogService">The folder browser dialog service.</param> public PluginsViewModel( ISettingsService settingsService, IFolderBrowserDialogService folderBrowserDialogService) : base(settingsService) { this.folderBrowserDialogService = folderBrowserDialogService; this.Init(); }
/// <summary> /// Initializes a new instance of the <see cref="ProjectsViewModel" /> class. /// </summary> /// <param name="visualStudioService">The visual studio service.</param> /// <param name="settingsService">The settings service.</param> /// <param name="projectFactory">The project factory.</param> /// <param name="fileSystem">The file system.</param> /// <param name="messageBoxService">The message box service.</param> /// <param name="folderBrowserDialogService">The folder browser dialog service.</param> /// <param name="cachingService">The caching service.</param> public ProjectsViewModel( IVisualStudioService visualStudioService, ISettingsService settingsService, IProjectFactory projectFactory, IFileSystem fileSystem, IMessageBoxService messageBoxService, IFolderBrowserDialogService folderBrowserDialogService, ICachingService cachingService) { TraceService.WriteLine("ProjectsViewModel::Constructor Start"); this.visualStudioService = visualStudioService; this.settingsService = settingsService; this.fileSystem = fileSystem; this.projectFactory = projectFactory; this.messageBoxService = messageBoxService; this.folderBrowserDialogService = folderBrowserDialogService; this.cachingService = cachingService; this.projects = new ObservableCollection <SelectableItemViewModel <ProjectTemplateInfo> >(); //// set the defaults! this.Project = visualStudioService.GetDefaultProjectName(); if (string.IsNullOrEmpty(this.Project) && this.settingsService.UseTempProjectName) { this.Project = "P" + DateTime.Now.ToString("yyMMddHHmm"); } string defaultPath = this.settingsService.DefaultProjectsPath; //// if we are already in the solution disable project name and path. this.solutionAlreadyCreated = this.visualStudioService.SolutionAlreadyCreated; if (this.solutionAlreadyCreated) { TraceService.WriteLine("Solution already created"); this.Path = visualStudioService.SolutionService.GetParentDirectoryName(); } else { this.Path = string.IsNullOrEmpty(defaultPath) == false ? defaultPath : visualStudioService.DTEService.GetDefaultProjectsLocation(); } TraceService.WriteLine("ProjectsViewModel::Constructor End"); }
public EmulatorManagementViewModel(IFolderBrowserDialogService folderBrowserDialogService, IEmulatorShell emulatorShell) { _folderBrowserDialogService = folderBrowserDialogService; _emulatorShell = emulatorShell; _emulatorShell.EmulationStopped += EmulationStopped; SelectRomDirectoryCommand = new RelayCommand <Visual>(SelectRom); StartEmulationCommand = new RelayCommand(StartEmulation, () => !EmulationRunning); StopEmulationCommand = new RelayCommand(StopEmulation, () => EmulationRunning); RomFilename = "fishie.chip8"; RomDirectoryPath = "C:\\chip8"; CycleDelay = 10; }
public MonitorViewModel( IDataSelectViewModel dataViewModel, ITrainingViewModel trainingViewModel, IFileMonitorFactory fileMonitorFactory, IFolderBrowserDialogService folderBrowserDialog) : base(new NullHandler <IFileMonitor>()) { Guard.NotNull(() => trainingViewModel, trainingViewModel); Guard.NotNull(() => fileMonitorFactory, fileMonitorFactory); Guard.NotNull(() => dataViewModel, dataViewModel); this.dataViewModel = dataViewModel; this.trainingViewModel = trainingViewModel; this.fileMonitorFactory = fileMonitorFactory; Monitor = new SelectableViewModel(folderBrowserDialog, this, Observable.Return(Settings.Default.MonitorPath)); Destination = new SelectableViewModel(folderBrowserDialog, path: dataViewModel.Select.PathData); var canMonitor = this.WhenAny(x => x.Monitor.Path, y => y.Result, (x, y) => x.Value != null && Directory.Exists(x.Value) && y.Value == null); this.WhenAnyValue(x => x.Monitor.Path) .Where(x => x != Settings.Default.MonitorPath) .Subscribe( x => { Settings.Default.MonitorPath = x; Settings.Default.Save(); }); var visibility = this.WhenAny( item => item.trainingViewModel.Result, item => item.dataViewModel.Result, (model1, model2) => model1.Value == null || model2.Value == null ? Visibility.Collapsed : Visibility.Visible); classes = this.WhenAny(item => item.trainingViewModel.Result, model => ((NominalHeader)model.Value?.DataSet?.Header?.Class)?.Nominals).ToProperty(this, model => model.Classes); InitMain(canMonitor, visibility); PendingFiles = resultList.CreateDerivedCollection(x => x, scheduler: RxApp.MainThreadScheduler); var selected = SelectedItems.CreateDerivedCollection(x => x); var canMove = selected.Changed.StartWith().Select(_ => selected.Count > 0); Move = ReactiveCommand.Create(MoveSelected, canMove); Move.Subscribe(o => { MoveSelected(); }); Move.ThrownExceptions.Subscribe( ex => { MessageBox.Show("Move of some items failed", "Error", MessageBoxButton.OK); }); }
public SelectableViewModel(IFolderBrowserDialogService openFolder, IViewModelPage parent = null, IObservable <string> path = null) { Guard.NotNull(() => openFolder, openFolder); this.parent = parent; this.openFolder = openFolder; if (parent != null) { var canSelectSearch = this.WhenAnyObservable(x => x.parent.IsExecuting) .Select(x => !x) .ObserveOn(RxApp.MainThreadScheduler); Open = ReactiveCommand.Create(OpenLogic, canSelectSearch); } else { Open = ReactiveCommand.Create(OpenLogic); } path?.Subscribe(value => Path = value); }
/// <summary> /// Initializes a new instance of the <see cref="DirectoryPickerViewModel" /> class. /// </summary> /// <param name="folderBrowserDialogService">The folder browser dialog service.</param> public DirectoryPickerViewModel(IFolderBrowserDialogService folderBrowserDialogService) { this.folderBrowserDialogService = folderBrowserDialogService; }
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); } } } }
/// <summary> /// Initializes a new instance of the <see cref="ProjectsViewModel" /> class. /// </summary> /// <param name="visualStudioService">The visual studio service.</param> /// <param name="settingsService">The settings service.</param> /// <param name="projectFactory">The project factory.</param> /// <param name="fileSystem">The file system.</param> /// <param name="messageBoxService">The message box service.</param> /// <param name="folderBrowserDialogService">The folder browser dialog service.</param> /// <param name="viewModelAndViewsFactory">The view model and views factory.</param> public ProjectsViewModel( IVisualStudioService visualStudioService, ISettingsService settingsService, IProjectFactory projectFactory, IFileSystem fileSystem, IMessageBoxService messageBoxService, IFolderBrowserDialogService folderBrowserDialogService, IViewModelAndViewsFactory viewModelAndViewsFactory) : base(settingsService) { TraceService.WriteLine("ProjectsViewModel::Constructor Start"); this.settingsService = settingsService; this.fileSystem = fileSystem; this.messageBoxService = messageBoxService; this.folderBrowserDialogService = folderBrowserDialogService; this.projects = new ObservableCollection<SelectableItemViewModel<ProjectTemplateInfo>>(); IEnumerable<ProjectTemplateInfo> projectTemplateInfos = projectFactory.GetAllowedProjects(); foreach (SelectableItemViewModel<ProjectTemplateInfo> viewModel in projectTemplateInfos .Select(projectTemplateInfo => new SelectableItemViewModel<ProjectTemplateInfo>(projectTemplateInfo, projectTemplateInfo.PreSelected))) { this.projects.Add(viewModel); } //// set the defaults! this.Project = visualStudioService.GetDefaultProjectName(); string defaultPath = this.settingsService.DefaultProjectsPath; //// if we are already in the solution disable project name and path. this.solutionAlreadyCreated = this.Project.Length > 0; this.Path = string.IsNullOrEmpty(defaultPath) == false ? defaultPath : visualStudioService.DTEService.GetDefaultProjectsLocation(); this.useNuget = this.settingsService.UseNugetForProjectTemplates; this.viewTypes = viewModelAndViewsFactory.GetAvailableViewTypes(); this.selectedViewType = this.settingsService.SelectedViewType; TraceService.WriteLine("ProjectsViewModel::Constructor End"); }
public DataSelectViewModel(IDataHandler <DocumentSet> dataHandler, IFileManagerFactory fileManagerFactory, IFolderBrowserDialogService openFolder) : base(dataHandler) { Guard.NotNull(() => openFolder, openFolder); Guard.NotNull(() => fileManagerFactory, fileManagerFactory); this.fileManagerFactory = fileManagerFactory; Select = new SelectableViewModel(openFolder, this); var canSearch = this.WhenAny(x => x.Select.Path, x => x.Value != null && Directory.Exists(x.Value)); var visibility = Observable.Return(Visibility.Visible); InitMain(canSearch, visibility); }
/// <summary> /// Initializes a new instance of the <see cref="ProjectsViewModel" /> class. /// </summary> /// <param name="visualStudioService">The visual studio service.</param> /// <param name="settingsService">The settings service.</param> /// <param name="projectFactory">The project factory.</param> /// <param name="fileSystem">The file system.</param> /// <param name="messageBoxService">The message box service.</param> /// <param name="folderBrowserDialogService">The folder browser dialog service.</param> /// <param name="cachingService">The caching service.</param> public ProjectsViewModel( IVisualStudioService visualStudioService, ISettingsService settingsService, IProjectFactory projectFactory, IFileSystem fileSystem, IMessageBoxService messageBoxService, IFolderBrowserDialogService folderBrowserDialogService, ICachingService cachingService) { TraceService.WriteLine("ProjectsViewModel::Constructor Start"); this.visualStudioService = visualStudioService; this.settingsService = settingsService; this.fileSystem = fileSystem; this.projectFactory = projectFactory; this.messageBoxService = messageBoxService; this.folderBrowserDialogService = folderBrowserDialogService; this.cachingService = cachingService; this.projects = new ObservableCollection<SelectableItemViewModel<ProjectTemplateInfo>>(); //// set the defaults! this.Project = visualStudioService.GetDefaultProjectName(); if (string.IsNullOrEmpty(this.Project) && this.settingsService.UseTempProjectName) { this.Project = "P" + DateTime.Now.ToString("yyMMddHHmm"); } string defaultPath = this.settingsService.DefaultProjectsPath; //// if we are already in the solution disable project name and path. this.solutionAlreadyCreated = this.visualStudioService.SolutionAlreadyCreated; if (this.solutionAlreadyCreated) { TraceService.WriteLine("Solution already created"); this.Path = visualStudioService.SolutionService.GetParentDirectoryName(); } else { this.Path = string.IsNullOrEmpty(defaultPath) == false ? defaultPath : visualStudioService.DTEService.GetDefaultProjectsLocation(); } TraceService.WriteLine("ProjectsViewModel::Constructor End"); }