using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Input; using Microsoft.Win32; using System.Windows.Controls; using DriveDotNetGuiClient.SettingsObjects; namespace DriveDotNetGuiClient.Commands { public class OpenFileBrowserCommand : ICommand { public bool CanExecute(object parameter) { return true; } public event EventHandler CanExecuteChanged; public void Execute(object parameter) { OpenFileDialog fdlg = new OpenFileDialog(); fdlg.RestoreDirectory = true; bool? res = fdlg.ShowDialog(); if (res.HasValue && res.Value) { if (parameter is SettingsObjectViewModel) { (parameter as SettingsObjectViewModel).Path = fdlg.FileName; } else if (parameter is ViewModel) { (parameter as ViewModel).PersonalityPath = fdlg.FileName; } } } } }