Visual Studio Editor Clone V0.1a






3.31/5 (18 votes)
Mar 5, 2005

117211

4405
A clone of the Visual Studio .NET 2002 editor.
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();
//add control to form
this.Controls.Add(ToolBoxControl);
//*** Add Toolbox Controls ***//
//Add Tabs
ToolBoxControl.AddTab("Data",0);
ToolBoxControl.AddTab("Components",0);
ToolBoxControl.AddTab("Windows Forms",0);
ToolBoxControl.AddTab("General",0);
//Add Items
//Add Items
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);
//*** Done Adding Items ***//
// ** Set Visual Properties **//
ToolBoxControl.Font = new Font("Arial",8);
ToolBoxControl.BackColor = SystemColors.Control;
ToolBoxControl.ItemSelectedColor = Color.LightGray;
//scroll items up
for (int i=0;i<5;i++)
ToolBoxControl[2].ScrollItems(ScrollDirection.Up);
}
private void FormDisplay_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)
{
try
{
//get drop data
ToolBoxItem DragData =
(ToolBoxItem)e.Data.GetData(typeof(ToolBoxItem));
//create a new control
Assembly controlAsm =
Assembly.LoadWithPartialName(DragData.Object.ToString());
Type controlType =
controlAsm.GetType(DragData.Object.ToString()
+ "." + DragData.Caption);
Control newControl =
(Control)Activator.CreateInstance(controlType);
//location on client form
newControl.Location = PointToClient(new Point(e.X,e.Y));
//default text
newControl.Text = DragData.Caption;
//show properties in propertygrid when clicked
newControl.Click += new EventHandler(Control_Click);
//add control to form
this.Controls.Add(newControl);
//make z-order upper
newControl.BringToFront();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
Docking all the Controls Together
private void DockControls()
{
//Set Displayes
DockManager.InnerControl = DisplayTabControl;
//Right Dock
//******** Add Toolbox
cToolBox = DockManager.Contents.Add(ToolBoxControl,"ToolBox");
//set the toolbox to be 1/7 of the screen
cToolBox.DisplaySize =
new Size(this.ClientSize.Width / 7,this.ClientSize.Height);
//******** Add Display Explorer
cExplorer = DockManager.Contents.Add(DisplayTree,"Solution Explorer");
//set the solution explorer to be 1/6 of the screen
cExplorer.DisplaySize =
new Size(this.ClientSize.Width / 6,this.ClientSize.Height);
//******** Add PropertyGrid
cProperties = DockManager.Contents.Add(PropertyGridControl,"Proprties");
//******** Add Output
OutputWindow = new FormOutput();
cOutput = DockManager.Contents.Add(OutputWindow,"Output",imageList,18);
//******** Add Tasklist
FormOutput TaskList = new FormOutput();
cTaskList = DockManager.Contents.Add(TaskList,"Task List",imageList,19);
//divide the content to two (Properties and Tree)
wcRight = DockManager.AddContentWithState(cExplorer, State.DockRight);
//add Properties and ProjectTree
DockManager.AddContentToZone(cProperties,wcRight.ParentZone,1);
//add OutputTab
wcBottom = DockManager.AddContentWithState(cOutput,State.DockBottom);
//add output and tasklist
DockManager.AddContentToWindowContent(cTaskList,wcBottom);
//Add Toolbox
DockManager.AddContentWithState(cToolBox,State.DockLeft);
//Set Status Bar
DockManager.OuterControl = statusBar;
//Resize Controls/Forms
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.