Esempio n. 1
0
        private void label190_DoubleClick(object sender, EventArgs e)
        {
            Label  label = (Label)sender;
            string str   = toolTip1.GetToolTip(label);

            int startIndex = str.IndexOf('r');
            int endIndex   = str.IndexOf('|');

            if (startIndex == -1 || endIndex == -1)
            {
                return;
            }
            else
            {
                BasicFile        file = FileFunction.GetInstance().searchFile(str.Substring(startIndex, endIndex - startIndex), parentform.root);
                List <BasicFile> list = new List <BasicFile>();
                if (file.Attr == 2)
                {
                    MessageBox.Show(parentform.disk_Content[Convert.ToInt32(label.Text)], "磁盘块内容", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //Dictionary<string, BasicFile> dic = new Dictionary<string, BasicFile>();
                    //dic.Add(file.Name, file);
                    //File_information of = new File_information(dic);
                    //SetParent((int)of.Handle, (int)this.parentform.Handle);
                    //of.Show();
                }
                else
                {
                    File_information of = new File_information(file.ChildFile, parentform.fat);
                    SetParent((int)of.Handle, (int)this.parentform.Handle);
                    of.Show();
                }
            }
            //MessageBox.Show();
        }
Esempio n. 2
0
        //点击新建文件
        private void 文件ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (father.ChildFile.Count >= father.Size * 8)
            {
                FileFun.reAddFat(father, 1, parent.fat);//追加目录磁盘块
            }
            BasicFile file = FileFunction.GetInstance().createFile(father, parent.Fat);

            if (file != null)
            {
                fileView.Items.Add(file.Item);
                fileView_Activated(this, e);
            }
            else
            {
                MessageBox.Show("创建文件失败", "磁盘空间不足!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Esempio n. 3
0
        //递归复制
        private void copyCatolog(BasicFile copy_file, BasicFile file_father)
        {
            if (copy_file.Attr == 2)
            {
                //分配空间
                if (file_father.ChildFile.Count >= file_father.Size * 8)
                {
                    FileFun.reAddFat(file_father, 1, parent.fat);//追加目录磁盘块
                }
                BasicFile file = FileFunction.GetInstance().createFile_(file_father, parent.Fat, copy_file.Name, copy_file.Type, copy_file.Size, copy_file.Suffix, copy_file.Content);
                //创建成功
                if (file != null)
                {
                    FileFun.setDiskContent(parent.disk_Content, file, parent.fat);
                }
                else
                {
                    MessageBox.Show("复制文件失败", "磁盘空间不足!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            //文件夹
            else if (copy_file.Attr == 3)
            {
                if (file_father.ChildFile.Count >= file_father.Size * 8)
                {
                    FileFun.reAddFat(file_father, 1, parent.fat);//追加目录磁盘块
                }
                //创建1层文件夹
                BasicFile file = FileFun.createCatolog_(file_father, parent.fat, file_father, copy_file.Name);

                if (file != null)
                {
                    foreach (var a in copy_file.ChildFile)
                    {
                        //递归创建文件
                        copyCatolog(a.Value, file);
                    }
                }
            }
        }
Esempio n. 4
0
        private void 粘贴VToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //确保父目录在第一个被复制
            for (int i = 0; i < copyFile_list.Count(); i++)
            {
                if (copyFile_list[i] == father)
                {
                    BasicFile temp = copyFile_list[0];
                    copyFile_list[0] = copyFile_list[i];
                    copyFile_list[i] = temp;
                    break;
                }
            }

            for (int i = 0; i < copyFile_list.Count(); i++)
            {
                BasicFile copyFile = copyFile_list[i];

                if (copyFile.Attr == 2)
                {
                    if (father.ChildFile.Count >= father.Size * 8)
                    {
                        FileFun.reAddFat(father, 1, parent.fat);//追加目录磁盘块
                    }
                    BasicFile file = FileFunction.GetInstance().createFile_(father, parent.Fat, copyFile.Name, copyFile.Type, copyFile.Size, copyFile.Suffix, copyFile.Content);

                    if (file != null)
                    {
                        fileView.Items.Add(file.Item);
                        fileView_Activated(this, e);

                        FileFun.setDiskContent(parent.disk_Content, file, parent.fat);
                    }
                    else
                    {
                        MessageBox.Show("复制文件失败", "磁盘空间不足!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else if (copyFile.Attr == 3)
                {
                    if (parent.fat[0] < countDisk(copyFile))
                    {
                        MessageBox.Show("复制文件失败", "磁盘空间不足!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    //创建第一层
                    if (father.ChildFile.Count >= father.Size * 8)
                    {
                        FileFun.reAddFat(father, 1, parent.fat);//追加目录磁盘块
                    }
                    //第一层文件夹
                    BasicFile file = FileFun.createCatolog_(father, parent.fat, copyFile, copyFile.Name);
                    if (file != null)
                    {
                        fileView.Items.Add(file.Item);

                        foreach (var a in copyFile.ChildFile)
                        {
                            if (a.Value == file)
                            {
                                continue;
                            }
                            //递归创建文件
                            copyCatolog(a.Value, file);
                        }
                    }
                    //树形视图的维护
                    upDateTreeView();
                    fileView_Activated(this, e);
                }
            }
        }