Inheritance: System.Windows.Forms.UserControl
Beispiel #1
0
        private void UpdateSelectedNodeInfo(GameMasterNode node)
        {
            if (mSelectedNode == node)
            {
                return;
            }

            mSelectedNode = node;

            if (mNodePreview != null)
            {
                if (!mNodePreview.TrySetFileDataFromTextbox())
                {
                    // Don't allow switching nodes if the file is invalid.
                    // This is terrible, but since we currently don't allow writing out invalid JSON,
                    // switching away could cause data loss.
                    return;
                }

                editorInfoSplitter.Panel1.Controls.Remove(mNodePreview);
                mNodePreview.Dispose();
                mNodePreview = null;
            }

            if (node != null)
            {
                // Add a text editor.
                mNodePreview      = new FilePreview(this, node.FileData);
                mNodePreview.Dock = DockStyle.Fill;
                editorInfoSplitter.Panel1.Controls.Add(mNodePreview);
                UpdateValidationSchema();
                mNodePreview.OnModifiedChanged += (bool isModified) =>
                {
                    if (mSelectedNode?.FileData == mNodePreview.FileData)
                    {
                        mSelectedNode.IsModified = isModified;
                        mSelectedNode.NodeData.UpdateGraphNode(mSelectedDNode.DrawingNode);
                        graphViewer.Invalidate(mSelectedDNode);
                    }
                };

                // Add some extra labels to the text editor toolbar.
                var nodeNameLabel = mNodePreview.toolStrip.Items.Add(node.Name + (node.NodeType == GameMasterNodeType.ENCOUNTER ? (" (" + ((EncounterNodeData)node.NodeData).EncounterType + ")") : ""));
                nodeNameLabel.Margin  = new Padding(24, 0, 0, 0);
                nodeNameLabel.Enabled = false;
                var nodePathLabel = mNodePreview.toolStrip.Items.Add(node.Path);
                nodePathLabel.Enabled   = false;
                nodePathLabel.Alignment = ToolStripItemAlignment.Right;

                // Set up the details panel.
                PopulateFileDetails(node);
                editorInfoSplitter.Panel2Collapsed = fileDetailsListBox.Items.Count == 0;
            }
            else
            {
                PopulateFileDetails(null);
                editorInfoSplitter.Panel2Collapsed = true;
            }
        }
        private void OnLuaFileDataSelected()
        {
            FileData openedFile = mSelectedFileData;
            TabPage  newTabPage = new TabPage();

            newTabPage.Text = openedFile.FileName;
            FilePreview filePreview = new FilePreview(this, openedFile);

            filePreview.Dock = DockStyle.Fill;
            newTabPage.Controls.Add(filePreview);
            filePreviewTabs.TabPages.Add(newTabPage);
        }
        private void UpdateSelectedNodeInfo(GameMasterNode node)
        {
            if (node != null)
            {
                mSelectedNode     = node;
                nodeInfoName.Text = node.Name;
                encounterRightSideFilePath.Text = node.Path;
                nodeInfoType.Text    = node.NodeType.ToString();
                nodePath.Text        = node.Path;
                nodeInfoSubType.Text = node.NodeType == GameMasterNodeType.ENCOUNTER ? ((EncounterNodeData)node.NodeData).EncounterType : "";

                if (mNodePreview != null)
                {
                    splitContainer2.Panel1.Controls.Remove(mNodePreview);
                }

                mNodePreview      = new FilePreview(this, node.FileData);
                mNodePreview.Dock = DockStyle.Fill;
                splitContainer2.Panel1.Controls.Add(mNodePreview);

                copyGameMasterNode.Text             = "Clone " + node.Name;
                copyGameMasterNode.Enabled          = true;
                openEncounterFileButton.Visible     = true;
                deleteNodeToolStripMenuItem.Visible = true;
                PopulateFileDetails(node);
            }
            else
            {
                mSelectedNode     = null;
                nodeInfoName.Text = "Select a Node";
                encounterRightSideFilePath.Text = string.Empty;
                nodeInfoType.Text    = string.Empty;
                nodeInfoSubType.Text = string.Empty;
                nodePath.Text        = string.Empty;
                if (mNodePreview != null)
                {
                    splitContainer2.Panel1.Controls.Remove(mNodePreview);
                }

                copyGameMasterNode.Text             = "Clone Node";
                copyGameMasterNode.Enabled          = false;
                openEncounterFileButton.Visible     = false;
                deleteNodeToolStripMenuItem.Visible = false;
                PopulateFileDetails(null);
            }
        }
