Esempio n. 1
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;
        }
Esempio n. 2
0
        private void UpdateValidationSchema()
        {
            if (mNodePreview == null || mSelectedNode == null)
            {
                return;
            }

            var encounterNode = mSelectedNode.NodeData as EncounterNodeData;

            if (encounterNode == null)
            {
                return;
            }

            var schema = GameMasterDataManager.GetInstance().GetEncounterSchema(encounterNode.EncounterType);

            if (schema != null)
            {
                var suggester = mNodePreview.SetValidationSchema(schema);
                suggester.AddCustomSource("http://stonehearth.net/schemas/encounters/elements/edge.json", GetAllEdges);
                suggester.AddCustomSource("http://stonehearth.net/schemas/encounters/elements/node.json", GetAllNodes);
            }
        }