Пример #1
0
        private void Init()
        {
            root = new TreeItem("root", null);
            var systemDrives = DriveInfo.GetDrives();

            foreach (var sd in systemDrives)
            {
                var item = new DriveTreeItem(sd.Name, sd.DriveType, root);
                item.Childs.Add(new TreeItem(EmptyItemName, item));

                root.Childs.Add(item);
            }

            Root = root; // to notify UI
        }
Пример #2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var treeItem = value as TreeItem;

            if (treeItem == null)
            {
                throw new ArgumentException("Illegal item type");
            }

            if (treeItem is DriveTreeItem)
            {
                DriveTreeItem driveItem = treeItem as DriveTreeItem;
                switch (driveItem.DriveType)
                {
                case DriveType.CDRom:
                    return(cdrom);

                case DriveType.Fixed:
                    return(drive);

                case DriveType.Network:
                    return(netDrive);

                case DriveType.NoRootDirectory:
                    return(drive);

                case DriveType.Ram:
                    return(ram);

                case DriveType.Removable:
                    return(removable);

                case DriveType.Unknown:
                    return(drive);
                }
            }
            else
            {
                return(folder);
            }

            return(null);
        }