Ejemplo n.º 1
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);
        }
Ejemplo n.º 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);
        }