Exemple #1
0
        public async Task LoadDirectoryItemsAsync()
        {
            var dirItems = await mediaServer.LoadDirectoryItemsAsync(Id);

            DirectoryItems.Clear();
            dirItems.ToList().ForEach(dirItem => DirectoryItems.Add(dirItem));
        }
Exemple #2
0
        public async Task LoadDirectoryItemsAsync()
        {
            var dirItems = await LoadDirectoryItemsAsync(Dlna.ContentDirectory.BrowseAction.RootObjectId);

            DirectoryItems.Clear();
            dirItems.ToList().ForEach(dirItem => DirectoryItems.Add(dirItem));
        }
 public DirectoryItemModel(DirectoryItems type, string path, DateTime creationDate, DateTime modifyDate)
 {
     Type           = type;
     Path           = path;
     CreationDate   = creationDate;
     LastModifyDate = modifyDate;
 }
        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;
        }
Exemple #5
0
        public DirectoryItemVM(string path, DirectoryItems type)
        {
            Path = path;
            Type = type;

            ExpandCommand = new RelayCommand(ExpandDirectory);

            ClearChildren();
        }
Exemple #6
0
        public async Task FtpDeleteFileAsync(string fileName, DirectoryItems type)
        {
            string method = WebRequestMethods.Ftp.DeleteFile;

            if (type == DirectoryItems.Folder)
            {
                method = WebRequestMethods.Ftp.RemoveDirectory;
            }

            FtpWebRequest request = Request(fileName, method);

            FtpWebResponse response = await ResponseAsync(request);

            response.Close();
        }
Exemple #7
0
 public MainWindowViewModel()
 {
     //add the items...
     DirectoryItems.Add(new DirectoryItem()
     {
         DisplayName = "test", Children = new ObservableCollection <DirectoryItem>()
         {
             new DirectoryItem()
             {
                 DisplayName = "child"
             }
         }
     });
     foreach (var item in DirectoryItems)
     {
         item.PropertyChanged += Item_PropertyChanged;
     }
 }
        /// <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.";
            }
        }
 public DirectoryItemModel(DirectoryItems type, string path)
 {
     Type = type;
     Path = path;
 }
 public List <long> GetDirectoryIds()
 {
     return(DirectoryItems.Select(x => x.Id).Distinct().ToList());
 }
        /// <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");
            }
        }