public MainWindow(string filename, Size s) { InitializeComponent(); var backup = this.Size; try { if (s.Height <= 0 || s.Width <= 0) { throw new Exception(); } this.Size = s; } catch (Exception) { this.Size = backup; } this.MainPictureBox.AllowDrop = true; this.Show(); var box = new Processing(); try { Thread T; T = new Thread(new ThreadStart(new Action(() => { box.ShowDialog(); }))); T.IsBackground = true; T.Start(); open(filename); box.Invoke(new Action(() => { box.Close(); })); this.Focus(); } catch (Exception) { box.Invoke(new Action(() => { box.Close(); })); this.Focus(); var errorbox = new Error(); errorbox.maintext.Text = "Unable to open this file."; errorbox.linklabel.Text = "Online Support"; errorbox.link = "https://liuziangexit.com/HEIF-Utility/Help/No1.html"; errorbox.ShowDialog(); return; } }
private void 另存为ToolStripMenuItem_Click(object sender, EventArgs e) { var box2 = new Processing(); try { var box = new SaveFileDialog(); box.Title = "Save"; box.Filter = "JPEG(.jpg)|*.jpg"; box.ShowDialog(); if (box.FileName == "") { return; } var sq = new setjpgquality(); sq.ShowDialog(); Thread T; T = new Thread(new ThreadStart(new Action(() => { box2.ShowDialog(); }))); T.IsBackground = true; T.Start(); try { invoke_dll.invoke_heif_to_jpg(heicfile, sq.value, "temp_bitstream.hevc").Save(box.FileName, ImageFormat.Jpeg); } catch (Exception) { MessageBox.Show("Can not save to " + box.FileName); return; } box2.Invoke(new Action(() => { box2.Close(); })); this.Focus(); MessageBox.Show("Successfully saved to " + box.FileName); return; } catch (Exception ex) { box2.Invoke(new Action(() => { box2.Close(); })); this.Focus(); MessageBox.Show(ex.Message); return; } }
private void 择HEIFToolStripMenuItem_Click(object sender, EventArgs e) { var box = new Processing(); try { var filepicker = new OpenFileDialog(); filepicker.Title = "打开"; filepicker.Multiselect = false; filepicker.Filter = "HEIF(.heic)|*.heic|任意文件|*.*"; if (filepicker.ShowDialog() != DialogResult.OK) { return; } if (filepicker.FileName == "") { return; } Thread T; T = new Thread(new ThreadStart(new Action(() => { box.ShowDialog(); }))); T.IsBackground = true; T.Start(); while (!box.IsHandleCreated) { Thread.Sleep(100); } open(filepicker.FileName); box.Invoke(new Action(() => { box.Close(); })); this.Focus(); } catch (Exception) { box.Invoke(new Action(() => { box.Close(); })); this.Focus(); var errorbox = new Error(); errorbox.maintext.Text = "无法打开此文件。"; errorbox.linklabel.Text = "转到在线帮助"; errorbox.link = "https://liuziangexit.com/HEIF-Utility/Help/No1.html"; errorbox.ShowDialog(); return; } }
public MainWindow(string filename, Size s) { InitializeComponent(); var backup = this.Size; try { if (s.Height <= 0 || s.Width <= 0) { throw new Exception(); } this.Size = s; } catch (Exception) { this.Size = backup; } this.MainPictureBox.AllowDrop = true; this.Show(); var box = new Processing(); try { Thread T; T = new Thread(new ThreadStart(new Action(() => { box.ShowDialog(); }))); T.IsBackground = true; T.Start(); open(filename); box.Invoke(new Action(() => { box.Close(); })); this.Focus(); } catch (Exception ex) { MessageBox.Show(ex.Message); box.Invoke(new Action(() => { box.Close(); })); this.Focus(); MessageBox.Show("Unable to open this file."); return; } }
private void 择HEIFToolStripMenuItem_Click(object sender, EventArgs e) { var box = new Processing(); try { var filepicker = new OpenFileDialog(); filepicker.Title = "Open"; filepicker.Multiselect = false; filepicker.Filter = "HEIF(.heic)|*.heic|Any File|*.*"; filepicker.ShowDialog(); if (filepicker.FileName == "") { return; } Thread T; T = new Thread(new ThreadStart(new Action(() => { box.ShowDialog(); }))); T.IsBackground = true; T.Start(); open(filepicker.FileName); box.Invoke(new Action(() => { box.Close(); })); this.Focus(); } catch (Exception) { box.Invoke(new Action(() => { box.Close(); })); this.Focus(); var errorbox = new Error(); errorbox.maintext.Text = "Unable to open this file."; errorbox.linklabel.Text = "Online Support"; errorbox.link = "https://liuziangexit.com/HEIF-Utility/Help/No1.html"; errorbox.ShowDialog(); return; } }
private void 择HEIFToolStripMenuItem_Click(object sender, EventArgs e) { var box = new Processing(); try { var filepicker = new OpenFileDialog(); filepicker.Title = "Open"; filepicker.Multiselect = false; filepicker.Filter = "HEIF(.heic)|*.heic|Any File|*.*"; filepicker.ShowDialog(); if (filepicker.FileName == "") { return; } filename = filepicker.FileName; Thread T; T = new Thread(new ThreadStart(new Action(() => { box.ShowDialog(); }))); T.IsBackground = true; T.Start(); open(filename); box.Invoke(new Action(() => { box.Close(); })); this.Focus(); } catch (Exception ex) { //MessageBox.Show(ex.Message); box.Invoke(new Action(() => { box.Close(); })); this.Focus(); MessageBox.Show("Unable to open this file."); return; } }
private void HU_DragDrop(object sender, DragEventArgs e) { var box = new Processing(); try { Thread T; T = new Thread(new ThreadStart(new Action(() => { box.ShowDialog(); }))); T.IsBackground = true; T.Start(); while (!box.IsHandleCreated) { Thread.Sleep(100); } open(((string[])e.Data.GetData(DataFormats.FileDrop, false))[0]); box.Invoke(new Action(() => { box.Close(); })); this.Focus(); } catch (Exception) { box.Invoke(new Action(() => { box.Close(); })); this.Focus(); var errorbox = new Error(); errorbox.maintext.Text = "Unable to open this file."; errorbox.linklabel.Text = "Online Support"; errorbox.link = "https://liuziangexit.com/HEIF-Utility/Help/No1.html"; errorbox.ShowDialog(); } }
private void HU_DragDrop(object sender, DragEventArgs e) { var box = new Processing(); try { Thread T; T = new Thread(new ThreadStart(new Action(() => { box.ShowDialog(); }))); T.IsBackground = true; T.Start(); open(((string[])e.Data.GetData(DataFormats.FileDrop, false))[0]); box.Invoke(new Action(() => { box.Close(); })); this.Focus(); } catch (Exception) { box.Invoke(new Action(() => { box.Close(); })); this.Focus(); var errorbox = new Error(); errorbox.maintext.Text = "无法打开此文件。"; errorbox.linklabel.Text = "转到在线帮助"; errorbox.link = "https://liuziangexit.com/HEIF-Utility/Help/No1.html"; errorbox.ShowDialog(); } }
private void HU_DragDrop(object sender, DragEventArgs e) { try { var box = new Processing(); Thread T; T = new Thread(new ThreadStart(new Action(() => { box.ShowDialog(); }))); T.IsBackground = true; T.Start(); open(((string[])e.Data.GetData(DataFormats.FileDrop, false))[0]); box.Invoke(new Action(() => { box.Close(); })); this.Focus(); } catch (Exception) { } }
private void 另存为ToolStripMenuItem_Click(object sender, EventArgs e) { var box2 = new Processing(); try { var box = new SaveFileDialog(); box.Title = "Save"; box.Filter = "JPEG(.jpg)|*.jpg"; box.ShowDialog(); if (box.FileName == "") { return; } var sq = new setjpgquality(); sq.ShowDialog(); Thread T; T = new Thread(new ThreadStart(new Action(() => { box2.ShowDialog(); }))); T.IsBackground = true; T.Start(); try { int copysize = 0; byte[] write_this; if (!sq.includes_exif) { write_this = invoke_dll.invoke_heif2jpg(heicfile, sq.value, "temp_bitstream.hevc", ref copysize, false); } else { write_this = invoke_dll.invoke_heif2jpg(heicfile, sq.value, "temp_bitstream.hevc", ref copysize, true); } FileStream fs = new FileStream(box.FileName, FileMode.Create); BinaryWriter writer = new BinaryWriter(fs); try { writer.Write(write_this, 0, copysize); writer.Close(); fs.Close(); } catch (Exception ex) { try { writer.Close(); fs.Close(); } catch (Exception) { } throw ex; } } catch (Exception) { box2.Invoke(new Action(() => { box2.Close(); })); this.Focus(); var errorbox = new Error(); errorbox.maintext.Text = "Can not save to " + box.FileName; errorbox.linklabel.Text = "Online Support"; errorbox.link = "https://liuziangexit.com/HEIF-Utility/Help/No2.html"; errorbox.ShowDialog(); return; } box2.Invoke(new Action(() => { box2.Close(); })); this.Focus(); MessageBox.Show("Successfully saved to " + box.FileName); return; } catch (Exception) { box2.Invoke(new Action(() => { box2.Close(); })); this.Focus(); MessageBox.Show("An unknown error occurred."); return; } }
private void 另存为ToolStripMenuItem_Click(object sender, EventArgs e) { var box2 = new Processing(); try { var box = new SaveFileDialog(); box.Title = "保存"; box.Filter = "JPEG(.jpg)|*.jpg"; box.FileName = Batch_Conversion.make_output_filename(filename); if (box.ShowDialog() != DialogResult.OK) { return; } if (box.FileName == "") { return; } var sq = new setjpgquality(); sq.ShowDialog(); Thread T; T = new Thread(new ThreadStart(new Action(() => { box2.ShowDialog(); }))); T.IsBackground = true; T.Start(); while (!box2.IsHandleCreated) { Thread.Sleep(100); } try { int copysize = 0; byte[] write_this; write_this = invoke_dll.invoke_heif2jpg(heicfile, sq.value, "tmp/temp_bitstream.hevc", ref copysize, sq.includes_exif, sq.color_profile); FileStream fs = new FileStream(box.FileName, FileMode.Create); BinaryWriter writer = new BinaryWriter(fs); try { writer.Write(write_this, 0, copysize); writer.Close(); fs.Close(); } catch (Exception ex) { try { writer.Close(); fs.Close(); } catch (Exception) { } throw ex; } } catch (Exception) { box2.Invoke(new Action(() => { box2.Close(); })); this.Focus(); var errorbox = new Error(); errorbox.maintext.Text = "无法保存到 " + box.FileName; errorbox.linklabel.Text = "转到在线帮助"; errorbox.link = "https://liuziangexit.com/HEIF-Utility/Help/No2.html"; errorbox.ShowDialog(); return; } box2.Invoke(new Action(() => { box2.Close(); })); this.Focus(); MessageBox.Show("成功保存到 " + box.FileName); return; } catch (Exception) { box2.Invoke(new Action(() => { box2.Close(); })); this.Focus(); MessageBox.Show("发生未知错误。"); return; } }