示例#1
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public VolumeWatcherMain()
        {
            var app = System.Windows.Application.Current;

            // Windowをクローズしてもアプリケーションが終了しないように設定しておく。
            app.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown;  // Exitを明示的にCallすることでアプリケーションが終了するように設定

            // VolumeMonitor初期化
            VolumeMonitor1 = new VolumeMonitor(EDataFlow.eRender, ERole.eConsole);
            VolumeMonitor1.initDevice();

            CaptureMonitor = new VolumeMonitor(EDataFlow.eCapture, ERole.eConsole);
            CaptureMonitor.initDevice();

            // Model初期化
            model = new VolumeWatcherModel();
            model.LoadSettings();
            if (model.IsMicMute)
            {
                if (CaptureMonitor.AudioDevice != null && CaptureMonitor.AudioDevice.AudioEndpointVolume != null)
                {
                    CaptureMonitor.AudioDevice.AudioEndpointVolume.Mute = true;
                }
            }

            var VolumeMonitorViewModel1 = new VolumeMonitorViewModel(VolumeMonitor1, CaptureMonitor, model);
        }
示例#2
0
        static void Main(string[] args)
        {
            GLib.GType.Init();
            VolumeMonitor monitor = VolumeMonitor.Default;

            Console.WriteLine("Volumes:");
            foreach (Volume v in monitor.Volumes)
            {
                Console.WriteLine("\t{0}", v.Name);
            }
            Console.WriteLine("\nMounts:");
            foreach (Mount m in monitor.Mounts)
            {
                Console.WriteLine("\tName:{0}, UUID:{1}, root:{2}, CanUnmount: {3}", m.Name, m.Uuid, m.Root, m.CanUnmount);
                Volume v = m.Volume;
                if (v != null)
                {
                    Console.WriteLine("\t\tVolume:{0}", v.Name);
                }
                Drive d = m.Drive;
                if (d != null)
                {
                    Console.WriteLine("\t\tDrive:{0}", d.Name);
                }
            }
            Console.WriteLine("\nConnectedDrives:");
            foreach (Drive d in monitor.ConnectedDrives)
            {
                Console.WriteLine("\t{0}, HasVolumes:{1}", d.Name, d.HasVolumes);
            }
        }
示例#3
0
        public TestVolumes()
        {
            Gnome.Vfs.Vfs.Initialize();

            VolumeMonitor monitor = VolumeMonitor.Get();

            monitor.DriveConnected    += new DriveConnectedHandler(OnDriveConnected);
            monitor.DriveDisconnected += new DriveDisconnectedHandler(OnDriveDisconnected);
            monitor.VolumeMounted     += new VolumeMountedHandler(OnVolumeMounted);
            monitor.VolumeUnmounted   += new VolumeUnmountedHandler(OnVolumeUnmounted);

            Volume[] vols = monitor.MountedVolumes;
            Console.WriteLine("Mounted volumes:");
            foreach (Volume v in vols)
            {
                PrintVolume(v);
            }

            Drive[] drives = monitor.ConnectedDrives;
            Console.WriteLine("\nConnected drives:");
            foreach (Drive d in drives)
            {
                PrintDrive(d);
            }

            Console.WriteLine("\nWaiting for volume events...");
            GLib.MainLoop loop = new GLib.MainLoop();
            loop.Run();

            Gnome.Vfs.Vfs.Shutdown();
        }
示例#4
0
 public Manager()
 {
     client                 = new Client(subsystems);
     monitor                = VolumeMonitor.Default;
     monitor.MountAdded    += HandleMonitorMountAdded;
     monitor.MountRemoved  += HandleMonitorMountRemoved;
     monitor.VolumeRemoved += HandleMonitorVolumeRemoved;
     volume_device_map      = new Dictionary <IntPtr, GUdev.Device> ();
 }
        public VolumeMonitorViewModel(VolumeMonitor renderMonitor, VolumeMonitor captureMonitor, VolumeWatcherModel model)
        {
            Model = model;

            renderMonitor.OnVolumeNotification   += OnVolumeChanged;
            renderMonitor.OnDefaultDeviceChanged += OnDeviceChanged;

            captureMonitor.OnVolumeNotification   += OnRecVolumeChanged;
            captureMonitor.OnDefaultDeviceChanged += OnRecDeviceChanged;

            Model.SetDeviceInfo(renderMonitor.AudioDevice);
            Model.SetRecDeviceInfo(captureMonitor.AudioDevice);
        }
