Esempio n. 1
0
 //非同期で変換処理が終わるのを監視
 private void Process_Exited(object sender, EventArgs e)
 {
     _convertNow.Stop();
     Dispatcher.Invoke(new Action(() =>
     {
         EnableCheck en   = new EnableCheck();
         en.Enable        = true;
         this.DataContext = en;
     }));
     if (System.IO.File.Exists(outputFile))
     {
         System.Windows.Forms.MessageBox.Show("変換処理が完了しました。", "変換完了", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         System.Windows.Forms.MessageBox.Show("変換処理に失敗しました。\r\n出力ファイル名が不正です。", "変換失敗", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Dispatcher.Invoke(new Action(() =>
         {
             this.output.Focus();
         }));
     }
 }
Esempio n. 2
0
        //変換ボタン押下
        public void Conversion(object sender, RoutedEventArgs e)
        {
            //対象ファイル存在チェック
            if (!System.IO.File.Exists(this.input.Text))
            {
                System.Windows.Forms.MessageBox.Show("対象ファイルが見つかりません。", "実行エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //.mp4からの変換の場合上書きになってしまうので、出力ファイル名を変更させる
            if (System.IO.Path.GetExtension(this.input.Text) == ".mp4" && this.input.Text == this.output.Text)
            {
                System.Windows.Forms.MessageBox.Show("対象ファイル名と出力ファイル名が同じです。\r\n出力ファイル名を変更してください。", "実行エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.output.Focus();
                return;
            }

            //出力ファイル存在チェック
            if (System.IO.File.Exists(this.output.Text))
            {
                System.Windows.Forms.MessageBox.Show("出力ファイルが既に存在します。\r\n出力ファイル名を変更してください。", "実行エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.output.Focus();
                return;
            }

            _convertNow = (Storyboard)this.Resources["convAnimeKey"];
            _convertNow.Begin();
            EnableCheck en           = new EnableCheck();
            var         regProcessor = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Session Manager\Environment", false);

            try
            {
                //変換処理
                var process = new Process();

                process.StartInfo = new ProcessStartInfo
                {
                    Arguments       = $"-i \"{this.input.Text}\" -vcodec libx264 -s vga -y \"{this.output.Text}\"",
                    CreateNoWindow  = true,
                    UseShellExecute = false,
                };

                //レジストリキー確認、WinVer(64bit?32bit?)
                if ((string)regProcessor.GetValue("PROCESSOR_ARCHITECTURE") == "x86")
                {
                    process.StartInfo.FileName = @"C:\WM_BWK\ffmpeg_32.exe";
                }
                else
                {
                    process.StartInfo.FileName = @"C:\WM_BWK\ffmpeg.exe";
                }

                process.EnableRaisingEvents = true;
                process.Exited += new EventHandler(Process_Exited);
                process.Start();
                en.Enable        = false;
                this.DataContext = en;
                outputFile       = this.output.Text;
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("変換処理に失敗しました");
                _convertNow.Stop();
                en.Enable        = true;
                this.DataContext = en;
            }
        }