public static void Start(String name, WSRKinectSensor sensor) { Thread thread = new Thread(() => { SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher)); WSRCamera camera = new WSRCamera(name, sensor); camera.Closing += (sender2, e2) => { camera.Hide(); e2.Cancel = true; }; System.Windows.Threading.Dispatcher.Run(); }); thread.Name = name; thread.SetApartmentState(ApartmentState.STA); thread.IsBackground = true; thread.Start(); }
public override void Dispose() { // Stop super base.Dispose(); // Stop Thread WSRCamera.Shutdown(); // Stop Sensor WSRConfig.GetInstance().logInfo("KINECT", "Stop Sensors"); if (Sensors != null) { foreach (WSRKinectSensor sensor in Sensors) { if (sensor != null) { sensor.Dispose(); } } } }
// ========================================== // HANDLE SYSTEM TRAY // ========================================== public override void HandleCtxMenu(ContextMenuStrip menu) { int i = 0; foreach (WSRKinectSensor sensor in Sensors) { var name = "Kinect_" + i++; // Start Camera window WSRCamera.Start(name, sensor); // Build CtxMenu var item = new ToolStripMenuItem(); item.Text = name; item.Click += new EventHandler(Kinect_Click); item.Image = net.encausse.sarah.Properties.Resources.Kinect; // Add CtxMenu menu.Items.Add(item); } // Super base.HandleCtxMenu(menu); }
public static void Start() { Thread thread = new Thread(() => { camera = new WSRCamera(); // camera.Show(); // camera.Closed += (sender2, e2) => camera.Dispatcher.InvokeShutdown(); camera.Closing += (sender2, e2) => { camera.Hide(); e2.Cancel = true; }; System.Windows.Threading.Dispatcher.Run(); }); thread.Name = "Camera"; thread.SetApartmentState(ApartmentState.STA); thread.Start(); }
void Kinect_Click(object sender, EventArgs e) { ToolStripMenuItem menu = sender as ToolStripMenuItem; WSRCamera.Display(menu.Text); }