public bool Load() { LocBamlOptions options = new LocBamlOptions(); options.Input = this.InputPath; options.ToParseAsStream = true; options.Output = "res.txt"; // Transient string errors = options.CheckAndSetDefault(); if (string.IsNullOrEmpty(errors) == false) { CurrentViewModel.Loaded = false; CurrentViewModel.Status = errors; MessageBox.Show(errors, "Error", MessageBoxButton.OK, MessageBoxImage.Information); return(false); } Stream stream = LocBaml.ParseBamlResourcesAsSteram(options, out errors); if (string.IsNullOrEmpty(errors) == false) { CurrentViewModel.Loaded = false; CurrentViewModel.Status = errors; MessageBox.Show(errors, "Error", MessageBoxButton.OK, MessageBoxImage.Information); return(false); } CurrentViewModel.Loaded = true; SetTable((MemoryStream)stream, '\t'); return(true); }
public bool Save() { //FileInfo fi = new FileInfo(this.InputPath); LocBamlOptions options = new LocBamlOptions(); options.CultureInfo = this.CurrentCultureInfo; options.Input = this.InputPath; options.Output = this.OutputPath; options.ToGenerate = true; options.TranslationFileType = FileType.CSV; options.ToGenerateWithStream = true; // Get input by stream MemoryStream ms = new MemoryStream(); string errors = LocalizationItem.ExportAsStream(CurrentViewModel.LocalizationList, false, ms, false); if (string.IsNullOrEmpty(errors) == false) { CurrentViewModel.Status = errors; MessageBox.Show(errors, "Error", MessageBoxButton.OK, MessageBoxImage.Information); return(false); } errors = options.CheckAndSetDefault(); if (string.IsNullOrEmpty(errors) == false) { CurrentViewModel.Status = errors; MessageBox.Show(errors, "Error", MessageBoxButton.OK, MessageBoxImage.Information); return(false); } errors = LocBaml.GenerateBamlResourcesFromStream(options, ms); if (string.IsNullOrEmpty(errors) == false) { CurrentViewModel.Status = errors; MessageBox.Show(errors, "Error", MessageBoxButton.OK, MessageBoxImage.Information); return(false); } return(true); }