Exemplo n.º 1
0
        private void OpenMetaFile(TreeNode metaFileNode)
        {
            if (metaFileNode.Text == "<пусто>")
            {
                return;
            }

            string metaFilePath = GetNodePath(metaFileNode);

            try
            {
                if (metaFileNode.GetNodeCount(true) > 0)
                {
                    Directory          directory = _dehaxOS.OpenDirectory(metaFilePath);
                    TreeNodeCollection nodes     = metaFileNode.Nodes;
                    nodes.Clear();

                    for (int i = 2; i < directory.Count; i++)
                    {
                        MetaFile metaFile = directory[i];

                        TreeNode node = new TreeNode(metaFile.FullName);
                        node.Name = metaFile.FullName;
                        if (metaFile is Directory)
                        {
                            node.Nodes.Add("<пусто>");
                        }
                        nodes.Add(node);
                    }

                    if (nodes.Count == 0)
                    {
                        nodes.Add("<пусто>");
                    }
                }
                else
                {
                    byte[] data    = _dehaxOS.ReadFile(metaFilePath);
                    string content = Encoding.ASCII.GetString(data);

                    TextFileEditorForm editorForm = new TextFileEditorForm();
                    editorForm.FileContent = content;

                    if (editorForm.ShowDialog(this) == DialogResult.OK)
                    {
                        content = editorForm.FileContent;
                        data    = Encoding.ASCII.GetBytes(content);

                        _dehaxOS.WriteFile(metaFilePath, data);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Exemplo n.º 2
0
        private void OpenMetaFile(TreeNode metaFileNode)
        {
            if (metaFileNode.Text == "<пусто>")
            {
                return;
            }

            string metaFilePath = GetNodePath(metaFileNode);

            try
            {
                if (metaFileNode.GetNodeCount(true) > 0)
                {
                    Directory directory = _dehaxOS.OpenDirectory(metaFilePath);
                    TreeNodeCollection nodes = metaFileNode.Nodes;
                    nodes.Clear();

                    for (int i = 2; i < directory.Count; i++)
                    {
                        MetaFile metaFile = directory[i];

                        TreeNode node = new TreeNode(metaFile.FullName);
                        node.Name = metaFile.FullName;
                        if (metaFile is Directory)
                        {
                            node.Nodes.Add("<пусто>");
                        }
                        nodes.Add(node);
                    }

                    if (nodes.Count == 0)
                    {
                        nodes.Add("<пусто>");
                    }
                }
                else
                {
                    byte[] data = _dehaxOS.ReadFile(metaFilePath);
                    string content = Encoding.ASCII.GetString(data);

                    TextFileEditorForm editorForm = new TextFileEditorForm();
                    editorForm.FileContent = content;

                    if (editorForm.ShowDialog(this) == DialogResult.OK)
                    {
                        content = editorForm.FileContent;
                        data = Encoding.ASCII.GetBytes(content);

                        _dehaxOS.WriteFile(metaFilePath, data);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }