Example #1
0
        private void OnActRescanVolumeActivated(object sender, System.EventArgs args)
        {
            TreeIter iter;

            if (!tvVolumes.GetSelectedIter(out iter))
            {
                return;
            }

            Volume oldVolume = tvVolumes.GetVolume(iter);

            WaitFunc <PlatformIO.DriveInfo> IsVolumeConnected = delegate(out PlatformIO.DriveInfo dinf) {
                foreach (PlatformIO.DriveInfo di in PlatformIO.DriveInfo.GetDrives())
                {
                    if (di.IsReady && di.IsMounted &&
                        (di.DriveType.ToVolumeDriveType() == oldVolume.DriveType) &&
                        (di.VolumeLabel == oldVolume.Title))
                    {
                        dinf = di;
                        return(true);
                    }
                }
                dinf = null;
                return(false);
            };

            bool proceed = true;

            PlatformIO.DriveInfo drive;

            if (!IsVolumeConnected(out drive))
            {
                string message = string.Format(S._("Please insert volume '<b>{0}</b>'."), Util.Escape(oldVolume.Title));
                var    wd      = new WaitingDialog <PlatformIO.DriveInfo>(IsVolumeConnected, message);
                wd.Title = S._("Waiting for volume");
                if (wd.Run() == (int)ResponseType.Ok)
                {
                    proceed = true;
                    drive   = wd.Value;
                }
                else
                {
                    proceed = false;
                }
                wd.Destroy();
            }

            if (proceed)
            {
                VolumeScanner vs = new VolumeScanner(database, drive);
                vs.VolumeEditor.Load(oldVolume);
                // remove old volume from the volume treeview and purge all associated data
                vs.NewVolumeAdded += (object o, NewVolumeAddedEventArgs a) => {
                    PurgeVolume(iter);
                };
                // add new volume to the volume treeview
                AddNewVolumeAddedEventHandler(vs);
            }
        }
Example #2
0
        private void AddVolume()
        {
            PlatformIO.DriveInfo drive;

            if (App.Settings.ScannerDevice.Length > 0)
            {
                try {
                    drive = PlatformIO.DriveInfo.FromDevice(App.Settings.ScannerDevice);
                } catch (ArgumentException e) {                // e.g. drive not found
                    MsgDialog.ShowError(this,
                                        S._("Error"),
                                        S._("An error occured while accessing drive {0}:\n{1}"),
                                        App.Settings.ScannerDevice,
                                        e.Message);

                    return;
                }
            }
            else
            {
                DriveSelection ds     = new DriveSelection();
                ResponseType   result = (ResponseType)ds.Run();
                ds.Destroy();

                if (result != ResponseType.Ok)
                {
                    return;
                }

                drive = ds.SelectedDrive;
            }

            if (!drive.IsReady)
            {
                MsgDialog.ShowError(this,
                                    S._("Error"),
                                    S._("Drive {0} is not ready."),
                                    drive.Device);                 // e.g. no volume inserted

                return;
            }

            if (!drive.IsMounted && !drive.HasAudioCdVolume)
            {
                MsgDialog.ShowError(this,
                                    S._("Error"),
                                    S._("Drive {0} is neither mounted nor does it contain an audio cd."),
                                    drive.Device);

                return;
            }

            VolumeScanner vs = new VolumeScanner(database, drive);

            AddNewVolumeAddedEventHandler(vs);
        }
Example #3
0
 private void AddNewVolumeAddedEventHandler(VolumeScanner vs)
 {
     vs.NewVolumeAdded += (object o, NewVolumeAddedEventArgs args) => {
         if (lastSuccessfulSearchCriteria != null)
         {
             // the volumes treeview is filtered,
             // so refill the treeview using the last sucessful searchcriteria.
             // (the freshly added volume may be matched by that criteria.)
             SearchVolumeAsync(lastSuccessfulSearchCriteria, null);
         }
         else
         {
             // volumes treeview isn't filtered and contains all volumes,
             // so just append.
             tvVolumes.AddVolume(args.Volume);
         }
     };
 }
Example #4
0
 public StatusUpdateTimer(VolumeScanner vs)
 {
     this.vscanner = vs;
     this.remove   = true;
 }
