private void Delete(DataFolderViewModel dataFolderViewModel) { var index = DataFolders.IndexOf(dataFolderViewModel); if (index < 0) { return; } DataFolders.RemoveAt(index); }
private void MoveUp(DataFolderViewModel dataFolderViewModel) { var index = DataFolders.IndexOf(dataFolderViewModel); if (index <= 0) { return; } DataFolders.RemoveAt(index); DataFolders.Insert(index - 1, dataFolderViewModel); }
private void MoveDown(DataFolderViewModel dataFolderViewModel) { var index = DataFolders.IndexOf(dataFolderViewModel); if (index < 0 || index >= DataFolders.Count - 1) { return; } DataFolders.RemoveAt(index); DataFolders.Insert(index + 1, dataFolderViewModel); }
private ActionResult PdfDownload(DataFolders folder, Func<FileInfo, bool> predicate) { var pdffile = Data.GetDirectory(folder).GetFiles("*.pdf").FirstOrDefault(predicate); if(pdffile == null) { return PageNotFound(); } else { return File(pdffile.FullName, "application/pdf"); } }
public void Apply() { _configRepository.Value.DataFolders = DataFolders .Select(_ => new AppConfiguration.DataFolder { Path = _.Path, IsEnabled = _.IsEnabled }).ToList(); _configRepository.Save(); MessageBox.Show( "Please restart the editor to switch resource path.\nActive resource paths:\n" + string.Join(Environment.NewLine, _configRepository.Value.GetActiveDataFolders().Select(_ => _.Path)), "Restart required", MessageBoxButton.OK, MessageBoxImage.Exclamation); }
public static string GetFolderPath(DataFolders folder) { switch (folder) { case DataFolders.Documents: var i = Get.Where <SingleApplication>(); return($@"{Environment.SpecialFolder.MyDocuments.Path()}\{AssemblyData.Company(AssemblyData.Name)}"); case DataFolders.ExecutionPath: return(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)); } throw new NotSupportedException(); }
public FileInfo GetFileBasedOnContent(DataFolders folder, Predicate<string> predicate) { foreach(var file in GetDirectory(folder).GetFiles()) { foreach(var line in File.ReadAllLines(file.FullName)) { if(predicate(line)) { return file; } } } return null; }
public void AddFolder() { var dialog = new CommonOpenFileDialog(); dialog.IsFolderPicker = true; if (dialog.ShowDialog() == CommonFileDialogResult.Ok) { DataFolders.Insert(0, new DataFolderViewModel(this) { Path = dialog.FileName, IsEnabled = true }); UpdateArrowButtons(); } }
public void ReadInSettings(TestingSettings settings) { this.TestNormal = settings.PassthroughSettings.TestNormal; this.TestCopyIn = settings.PassthroughSettings.TestCopyIn; this.TestImport = settings.PassthroughSettings.TestImport; this.TestOverlay = settings.PassthroughSettings.TestBinaryOverlay; this.TestEquals = settings.TestEquality; this.TestPex = settings.TestPex; this.CacheAlignment = settings.PassthroughSettings.CacheReuse.ReuseAlignment; this.CacheDecompression = settings.PassthroughSettings.CacheReuse.ReuseDecompression; this.CacheProcessing = settings.PassthroughSettings.CacheReuse.ReuseProcessing; this.Groups.Clear(); this.Groups.AddRange(settings.TargetGroups .Select(g => new PassthroughGroupVM(this, g))); if (DataFolders.TryGetValue(GameRelease.Oblivion, out var df)) { df.DataFolder.TargetPath = settings.DataFolderLocations.Oblivion; } if (DataFolders.TryGetValue(GameRelease.SkyrimLE, out df)) { df.DataFolder.TargetPath = settings.DataFolderLocations.Skyrim; } if (DataFolders.TryGetValue(GameRelease.SkyrimSE, out df)) { df.DataFolder.TargetPath = settings.DataFolderLocations.SkyrimSpecialEdition; } if (DataFolders.TryGetValue(GameRelease.SkyrimVR, out df)) { df.DataFolder.TargetPath = settings.DataFolderLocations.SkyrimVR; } if (DataFolders.TryGetValue(GameRelease.Fallout4, out df)) { df.DataFolder.TargetPath = settings.DataFolderLocations.Fallout4; } }
public void SaveToSettings(TestingSettings settings) { settings.PassthroughSettings.TestNormal = this.TestNormal; settings.PassthroughSettings.TestImport = this.TestImport; settings.PassthroughSettings.TestBinaryOverlay = this.TestOverlay; settings.PassthroughSettings.TestCopyIn = this.TestCopyIn; settings.TestEquality = this.TestEquals; settings.TestPex = this.TestPex; settings.PassthroughSettings.CacheReuse.ReuseDecompression = this.CacheDecompression; settings.PassthroughSettings.CacheReuse.ReuseAlignment = this.CacheAlignment; settings.PassthroughSettings.CacheReuse.ReuseProcessing = this.CacheProcessing; settings.TargetGroups = Groups .Select(g => new TargetGroup() { Do = g.Do, GameRelease = g.GameRelease, NicknameSuffix = g.NicknameSuffix, Targets = g.Passthroughs .Select(p => { return(new Target() { Do = p.Do, Path = p.Path.TargetPath }); }) .ToList(), }) .ToList(); settings.DataFolderLocations.Oblivion = DataFolders.Get(GameRelease.Oblivion).DataFolder.TargetPath; settings.DataFolderLocations.Skyrim = DataFolders.Get(GameRelease.SkyrimLE).DataFolder.TargetPath; settings.DataFolderLocations.SkyrimSpecialEdition = DataFolders.Get(GameRelease.SkyrimSE).DataFolder.TargetPath; settings.DataFolderLocations.SkyrimVR = DataFolders.Get(GameRelease.SkyrimVR).DataFolder.TargetPath; settings.DataFolderLocations.Fallout4 = DataFolders.Get(GameRelease.Fallout4).DataFolder.TargetPath; }
public DirectoryInfo GetDirectory(DataFolders folder) { switch(folder) { case DataFolders.Users: return new DirectoryInfo(Path.Combine(GetDataFolder(), "gebruikers")); case DataFolders.UsersToken: return new DirectoryInfo(Path.Combine(GetDataFolder(), "gebruikers", "tokens")); case DataFolders.UsersResetPasswords: return new DirectoryInfo(Path.Combine(GetDataFolder(), "gebruikers", "resetpassword")); case DataFolders.Indexes: return new DirectoryInfo(Path.Combine(GetDataFolder(), "indexen")); case DataFolders.InternBaarn: return new DirectoryInfo(Path.Combine(GetDataFolder(), "intern", "baarn")); case DataFolders.InternBunschoten: return new DirectoryInfo(Path.Combine(GetDataFolder(), "intern", "bunschoten")); case DataFolders.InternContactblad: return new DirectoryInfo(Path.Combine(GetDataFolder(), "intern", "contactblad")); case DataFolders.Calendar: return new DirectoryInfo(Path.Combine(GetDataFolder(), "calendar")); } return null; }
public FileInfo GetFile(DataFolders folder, string name) { return new FileInfo(Path.Combine(GetDirectory(folder).FullName, name)); }
public ApplicationProperties(DataFolders folder, string fileName, string fileExtension) { Folder = folder; FileName = fileName; FileExtension = fileExtension; }
public FileInfo GetFile(DataFolders folder, Predicate<FileInfo> predicate) { return this.GetDirectory(DataFolders.UsersToken) .GetFiles() .First(f => predicate(f)); }
public FileInfo GetNewFile(DataFolders folder, string name) { var fileName = Path.Combine(GetDirectory(folder).FullName, name); if(File.Exists(fileName)) { File.Delete(fileName); } File.CreateText(fileName).Close(); return new FileInfo(fileName); }
public MainVM() { // Set up selected config swapping and loading _SelectedSettings = this.WhenAnyValue(x => x.SelectedConfigPath.TargetPath) .Select(x => { TestingSettings?settings = null; try { if (File.Exists(x)) { settings = JsonConvert.DeserializeObject <TestingSettings>(File.ReadAllText(x)); } } catch (Exception) { // ToDo // Log } return(Path: x, Settings: settings); }) .Skip(1) .Pairwise() .Select(p => { if (p.Previous.Settings != null) { SaveToSettings(p.Previous.Settings); File.WriteAllText(p.Previous.Path, JsonConvert.SerializeObject(p.Previous.Settings, Formatting.Indented)); } ReadInSettings(p.Current.Settings ?? new TestingSettings()); return(p.Current.Settings); }) .ToGuiProperty(this, nameof(SelectedSettings), default); // Set up additional file picker error to fire if settings couldn't parse SelectedConfigPath.AdditionalError = this.WhenAnyValue(x => x.SelectedSettings) .Select <TestingSettings?, ErrorResponse>(settings => { if (settings == null) { return(ErrorResponse.Fail("Settings could not be serialized.")); } return(ErrorResponse.Success); }); // Funnel into convenient valid boolean for GUI use _ValidTarget = this.WhenAnyValue(x => x.SelectedConfigPath.ErrorState) .Select(err => err.Succeeded) .ToGuiProperty(this, nameof(ValidTarget)); RunAllCommand = ReactiveCommand.CreateFromTask(Run); AddPassthroughGroupCommand = ReactiveCommand.Create(AddPassthroughGroup); DataFolders.AddOrUpdate(EnumExt.GetValues <GameRelease>() .Select(r => new DataFolderVM(r))); DataFolders.Connect() .Bind(DataFoldersDisplay) .Subscribe() .DisposeWith(this); }
public FileInfo GetFile(DataFolders folder, IndexFiles file) { return new FileInfo(Path.Combine(GetDirectory(folder).FullName, GetFileName(file))); }