Beispiel #1
0
        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 BtnSaveLog_Click(object sender, RoutedEventArgs e)
        {
            var path = AppService.ShowSaveDialog(opts, "txt", $"{DateTime.Now.Year}-{DateTime.Now.Month}-{DateTime.Now.Day}_{DateTime.Now.Hour}-{DateTime.Now.Minute}_log");

            if (!string.IsNullOrWhiteSpace(path))
            {
                var logs = new List <string>();
                foreach (var log in lstLog.Items)
                {
                    logs.Add(log.ToString());
                }

                FileIoService.SaveLineCollectionToFile(logs, path);
                RefreshOptions();
                LogLine($"Saved logs to \"{path}\"");
            }
        }