Exemplo n.º 1
0
 /// <summary>
 /// Gets the RiotArhiveFile associated with the specified path.
 /// </summary>
 /// <param name="path">The path of the RiotArchiveFile to get.</param>
 /// <returns></returns>
 public RiotArchiveFile this[string path]
 {
     get
     {
         return(Archives.First(a => a.Exists(path))[path]);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="manager">The archive data manager</param>
        /// <param name="filePaths">The archive file paths</param>
        public ArchiveExplorerDialogViewModel(IArchiveExplorerDataManager manager, IEnumerable <FileSystemPath> filePaths)
        {
            try
            {
                // Set the default title
                Title = Resources.Archive_Title;

                // Get the manager
                Manager = manager;

                // Create the load action
                var load = new Operation(() => IsLoading = true, () => IsLoading = false, true);

                // Get the archives
                Archives = filePaths.Select(x => new ArchiveViewModel(x, manager, load, this)).ToArray();

                // Set the archive lock
                ArchiveLock = new AsyncLock();

                RL.Logger?.LogInformationSource($"The Archive Explorer is loading with {Archives.Length} archives");

                // Make sure we got an archive
                if (!Archives.Any())
                {
                    throw new ArgumentException("At least one archive path needs to be available");
                }

                // Lock when accessing the archive
                using (ArchiveLock.Lock())
                {
                    // Load each archive
                    foreach (var archive in Archives)
                    {
                        archive.LoadArchive();
                    }
                }

                // Select and expand the first item
                Archives.First().IsSelected = true;
                Archives.First().IsExpanded = true;
            }
            catch
            {
                // Make sure the view model gets disposed
                Dispose();

                throw;
            }
        }
Exemplo n.º 3
0
    /// <summary>
    /// Default constructor
    /// </summary>
    /// <param name="manager">The archive data manager</param>
    /// <param name="filePaths">The archive file paths</param>
    public ArchiveExplorerDialogViewModel(IArchiveDataManager manager, FileSystemPath[] filePaths)
    {
        // Create commands
        NavigateToAddressCommand = new RelayCommand(() => LoadDirectory(CurrentDirectoryAddress));
        DeleteSelectedDirCommand = new AsyncRelayCommand(DeleteSelectedDirAsync);

        // Set properties
        CurrentDirectorySuggestions = new ObservableCollection <string>();
        StatusBarItems = new ObservableCollection <LocalizedString>();
        SearchProvider = new BaseSuggestionProvider(SearchForEntries);

        BindingOperations.EnableCollectionSynchronization(StatusBarItems, Application.Current);

        // TODO: Do not load the archives in the constructor! Create a separate init method or similar.

        try
        {
            // Set the default title
            Title = Resources.Archive_Title;

            // Get the manager
            Manager = manager;

            // Create the load action
            Operation load = new(() => IsLoading = true, () => IsLoading = false);

            // Get the archives
            Archives = filePaths.Select(x => new ArchiveViewModel(x, manager, load, this, filePaths.Any(f => f != x && f.Name == x.Name))).ToArray();

            // Set the archive lock
            ArchiveLock = new AsyncLock();

            Logger.Info("The Archive Explorer is loading with {0} archives", Archives.Length);

            // Make sure we got an archive
            if (!Archives.Any())
            {
                throw new ArgumentException("At least one archive path needs to be available");
            }

            // Lock when accessing the archive
            using (ArchiveLock.Lock())
            {
                // Load each archive
                foreach (var archive in Archives)
                {
                    archive.LoadArchive();
                }
            }

            // Select and expand the first item
            Archives.First().IsSelected = true;
            Archives.First().IsExpanded = true;
        }
        catch
        {
            // Make sure the view model gets disposed
            Dispose();

            throw;
        }
    }