コード例 #1
0
        //
        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;
        }
コード例 #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();
                }
            }
        }
コード例 #3
0
 //更新目录
 public static void Update()
 {
     DiskManage.save();
     CategoryManage.save();
     CategoryManage.readDisk();
     CategoryManage.updateSize();
     //createTreeView(treeFiles[0], Create);
 }
コード例 #4
0
 //删除文件
 private void Click_Delete(object sender, RoutedEventArgs e)
 {
     if (listBox.SelectedItem != null)
     {
         CategoryManage.listFiles.Remove((File)listBox.SelectedItem);
         CategoryManage.Update();
     }
 }
コード例 #5
0
 //初始化内存,恢复数据
 public void init()
 {
     CategoryManage.init();
     DiskManage.init();
     listBox.ItemsSource  = CategoryManage.listFiles;
     treeView.ItemsSource = CategoryManage.root;
     //treeView.ItemsSource = CategoryManage.treeFiles;
 }
コード例 #6
0
        //
        public void delete_click()
        {
            CategoryManage.listFiles.Remove(CategoryManage.selectedFile);


            CategoryManage.Update();

            this.DialogResult = true;
        }
コード例 #7
0
        //
        public async void rename_click()
        {
            if (CategoryManage.CurrentFile != null)
            {
                RenameControl a = new RenameControl();
                await DialogHost.Show(a);

                this.DialogResult = true;
                CategoryManage.Update();
            }
        }
コード例 #8
0
        //上一层目录
        private void Click_Up(object sender, RoutedEventArgs e)
        {
            File file = CategoryManage.FindParent(CategoryManage.Create, CategoryManage.CurrentFile.Path);

            if (file != null)
            {
                CategoryManage.CurrentFile = file;
                CategoryManage.listFiles   = file.SubFiles;
                listBox.ItemsSource        = CategoryManage.listFiles;
            }
        }
コード例 #9
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();
        }
コード例 #10
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();
 }
コード例 #11
0
        //新建文件夹
        private void Click_NewFolder(object sender, RoutedEventArgs e)
        {
            File   file = new File();
            string name = "未命名_" + CategoryManage.findCategory();

            file.Name       = name;
            file.Disk_start = -1;
            file.Path       = CategoryManage.CurrentFile.Path + "/" + name;
            file.Date       = DateTime.Now.ToString();
            file.Size       = 0;
            file.Type       = "Folder";
            CategoryManage.listFiles.Add(file);
            CategoryManage.Update();
        }
コード例 #12
0
        //
        public void new_file_click()
        {
            if (CategoryManage.CurrentFile.Type.Equals("Folder"))
            {
                File   file = new File();
                string name = "未命名_" + CategoryManage.findCategory();
                file.Name = name;

                file.Path       = CategoryManage.CurrentFile.Path + "/" + name;
                file.Date       = DateTime.Now.ToString();
                file.Disk_start = -1;
                file.Size       = 0;
                file.Type       = "File";
                CategoryManage.listFiles.Add(file);
                CategoryManage.Update();
            }
            this.DialogResult = true;
        }
コード例 #13
0
 //剪切
 private void Click_Cut(object sender, RoutedEventArgs e)
 {
     if (CategoryManage.CurrentFile != null)
     {
         File file = new File();
         file.Name               = CategoryManage.CurrentFile.Name;
         file.Path               = CategoryManage.CurrentFile.Path;
         file.Date               = CategoryManage.CurrentFile.Date;
         file.Size               = CategoryManage.CurrentFile.Size;
         file.Disk_start         = CategoryManage.CurrentFile.Disk_start;
         file.Occupation_space   = CategoryManage.CurrentFile.Occupation_space;
         file.Type               = CategoryManage.CurrentFile.Type;
         file.SubFiles           = CategoryManage.CurrentFile.SubFiles;
         CategoryManage.cut_file = file;
         CategoryManage.IsCut    = true;
         CategoryManage.Update();
     }
 }
コード例 #14
0
 //
 public void cut_click()
 {
     if (CategoryManage.selectedFile != null)
     {
         File file = new File();
         file.Name                = CategoryManage.selectedFile.Name;
         file.Path                = CategoryManage.selectedFile.Path;
         file.Date                = CategoryManage.selectedFile.Date;
         file.Size                = CategoryManage.selectedFile.Size;
         file.Disk_start          = CategoryManage.selectedFile.Disk_start;
         file.Occupation_space    = CategoryManage.selectedFile.Occupation_space;
         file.Type                = CategoryManage.selectedFile.Type;
         file.SubFiles            = CategoryManage.selectedFile.SubFiles;
         CategoryManage.copy_file = file;
         CategoryManage.IsCut     = true;
         CategoryManage.Update();
     }
     this.DialogResult = true;
 }
コード例 #15
0
 void save_click(object sender, RoutedEventArgs e)
 {
     if (!rename_textbox.Text.Equals(""))
     {
         if (rename_textbox.Text.Length > 19)
         {
             MessageBox.Show("文件名过长!");
         }
         else if (!CategoryManage.IsSameName(CategoryManage.selectedFile, rename_textbox.Text))
         {
             CategoryManage.selectedFile.Name = rename_textbox.Text;
             CategoryManage.selectedFile.Path = CategoryManage.selectedFile.Path.Substring(0, CategoryManage.selectedFile.Path.LastIndexOf('/') + 1) +
                                                rename_textbox.Text;
             CategoryManage.selectedFile.Date = DateTime.Now.ToString();
             CategoryManage.Update();
         }
         else
         {
             MessageBox.Show("文件名已存在!");
         }
     }
 }
コード例 #16
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();
        }