コード例 #1
0
 //初始化内存,恢复数据
 public void init()
 {
     CategoryManage.init();
     DiskManage.init();
     listBox.ItemsSource  = CategoryManage.listFiles;
     treeView.ItemsSource = CategoryManage.root;
     //treeView.ItemsSource = CategoryManage.treeFiles;
 }
コード例 #2
0
        //初始化数据
        public void initData()
        {
            string[] filenames = { "DB", "Android", "Unity", "VS", "Python", "Ruby", "Scrapy", "Bootstrap" };
            CategoryManage.root = new ObservableCollection <File>();

            //新建一个目录
            File file0 = new File();

            file0.Name       = "CxtDisk";
            file0.Path       = "CxtDisk";
            file0.Date       = DateTime.Now.ToString();
            file0.Size       = 0;
            file0.Disk_start = -1;
            file0.Type       = "Folder";

            //第一层
            for (int i = 0; i < filenames.Length; i++)
            {
                File mfile = new File();
                mfile.Name       = filenames[i];
                mfile.Path       = "CxtDisk/" + filenames[i];
                mfile.Date       = DateTime.Now.ToString();
                mfile.Size       = 0;
                mfile.Disk_start = -1;
                mfile.Type       = "Folder";
                file0.SubFiles.Add(mfile);

                File file = new File();
                file.Name       = "Homework";
                file.Path       = mfile.Path + "/Homework";
                file.Date       = DateTime.Now.ToString();
                file.Size       = 0;
                file.Disk_start = -1;
                file.Type       = "Folder";
                mfile.SubFiles.Add(file);

                File file3 = new File();
                file3.Name       = "file" + i;
                file3.Path       = file.Path + "/file" + i;
                file3.Date       = DateTime.Now.ToString();
                file3.Size       = 0;
                file3.Disk_start = -1;
                file3.Type       = "File";
                file.SubFiles.Add(file3);
            }


            CategoryManage.root.Add(file0);


            if (CategoryManage.root != null)
            {
                CategoryManage.listFiles = CategoryManage.root[0].SubFiles;
            }
            else
            {
                CategoryManage.listFiles = CategoryManage.root;
            }
            listBox.ItemsSource  = CategoryManage.listFiles;
            treeView.ItemsSource = CategoryManage.root;


            CategoryManage.init();
            DiskManage.init();
            //DiskManage.save();
            //CategoryManage.save();
            CategoryManage.Update();
        }