Example #5
0
 public StatusUpdateTimer(VolumeScanner vs)
 {
     this.vscanner	= vs;
     this.remove		= true;
 }
Example #6
0
        private void OnActRescanVolumeActivated(object sender, System.EventArgs args)
        {
            TreeIter iter;
            if (!tvVolumes.GetSelectedIter(out iter))
                return;

            Volume oldVolume = tvVolumes.GetVolume(iter);

            WaitFunc<PlatformIO.DriveInfo> IsVolumeConnected = delegate(out PlatformIO.DriveInfo dinf) {
                foreach (PlatformIO.DriveInfo di in PlatformIO.DriveInfo.GetDrives()) {
                    if (di.IsReady && di.IsMounted &&
                            (di.DriveType.ToVolumeDriveType() == oldVolume.DriveType) &&
                            (di.VolumeLabel == oldVolume.Title)) {
                        dinf = di;
                        return true;
                    }
                }
                dinf = null;
                return false;
            };

            bool proceed = true;
            PlatformIO.DriveInfo drive;

            if (!IsVolumeConnected(out drive)) {
                string message = string.Format(S._("Please insert volume '<b>{0}</b>'."), Util.Escape(oldVolume.Title));
                var wd = new WaitingDialog<PlatformIO.DriveInfo>(IsVolumeConnected, message);
                wd.Title = S._("Waiting for volume");
                if (wd.Run() == (int)ResponseType.Ok) {
                    proceed = true;
                    drive = wd.Value;
                } else {
                    proceed = false;
                }
                wd.Destroy();
            }

            if (proceed) {
                VolumeScanner vs = new VolumeScanner(database, drive);
                vs.VolumeEditor.Load(oldVolume);
                // remove old volume from the volume treeview and purge all associated data
                vs.NewVolumeAdded += (object o, NewVolumeAddedEventArgs a) => {
                    PurgeVolume(iter);
                };
                // add new volume to the volume treeview
                AddNewVolumeAddedEventHandler(vs);
            }
        }
Example #7
0
        private void AddVolume()
        {
            PlatformIO.DriveInfo drive;

            if (App.Settings.ScannerDevice.Length > 0) {
                try {
                    drive = PlatformIO.DriveInfo.FromDevice(App.Settings.ScannerDevice);
                } catch(ArgumentException e) { // e.g. drive not found
                    MsgDialog.ShowError(this,
                                        S._("Error"),
                                        S._("An error occured while accessing drive {0}:\n{1}"),
                                        App.Settings.ScannerDevice,
                                        e.Message);

                    return;
                }

            } else {

                DriveSelection ds = new DriveSelection();
                ResponseType result = (ResponseType)ds.Run();
                ds.Destroy();

                if (result != ResponseType.Ok)
                    return;

                drive = ds.SelectedDrive;
            }

            if (!drive.IsReady) {
                MsgDialog.ShowError(this,
                                    S._("Error"),
                                    S._("Drive {0} is not ready."),
                                    drive.Device); // e.g. no volume inserted

                return;
            }

            if (!drive.IsMounted && !drive.HasAudioCdVolume) {
                MsgDialog.ShowError(this,
                                    S._("Error"),
                                    S._("Drive {0} is neither mounted nor does it contain an audio cd."),
                                    drive.Device);

                return;
            }

            VolumeScanner vs = new VolumeScanner(database, drive);
            AddNewVolumeAddedEventHandler(vs);
        }
Example #8
0
 private void AddNewVolumeAddedEventHandler(VolumeScanner vs)
 {
     vs.NewVolumeAdded += (object o, NewVolumeAddedEventArgs args) => {
         if (lastSuccessfulSearchCriteria != null) {
             // the volumes treeview is filtered,
             // so refill the treeview using the last sucessful searchcriteria.
             // (the freshly added volume may be matched by that criteria.)
             SearchVolumeAsync(lastSuccessfulSearchCriteria, null);
         } else {
             // volumes treeview isn't filtered and contains all volumes,
             // so just append.
             tvVolumes.AddVolume(args.Volume);
         }
     };
 }