1 using System;
 2 using System.Collections;
 3 using System.Windows;
 4 
 5 namespace FileExplorer
 6 {
 7     public class DriveNode : Node
 8     {
 9         public nothrow DriveNode(const string& name_) : base(name_)
10         {
11         }
12         public nothrow void SetRootDirectory(DirectoryNode* rootDirectory_)
13         {
14             rootDirectory.Reset(rootDirectory_);
15             rootDirectory->SetParent(this);
16             rootDirectory->SetRootDirectory();
17         }
18         public inline nothrow DirectoryNode* RootDirectory() const
19         {
20             return rootDirectory.Get();
21         }
22         public override nothrow string ImageName() const
23         {
24             return "hard_drive.bitmap";
25         }
26         public override nothrow TreeViewNode* ToTreeViewNode(bool createChildrenImageList* imageList)
27         {
28             UniquePtr<TreeViewNode> treeViewNodePtr(new TreeViewNode(Name()));
29             TreeViewNode* treeViewNode = treeViewNodePtr.Get();
30             SetTreeViewNode(treeViewNode);
31             if (imageList != null)
32             {
33                 int imageIndex = imageList->GetImageIndex(ImageName());
34                 if (imageIndex != -1)
35                 {
36                     treeViewNode->SetImageIndex(imageIndex);
37                 }
38             }
39             return treeViewNodePtr.Release();
40         }
41         public override Control* CreateView(ImageList* imageList)
42         {
43             if (!rootDirectory.IsNull())
44             {
45                 return rootDirectory->CreateView(imageList);
46             }
47             else
48             {
49                 return null;
50             }
51         }
52         private UniquePtr<DirectoryNode> rootDirectory;
53     }
54 }
55