protected virtual void OnDeviceChange(object o, DeviceChangeArgs args) { /* device disconnected, pause capture */ if (args.DeviceChange == -1) { if (capturing) { TogglePause(); } recbutton.Sensitive = false; MessageDialog md = new MessageDialog((Gtk.Window) this.Toplevel, DialogFlags.Modal, MessageType.Question, ButtonsType.Ok, Catalog.GetString("Device disconnected. " + "The capture will be paused")); md.Icon = Stetic.IconLoader.LoadIcon(md, "longomatch", Gtk.IconSize.Dialog); md.Run(); md.Destroy(); } else { recbutton.Sensitive = true; MessageDialog md = new MessageDialog((Gtk.Window) this.Toplevel, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo, Catalog.GetString("Device reconnected." + "Do you want to restart the capture?")); md.Icon = Stetic.IconLoader.LoadIcon(md, "longomatch", Gtk.IconSize.Dialog); if (md.Run() == (int)ResponseType.Yes) { TogglePause(); } md.Destroy(); } }
void OnAvailabilityDeviceChanged(object sender, DeviceChangeArgs e) { if (!e.DevicePath.Contains(SearchPattern)) { return; } DeviceInformation deviceInfo; switch (e.ChangeType) { case DeviceChange.Added: deviceInfo = DeviceManager.EnumerateAllDevices().First(d => d.Path == e.DevicePath); Contract.Assert(!AvailableDevices.Contains(deviceInfo)); InsertDeviceInfo(deviceInfo); Log.InfoFormat(Strings.USB_Device_Plugged_0, deviceInfo.Description); break; case DeviceChange.Removed: deviceInfo = AvailableDevices.First(d => d.Path == e.DevicePath); Contract.Assert(AvailableDevices.Contains(deviceInfo)); AvailableDevices.Remove(deviceInfo); Log.InfoFormat(Strings.USB_Device_Unplugged_0, deviceInfo.Description); break; } }
static void DeviceChangeSignalCallback(IntPtr arg0, int arg1, IntPtr gch) { DeviceChangeArgs args = new DeviceChangeArgs(); try { GLib.Signal sig = ((GCHandle)gch).Target as GLib.Signal; if (sig == null) { throw new Exception("Unknown signal GC handle received " + gch); } args.Args = new object[1]; args.Args [0] = arg1; GlibDeviceChangeHandler handler = (GlibDeviceChangeHandler)sig.Handler; handler(GLib.Object.GetObject(arg0), args); } catch (Exception e) { GLib.ExceptionManager.RaiseUnhandledException(e, false); } }