Beispiel #4
0
        private void previewMixinsButton_Click(object sender, EventArgs args)
        {
            if (!TrySetFileDataFromTextbox())
            {
                return;
            }

            Dictionary <string, string> annotations;
            JsonFileData mixinsFile;

            try
            {
                mixinsFile = (mFileData as JsonFileData).CreateFileWithMixinsApplied(out annotations);
            }
            catch (Exception e)
            {
                MessageBox.Show("Could not generate mixin preview. Error: " + e.Message);
                return;
            }

            var newPreview = new FilePreview(mOwner, mixinsFile);

            newPreview.Dock = DockStyle.Fill;
            newPreview.toolStrip.Visible = false;
            if (jsonValidationSchema != null)
            {
                newPreview.SetValidationSchema(jsonValidationSchema);
            }

            var form = new Form();

            form.Width         = 800;
            form.Height        = 600;
            form.SizeGripStyle = SizeGripStyle.Show;
            form.Controls.Add(newPreview);
            form.Icon = ParentForm.Icon;
            form.Text = "Mixin preview: " + mFileData.FileName;
            // StartPosition doesn't work unless modal. :(
            form.Show();
            form.Location = new System.Drawing.Point(ParentForm.Location.X + ParentForm.Width / 2 - form.Width / 2,
                                                     ParentForm.Location.Y + ParentForm.Height / 2 - form.Height / 2);

            newPreview.ApplySourceAnnotations(annotations);
            newPreview.textBox.ReadOnly = true;
        }
        private void updateOnItemSelection(
            Dictionary <string, JsonFileData> categoryJsonFiles,
            Dictionary <string, string> imgPaths,
            string alias)
        {
            filePreviewTabs.TabPages.Clear();
            iconView.ImageLocation = "";
            JsonFileData json;

            categoryJsonFiles.TryGetValue(alias, out json);

            if (json != null)
            {
                foreach (FileData openedFile in json.OpenedFiles)
                {
                    TabPage newTabPage = new TabPage();
                    newTabPage.Text = openedFile.FileName;
                    if (ModuleDataManager.GetInstance().ModifiedFiles.Contains(openedFile))
                    {
                        newTabPage.Text = newTabPage.Text + "*";
                    }

                    if (openedFile.HasErrors)
                    {
                        newTabPage.ImageIndex  = 0;
                        newTabPage.ToolTipText = openedFile.Errors;
                    }

                    FilePreview filePreview = new FilePreview(this, openedFile);
                    filePreview.Dock = DockStyle.Fill;
                    newTabPage.Controls.Add(filePreview);
                    filePreviewTabs.TabPages.Add(newTabPage);
                    string path;
                    if (imgPaths != null && imgPaths.TryGetValue(alias, out path))
                    {
                        iconView.ImageLocation = path;
                    }
                }
            }
        }
