1 using System;
 2 using System.Collections;
 3 using System.Windows;
 4 
 5 namespace FileExplorer
 6 {
 7     public class ComputerNode : Node
 8     {
 9         public nothrow ComputerNode() : base("Computer")
10         {
11         }
12         public nothrow void AddDrive(DriveNode* drive)
13         {
14             drive->SetParent(this);
15             drives.Add(UniquePtr<DriveNode>(drive));
16         }
17         public inline nothrow const List<UniquePtr<DriveNode>>& Drives() const
18         {
19             return drives;
20         }
21         public override nothrow MainWindow* GetMainWindow() const
22         {
23             return mainWindow;
24         }
25         public nothrow void SetMainWindow(MainWindow* mainWindow_)
26         {
27             mainWindow = mainWindow_;
28         }
29         public override nothrow string ImageName() const
30         {
31             return "computer.bitmap";
32         }
33         public override nothrow TreeViewNode* ToTreeViewNode(bool createChildrenImageList* imageList)
34         {
35             UniquePtr<TreeViewNode> rootPtr(new TreeViewNode(Name()));
36             TreeViewNode* root = rootPtr.Get();
37             root->SetImageIndex(imageList->GetImageIndex(ImageName()));
38             SetTreeViewNode(root);
39             if (createChildren)
40             {
41                 for (const UniquePtr<DriveNode>& drive : drives)
42                 {
43                     UniquePtr<TreeViewNode> childPtr(drive->ToTreeViewNode(falseimageList));
44                     TreeViewNode* child = childPtr.Get();
45                     if (imageList != null)
46                     {
47                         int imageIndex = imageList->GetImageIndex(drive->ImageName());
48                         if (imageIndex != -1)
49                         {
50                             child->SetImageIndex(imageIndex);
51                         }
52                     }
53                     root->AddChild(childPtr.Release());
54                 }
55             }
56             return rootPtr.Release();
57         }
58         public override Control* CreateView(ImageList* imageList)
59         {
60             ListView* listView = new ListView(ListViewCreateParams(ListViewControlCreateParams(ControlCreateParams().Defaults())).Defaults());
61             listView->SetData(this);
62             MainWindow* mainWindow = GetMainWindow();
63             if (mainWindow != null)
64             {
65                 mainWindow->AddListViewEventHandlers(listView);
66             }
67             listView->SetDoubleBuffered();
68             listView->SetImageList(imageList);
69             listView->AddColumn("Drive"200);
70             for (const UniquePtr<DriveNode>& drive : drives)
71             {
72                 ListViewItem* driveItem = listView->AddItem();
73                 drive->SetData(driveItemimageList);
74             }
75             return listView;
76         }
77         private List<UniquePtr<DriveNode>> drives;
78         private MainWindow* mainWindow;
79     }
80 }
81