Esempio n. 1
0
        /// <summary>
        /// Pass prompt=false to disable asking to reorganize library
        /// </summary>
        /// <remarks>
        /// This method is a bit wonky but I wanted to lay the basics
        /// for handling different kinds of devices in case it is needed
        /// in the future.
        /// </remarks>
        private async Task <Unit> _EditDeviceSettings(bool skipPrompt = false)
        {
            if (SelectedDevice == null)
            {
                return(Unit.Default);
            }

            if (SelectedDevice is Devices.FSDevice d)
            {
                var dlg = new Dialogs.FSDeviceConfigEditor(d.Config);
                await MaterialDesignThemes.Wpf.DialogHost.Show(dlg);

                if (dlg.DialogResult == false)
                {
                    return(Unit.Default);
                }
                d.Config.CopyFrom(dlg.Config);

                if (!skipPrompt && dlg.RequestReorg)
                {
                    var dlg2 = new Dialogs.YesNo("Reorganize Library", "You have changed your device library's Directory Format. Would you like to reorganize your library now?", "Reorganize");
                    await MaterialDesignThemes.Wpf.DialogHost.Show(dlg2);

                    if (dlg2.DialogResult == true)
                    {
                        _ReorganizeDeviceLibrary();
                    }
                }
            }
            return(Unit.Default);
        }
Esempio n. 2
0
        public async void _ScanDeviceLibrary()
        {
            var dlg = new Dialogs.YesNo("Rescan Library", "Your Kindle will be scanned for books which will then be organized and renamed according to your Kindle's settings.");
            await MaterialDesignThemes.Wpf.DialogHost.Show(dlg);

            if (dlg.DialogResult == false)
            {
                return;
            }

            var prgDlg = new Dialogs.Progress("Scanning Library", true);

            OpenBottomDrawer(prgDlg.Content);

            _ = Task.Run(() =>
            {
                try
                {
                    foreach (BookBase book in SelectedDevice.Rescan())
                    {
                        prgDlg.Current = $"Processed {book.Title}";
                    }
                }
                catch (Exception e)
                {
                    prgDlg.ShowError(e);
                }
                finally
                {
                    prgDlg.Finish($"{SelectedDevice.Name} library scan complete.");
                }
            });
        }
Esempio n. 3
0
        public async Task <bool> _SelectDevice(string driveLetter)
        {
            try
            {
                SelectedDevice = DevManager.OpenDevice(driveLetter);
            }
            catch (Exception e)
            {
                var errDlg = new Dialogs.Error("Unable to open Device", e.Message);
                await MaterialDesignThemes.Wpf.DialogHost.Show(errDlg);

                return(false);
            }

            if (SelectedDevice.Open())
            {
                var dlg = new Dialogs.YesNo("Device Setup", "It appears this is the first time you've used this device with KindleManager. A new configuration and database will be created.");
                await MaterialDesignThemes.Wpf.DialogHost.Show(dlg);

                if (dlg.DialogResult == false)
                {
                    SelectedDevice = null;
                    return(false);
                }

                await _EditDeviceSettings(true);

                _ScanDeviceLibrary();
            }

            CombinedLibrary.AddRemoteLibrary(SelectedDevice.Database.BOOKS);

            return(true);
        }
Esempio n. 4
0
        public async void _ReorganizeDeviceLibrary()
        {
            var dlg = new Dialogs.YesNo("Reorganize Library", "All books in your Kindle's library will be moved and renamed according to your Kindle's settings. This may take some time depending on the size of your library.");
            await MaterialDesignThemes.Wpf.DialogHost.Show(dlg);

            if (dlg.DialogResult == false)
            {
                return;
            }

            var prgDlg = new Dialogs.Progress("Reorganizing Library", true);

            OpenBottomDrawer(prgDlg.Content);

            _ = Task.Run(() =>
            {
                try
                {
                    foreach (BookBase book in SelectedDevice.Reorganize())
                    {
                        prgDlg.Current = $"Processed {book.Title}";
                    }
                    prgDlg.Current = "Cleaning up...";
                    SelectedDevice.Clean();
                }
                catch (Exception e)
                {
                    prgDlg.ShowError(e);
                }
                finally
                {
                    prgDlg.Finish($"{SelectedDevice.Name} reorganized.");
                }
            });
        }