void UxStartButton_Click(object sender, EventArgs e) { Trace.TraceInformation(Util.GetCurrentMethodName()); if (this.captureContext == null || this.captureContext.Mode == CaptureContext.CaptureMode.Single) { var device = this.sumacon.DeviceManager.ActiveDevice; if (device == null) { return; } if (this.uxContinuousCheck.Checked) { var setting = this.GetContinuousCaptureSetting(); this.captureContext = CaptureContext.StartContinuousCapture(device, setting, this.OnCaptured, this.OnFinished); } else { this.captureContext = CaptureContext.StartSingleCapture(device, this.OnCaptured, this.OnFinished); } this.sumacon.DeviceManager.SuspendPropertyUpdate(device); } else { // 連続撮影中止 this.captureContext.Stop(); } this.UpdateControlState(); }
void OnFinished() { var device = this.captureContext?.Device; this.captureContext = null; this.SafeInvoke(() => { this.sumacon.DeviceManager.ResumePropertyUpdate(device); this.UpdateControlState(); }); }
public static CaptureContext StartSingleCapture(Device device, Action <Bitmap> onCaptured, Action onFinished) { var instance = new CaptureContext(); instance.Device = device ?? throw new ArgumentNullException(nameof(device)); instance.Mode = CaptureMode.Single; instance.onCaptured = onCaptured; instance.onFinished = onFinished; instance.RunCapture(); return(instance); }
public static CaptureContext StartContinuousCapture(Device device, ContinuousCaptureSetting setting, Action <Bitmap> onCaptured, Action onFinished) { var instance = new CaptureContext(); instance.Device = device ?? throw new ArgumentNullException(nameof(device)); instance.Mode = CaptureMode.Continuous; instance.continousSetting = setting; instance.onCaptured = onCaptured; instance.onFinished = onFinished; instance.RunCapture(); return(instance); }
protected override void OnClosing(CancelEventArgs e) { Trace.TraceInformation(Util.GetCurrentMethodName()); base.OnClosing(e); Properties.Settings.Default.CaptureSplitterDistance = this.uxSplitContainer.SplitterDistance; Properties.Settings.Default.CaptureSaveDirectoryPath = this.uxSaveDirectoryText.Text; Properties.Settings.Default.CaptureFileNamePattern = this.uxPatternText.Text; Properties.Settings.Default.CaptureContinuousEnabled = this.uxContinuousCheck.Checked; Properties.Settings.Default.CaptureIntervalSeconds = (int)this.uxIntervalNumeric.Value; Properties.Settings.Default.CaptureCountEnabled = this.uxCountCheck.Checked; Properties.Settings.Default.CaptureCount = (int)this.uxCountNumeric.Value; Properties.Settings.Default.CaptureSkipDuplicateEnabled = this.uxSkipDuplicatedImageCheck.Checked; this.captureContext?.Stop(); this.captureContext = null; this.sumacon.DeviceManager.ActiveDeviceChanged -= DeviceManager_ActiveDeviceChanged; }