Exemple #1
0
        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();
            }
        }
Exemple #2
0
        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) { }
        }
Exemple #3
0
        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 另存为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;
            }
        }
Exemple #5
0
        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;

            if (invoke_dll.read_profile())
            {
                has_icc = 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  = "无法打开此文件。";
                errorbox.linklabel.Text = "转到在线帮助";
                errorbox.link           = "https://liuziangexit.com/HEIF-Utility/Help/No1.html";
                errorbox.ShowDialog();

                return;
            }
        }
Exemple #6
0
        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;
            }
        }