public FolderWatcher(SoftwareRepository List) { _softwareRepository = List; watcher = new FileSystemWatcher(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Microsoft\Windows\Recent\AutomaticDestinations"), "*.automaticDestinations-ms"); watcher.NotifyFilter = NotifyFilters.LastWrite; watcher.Changed += Watcher_Changed; watcher.Created += Watcher_Created; watcher.EnableRaisingEvents = true; }
public MainWindowViewModel(IncognitoSettings settings, SoftwareRepository softwareRepository) { _softwareRepository = softwareRepository; _incognitoSettings = settings; this._folderWatcher = new FolderWatcher(_softwareRepository); this.SoftwareList = new SoftwareListViewModel(_softwareRepository); this.Incognito = new IncognitoViewModel(_softwareRepository, _incognitoSettings); this.Settings = new SettingsViewModel(_incognitoSettings); CloseWindowCommand = new RelayCommand(CloseWindowExecute); ShowWindowCommand = new RelayCommand(ShowWindowExecute, () => ShowWindowCanExecute()); HideWindowCommand = new RelayCommand(HideWindowExecute, () => HideWindowCanExecute()); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); //Use RoamingAppDataStorage if you have the package version of SettingsProvider.net package settingsProvider = new SettingsProvider(new LocalAppDataStorage("WindowsIncognito")); appSettings = settingsProvider.GetSettings<IncognitoSettings>(); MainWindow mw = new MainWindow(); softwareRepository = new SoftwareRepository(); var viewModel = new MainWindowViewModel(appSettings, softwareRepository); mw.DataContext = viewModel; mw.Show(); }
public IncognitoViewModel(SoftwareRepository softwareRepository, IncognitoSettings settings) { if (softwareRepository == null) { throw new ArgumentNullException("softwareRepository"); } this._softwareRepository = softwareRepository; this.AllSoftwares = new ObservableCollection<fileBlocker>(softwareRepository.GetSoftwares()); this._incognitoSettings = settings; if(_incognitoSettings.LockOnStartup) { LockAll(); } else { UnlockAll(); } isIncognito = _incognitoSettings.LockOnStartup; IncognitoOnCommand = new RelayCommand(IncognitoOnExecute, () => IncognitoOnCanExecute); IncognitoOffCommand = new RelayCommand(IncognitoOffExecute, () => IncognitoOffCanExecute); }