internal void NewPattern(object sender, EventArgs e) { if (retableBackgroundWorker.IsBusy) { retableBackgroundWorker.CancelAsync(); are.WaitOne(); } else if (ModifiedWarnCancel()) { return; } DialogResult result; ImportForm iform = new ImportForm(); result = iform.ShowDialog(this); if (result == System.Windows.Forms.DialogResult.Cancel) { return; } table = new CharacterPattern(iform.PatternNumber, iform.PatternScanLines, iform.PatternWidth); //table.width = iform.PatternWidth; table.PropertyChanged += new PropertyChangedEventHandler(table_PropertyChanged); fileName = Properties.Resources.Untitled; Modified = false; ReinitializeTable(); //MessageBox.Show(String.Format("{0} x {1}", table.width, table.ScanLines)); }
internal void ImportFnt(object sender, EventArgs e) { if (retableBackgroundWorker.IsBusy) { retableBackgroundWorker.CancelAsync(); are.WaitOne(); } else if (ModifiedWarnCancel()) { return; } DialogResult result; openFileDialog.Title = Properties.Resources.ImportTitle; openFileDialog.Filter = Properties.Resources.FontFilter; openFileDialog.FileName = ""; result = openFileDialog.ShowDialog(this); if (result == System.Windows.Forms.DialogResult.Cancel) { return; } ImportForm iform = new ImportForm(); result = iform.ShowDialog(this); if (result == System.Windows.Forms.DialogResult.Cancel) { return; } try { table = new CharacterPattern(iform.PatternNumber, iform.PatternScanLines, openFileDialog.FileName); fileName = Path.GetFileNameWithoutExtension(openFileDialog.FileName); table.PropertyChanged += new PropertyChangedEventHandler(table_PropertyChanged); Modified = true; ReinitializeTable(); } catch (IOException ex) { // Warn the user of EOF, MissingNO or other. Debug.WriteLine(ex, "FntEditor"); MessageBox.Show(this, String.Format(Properties.Resources.IOErrorMsg, ex.Message), Properties.Resources.IOErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public TableForm(string file, int scanLines, int number) : this() { if (retableBackgroundWorker.IsBusy) { retableBackgroundWorker.CancelAsync(); are.WaitOne(); } if (Path.GetExtension(file).Equals(".fnp")) { try { using (Stream fileStream = new FileStream(file, FileMode.Open)) { BinaryFormatter formatter = new BinaryFormatter(); formatter.AssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple; table = formatter.Deserialize(fileStream) as CharacterPattern; table.PropertyChanged += new PropertyChangedEventHandler(table_PropertyChanged); fileName = file; Modified = false; } if (table == null) { MessageBox.Show(this, Properties.Resources.SerializationErrorMsg, Properties.Resources.IOErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); table = new CharacterPattern(); table.PropertyChanged += new PropertyChangedEventHandler(table_PropertyChanged); fileName = Properties.Resources.Untitled; Modified = false; } } catch (SystemException e) { // For Sysinternal DebugView support Debug.WriteLine(e, "FntEditor"); MessageBox.Show(this, String.Format(Properties.Resources.IOErrorMsg, file), //e.Message) , Properties.Resources.IOErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { if (scanLines == 0 || number == 0) { ImportForm iform = new ImportForm(); DialogResult result = iform.ShowDialog(); try { if (result == System.Windows.Forms.DialogResult.OK) { table = new CharacterPattern(iform.PatternNumber, iform.PatternScanLines, file); } table.PropertyChanged += new PropertyChangedEventHandler(table_PropertyChanged); fileName = Path.GetFileNameWithoutExtension(file); Modified = true; } catch (IOException e) { // Warn the user of EOF, MissingNO or other. Debug.WriteLine(e, "FntEditor"); MessageBox.Show(this, String.Format(Properties.Resources.IOErrorMsg, file), //e.Message), Properties.Resources.IOErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { try { table = new CharacterPattern(number, scanLines, file); table.PropertyChanged += new PropertyChangedEventHandler(table_PropertyChanged); fileName = Path.GetFileNameWithoutExtension(file); Modified = true; } catch (IOException e) { // Warn the user of EOF, MissingNO or other. Debug.WriteLine(e, "FntEditor"); MessageBox.Show(this, String.Format(Properties.Resources.IOErrorMsg, file), //e.Message), Properties.Resources.IOErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }