Visual Designer:
* Objects can now be dragged from the object list onto the designer & a new tab will be created for each object.
This commit is contained in:
parent
12f5776d21
commit
8fde0bcc43
4 changed files with 211 additions and 173 deletions
|
@ -6,14 +6,28 @@ using System.Drawing;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using ManagedScripting;
|
||||
using MUDEngine;
|
||||
using MUDEngine.Objects;
|
||||
using MUDEngine.Objects.Environment;
|
||||
using MUDEngine.FileSystem;
|
||||
|
||||
namespace VisualDesigner
|
||||
{
|
||||
public partial class frmMain : Form
|
||||
{
|
||||
ScriptingEngine engine = new ScriptingEngine();
|
||||
ScriptObject currentScript;
|
||||
Type[] types;
|
||||
object movingObject;
|
||||
|
||||
public frmMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
engine.LoadAssembly(Application.StartupPath + "/MUDEngine.dll");
|
||||
types = engine.GetAssembly.GetTypes();
|
||||
currentScript = new ScriptObject();
|
||||
}
|
||||
|
||||
private void closeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
|
@ -24,46 +38,75 @@ namespace VisualDesigner
|
|||
private void frmMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
//Load the engine
|
||||
System.Reflection.Assembly assem = System.Reflection.Assembly.LoadFile(Application.StartupPath + "/MUDEngine.dll");
|
||||
Type[] types = assem.GetTypes();
|
||||
engine.LoadAssembly(Application.StartupPath + "/MUDEngine.dll");
|
||||
Type[] foundTypes = engine.GetAssembly.GetTypes();
|
||||
Button button = new Button();
|
||||
this.flowLayoutPanel1.Controls.Add(button);
|
||||
|
||||
foreach (Type t in types)
|
||||
List<Type> tempTypes = new List<Type>();
|
||||
ListBox lst = new ListBox();
|
||||
lst.Sorted = true;
|
||||
|
||||
foreach (Type t in foundTypes)
|
||||
{
|
||||
if (t.BaseType.Name == "BaseObject")
|
||||
{
|
||||
button = new Button();
|
||||
button.Width = flowLayoutPanel1.Width - 10;
|
||||
button.Text = t.Name;
|
||||
button.Click += new EventHandler(newObject_Click);
|
||||
this.flowLayoutPanel1.Controls.Add(button);
|
||||
tempTypes.Add(t);
|
||||
lst.Items.Add(t.Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach (string t in lst.Items)
|
||||
{
|
||||
button = new Button();
|
||||
button.Width = flowLayoutPanel1.Width - 10;
|
||||
button.Text = t;
|
||||
button.AllowDrop = true;
|
||||
button.MouseDown += new MouseEventHandler(newObject_MouseDown);
|
||||
flowLayoutPanel1.Controls.Add(button);
|
||||
}
|
||||
|
||||
propertyGrid1.ViewForeColor = Color.Blue;
|
||||
propertyGrid1.SelectedObject = engine;
|
||||
}
|
||||
|
||||
void newObject_Click(object sender, EventArgs e)
|
||||
void newObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
Button button = (Button)sender;
|
||||
System.Reflection.Assembly assem = System.Reflection.Assembly.LoadFile(Application.StartupPath + "/MUDEngine.dll");
|
||||
Type[] types = assem.GetTypes();
|
||||
bool found = false;
|
||||
movingObject = button;
|
||||
DoDragDrop(button, DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
foreach (Type t in types)
|
||||
private void page1_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
|
||||
if (movingObject is Button)
|
||||
{
|
||||
if (t.Name == button.Text)
|
||||
{
|
||||
//Found it
|
||||
found = true;
|
||||
Button button = (Button)movingObject;
|
||||
|
||||
ManagedScripting.ScriptingEngine engine = new ManagedScripting.ScriptingEngine();
|
||||
engine.LoadAssembly(Application.StartupPath + "/MUDEngine.dll");
|
||||
engine.InstanceObject(t, null);
|
||||
ManagedScripting.ScriptObject obj = engine.GetObject(t.Name);
|
||||
propertyGrid1.SelectedObject = obj.Instance;
|
||||
foreach (Type t in types)
|
||||
{
|
||||
if (t.Name == button.Text)
|
||||
{
|
||||
engine.InstanceObject(t, null);
|
||||
currentScript = engine.GetObject(t.Name);
|
||||
propertyGrid1.SelectedObject = currentScript.Instance;
|
||||
if (page1.Text == "Empty")
|
||||
{
|
||||
page1.Text = currentScript.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
TabPage tab = new TabPage(currentScript.Name);
|
||||
tabControl1.TabPages.Add(tab);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void page1_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue