示例#1
0
        static public bool OpenPropEditorForm(FCYResPackageDataNode tNode)
        {
            PropEditor tForm = new PropEditor(tNode.IsCompressed, tNode.AdditionData, tNode.Name);

            if (tForm.ShowDialog() == DialogResult.Cancel)
            {
                tForm.Dispose();
                return(false);
            }
            else
            {
                tNode.IsCompressed = tForm.checkBox1.Checked;
                tNode.AdditionData = tForm.textBox1.Text;
                try
                {
                    if (tNode.Name != tForm.textBox2.Text)
                    {
                        tNode.Name = tForm.textBox2.Text;
                    }
                }
                catch (FCYExcpNameErr)
                {
                    MessageBox.Show("修改节点名称失败。可能存在同名节点或者节点名称不合法。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                tForm.Dispose();
                return(true);
            }
        }
示例#2
0
        // --- 导出文件夹 ---
        /// <summary>
        /// 将节点数据解包到文件夹
        /// </summary>
        /// <param name="Dir">目的文件夹</param>
        /// <param name="Node">节点</param>
        private void exportFloder(DirectoryInfo Dir, TreeNode Node)
        {
            FCYResPackageNode tNode = (FCYResPackageNode)Node.Tag;

            // 文件夹节点
            if (tNode.IsFloder())
            {
                // 创建文件夹
                DirectoryInfo tOut = Directory.CreateDirectory(Dir.FullName + "\\" + tNode.Name);
                // 遍历
                foreach (TreeNode x in Node.Nodes)
                {
                    exportFloder(tOut, x);
                }
            }
            else // 文件节点
            {
                // 准备文件
                FileStream tOutput = new FileStream(Dir.FullName + "\\" + tNode.Name, FileMode.Create, FileAccess.ReadWrite, FileShare.Read);

                FCYResPackageDataNode tDataNode = (FCYResPackageDataNode)tNode;

                // 直接写出
                tDataNode.ExtractStreamTo(tOutput);

                // 关闭
                tOutput.Close();
            }
        }
示例#3
0
        // --- 导出流 ---
        private void toolStripButton_Export_Click(object sender, EventArgs e)
        {
            if (tabControl_Data.Tag != null)
            {
                FCYResPackageNode tTempNode = ((FCYResPackageNode)((TreeNode)tabControl_Data.Tag).Tag);
                if (tTempNode.IsFloder())
                {
                    return;
                }

                FCYResPackageDataNode tData = (FCYResPackageDataNode)tTempNode;

                if (tData.DataRealSize == 0)
                {
                    showErr("节点无数据。");
                    return;
                }
                saveFileDialog2.FileName = tData.Name;
                if (saveFileDialog2.ShowDialog() != DialogResult.Cancel)
                {
                    FileStream tOut = new FileStream(saveFileDialog2.FileName, FileMode.Create);

                    tData.ExtractStreamTo(tOut);
                }
            }
        }
示例#4
0
        // --- 导入流 ---
        private void toolStripButton_Import_Click(object sender, EventArgs e)
        {
            if (tabControl_Data.Tag != null)
            {
                FCYResPackageNode tTempNode = ((FCYResPackageNode)((TreeNode)tabControl_Data.Tag).Tag);
                if (tTempNode.IsFloder())
                {
                    return;
                }

                FCYResPackageDataNode tData = (FCYResPackageDataNode)tTempNode;

                openFileDialog2.FileName = tData.Name;
                if (openFileDialog2.ShowDialog() != DialogResult.Cancel)
                {
                    FileStream tOut = new FileStream(openFileDialog2.FileName, FileMode.Open, FileAccess.Read, FileShare.Read);

                    tData.ReplaceStream(tOut);
                }
            }
        }
示例#5
0
        // --- 选择流 ---
        private void updateDetail(TreeNode pNode)
        {
            tabControl_Data.Tag = pNode;

            if (pNode != null)
            {
                toolStripTextBox_Path.Text = pNode.FullPath;
            }
            else
            {
                toolStripTextBox_Path.Text = "";
            }

            textBox1.Text     = "";
            textBox2.Text     = "";
            textBox3.Text     = "";
            textBox4.Text     = "";
            checkBox1.Checked = false;

            if (pNode != null)
            {
                if (((FCYResPackageNode)pNode.Tag).IsFloder())
                {
                    FCYResPackageFloderNode tFolderNode = (FCYResPackageFloderNode)pNode.Tag;

                    textBox1.Text = tFolderNode.Name;
                }
                else
                {
                    FCYResPackageDataNode tDataNode = (FCYResPackageDataNode)pNode.Tag;

                    textBox1.Text     = tDataNode.Name;
                    textBox2.Text     = tDataNode.DataRealSize.ToString();
                    textBox3.Text     = tDataNode.DataCompressedSize.ToString();
                    textBox4.Text     = tDataNode.AdditionData;
                    checkBox1.Checked = tDataNode.IsCompressed;
                }
            }
        }
示例#6
0
        // --- 创建流 ---
        private void ToolStripMenuItem_CreateStream_Click(object sender, EventArgs e)
        {
            // 获得父节点
            TreeNode tParent = treeView_Main.SelectedNode;

            if (tParent != null)
            {
                // 检查父节点
                if (!((FCYResPackageNode)tParent.Tag).IsFloder())
                {
                    showErr("请选择一个文件夹节点。");
                    return;
                }

                // 获得父节点
                FCYResPackageFloderNode tParentFloder = (FCYResPackageFloderNode)tParent.Tag;

                // 获得新节点名称
                string tNodeName = "";
                string tFileName = "";
                string tAddition = "";
                bool   tCompress = false;

                if (!CreateStreamForm.OpenCreateStreamForm(treeView_Main.SelectedNode.FullPath, ref tNodeName, ref tFileName, ref tAddition, ref tCompress))
                {
                    return;
                }

                if (tNodeName == "")
                {
                    showErr("无效的名称。");
                    return;
                }

                // 创建节点
                FCYResPackageDataNode tNewSubNode = new FCYResPackageDataNode((FCYResPackage)treeView_Main.Tag, tParentFloder, tNodeName, tFileName);

                // 尝试加入
                try
                {
                    tParentFloder.Add(tNewSubNode);
                }
                catch
                {
                    showErr("节点名已存在或者无效。");
                    return;
                }

                // 设置属性
                tNewSubNode.IsCompressed = tCompress;
                tNewSubNode.AdditionData = tAddition;

                // 创建树节点
                TreeNode tTreeNode = new TreeNode(tNodeName, 1, 1);
                tTreeNode.Tag = tNewSubNode;

                // 加入
                tParent.Nodes.Add(tTreeNode);
                tParent.Expand();
            }
        }