// Callback called when the camera is plugged/unplugged. static void LinkCB(IntPtr Context, tInterface Interface, tLinkEvent Event, UInt32 UniqueId) { switch (Event) { case tLinkEvent.eLinkAdd: { Console.WriteLine("Camera {0} plugged in.", UniqueId); break; } case tLinkEvent.eLinkRemove: { Console.WriteLine("Camera {0} unplugged.", UniqueId); break; } } }
// Callbacks called when the camera is plugged/unplugged. static void LinkCB(IntPtr Context, tInterface Interface, tLinkEvent Event, UInt32 UniqueId) { switch (Event) { case tLinkEvent.eLinkAdd: { System.Console.WriteLine("Camera {0} has been plugged in.", UniqueId); HandleCameraPlugged(UniqueId); break; } case tLinkEvent.eLinkRemove: { System.Console.WriteLine("Camera {0} has been unplugged.", UniqueId); HandleCameraUnplugged(UniqueId); break; } } }
protected void OnCameraConnectionChanged(IntPtr context, tInterface iface, tLinkEvent evt, UInt32 uniqueId) { bool connected = (evt == tLinkEvent.eLinkAdd); Camera camera; if (connected) { tCameraInfo cameraInfo = new tCameraInfo(); tErr err = Pv.CameraInfo(uniqueId, ref cameraInfo); if (err != tErr.eErrSuccess) { throw new PvException(err); } camera = new Camera(cameraInfo); cameras.Add(camera); } else { camera = cameras.Find(c => c.UniqueId == uniqueId); } if (camera != null && (CameraConnected != null && connected) || (CameraDisconnected != null && !connected)) { CameraConnectionHandler eventHandler = connected ? CameraConnected : CameraDisconnected; Delegate[] delegates = eventHandler.GetInvocationList(); foreach (CameraConnectionHandler handler in delegates) { DispatcherObject dispatcherObject = handler.Target as DispatcherObject; if (dispatcherObject != null && !dispatcherObject.CheckAccess()) { dispatcherObject.Dispatcher.Invoke(DispatcherPriority.DataBind, handler, camera); } else { handler(camera); } } } }
// Callbacks called when the camera is plugged/unplugged. static void LinkCB(IntPtr Context, tInterface Interface, tLinkEvent Event, UInt32 UniqueId) { switch (Event) { case tLinkEvent.eLinkAdd: { System.Console.WriteLine("Camera {0} has been plugged in.", UniqueId); Camera_UniqueId = UniqueId; //HandleCameraPlugged(UniqueId); Connected = true; break; } case tLinkEvent.eLinkRemove: { System.Console.WriteLine("Camera {0} has been unplugged.", UniqueId); HandleCameraUnplugged(UniqueId); Connected = false; err_string = "相机已断开!"; break; } } }