Example #1
0
        public async Task LoadDirectoryItemsAsync()
        {
            var dirItems = await LoadDirectoryItemsAsync(Dlna.ContentDirectory.BrowseAction.RootObjectId);

            DirectoryItems.Clear();
            dirItems.ToList().ForEach(dirItem => DirectoryItems.Add(dirItem));
        }
        private async Task LoadFilesAndFoldersAsync()
        {
            LoggingViewModel.Instance.Information = "Retrieving items ...";
            this.LoadingFilesAndFolders           = true;

            DirectoryItems.Clear();

            IEnumerable <IItem> files = await _fileOperations.GetMyFilesAsync();

            if (files != null)
            {
                foreach (IItem file in files)
                {
                    FileSystemItemViewModel _directoryItem = new FileSystemItemViewModel(file);

                    //Adding FileSystemItems to observable collection.
                    DirectoryItems.Add(_directoryItem);
                }
                LoggingViewModel.Instance.Information = string.Empty;
            }
            else
            {
                LoggingViewModel.Instance.Information = "We couldn't get your file and folder list.";
            }

            this.LoadingFilesAndFolders = false;
        }
Example #3
0
        public async Task LoadDirectoryItemsAsync()
        {
            var dirItems = await mediaServer.LoadDirectoryItemsAsync(Id);

            DirectoryItems.Clear();
            dirItems.ToList().ForEach(dirItem => DirectoryItems.Add(dirItem));
        }
        /// <summary>
        /// Command for getting the file and folder list.
        /// </summary>
        async void ExecuteGetFileAndFolderListCommandAsync()
        {
            DirectoryItems.Clear();

            IEnumerable <IFileSystemItem> files = await _fileOperations.GetMyFilesAsync();

            if (files != null)
            {
                foreach (IFileSystemItem file in files)
                {
                    FileSystemItemViewModel _directoryItem = new FileSystemItemViewModel(file);

                    //Adding FileSystemItems to observable collection.
                    DirectoryItems.Add(_directoryItem);
                }
            }
            else
            {
                LoggingViewModel.Instance.Information = "We couldn't get your file and folder list.";
            }
        }
        /// <summary>
        /// Parse the directory.
        /// </summary>
        internal async Task ParseAsync()
        {
            Log($"{nameof(DirectoryViewModel)}.{nameof(ParseAsync)}: Start");

            try
            {
                if (string.IsNullOrWhiteSpace(DirectoryToParse))
                {
                    LogError($"{nameof(ParseAsync)} => {nameof(DirectoryToParse)} is empty/null.  Returning.");

                    return;
                }

                m_DirectoryCount = 0;
                m_FileCount      = 0;

                DirectoryItems.Clear();

                if (IsItemFile(DirectoryToParse))
                {
                    FileInfo fi = new FileInfo(DirectoryToParse);

                    RootNode = new DirectoryItem(fi)
                    {
                        Depth = 0
                    };

                    m_FileCount = 1;
                }
                else
                {
                    DirectoryInfo dirInfo = new DirectoryInfo(DirectoryToParse);

                    RootNode = new DirectoryItem(dirInfo)
                    {
                        Depth = 0
                    };

                    DirectoryItems.Add(RootNode);

                    m_DirectoryCount = 0;
                    m_FileCount      = 0;

                    Stopwatch timer = Stopwatch.StartNew();

                    await Task.Run(() => ParseDirectory(RootNode, dirInfo.FullName));

                    timer.Stop();

                    RaisePropertyChanged(nameof(DirectoryItems));

                    RootNode.IsExpanded = true;

                    ShowStatusMessage($"Time to parse " +
                                      $"{m_DirectoryCount.ToString(m_FmtInt)} directories and" +
                                      $" {m_FileCount.ToString(m_FmtInt)} files: " +
                                      $"{timer.Elapsed.GetTimeFromTimeSpan()}");
                }
            }
            catch (Exception ex)
            {
                LogError($"  Exception: {ex.ToString()}");
            }
            finally
            {
                Log($"{nameof(DirectoryViewModel)}.{nameof(ParseAsync)}: End");
            }
        }