
Background
Following the upcoming Visual Studio components (menu bar, toolbox etc.), I decided to gather them all and implement all in one application, to be a clone of the VS 2002 .NET Editor. Thanks to all the developers writing such controls, they are extremely helpful and time saving.
Introduction
This is an alpha version of the VS Clone project and it only contains the GUI part (most of it); the plan is to reach a fully working editor, which looks like the VS Editor, only without the debugger (I lack this knowledge). Anyway, this is the first released version.
Form Control Creation
private void SetToolBox()
{
ToolBoxControl = new ToolBox();
this.Controls.Add(ToolBoxControl);
ToolBoxControl.AddTab("Data",0);
ToolBoxControl.AddTab("Components",0);
ToolBoxControl.AddTab("Windows Forms",0);
ToolBoxControl.AddTab("General",0);
ToolBoxControl[2].AddItem("Label",0,true,typeof(Label).Namespace);
ToolBoxControl[2].AddItem("TextBox",0,true,typeof(TextBox).Namespace);
ToolBoxControl[2].AddItem("PictureBox",0,
true,typeof(PictureBox).Namespace);
ToolBoxControl[2].AddItem("ListView",0,true,typeof(ListView).Namespace);
ToolBoxControl[2].AddItem("ComboBox",0,true,typeof(ComboBox).Namespace);
ToolBoxControl[2].AddItem("Button",0,true,typeof(Button).Namespace);
ToolBoxControl[2].AddItem("CheckBox",0,true,typeof(CheckBox).Namespace);
ToolBoxControl.Font = new Font("Arial",8);
ToolBoxControl.BackColor = SystemColors.Control;
ToolBoxControl.ItemSelectedColor = Color.LightGray;
for (int i=0;i<5;i++)
ToolBoxControl[2].ScrollItems(ScrollDirection.Up);
}
private void FormDisplay_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)
{
try
{
ToolBoxItem DragData =
(ToolBoxItem)e.Data.GetData(typeof(ToolBoxItem));
Assembly controlAsm =
Assembly.LoadWithPartialName(DragData.Object.ToString());
Type controlType =
controlAsm.GetType(DragData.Object.ToString()
+ "." + DragData.Caption);
Control newControl =
(Control)Activator.CreateInstance(controlType);
newControl.Location = PointToClient(new Point(e.X,e.Y));
newControl.Text = DragData.Caption;
newControl.Click += new EventHandler(Control_Click);
this.Controls.Add(newControl);
newControl.BringToFront();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
Docking all the Controls Together
private void DockControls()
{
DockManager.InnerControl = DisplayTabControl;
cToolBox = DockManager.Contents.Add(ToolBoxControl,"ToolBox");
cToolBox.DisplaySize =
new Size(this.ClientSize.Width / 7,this.ClientSize.Height);
cExplorer = DockManager.Contents.Add(DisplayTree,"Solution Explorer");
cExplorer.DisplaySize =
new Size(this.ClientSize.Width / 6,this.ClientSize.Height);
cProperties = DockManager.Contents.Add(PropertyGridControl,"Proprties");
OutputWindow = new FormOutput();
cOutput = DockManager.Contents.Add(OutputWindow,"Output",imageList,18);
FormOutput TaskList = new FormOutput();
cTaskList = DockManager.Contents.Add(TaskList,"Task List",imageList,19);
wcRight = DockManager.AddContentWithState(cExplorer, State.DockRight);
DockManager.AddContentToZone(cProperties,wcRight.ParentZone,1);
wcBottom = DockManager.AddContentWithState(cOutput,State.DockBottom);
DockManager.AddContentToWindowContent(cTaskList,wcBottom);
DockManager.AddContentWithState(cToolBox,State.DockLeft);
DockManager.OuterControl = statusBar;
OutputWindow.Bounds = wcBottom.Bounds;
}
Control Links
What's Next?
Now working on enabling GUI into code - creating forms, dragging controls etc. Also creating a code editor to allow design time editing.