//
        public void stick_click()
        {
            if (CategoryManage.IsCut)
            {
                //删除
                CategoryManage.delete(CategoryManage.Create, CategoryManage.cut_file.Path);

                CategoryManage.cut_file.Path = CategoryManage.CurrentFile.Path + "/" + CategoryManage.cut_file.Name;
                CategoryManage.cut_file.Date = DateTime.Now.ToString();
                CategoryManage.listFiles.Add(CategoryManage.cut_file);
                CategoryManage.IsCut = false;
                CategoryManage.Update();
            }
            else if (CategoryManage.IsCopy)
            {
                //复制
                if (CategoryManage.copy_file != null)
                {
                    string str   = DiskManage.getStrContent(CategoryManage.copy_file.Disk_start, CategoryManage.copy_file.Size);
                    int    size  = 0;
                    int    start = DiskManage.saveContent(str, ref size);
                    CategoryManage.copy_file.Disk_start = start;
                    CategoryManage.copy_file.Size       = size;
                    CategoryManage.copy_file.Date       = DateTime.Now.ToString();

                    CategoryManage.listFiles.Add(CategoryManage.copy_file);
                    CategoryManage.Update();
                }
            }

            this.DialogResult = true;
        }
Exemplo n.º 2
0
        //粘贴
        private void Click_Stick(object sender, RoutedEventArgs e)
        {
            //剪切
            if (CategoryManage.IsCut)
            {
                //删除
                CategoryManage.delete(CategoryManage.Create, CategoryManage.cut_file.Path);
                CategoryManage.cut_file.Path = CategoryManage.CurrentFile.Path + "/" + CategoryManage.cut_file.Name;
                CategoryManage.cut_file.Date = DateTime.Now.ToString();
                CategoryManage.listFiles.Add(CategoryManage.cut_file);
                CategoryManage.IsCut = false;
                CategoryManage.Update();
            }
            //复制
            else if (CategoryManage.IsCopy)
            {
                if (CategoryManage.copy_file != null)
                {
                    string str   = DiskManage.getStrContent(CategoryManage.copy_file.Disk_start, CategoryManage.copy_file.Size);
                    int    size  = 0;
                    int    start = DiskManage.saveContent(str, ref size);
                    CategoryManage.copy_file.Disk_start = start;
                    CategoryManage.copy_file.Size       = size;

                    CategoryManage.copy_file.Path = CategoryManage.CurrentFile.Path + "/" + CategoryManage.copy_file.Name;
                    CategoryManage.copy_file.Date = DateTime.Now.ToString();

                    CategoryManage.listFiles.Add(CategoryManage.copy_file);
                    CategoryManage.Update();
                }
            }
        }
Exemplo n.º 3
0
 //更新目录
 public static void Update()
 {
     DiskManage.save();
     CategoryManage.save();
     CategoryManage.readDisk();
     CategoryManage.updateSize();
     //createTreeView(treeFiles[0], Create);
 }
Exemplo n.º 4
0
 //初始化内存,恢复数据
 public void init()
 {
     CategoryManage.init();
     DiskManage.init();
     listBox.ItemsSource  = CategoryManage.listFiles;
     treeView.ItemsSource = CategoryManage.root;
     //treeView.ItemsSource = CategoryManage.treeFiles;
 }
Exemplo n.º 5
0
        public void save_MenuItem_Click(object sender, RoutedEventArgs e)
        {
            int size = 0;

            DiskManage.deleteFile(CategoryManage.selectedFile.Disk_start);  //删除原本磁盘
            int start = DiskManage.saveContent(text_content.Text, ref size);

            CategoryManage.selectedFile.Disk_start       = start;
            CategoryManage.selectedFile.Size             = size;
            CategoryManage.selectedFile.Occupation_space = (int)Math.Ceiling(Convert.ToDouble(size / 512.0)) * 512;
            CategoryManage.selectedFile.Date             = DateTime.Now.ToString();
            CategoryManage.Update();
        }
Exemplo n.º 6
0
 void sure_click(object sender, RoutedEventArgs e)
 {
     CategoryManage.Create.SubFiles         = new ObservableCollection <File>();
     CategoryManage.Create.Date             = DateTime.Now.ToString();
     CategoryManage.Create.Name             = "CxtDisk";
     CategoryManage.Create.Path             = "CxtDisk";
     CategoryManage.Create.Size             = 0;
     CategoryManage.Create.Occupation_space = 0;
     CategoryManage.listFiles   = CategoryManage.Create.SubFiles;
     CategoryManage.CurrentFile = CategoryManage.Create;
     DiskManage.clearDisk();
     CategoryManage.Update();
 }
Exemplo n.º 7
0
 //删除
 public static void delete(File file, string path)
 {
     if (file != null && file.SubFiles != null)
     {
         for (int index = 0; index < file.SubFiles.Count(); index++)
         {
             if (file.SubFiles[index].Path.Equals(path))
             {
                 DiskManage.deleteFile(file.SubFiles[index].Disk_start);
                 file.SubFiles.Remove(file.SubFiles[index]);
             }
             else
             {
                 delete(file.SubFiles[index], path);
             }
         }
     }
 }
Exemplo n.º 8
0
 public EditWindow()
 {
     InitializeComponent();
     text_content.Text = DiskManage.getStrContent(CategoryManage.selectedFile.Disk_start, CategoryManage.selectedFile.Size);
 }
Exemplo n.º 9
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();
        }