示例#1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            ContentInfo info = new ContentInfo(ProjectIO.GenerateUniqueID(), txtTitle.Text, BeingAdded, AddingExtension);

            AddContentToTree(txtTitle.Text, info);

            btnCancel.PerformClick();
        }
示例#2
0
        // "manual" file opening function with some options so we can load recent projects properly
        private void OpenProject(bool useDialog, string manualFileName = "none")
        {
            try
            {
                string filename = "";

                if (useDialog)
                {
                    OpenFileDialog open = new OpenFileDialog();
                    open.Filter = "BrainStormer Project File (*.bpf)|*.bpf|All Files (*.*)|*.*";
                    if (open.ShowDialog() == DialogResult.Cancel)
                    {
                        return;
                    }

                    if (Directory.Exists(ProjectInfo.ProjectPath))
                    {
                        var result = MessageBox.Show("There is a project already open. Overwrite?", "Overwrite", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (result == DialogResult.No)
                        {
                            return;
                        }
                        Directory.Delete(ProjectInfo.ProjectPath, true);
                    }

                    filename = open.FileName;
                }
                else
                {
                    filename = manualFileName;
                }

                if (manualFileName == "")
                {
                    MessageBox.Show("Error loading file. Blank filename.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (Directory.Exists(ProjectInfo.ProjectPath))
                {
                    Directory.Delete(ProjectInfo.ProjectPath, true);
                }

                ZipFile.ExtractToDirectory(filename, ProjectInfo.ProjectPath);
                ProjectIO.LoadTree(tvContent, ProjectInfo.ProjectPath + "/tree.TREEINFO");

                BuildNodes(tvContent.Nodes);

                ProjectInfo.Dirty = false;
                recentProjects.Add(filename);
            } catch (UnauthorizedAccessException)
            {
                MessageBox.Show("Unauthorized access to the files in BrainStormer's project directory. Is the file in use? Note: Google Drive may list files as unsyncable on poor internet connections while still 'using' those files. This is a common issue.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
示例#3
0
        // Content present in the tree on-load
        private void frmMain_Load(object sender, EventArgs e)
        {
            AddContentToTree("Notes", new ContentInfo(ProjectIO.GenerateUniqueID(), "Notes", "folder", ""));
            AddContentToTree("Chapters", new ContentInfo(ProjectIO.GenerateUniqueID(), "Notes", "folder", ""));
            AddContentToTree("Characters", new ContentInfo(ProjectIO.GenerateUniqueID(), "Notes", "folder", ""));
            AddContentToTree("Locations", new ContentInfo(ProjectIO.GenerateUniqueID(), "Notes", "folder", ""));

            ProjectInfo.Dirty = false;

            panRecent.Visible = true;
        }
示例#4
0
        // TriggerDirty = makes project clean (ProjectInfo.Dirty = false)
        public void ManualSaveProject(string path, bool TriggerDirty)
        {
            ProjectIO.SaveTree(tvContent, ProjectInfo.ProjectPath + "tree.TREEINFO");

            if (File.Exists(path))
            {
                File.Delete(path);
            }
            ZipFile.CreateFromDirectory(ProjectInfo.ProjectPath, path);

            if (TriggerDirty == true)
            {
                ProjectInfo.Dirty = false;
            }
        }
示例#5
0
        private void saveProjectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ProjectIO.SaveTree(tvContent, ProjectInfo.ProjectPath + "tree.TREEINFO");

            SaveFileDialog save = new SaveFileDialog();

            save.Filter = "BrainStormer Project File (*.bpf)|*.bpf|All Files (*.*)|*.*";
            if (save.ShowDialog() == DialogResult.OK)
            {
                if (File.Exists(save.FileName))
                {
                    File.Delete(save.FileName);
                }
                ZipFile.CreateFromDirectory(ProjectInfo.ProjectPath, save.FileName);
            }

            ProjectInfo.Dirty = false;



            recentProjects.Add(save.FileName);
        }
示例#6
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;
        }