コード例 #1
0
        private void CloseArchiveButton_Click(object sender, RoutedEventArgs e)
        {
            Button button = e.OriginalSource as Button;

            if ((object)button != null)
            {
                foreach (Archive archive in Archives.Where(archive => (int)button.DataContext == archive.ID).ToList())
                {
                    Archives.Remove(archive);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Removes the specified archive and all children from the index.</summary>
        /// <param name="writeToDb">If true, the object will be removed from the Database.</param>
        public async Task RemoveArchiveAsync(Archive archive, bool writeToDb)
        {
            if (archive is null)
            {
                return;
            }

            if (Archives.Where(x => x.Volume.Equals(archive.Volume)).Count() < 2)
            {
                // No other archive shares the logical volume of the
                // set that's about to be deleted, it can therefore be removed
                LogicalVolumes.Remove(archive.Volume);
                if (writeToDb)
                {
                    await Database.DeleteLogicalVolumeAsync(archive.Volume);
                }
            }

            // Get a list of all hashes related to the current archive,
            // remove all nodes from these hashes.
            var archiveHashes = archive.GetFileHashes();
            await archive.ClearAsync();

            archive.Dispose();

            // Get hashes in the collection with node count 0
            // these can be removed from the index
            var emptyHashes = archiveHashes.Where(x => x.NodeCount.Equals(0)).ToList();

            emptyHashes.ForEach(x => Hashes.Remove(x));

            if (writeToDb)
            {
                await Database.BatchDeleteFileHashAsync(emptyHashes);
            }

            Archives.Remove(archive);
            //NotifyPropertyChanged("Archive");
            if (writeToDb)
            {
                await Database.DeleteArchiveAsync(archive);
            }
        }
コード例 #3
0
        private void BrowseButton_Click(object sender, RoutedEventArgs e)
        {
            Button button = e.OriginalSource as Button;

            FolderBrowserDialog dialog;

            if ((object)button != null)
            {
                dialog = new FolderBrowserDialog();

                foreach (Archive archive in Archives.Where(archive => (int)button.DataContext == archive.ID))
                {
                    dialog.SelectedPath = archive.OffloadLocation;

                    if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        archive.OffloadLocation = dialog.SelectedPath;
                    }
                }
            }
        }