private void startButton_Click(object sender, EventArgs e) { string value = (string)providerBox.SelectedItem; // Sanity check if (value == null) { MessageBox.Show("Specify input source!"); return; } //This has sense only if somebody is listening if (sampler != null && SetupComplete != null) { startButton.Visible = false; bufferedMode.Enabled = false; providerBox.Enabled = false; statistics.Enabled = false; closeWindow.Enabled = false; Text = "Active sampler" + " " + version; InteractiveDSConfig config = new InteractiveDSConfig(); config.Buffered = bufferedMode.Checked; config.Statistics = statistics.Checked; config.Preview = true; config.Provider = providertab[value]; config.Owner = videoPanel; sampler.MediaOnline += new DsSampler.MediaStartup(sampler_MediaOnline); SetupComplete(config); } }
/// <summary> /// Parametrizes the provider and itself according to the required config. /// You can consider it as converting required -> actual config. /// </summary> /// <param name="config">The required configuration from the UI</param> private void configPane_SetupComplete(InteractiveDSConfig config) { // Copy the provider provider = config.Provider; // Enable stats if necessary stats.Enabled = config.Statistics; // Prepare the buffer BMPbuffer = null; BMPbuffered = config.Buffered; videoInfoHeader = provider.StartProvider(config.Preview, this, config.Owner.Handle); // Setup image storage imageWidth = videoInfoHeader.BmiHeader.Width; imageHeight = videoInfoHeader.BmiHeader.Height; imageStride = imageWidth * 3; imageOffset = (imageHeight - 1) * imageStride; savedArray = new byte[imageWidth * imageHeight * 4]; // Adjust the preview ResizeVideo(config.Owner.Size); // Create the current configuration object configuration = new DSConfig(provider, imageWidth, imageHeight, config.Preview, config.Statistics); // Indicate that the preparations are complete mediaOnline = true; if (MediaOnline != null) { MediaOnline(configuration); } }