public SaveToTlkFile ( string fileName ) : void | ||
fileName | string | |
Результат | void |
public bool SaveToFile(string path) { HuffmanCompression hc = new HuffmanCompression(); hc.LoadInputData(StringRefs); hc.SaveToTlkFile(path); return(true); }
private void StartWritingTlkButton_Click(object sender, RoutedEventArgs e) { bool debugVersion = false; if (DebugCheckBox.IsChecked == true) { debugVersion = true; } BusyWriting(true); var writingWorker = new BackgroundWorker(); writingWorker.DoWork += delegate { try { HuffmanCompression hc = new HuffmanCompression(); hc.LoadInputData(_inputXmlFilePath, debugVersion); hc.SaveToTlkFile(_outputTlkFilePath); } catch (FileNotFoundException) { MessageBox.Show( Properties.Resources.AlertExceptionXmlNotFound, Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); } catch (System.Xml.XmlException ex) { MessageBox.Show($"Parse Error: {ex.Message}"); } catch (Exception ex) { string message = Properties.Resources.AlertExceptionGeneric; message += Properties.Resources.AlertExceptionGenericDescription + ex.Message; MessageBox.Show(message, Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Exclamation); } }; writingWorker.RunWorkerCompleted += delegate { BusyWriting(false); MessageBox.Show(Properties.Resources.AlertWritingTlkFinished, Properties.Resources.Done, MessageBoxButton.OK, MessageBoxImage.Information); }; writingWorker.RunWorkerAsync(); }
private void StartWritingTlkButton_Click(object sender, RoutedEventArgs e) { bool debugVersion = false; if (DebugCheckBox.IsChecked == true) { debugVersion = true; } BusyWriting(true); var writingWorker = new BackgroundWorker(); writingWorker.DoWork += delegate { try { HuffmanCompression hc = new HuffmanCompression(); hc.LoadInputData(_inputXmlFilePath, debugVersion); hc.SaveToTlkFile(OutputTlkFilePath); MessageBox.Show("Finished creating TLK file.", "Done!", MessageBoxButton.OK, MessageBoxImage.Information); } catch (FileNotFoundException) { MessageBox.Show("Selected XML file was not found or is corrupted.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } catch (System.Xml.XmlException ex) { MessageBox.Show($"Parse Error: {ex.Message}"); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }; writingWorker.RunWorkerCompleted += delegate { BusyWriting(false); }; writingWorker.RunWorkerAsync(); }
private void StartWritingTlkButton_Click(object sender, RoutedEventArgs e) { bool debugVersion = false; if (DebugCheckBox.IsChecked == true) debugVersion = true; BusyWriting(true); var writingWorker = new BackgroundWorker(); writingWorker.DoWork += delegate { try { HuffmanCompression hc = new HuffmanCompression(); hc.LoadInputData(_inputXmlFilePath, TalkFile.Fileformat.Xml, debugVersion); hc.SaveToTlkFile(_outputTlkFilePath); } catch (FileNotFoundException) { System.Windows.MessageBox.Show( Properties.Resources.AlertExceptionXmlNotFound, Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); } catch (Exception ex) { string message = Properties.Resources.AlertExceptionGeneric; message += Properties.Resources.AlertExceptionGenericDescription + ex.Message; System.Windows.MessageBox.Show(message, Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Exclamation); } }; writingWorker.RunWorkerCompleted += delegate { BusyWriting(false); System.Windows.MessageBox.Show(Properties.Resources.AlertWritingTlkFinished, Properties.Resources.Done, MessageBoxButton.OK, MessageBoxImage.Information); }; writingWorker.RunWorkerAsync(); }