Beispiel #6
0
        // Loads file preview from single FileData
        private void FillFilePreview(FileData fileData)
        {
            TabPage newTabPage = new TabPage();

            newTabPage.Text = fileData.FileName;

            // if (fileData.IsModified)
            // {
            //   newTabPage.Text = newTabPage.Text + "*";
            // }
            if (fileData.HasErrors)
            {
                newTabPage.ImageIndex  = 0;
                newTabPage.ToolTipText = fileData.Errors;
            }

            FilePreview filePreview = new FilePreview(this, fileData);

            filePreview.Dock = DockStyle.Fill;
            newTabPage.Controls.Add(filePreview);
            filePreviewTabs.TabPages.Add(newTabPage);
        }
        private void OnJsonFileDataSelected()
        {
            JsonFileData fileData = mSelectedFileData as JsonFileData;

            if (fileData.TreeNode != null)
            {
                treeView.SelectedNode = fileData.TreeNode;
            }

            List <string> addedOpenFiles = new List <string>();
            bool          hasImage       = false;

            foreach (FileData openedFile in fileData.OpenedFiles)
            {
                TabPage newTabPage = new TabPage();
                newTabPage.Text = openedFile.FileName;
                if (ModuleDataManager.GetInstance().ModifiedFiles.Contains(openedFile))
                {
                    newTabPage.Text = newTabPage.Text + "*";
                }

                if (openedFile.HasErrors)
                {
                    newTabPage.ImageIndex  = 0;
                    newTabPage.ToolTipText = openedFile.Errors;
                }

                FilePreview filePreview = new FilePreview(this, openedFile);
                filePreview.Dock = DockStyle.Fill;
                newTabPage.Controls.Add(filePreview);
                filePreviewTabs.TabPages.Add(newTabPage);

                foreach (KeyValuePair <string, FileData> linkedFile in openedFile.LinkedFileData)
                {
                    if (addedOpenFiles.Contains(linkedFile.Key))
                    {
                        continue;
                    }

                    addedOpenFiles.Add(linkedFile.Key);

                    if (linkedFile.Value is QubicleFileData)
                    {
                        QubicleFileData qbFileData     = linkedFile.Value as QubicleFileData;
                        string          fileName       = qbFileData.FileName;
                        Button          openFileButton = new Button();
                        openFileButton.Name                    = qbFileData.GetOpenFilePath();
                        openFileButton.BackgroundImage         = global::StonehearthEditor.Properties.Resources.qmofileicon_small;
                        openFileButton.BackgroundImageLayout   = ImageLayout.None;
                        openFileButton.Text                    = Path.GetFileName(openFileButton.Name);
                        openFileButton.TextAlign               = System.Drawing.ContentAlignment.MiddleRight;
                        openFileButton.UseVisualStyleBackColor = true;
                        openFileButton.Click                  += new System.EventHandler(openFileButton_Click);
                        openFileButton.Padding                 = new Padding(22, 2, 2, 2);
                        openFileButton.AutoSize                = true;
                        openFileButtonPanel.Controls.Add(openFileButton);
                    }
                    else if (linkedFile.Value is ImageFileData)
                    {
                        string imageFilePath = linkedFile.Value.Path;
                        if (System.IO.File.Exists(imageFilePath))
                        {
                            if (!hasImage)
                            {
                                iconView.ImageLocation = imageFilePath;
                                hasImage = true;
                            }

                            Button openFileButton = new Button();
                            openFileButton.Name = imageFilePath;
                            Image thumbnail = ThumbnailCache.GetThumbnail(imageFilePath);

                            openFileButton.BackgroundImage       = thumbnail;
                            openFileButton.BackgroundImageLayout = ImageLayout.None;
                            openFileButton.Text      = Path.GetFileName(openFileButton.Name);
                            openFileButton.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
                            openFileButton.UseVisualStyleBackColor = true;
                            openFileButton.Click   += new System.EventHandler(openFileButton_Click);
                            openFileButton.Padding  = new Padding(22, 2, 2, 2);
                            openFileButton.AutoSize = true;
                            openFileButtonPanel.Controls.Add(openFileButton);
                        }
                    }
                }
            }
        }
        private void UpdateSelectedNodeInfo(GameMasterNode node)
        {
            if (node != null)
            {
                mSelectedNode = node;
                nodeInfoName.Text = node.Name;
                encounterRightSideFilePath.Text = node.Path;
                nodeInfoType.Text = node.NodeType.ToString();
                nodePath.Text = node.Path;
                nodeInfoSubType.Text = node.NodeType == GameMasterNodeType.ENCOUNTER ? ((EncounterNodeData)node.NodeData).EncounterType : "";

                if (mNodePreview != null)
                {
                    splitContainer2.Panel1.Controls.Remove(mNodePreview);
                }

                mNodePreview = new FilePreview(this, node.FileData);
                mNodePreview.Dock = DockStyle.Fill;
                splitContainer2.Panel1.Controls.Add(mNodePreview);

                copyGameMasterNode.Text = "Clone " + node.Name;
                copyGameMasterNode.Enabled = true;
                openEncounterFileButton.Visible = true;
                deleteNodeToolStripMenuItem.Visible = true;
                PopulateFileDetails(node);
            }
            else
            {
                mSelectedNode = null;
                nodeInfoName.Text = "Select a Node";
                encounterRightSideFilePath.Text = string.Empty;
                nodeInfoType.Text = string.Empty;
                nodeInfoSubType.Text = string.Empty;
                nodePath.Text = string.Empty;
                if (mNodePreview != null)
                {
                    splitContainer2.Panel1.Controls.Remove(mNodePreview);
                }

                copyGameMasterNode.Text = "Clone Node";
                copyGameMasterNode.Enabled = false;
                openEncounterFileButton.Visible = false;
                deleteNodeToolStripMenuItem.Visible = false;
                PopulateFileDetails(null);
            }
        }
        // Loads file preview from single FileData
        private void FillFilePreview(FileData fileData)
        {
            TabPage newTabPage = new TabPage();
            newTabPage.Text = fileData.FileName;

            // if (fileData.IsModified)
            // {
            //   newTabPage.Text = newTabPage.Text + "*";
            // }
            if (fileData.HasErrors)
            {
                newTabPage.ImageIndex = 0;
                newTabPage.ToolTipText = fileData.Errors;
            }

            FilePreview filePreview = new FilePreview(this, fileData);
            filePreview.Dock = DockStyle.Fill;
            newTabPage.Controls.Add(filePreview);
            filePreviewTabs.TabPages.Add(newTabPage);
        }
 private void OnLuaFileDataSelected()
 {
     FileData openedFile = mSelectedFileData;
     TabPage newTabPage = new TabPage();
     newTabPage.Text = openedFile.FileName;
     FilePreview filePreview = new FilePreview(this, openedFile);
     filePreview.Dock = DockStyle.Fill;
     newTabPage.Controls.Add(filePreview);
     filePreviewTabs.TabPages.Add(newTabPage);
 }
        private void OnJsonFileDataSelected()
        {
            JsonFileData fileData = mSelectedFileData as JsonFileData;
            if (fileData.TreeNode != null)
            {
                treeView.SelectedNode = fileData.TreeNode;
            }

            List<string> addedOpenFiles = new List<string>();
            bool hasImage = false;
            foreach (FileData openedFile in fileData.OpenedFiles)
            {
                TabPage newTabPage = new TabPage();
                newTabPage.Text = openedFile.FileName;
                if (ModuleDataManager.GetInstance().ModifiedFiles.Contains(openedFile))
                {
                    newTabPage.Text = newTabPage.Text + "*";
                }

                if (openedFile.HasErrors)
                {
                    newTabPage.ImageIndex = 0;
                    newTabPage.ToolTipText = openedFile.Errors;
                }

                FilePreview filePreview = new FilePreview(this, openedFile);
                filePreview.Dock = DockStyle.Fill;
                newTabPage.Controls.Add(filePreview);
                filePreviewTabs.TabPages.Add(newTabPage);

                foreach (KeyValuePair<string, FileData> linkedFile in openedFile.LinkedFileData)
                {
                    if (addedOpenFiles.Contains(linkedFile.Key))
                    {
                        continue;
                    }

                    addedOpenFiles.Add(linkedFile.Key);

                    if (linkedFile.Value is QubicleFileData)
                    {
                        QubicleFileData qbFileData = linkedFile.Value as QubicleFileData;
                        string fileName = qbFileData.FileName;
                        Button openFileButton = new Button();
                        openFileButton.Name = qbFileData.GetOpenFilePath();
                        openFileButton.BackgroundImage = global::StonehearthEditor.Properties.Resources.qmofileicon_small;
                        openFileButton.BackgroundImageLayout = ImageLayout.None;
                        openFileButton.Text = Path.GetFileName(openFileButton.Name);
                        openFileButton.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
                        openFileButton.UseVisualStyleBackColor = true;
                        openFileButton.Click += new System.EventHandler(openFileButton_Click);
                        openFileButton.Padding = new Padding(22, 2, 2, 2);
                        openFileButton.AutoSize = true;
                        openFileButtonPanel.Controls.Add(openFileButton);
                    }
                    else if (linkedFile.Value is ImageFileData)
                    {
                        string imageFilePath = linkedFile.Value.Path;
                        if (System.IO.File.Exists(imageFilePath))
                        {
                            if (!hasImage)
                            {
                                iconView.ImageLocation = imageFilePath;
                                hasImage = true;
                            }

                            Button openFileButton = new Button();
                            openFileButton.Name = imageFilePath;
                            Image thumbnail = ThumbnailCache.GetThumbnail(imageFilePath);

                            openFileButton.BackgroundImage = thumbnail;
                            openFileButton.BackgroundImageLayout = ImageLayout.None;
                            openFileButton.Text = Path.GetFileName(openFileButton.Name);
                            openFileButton.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
                            openFileButton.UseVisualStyleBackColor = true;
                            openFileButton.Click += new System.EventHandler(openFileButton_Click);
                            openFileButton.Padding = new Padding(22, 2, 2, 2);
                            openFileButton.AutoSize = true;
                            openFileButtonPanel.Controls.Add(openFileButton);
                        }
                    }
                }
            }
        }