public VideoDisplayWindow(IMission mission, IDeployment deployment) { InitializeComponent(); Mission = mission; Deployment = deployment; Title = String.Format("Video - {0} > {1}", mission.Name, deployment.DateTime.ToString()); var app = Application.Current as App; if (app == null) { throw new Exception("Something has gone arye!"); } triggerStateChangedHandler = new TriggerStateChangedHandler(ControllerTriggerStateChanged); buttonStateChangedHandler = new ButtonStateChangedHandler(ControllerButtonStateChanged); deviceManager = (Application.Current as App).DeviceManager; if (deployment.Devices.Count > 0) { deviceManager.ActiveDevice = deployment.Devices[0]; deviceManager.ActiveDevice.MessageReceived += new DeviceMessageHandler(ActiveDeviceMessageReceived); } headsUpDisplay.YawOffset = Settings.Default.YawOffset; this.Dispatcher.BeginInvoke(DispatcherPriority.Render, new DispatcherOperationCallback(delegate { if (deployment.Devices.Count > 0) { IDevice device = deployment.Devices[0]; device.FrameReady += DeviceFrameReady; device.Open(); try { IDevice activeDevice = deviceManager.ActiveDevice; deviceManager.ActiveDevice.StartVideoCapture(1000); activeDevice.FinRange = Settings.Default.FinRange; activeDevice.TopFinOffset = Settings.Default.TopFinOffset; activeDevice.RightFinOffset = Settings.Default.RightFinOffset; activeDevice.BottomFinOffset = Settings.Default.BottomFinOffset; activeDevice.LeftFinOffset = Settings.Default.LeftFinOffset; activeDevice.CTD = true; } catch (Exception ex) { StringBuilder message = new StringBuilder(ex.ToString()); Exception inner = ex.InnerException; while (inner != null) { message.AppendLine(inner.ToString()); inner = inner.InnerException; } MessageBox.Show(message.ToString(), "Error Initializing Capture:" + ex.Message); this.Close(); } } return(null); }), null); }
public VideoDisplayWindow(IMission mission, IDeployment deployment) { InitializeComponent(); Mission = mission; Deployment = deployment; Title = String.Format("Video - {0} > {1}", mission.Name, deployment.DateTime.ToString()); var app = Application.Current as App; if (app == null) { throw new Exception("Something has gone arye!"); } triggerStateChangedHandler = new TriggerStateChangedHandler(ControllerTriggerStateChanged); buttonStateChangedHandler = new ButtonStateChangedHandler(ControllerButtonStateChanged); deviceManager = (Application.Current as App).DeviceManager; if (deployment.Devices.Count > 0) { deviceManager.ActiveDevice = deployment.Devices[0]; deviceManager.ActiveDevice.MessageReceived += new DeviceMessageHandler(ActiveDeviceMessageReceived); } headsUpDisplay.YawOffset = Settings.Default.YawOffset; this.Dispatcher.BeginInvoke(DispatcherPriority.Render, new DispatcherOperationCallback(delegate { if (deployment.Devices.Count > 0) { IDevice device = deployment.Devices[0]; device.FrameReady += DeviceFrameReady; device.Open(); try { IDevice activeDevice = deviceManager.ActiveDevice; deviceManager.ActiveDevice.StartVideoCapture(1000); activeDevice.FinRange = Settings.Default.FinRange; activeDevice.TopFinOffset = Settings.Default.TopFinOffset; activeDevice.RightFinOffset = Settings.Default.RightFinOffset; activeDevice.BottomFinOffset = Settings.Default.BottomFinOffset; activeDevice.LeftFinOffset = Settings.Default.LeftFinOffset; activeDevice.CTD = true; } catch (Exception ex) { StringBuilder message = new StringBuilder(ex.ToString()); Exception inner = ex.InnerException; while (inner != null) { message.AppendLine(inner.ToString()); inner = inner.InnerException; } MessageBox.Show(message.ToString(), "Error Initializing Capture:" + ex.Message); this.Close(); } } return null; }), null); }
protected void OnButtonStateChanged(Button button, bool pressed) { if (ButtonStateChanged != null) { ButtonStateChangedHandler eventHandler = ButtonStateChanged; Delegate[] delegates = eventHandler.GetInvocationList(); foreach (ButtonStateChangedHandler handler in delegates) { DispatcherObject dispatcherObject = handler.Target as DispatcherObject; if (dispatcherObject != null && !dispatcherObject.CheckAccess()) { dispatcherObject.Dispatcher.Invoke(DispatcherPriority.DataBind, handler, button, pressed); } else { handler(button, pressed); } } } }