Beispiel #1
0
        /// ------------------------------------------------------------------------------------
        public static bool MoveToRecycleBin(ComponentFile file, bool askForConfirmation)
        {
            var path = file.PathToAnnotatedFile;

            if (!File.Exists(path))
            {
                return(false);
            }

            var uiFileName = Path.GetFileName(path);

            if (file.HasSubordinateFiles)
            {
                uiFileName = String.Format(LocalizationManager.GetString(
                                               "CommonToMultipleViews.FileList.DeleteSubordinateFilesFormat",
                                               "{0} and subordinate files",
                                               "Used to format a string that will indicate that subordinate files (i.e., annotation files)" +
                                               " will also be moved to the recycle bin. Parameter is the name (without path) of the main file being deleted."), uiFileName);
            }
            if (askForConfirmation && !ConfirmRecycleDialog.JustConfirm(uiFileName, file.HasSubordinateFiles, ApplicationContainer.kSayMoreLocalizationId))
            {
                return(false);
            }

            return(file.Delete());
        }
Beispiel #2
0
        /// ------------------------------------------------------------------------------------
        protected virtual bool DoesUserConfirmDeletingSelectedElements()
        {
            int itemCount = _elementsGrid.SelectedRows.Count;

            var msg = LocalizationManager.GetString("MainWindow.DeleteOneItemMsg", "{0}", "For deleting sessions and people items");

            msg = (itemCount > 1 ? string.Format(msg, itemCount) :
                   string.Format(msg, _elementsGrid.GetCurrentElement().Id));

            return(ConfirmRecycleDialog.JustConfirm(msg, itemCount > 1, ApplicationContainer.kSayMoreLocalizationId));
        }
        public bool DeleteBook(Book.Book book, BookCollection collection = null)
        {
            if (collection == null)
            {
                collection = TheOneEditableCollection;
            }
            Debug.Assert(book.FolderPath == _bookSelection.CurrentSelection?.FolderPath);

            if (_bookSelection.CurrentSelection != null && _bookSelection.CurrentSelection.CanDelete)
            {
                if (IsCurrentBookInCollection())
                {
                    if (!_bookSelection.CurrentSelection.IsSaveable)
                    {
                        var msg = LocalizationManager.GetString("TeamCollection.CheckOutForDelete",
                                                                "Please check out the book before deleting it.");
                        ErrorReport.NotifyUserOfProblem(msg);
                        return(false);
                    }

                    if (_tcManager.CannotDeleteBecauseDisconnected(_bookSelection.CurrentSelection.FolderPath))
                    {
                        var msg = LocalizationManager.GetString("TeamCollection.ConnectForDelete",
                                                                "Please connect to the Team Collection before deleting books that are part of it.");
                        ErrorReport.NotifyUserOfProblem(msg);
                        return(false);
                    }
                }
                var bookName = _bookSelection.CurrentSelection.NameBestForUserDisplay;
                var confirmRecycleDescription = L10NSharp.LocalizationManager.GetString("CollectionTab.ConfirmRecycleDescription", "The book '{0}'");
                if (ConfirmRecycleDialog.JustConfirm(string.Format(confirmRecycleDescription, bookName), false, "Palaso"))
                {
                    // The sequence of these is a bit arbitrary. We'd like to delete the book in both places.
                    // Either could conceivably fail. If something goes wrong with removing the selection
                    // from it (very unlikely), we may as well leave nothing changed. If we delete it from
                    // the local collection but fail to delete it from the repo, it will come back at the
                    // next startup. If we delete it from the repo but fail to delete it locally,
                    // it will just stick around, and at least the desired team collection result has
                    // been achieved and the local result won't be a surprise later. So it seems marginally
                    // better to do them in this order.
                    _bookSelection.SelectBook(null);
                    if (collection == TheOneEditableCollection)
                    {
                        _tcManager.CurrentCollection?.DeleteBookFromRepo(book.FolderPath);
                    }
                    collection.DeleteBook(book.BookInfo);
                    return(true);
                }
            }
            return(false);
        }
        public bool DeleteBook(Book.Book book)        //, BookCollection collection)
        {
            Debug.Assert(book == _bookSelection.CurrentSelection);

            if (_bookSelection.CurrentSelection != null && _bookSelection.CurrentSelection.CanDelete)
            {
                var title = _bookSelection.CurrentSelection.TitleBestForUserDisplay;
                var confirmRecycleDescription = L10NSharp.LocalizationManager.GetString("CollectionTab.ConfirmRecycleDescription", "The book '{0}'");
                if (ConfirmRecycleDialog.JustConfirm(string.Format(confirmRecycleDescription, title), false, "Palaso"))
                {
                    TheOneEditableCollection.DeleteBook(book.BookInfo);
                    _bookSelection.SelectBook(null);
                    _sendReceiver.CheckInNow(string.Format("Deleted '{0}'", title));
                    return(true);
                }
            }
            return(false);
        }
        // Request from sign language tool to delete the selected video.
        private void HandleDeleteVideoRequest(ApiRequest request)
        {
            lock (request)
            {
                string    videoPath;
                decimal[] dummy;
                if (!GetVideoDetailsFromRequest(request, true, out videoPath, out dummy))
                {
                    return;                     // request.Failed was called inside the above method
                }
                var label = LocalizationManager.GetString("EditTab.Toolbox.SignLanguage.SelectedVideo", "The selected video", "Appears in the context \"X will be moved to the recycle bin\"");
                if (!ConfirmRecycleDialog.JustConfirm(label))
                {
                    request.ReplyWithText("canceled");
                    return;
                }

                ConfirmRecycleDialog.Recycle(videoPath);
                request.ReplyWithText("deleted");
            }
        }