using System; using System.Collections.Generic; using System.Windows.Forms; using BizHawk.Client.Common; namespace BizHawk.Client.EmuHawk { /// /// implements a simple dialog which chooses an IVideoWriter to record with /// public partial class VideoWriterChooserForm : Form { private VideoWriterChooserForm() { InitializeComponent(); CaptureWidth = Global.Emulator.CoreComm.NominalWidth; CaptureHeight = Global.Emulator.CoreComm.NominalHeight; if (Global.Config.AVI_CaptureOSD) { using (var bb = GlobalWin.MainForm.CaptureOSD()) { CaptureWidth = bb.Width; CaptureHeight = bb.Height; } } lblSize.Text = $"Size:\r\n{CaptureWidth}x{CaptureHeight}"; if (CaptureWidth % 4 != 0 || CaptureHeight % 4 != 0) { lblResolutionWarning.Visible = true; } else { lblResolutionWarning.Visible = false; } } private int CaptureWidth, CaptureHeight; /// /// chose an IVideoWriter /// /// list of IVideoWriters to choose from /// parent window /// user choice, or null on Cancel\Close\invalid public static IVideoWriter DoVideoWriterChoserDlg(IEnumerable list, IWin32Window owner, out int resizew, out int resizeh, out bool pad, out bool audiosync) { VideoWriterChooserForm dlg = new VideoWriterChooserForm { labelDescriptionBody = { Text = "" } }; int idx = 0; int idx_select = -1; dlg.listBox1.BeginUpdate(); foreach (var vw in list) { dlg.listBox1.Items.Add(vw); if (vw.Attribs.ShortName == Global.Config.VideoWriter) { idx_select = idx; } idx++; } dlg.listBox1.SelectedIndex = idx_select; dlg.listBox1.EndUpdate(); foreach (Control c in dlg.panelSizeSelect.Controls) { c.Enabled = false; } DialogResult result = dlg.ShowDialog(owner); IVideoWriter ret; if (result == DialogResult.OK && dlg.listBox1.SelectedIndex != -1) { var vwi = (VideoWriterInfo)dlg.listBox1.SelectedItem; ret = vwi.Create(); Global.Config.VideoWriter = vwi.Attribs.ShortName; } else { ret = null; } if (ret != null && dlg.checkBoxResize.Checked) { resizew = dlg.numericTextBoxW.IntValue; resizeh = dlg.numericTextBoxH.IntValue; } else { resizew = -1; resizeh = -1; } pad = dlg.checkBoxPad.Checked; audiosync = dlg.checkBoxASync.Checked; dlg.Dispose(); return ret; } private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { labelDescriptionBody.Text = listBox1.SelectedIndex != -1 ? ((VideoWriterInfo)listBox1.SelectedItem).Attribs.Description : ""; } private void checkBoxResize_CheckedChanged(object sender, EventArgs e) { foreach (Control c in panelSizeSelect.Controls) { c.Enabled = checkBoxResize.Checked; } } private void buttonAuto_Click(object sender, EventArgs e) { numericTextBoxW.Text = CaptureWidth.ToString(); numericTextBoxH.Text = CaptureHeight.ToString(); } private void buttonOK_Click(object sender, EventArgs e) { if (checkBoxResize.Checked) { try { if (numericTextBoxW.IntValue < 1 || numericTextBoxH.IntValue < 1) { MessageBox.Show(this, "Size must be positive!"); DialogResult = DialogResult.None; } } catch (FormatException) { MessageBox.Show(this, "Size must be numeric!"); DialogResult = DialogResult.None; } } } } }