示例#1
0
        public void RefreshView()
        {
            VFS.Flush();
            var pos = GetCurrentPosition();

            SetCurrentPosition(pos);
        }
示例#2
0
        /// <summary>
        /// Delete item from both media library and disk drive.
        /// </summary>
        private void DeleteItemExec(object sender, ExecutedRoutedEventArgs e)
        {
            var items = CurrentDirectory.SelectedItems.Cast <EntryViewModel>().Where(f => !f.IsDirectory);

            if (!items.Any())
            {
                return;
            }

            this.IsEnabled = false;
            try
            {
                VFS.Flush();
                ResetPreviewPane();
                if (!items.Skip(1).Any())  // items.Count() == 1
                {
                    string item_name = Path.Combine(CurrentPath, items.First().Name);
                    Trace.WriteLine(item_name, "DeleteItemExec");
                    FileSystem.DeleteFile(item_name, UIOption.AllDialogs, RecycleOption.SendToRecycleBin);
                    DeleteItem(lv_GetCurrentContainer());
                    SetStatusText(string.Format(guiStrings.MsgDeletedItem, item_name));
                }
                else
                {
                    int count = 0;
                    StopWatchDirectoryChanges();
                    try
                    {
                        var file_list = items.Select(entry => Path.Combine(CurrentPath, entry.Name));
                        GARbro.Shell.File.Delete(file_list);
                        count = file_list.Count();
                    }
                    catch
                    {
                        ResumeWatchDirectoryChanges();
                        throw;
                    }
                    RefreshView();
                    SetStatusText(Localization.Format("MsgDeletedItems", count));
                }
            }
            catch (OperationCanceledException)
            {
            }
            catch (Exception X)
            {
                SetStatusText(X.Message);
            }
            finally
            {
                this.IsEnabled = true;
            }
        }