private void BtnConvert_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrWhiteSpace(txtConvertOld.Text) || !string.IsNullOrWhiteSpace(txtConvertNew.Text)) { var path = AppService.ShowOpenFileDialog(opts, "txt files (*.txt)|*.txt"); if (!string.IsNullOrWhiteSpace(path)) { var lines = FileIoService.GetStringCollectionFromFile(path); var newLines = new List <string>(); foreach (string line in lines) { newLines.Add(line.Replace(txtConvertOld.Text.Single(), txtConvertNew.Text.Single())); } FileIoService.SaveLineCollectionToFile(newLines, path); AppService.LogLine("Converted file: " + path); } else { MessageBox.Show("Path is required to convert file"); } } else { MessageBox.Show("Must have a value in both delimiter boxes"); } }
private void BtnLoad_Click(object sender, RoutedEventArgs e) { var fileName = AppService.ShowOpenFileDialog(opts, "txt files (*.txt)|*.txt"); if (!string.IsNullOrWhiteSpace(fileName)) { if (fileName.Split('.').Last().ToUpper().Equals("TXT")) { var itemObject = GetCurrentItemType(); itemObject = FileIoService.LoadObjectFromFile(itemObject, fileName, false); if (itemObject.IsNothing()) { LogLine("Item type mismatch. Select correct item type from drop down or add a new item via Options"); } else { LoadItem(itemObject, fileName); LogLine($"Loaded \"{fileName}\" as {itemObject.GetType().ToString()}"); } } else { AppService.LogLine($"Items must be in a TXT file format"); } } }
private void BtnSelectTermsPath_Click(object sender, RoutedEventArgs e) { var path = AppService.ShowOpenFileDialog(opts, "txt files (*.txt)|*.txt"); if (!string.IsNullOrWhiteSpace(path)) { txtTermsPath.Text = path; } }
/// <summary> /// copy a user specified html file to the template path /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnAddTemplate_Click(object sender, RoutedEventArgs e) { var path = AppService.ShowOpenFileDialog(opts, "Html-Files(*.html)|*.html"); if (!string.IsNullOrWhiteSpace(path)) { if (path.Split('.').Last().ToUpper().Equals("HTML")) { File.Copy(path, GlobalConstants.TemplatesPath + "\\" + path.Split('\\').Last(), true); AppService.LogLine($"Added template file \"{path}\" to Templates"); AppService.RefreshMainWindowOptions(); } else { AppService.LogLine($"Did not add template file \"{path}\". File must be HTML type"); } } else { MessageBox.Show("Must specify a file"); } }