예제 #1
0
        private async void Init()
        {
            var models = new ObservableCollection <DriveInfoModel>();

            DriveInfo[] drives = await _hcdzClient.GetDrives();

            if (drives == null)
            {
                return;
            }
            foreach (var item in drives)
            {
                var drive = new DriveInfoModel()
                {
                    AvailableFreeSpace     = item.AvailableFreeSpace,
                    AvailableFreeSpaceText = ByteFormatter.ToString(item.AvailableFreeSpace) + " 可用",
                    DriveFormat            = item.DriveFormat,
                    DriveType          = item.DriveType,
                    IsReady            = item.IsReady,
                    Name               = item.Name,
                    RootDirectory      = item.RootDirectory,
                    TotalFreeSpace     = item.TotalFreeSpace,
                    TotalFreeSpaceText = ByteFormatter.ToString(item.TotalFreeSpace),
                    TotalSize          = item.TotalSize,
                    TotalSizeText      = "共" + ByteFormatter.ToString(item.TotalSize),
                    VolumeLabel        = string.IsNullOrEmpty(item.VolumeLabel) ? "本地磁盘 " : item.VolumeLabel,
                    Percent            = 100.0 - (int)(item.AvailableFreeSpace * 100.0 / item.TotalSize),
                    DriveLetter        = item.Name.Replace("\\", "")
                };
                drive.NameDesc = drive.VolumeLabel + string.Format("({0}:)", item.ToString().Replace(":", "").Replace("\\", ""));
                models.Add(drive);
            }
            DriveInfoItems = models;
        }
예제 #2
0
        private async void Initializer()
        {
            IsBusy = true;
            //获取远程磁盘
            //DriveInfo[] drives =await _hcdzClient.GetDrives();
            //if (drives!=null)
            //{
            //    DriveInfoItems = new ObservableCollection<DriveInfo>(drives);
            //}
            var models = new ObservableCollection <DriveInfoModel>();

            var drives = await _hcdzClient.GetDrives();

            if (drives == null)
            {
                return;
            }
            //drives = drives.Take(2).ToArray();
            foreach (var item in drives)
            {
                var drive = new DriveInfoModel()
                {
                    AvailableFreeSpace     = item.AvailableFreeSpace,
                    AvailableFreeSpaceText = ByteFormatter.ToString(item.AvailableFreeSpace) + " 可用",
                    DriveFormat            = item.DriveFormat,
                    DriveType          = item.DriveType,
                    IsReady            = item.IsReady,
                    Name               = item.Name,
                    RootDirectory      = item.RootDirectory,
                    TotalFreeSpace     = item.TotalFreeSpace,
                    TotalFreeSpaceText = ByteFormatter.ToString(item.TotalFreeSpace),
                    TotalSize          = item.TotalSize,
                    TotalSizeText      = "共" + ByteFormatter.ToString(item.TotalSize),
                    VolumeLabel        = string.IsNullOrEmpty(item.VolumeLabel) ? "本地磁盘 " : item.VolumeLabel,
                    Percent            = 100.0 - (int)(item.AvailableFreeSpace * 100.0 / item.TotalSize),
                    DriveLetter        = item.Name.Replace("\\", "")
                };
                drive.NameDesc = drive.VolumeLabel + string.Format("({0}:)", item.ToString().Replace(":", "").Replace("\\", ""));
                models.Add(drive);
            }
            DriveInfoItems = models;
            var items = await List();

            if (items != null)
            {
                DirectoryItems = new ObservableCollection <DirectoryInfoModel>(items);
            }
            SelectedPath = DriveInfoItems.FirstOrDefault()?.Name;
            EnableValue  = DriveInfoItems.FirstOrDefault()?.AvailableFreeSpaceText;
            if (!string.IsNullOrEmpty(SelectedPath))
            {
                OnLoadSelectDir(SelectedPath.Substring(0, 3));
            }

            IsBusy = false;
        }
예제 #3
0
        private async void LoadData()
        {
            DriveInfo[] drives = await _hcdzClient.GetDrives();

            if (drives == null)
            {
                return;
            }
            DriveInfoItems = new ObservableCollection <DriveInfo>(drives);
            _selectedDsik  = DriveInfoItems.FirstOrDefault()?.Name;
            if (!string.IsNullOrEmpty(_selectedDsik))
            {
                OnLoadSelectDir(_selectedDsik);
            }
        }