示例#1
0
        private void AddNode(TenshiEntry i)
        {
            string[]           Path = i.EntryPath;
            int                index;
            TreeNodeCollection root    = FileTree.Nodes;
            TreeNodeCollection working = root;

            for (index = 0; index < Path.Length; index++)
            {
                string node = Path[index];
                if (!working.ContainsKey(node))
                {
                    break;
                }
                working = working[node].Nodes;
            }
            TreeNode last = null;

            for (; index < Path.Length; index++)
            {
                working.Add(new TreeNode(Path[index])
                {
                    Name = Path[index], Tag = null
                });
                last    = working[Path[index]];
                working = working[Path[index]].Nodes;
            }
            if (last != null)
            {
                last.Tag = i;
            }
        }
示例#2
0
        private void MenuAdd_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter          = "cvn 파일(*.cv*)|*.cv*|모든 파일(*.*)|*.*";
            ofd.FilterIndex     = 1;
            ofd.CheckFileExists = ofd.CheckPathExists = true;
            ofd.Multiselect     = true;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                foreach (string file_name in ofd.FileNames)
                {
                    frmEntryName dlgName = new frmEntryName();
                    dlgName.Top   = this.Top + 50;
                    dlgName.Left  = this.Left + 50;
                    dlgName.Entry = file_name;
                    dlgName.ShowDialog();
                    if (dlgName.Entry == string.Empty)
                    {
                        return;
                    }
                    TenshiEntry i = new TenshiEntry(null, dlgName.Entry, 0, 0);
                    i.ChangedStream = File.OpenRead(file_name);
                    m_workingfile.Entries.Add(i);
                    AddNode(i);
                }
            }
        }
示例#3
0
        void ContextMenu_DeleteClick(object sender, EventArgs e)
        {
            TenshiEntry entry = ((sender as MenuItem).Tag as TreeNode).Tag as TenshiEntry;

            m_workingfile.Entries.Remove(entry);
            ((sender as MenuItem).Tag as TreeNode).Remove();
        }
示例#4
0
        private void EditStart(TreeNode entry)
        {
            TenshiEntry palette = null;
            TreeNode    parent  = entry.Parent;

            if (parent != null)
            {
                TreeNodeCollection same_dir = parent.Nodes;
                foreach (TreeNode i in same_dir)
                {
                    if (i.Tag == null)
                    {
                        continue;
                    }
                    string[] entry_path = (i.Tag as TenshiEntry).EntryPath;
                    if (entry_path[entry_path.Length - 1] == "palette000.pal")
                    {
                        palette = i.Tag as TenshiEntry;
                        break;
                    }
                }
            }
            frmCvnEditor editor = new frmCvnEditor(entry.Tag as TenshiEntry, palette);

            if (editor.Failed)
            {
                return;
            }
            editor.FormClosed += new FormClosedEventHandler(EditFinished);
            editor.Show();
        }
示例#5
0
 public frmCvnEditor()
 {
     m_entry           = m_palette = null;
     m_workingfile     = null;
     m_workingpath     = string.Empty;
     m_discard_changes = true;
     m_is_from_stream  = false;
     m_changed         = false;
     m_failed          = false;
     InitializeComponent();
 }
示例#6
0
        void ContextMenu_ReplaceClick(object sender, EventArgs e)
        {
            OpenFileDialog ofd       = new OpenFileDialog();
            TenshiEntry    entry     = ((sender as MenuItem).Tag as TreeNode).Tag as TenshiEntry;
            string         entry_str = entry.Entry;
            string         ext       = entry_str.Substring(entry_str.IndexOf('.') + 1);

            ofd.Filter          = ext + "(*." + ext + ")|*." + ext;
            ofd.FilterIndex     = 1;
            ofd.CheckFileExists = ofd.CheckPathExists = true;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                entry.ChangedStream = ofd.OpenFile();
            }
        }
示例#7
0
        void ContextMenu_ExtractClick(object sender, EventArgs e)
        {
            SaveFileDialog sfd       = new SaveFileDialog();
            TenshiEntry    entry     = ((sender as MenuItem).Tag as TreeNode).Tag as TenshiEntry;
            string         entry_str = entry.Entry;
            string         ext       = Path.GetExtension(entry_str);

            sfd.Filter          = ext + "(*" + ext + ")|*" + ext + "|모든 파일(*.*)|*.*";
            sfd.FileName        = Path.GetFileName(entry_str);
            sfd.OverwritePrompt = true;
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                byte[] buf = new byte[entry.Length];
                entry.Read(buf, 0, (int)entry.Length);
                File.WriteAllBytes(sfd.FileName, buf);
            }
        }
示例#8
0
 public frmCvnEditor(TenshiEntry BaseFile, TenshiEntry Palette = null)
     : this()
 {
     m_entry       = BaseFile;
     m_palette     = Palette;
     m_workingpath = m_entry.Entry;
     try
     {
         m_workingfile = cvn.Open(BaseFile, BaseFile.Type, Palette);
     }
     catch (FormatException)
     {
         m_failed = true;
         return;
     }
     if (m_workingfile == null)
     {
         m_failed = true;
         return;
     }
     m_is_from_stream = true;
     RefreshView();
     m_changed = false;
 }