Пример #1
0
 public VolumeWatcherHelper(VolumeWatcher vw)
 {
     outer = vw;
     OSXUtils.ApplicationHelper.ExecuteWhenLaunched(delegate
     {
         using (NSAutoreleasePool pool = new NSAutoreleasePool())
         {
             NSNotificationCenter nc = NSWorkspace.SharedWorkspace.NotificationCenter;
             nc.AddObserver(this, new Selector("ev_VolumeDidMount:"), new NSString("NSWorkspaceDidMountNotification"), null);
             nc.AddObserver(this, new Selector("ev_VolumeDidUnmount:"), new NSString("NSWorkspaceDidUnmountNotification"), null);
             nc.AddObserver(this, new Selector("ev_VolumeWillUnmount:"), new NSString("NSWorkspaceWillUnmountNotification"), null);
         }
     });
 }
Пример #2
0
        void ev_VolumeChanged(VolumeWatcher sender, VolumeWatcherEvent evt, string volume)
        {
            if (!_fullpath.StartsWith(volume))
            {
                return;
            }

            Trace("ev_VolumeChanged " + evt + ": " + volume);

            if (evt == VolumeWatcherEvent.DidMount)
            {
                _CheckAvailable(false);
            }
            else if (evt == VolumeWatcherEvent.WillUnmount || evt == VolumeWatcherEvent.DidUnmount)
            {
                _CheckAvailable(true); // must stop watcher on WillUnmount so we don't block unmount
            }
        }
Пример #3
0
 public VolumeWatcherHelper(VolumeWatcher vw)
 {
     outer = vw;
     OSXUtils.ApplicationHelper.ExecuteWhenLaunched(delegate
     {
         using (NSAutoreleasePool pool = new NSAutoreleasePool ())
         {
             NSNotificationCenter nc = NSWorkspace.SharedWorkspace.NotificationCenter;
             nc.AddObserver(this, new Selector("ev_VolumeDidMount:"), new NSString("NSWorkspaceDidMountNotification"), null);
             nc.AddObserver(this, new Selector("ev_VolumeDidUnmount:"), new NSString("NSWorkspaceDidUnmountNotification"), null);
             nc.AddObserver(this, new Selector("ev_VolumeWillUnmount:"), new NSString("NSWorkspaceWillUnmountNotification"), null);
         }
     });
 }
Пример #4
0
 public void Initialize()
 {
     _volwatcher = new VolumeWatcher();
     _volwatcher.VolumeChanged += ev_VolumeChanged;
     ThreadPool.QueueUserWorkItem(delegate { _CheckAvailable(false); });
 }