示例#6
0
        public List <DriveInfo> GetAll(bool readyDrivesOnly)
        {
            List <DriveInfo> drives = new List <DriveInfo> ();
            VolumeMonitor    volmon = GLib.VolumeMonitor.Default;

            foreach (Mount m in volmon.Mounts)
            {
                DriveInfo d = new DriveInfo();

                FillDriveInfoFromMount(d, m,
                                       (m.Volume != null) ? m.Volume.GetIdentifier(G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE) : string.Empty);

                drives.Add(d);
            }

            if (!readyDrivesOnly)
            {
                foreach (Volume v in volmon.Volumes)
                {
                    if (drives.FindIndex(di => (v.GetIdentifier(G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE) == di.Device)) == -1)
                    {
                        // Volume is unmounted or else it would have been referenced via volmon.Mounts
                        DriveInfo d = new DriveInfo();

                        d.device    = v.GetIdentifier(G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
                        d.driveType = GuessDriveType(null, v.Icon, v.Drive);

                        drives.Add(d);
                    }
                }

                foreach (Drive dr in volmon.ConnectedDrives)
                {
                    if (dr.IsMediaRemovable && !dr.HasMedia)
                    {
                        DriveInfo d = new DriveInfo();

                        d.device    = dr.GetIdentifier(G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
                        d.driveType = GuessDriveType(null, dr.Icon, dr);

                        drives.Add(d);
                    }
                }
            }

            return(drives);
        }
示例#7
0
        public MountProvider()
        {
            Monitor = VolumeMonitor.Default;

            foreach (Mount m in Monitor.Mounts)
            {
                if (IsTrash(m))
                {
                    continue;
                }
                Mounts.Add(new MountItem(m));
                Log <MountProvider> .Debug("Adding {0}.", m.Name);
            }

            Monitor.MountAdded   += HandleMountAdded;
            Monitor.MountRemoved += HandleMountRemoved;

            Items = Mounts.Cast <AbstractDockItem> ();
        }
示例#8
0
        public void FromPath(DriveInfo d, string rootPath)
        {
            VolumeMonitor volmon = GLib.VolumeMonitor.Default;

            // Remove endling slash from path
            if ((rootPath.Length > 1) && (rootPath[rootPath.Length - 1] == System.IO.Path.DirectorySeparatorChar))
            {
                rootPath = rootPath.Substring(0, rootPath.Length - 1);
            }

            foreach (Mount m in volmon.Mounts)
            {
                if (m.Root.Path == rootPath)
                {
                    FillDriveInfoFromMount(d, m,
                                           (m.Volume != null) ? m.Volume.GetIdentifier(G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE) : string.Empty);
                    return;
                }
            }

            throw new ArgumentException("Can't find drive for specified path", "rootPath");
        }
示例#9
0
        public void FromDevice(DriveInfo d, string device)
        {
            VolumeMonitor volmon = GLib.VolumeMonitor.Default;

            // Search in mounts first
            foreach (Mount m in volmon.Mounts)
            {
                if ((m.Volume != null) && (m.Volume.GetIdentifier(G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE) == device))
                {
                    FillDriveInfoFromMount(d, m, device);
                    return;
                }
            }

            // Search in volumes (unmounted or else the device would have been found in volmon.Mounts)
            foreach (Volume v in volmon.Volumes)
            {
                if (v.GetIdentifier(G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE) == device)
                {
                    d.device    = device;
                    d.driveType = GuessDriveType(null, v.Icon, v.Drive);
                    return;
                }
            }

            // Search in drives (does not contain media or else the device
            // would have been found in volmon.Mounts/Volumes) (e.g. cdrom-drives))
            foreach (Drive dr in volmon.ConnectedDrives)
            {
                if (dr.GetIdentifier(G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE) == device)
                {
                    d.device    = device;
                    d.driveType = GuessDriveType(null, dr.Icon, dr);
                    return;
                }
            }

            throw new ArgumentException("Can't find drive for specified device", "device");
        }
示例#10
0
 public DriveItemSource()
 {
     Vfs.Initialize ();
     monitor = Gnome.Vfs.VolumeMonitor.Get ();
     items = new List<Item> ();
 }
示例#11
0
 public DriveItemSource()
 {
     Vfs.Initialize();
     monitor = Gnome.Vfs.VolumeMonitor.Get();
     items   = new List <Item> ();
 }