зеркало из https://github.com/mono/hal-sharp.git
Nice CD-Rom Test?
svn path=/trunk/hal-sharp/; revision=47369
This commit is contained in:
Родитель
ec914f0c0c
Коммит
fcf32b6dca
|
@ -29,13 +29,15 @@
|
|||
using System;
|
||||
using Hal;
|
||||
using Gtk;
|
||||
using System.Collections;
|
||||
|
||||
public class Entry
|
||||
{
|
||||
public static void Main()
|
||||
{
|
||||
Application.Init();
|
||||
new GtkTest();
|
||||
new CdromTest();
|
||||
//new GtkTest();
|
||||
Application.Run();
|
||||
|
||||
/* Context ctx = new Context(); */
|
||||
|
@ -56,6 +58,39 @@ public class Entry
|
|||
}
|
||||
}
|
||||
|
||||
public class CdromTest
|
||||
{
|
||||
private Context ctx;
|
||||
private ArrayList disks = new ArrayList();
|
||||
|
||||
public CdromTest()
|
||||
{
|
||||
ctx = new Context();
|
||||
|
||||
ctx.DeviceAdded += OnDeviceAdded;
|
||||
ctx.DeviceRemoved += OnDeviceRemoved;
|
||||
}
|
||||
|
||||
private void OnDeviceAdded(object o, DeviceAddedArgs args)
|
||||
{
|
||||
Device parentDevice = new Device(ctx, args.Device["info.parent"]);
|
||||
|
||||
if(parentDevice["storage.drive_type"].Equals("cdrom")) {
|
||||
Console.WriteLine("Found drive with disk: {0} ({1})",
|
||||
parentDevice,
|
||||
parentDevice["storage.model"]);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDeviceRemoved(object o, DeviceRemovedArgs args)
|
||||
{
|
||||
if(disks.IndexOf(args.Device.Udi) >= 0) {
|
||||
Console.WriteLine("Disk removed: {0}", args.Device);
|
||||
disks.Remove(args.Device.Udi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class GtkTest
|
||||
{
|
||||
private Window win;
|
||||
|
|
Загрузка…
Ссылка в новой задаче