/// <summary> /// Fills the UI with respect to the supplied parameter opts. /// </summary> public void BindOptions(PuppeteerOptions opts) { if (opts.Viewport != null) { widthNumericUpDown.Value = opts.Viewport.Width; heightNumericUpDown.Value = opts.Viewport.Height; scaleNumericUpDown.Value = Convert.ToDecimal(opts.Viewport.DeviceScaleFactor); mobileCheckBox.Checked = opts.Viewport.IsMobile; touchCheckBox.Checked = opts.Viewport.HasTouch; landscapeCheckBox.Checked = opts.Viewport.IsLandscape; } viewportEnabledCheckBox.Checked = opts.Viewport != null; slowMoNumericUpDown.Value = decimal.Multiply(opts.SlowMo, 10); devtoolsCheckBox.Checked = opts.DevTools; headlessCheckBox.Checked = opts.Headless; if (opts is ConnectPuppeteerOptions co) { hostTextBox.Text = co.EndPoint.Host; portTextBox.Text = co.EndPoint.Port.ToString(); connectionTypeComboBox.SelectedIndex = 1; SetBrowserMode(BrowserMode.Connect); } else if (opts is LaunchPuppeteerOptions lo) { pathTextBox.Text = lo.ExecutablePath; connectionTypeComboBox.SelectedIndex = 0; SetBrowserMode(BrowserMode.Launch); } }
private void RecorderSettings_Load(object sender, EventArgs e) { PuppeteerOptions po = ConfigManager.GetPuppeteerConfiguration(); RecordedEvents re = ConfigManager.GetRecordedEventsOptions(); puppeteerOptionsUserControl.BindOptions(po); recordedEventsPropertyGrid.SelectedObject = re; }
/// <summary> /// Exports current UI into PuppeteerOptions. /// </summary> /// <returns></returns> public PuppeteerOptions ExportOptions() { PuppeteerOptions po = null; if (connectionTypeComboBox.SelectedItem.ToString() == "Connect") { bool succ = Uri.TryCreate($"http://{hostTextBox.Text}:{portTextBox.Text}", UriKind.Absolute, out Uri endPoint); if (succ) { po = new ConnectPuppeteerOptions { EndPoint = endPoint }; } else { throw new ArgumentException("IP address or port is invalid. Changes not saved."); } } else if (connectionTypeComboBox.SelectedItem.ToString() == "Launch") { if (File.Exists(pathTextBox.Text) || pathTextBox.Text == "") { po = new LaunchPuppeteerOptions { ExecutablePath = pathTextBox.Text }; } else { throw new ArgumentException( "The filled path does not point to the actual file. Changes not saved."); } } po.DevTools = devtoolsCheckBox.Checked; po.Headless = headlessCheckBox.Checked; po.SlowMo = decimal.Divide(slowMoNumericUpDown.Value, 10); if (viewportEnabledCheckBox.Checked) { po.Viewport = new Viewport { DeviceScaleFactor = Convert.ToDouble(scaleNumericUpDown.Value), HasTouch = touchCheckBox.Checked, Height = decimal.ToInt32(heightNumericUpDown.Value), Width = decimal.ToInt32(widthNumericUpDown.Value), IsLandscape = landscapeCheckBox.Checked, IsMobile = mobileCheckBox.Checked }; } else { po.Viewport = null; } return(po); }
public RecorderConfiguration ExportRecorderOptions() { RecordedEvents r = (RecordedEvents)recordedEventsPropertyGrid.SelectedObject; try { PuppeteerOptions p = puppeteerOptionsUserControl.ExportOptions(); RecorderConfiguration rc = new RecorderConfiguration { PuppeteerOptions = p, RecordedEvents = r }; return(rc); } catch (ArgumentException e) { MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(new RecorderConfiguration { PuppeteerOptions = ConfigManager.GetPuppeteerConfiguration(), RecordedEvents = r }); } }