Exemplo n.º 1
0
        private void scriptToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (SelectTemplateForm frm = new SelectScriptTemplateForm())
            {
                if (frm.ShowDialog(this) == DialogResult.OK)
                {
                    CANAPETemplate template = frm.Template;

                    ScriptDocument document = CANAPEProject.CurrentProject.CreateDocument<ScriptDocument>(template.TypeName);

                    document.Script = template.GetText();

                    OnDisplayDocument(document);
                }
            }
        }
Exemplo n.º 2
0
        private void netEditor_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                GraphNode node = netEditor.SelectedObject as GraphNode;

                if (node != null)
                {
                    BaseNodeConfig config = (BaseNodeConfig)node.Tag;

                    PropertyDescriptorCollection coll = TypeDescriptor.GetProperties(config);

                    foreach (PropertyDescriptor desc in coll)
                    {
                        if (typeof(IDocumentObject).IsAssignableFrom(desc.PropertyType))
                        {
                            object o = config;
                            ICustomTypeDescriptor custom = config as ICustomTypeDescriptor;
                            if (custom != null)
                            {
                                o = custom.GetPropertyOwner(desc);
                            }

                            IDocumentObject document = (IDocumentObject)desc.GetValue(o);
                            if(document == null)
                            {
                                if (MessageBox.Show(this, Resources.ResourceManager.GetString("NetGraphDocumentControl_NoDocumentSet", GeneralUtils.GetCurrentCulture()),
                                    Resources.ResourceManager.GetString("NetGraphDocumentControl_NoDocumentSetCaption", GeneralUtils.GetCurrentCulture()),
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                {
                                    // Create document
                                    if (desc.PropertyType == typeof(ScriptDocument))
                                    {
                                        using (SelectScriptTemplateForm frm = new SelectScriptTemplateForm())
                                        {
                                            if (frm.ShowDialog(this) == DialogResult.OK)
                                            {
                                                ScriptDocument script = CANAPEProject.CurrentProject.CreateDocument<ScriptDocument>(frm.Template.TypeName);
                                                script.Script = frm.Template.GetText();
                                                document = script;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        document = CANAPEProject.CurrentProject.CreateDocument(desc.PropertyType);
                                    }
                                }
                            }

                            if(document != null)
                            {
                                DocumentControl.Show(document);
                                desc.SetValue(o, document);

                                // Reset selected objects
                                propertyGrid.SelectedObjects = propertyGrid.SelectedObjects;
                            }

                            break;
                        }
                    }
                }
            }
        }