예제 #1
0
        // Opens a new window with the proper content type as outlined by the switch statement
        private void TvContent_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            ContentInfo cinfo = JsonConvert.DeserializeObject <ContentInfo>(e.Node.Tag.ToString());

            switch (cinfo.Type)
            {
            case "note":
                frmNote noteform = new frmNote(cinfo.ID, cinfo.Title, File.ReadAllText(ProjectInfo.ProjectPath + "/" + cinfo.ID + cinfo.Extension));
                noteform.MdiParent = this;
                noteform.Show();
                break;

            case "richtext":
                frmRichText richtextform = new frmRichText(cinfo.ID, cinfo.Title, true);
                richtextform.MdiParent = this;
                richtextform.Show();
                break;

            case "image":
                frmImage imageform = new frmImage(cinfo.ID, cinfo.Title, ProjectInfo.ProjectPath + "/" + cinfo.ID + cinfo.Extension);
                imageform.MdiParent = this;
                imageform.Show();
                break;

            case "character":
                frmPrompt promptform = new frmPrompt(cinfo.ID, cinfo.Title, "character", File.ReadAllText(ProjectInfo.ProjectPath + "/" + cinfo.ID + cinfo.Extension));
                promptform.MdiParent = this;
                promptform.Show();
                break;

            case "location":
                frmPrompt promptform2 = new frmPrompt(cinfo.ID, cinfo.Title, "location", File.ReadAllText(ProjectInfo.ProjectPath + "/" + cinfo.ID + cinfo.Extension));
                promptform2.MdiParent = this;
                promptform2.Show();
                break;

            case "customprompt":
                frmPrompt promptform3 = new frmPrompt(cinfo.ID, cinfo.Title, "customprompt", File.ReadAllText(ProjectInfo.ProjectPath + "/" + cinfo.ID + cinfo.Extension));
                promptform3.MdiParent = this;
                promptform3.Show();
                break;

            default:
                break;
            }
        }
예제 #2
0
        // Add node properly to TreeView. Takes advantage of the "tag" property to help load relevant info into the
        // appropriate feature.
        private void AddContentToTree(string title, ContentInfo info)
        {
            tmrSnapshots.Enabled = true;
            TreeNode node = new TreeNode(title);

            switch (info.Type)
            {
            case "folder":
                node.ImageIndex = 0;
                node.Tag        = JsonConvert.SerializeObject(new ContentInfo(ProjectIO.GenerateUniqueID(), title, "folder", ""));;
                break;

            case "note":
                node.ImageIndex = 1;

                string  nodeid   = ProjectIO.GenerateUniqueID();
                frmNote noteform = new frmNote(nodeid, title, "");
                node.Tag = JsonConvert.SerializeObject(new ContentInfo(nodeid, title, "note", ".txt"));

                noteform.MdiParent = this;
                noteform.Text      = title;
                noteform.Show();
                break;

            case "richtext":
                node.ImageIndex = 2;

                string      nodeidRT     = ProjectIO.GenerateUniqueID();
                frmRichText richtextform = new frmRichText(nodeidRT, title, false);
                node.Tag = JsonConvert.SerializeObject(new ContentInfo(nodeidRT, title, "richtext", ".rtf"));

                richtextform.MdiParent = this;
                richtextform.Text      = title;
                richtextform.Show();

                break;

            case "image":
                node.ImageIndex = 3;

                string   nodeidimg = ProjectIO.GenerateUniqueID();
                FileInfo imageinfo = null;
                using (OpenFileDialog open = new OpenFileDialog())
                {
                    open.Filter = "PNG Images (*.png)|*.png|JPEG Images (*.jpg)|*.jpg|Bitmap Images (*.bmp)|*.bmp|GIF Images (*.gif)|*.gif|All Files (*.*)|*.*";
                    if (open.ShowDialog() == DialogResult.Cancel)
                    {
                        return;
                    }

                    imageinfo = new FileInfo(open.FileName);
                    File.Copy(open.FileName, ProjectInfo.ProjectPath + "/" + nodeidimg + imageinfo.Extension);
                }

                frmImage imageform = new frmImage(nodeidimg, title, ProjectInfo.ProjectPath + "/" + nodeidimg + imageinfo.Extension);
                node.Tag = JsonConvert.SerializeObject(new ContentInfo(nodeidimg, title, "image", imageinfo.Extension));

                imageform.MdiParent = this;
                imageform.Text      = title;
                imageform.Show();

                break;

            case "character":
                node.ImageIndex = 4;

                string    nodeidchar = ProjectIO.GenerateUniqueID();
                frmPrompt promptform = new frmPrompt(nodeidchar, title, "character");
                node.Tag = JsonConvert.SerializeObject(new ContentInfo(nodeidchar, title, "character", ".prompt"));

                promptform.MdiParent = this;
                promptform.Text      = title;
                promptform.Show();

                break;

            case "location":
                node.ImageIndex = 5;

                string    nodeidloc   = ProjectIO.GenerateUniqueID();
                frmPrompt promptform2 = new frmPrompt(nodeidloc, title, "location");
                node.Tag = JsonConvert.SerializeObject(new ContentInfo(nodeidloc, title, "location", ".prompt"));

                promptform2.MdiParent = this;
                promptform2.Text      = title;
                promptform2.Show();

                break;

            case "customprompt":
                node.ImageIndex = 6;

                string    nodeidprompt = ProjectIO.GenerateUniqueID();
                frmPrompt promptform3  = new frmPrompt(nodeidprompt, title, "customprompt");
                node.Tag = JsonConvert.SerializeObject(new ContentInfo(nodeidprompt, title, "customprompt", ".prompt"));

                promptform3.MdiParent = this;
                promptform3.Text      = title;
                promptform3.Show();

                break;

            default:
                return;
            }

            node.SelectedImageIndex = node.ImageIndex;

            if (tvContent.SelectedNode == null)
            {
                tvContent.Nodes.Add(node);
            }
            else
            {
                tvContent.SelectedNode.Nodes.Add(node);
                tvContent.SelectedNode.Expand();
            }

            ProjectInfo.Dirty = true;
        }