Click here to Skip to main content
15,886,199 members
Articles / Programming Languages / Visual Basic

Magic Library Docking Manager Designer

Rate me:
Please Sign up or sign in to vote.
3.39/5 (49 votes)
16 May 2013CPOL4 min read 437.8K   21.7K   160  
Provides docking support without writing one line of code.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

/*
 * Copyright � 2003 by Christoph Richner. All rights are reserved. If you like this 
  code then feel free to go ahead and use it. The only thing I ask is that 
  you don't remove or alter my copyright notice. Your use of this software 
  is entirely at your own risk. I make no claims or warrantees about the 
  reliability or fitness of this code for any particular purpose. If you 
  make changes or additions to this code please mark your code as being 
  yours. If you have questions or comments then please contact me at: 
  microweb@bluewin.ch
  */
namespace DockingManagerExtenderDemo
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class DockingExtendedForm :  System.Windows.Forms.Form
	{
		#region members
		private System.Windows.Forms.Panel panel1;
		private System.Windows.Forms.Panel panel2;
		private System.Windows.Forms.Panel panel3;
		private DockingManagerExtender.DockingManagerExtender dockingManagerExtender;
		private System.Windows.Forms.MainMenu mainMenu1;
		private System.Windows.Forms.ToolBar toolBar1;
		private System.Windows.Forms.StatusBar statusBar1;
		private System.Windows.Forms.DataGrid dataGrid1;
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.MenuItem menuItem2;
		private System.Windows.Forms.ToolBarButton toolBarButton1;
		private System.Windows.Forms.ToolBarButton toolBarButton2;
		private System.Windows.Forms.ImageList imageList1;
		private System.Windows.Forms.PropertyGrid propertyGrid1;
		private System.Windows.Forms.StatusBarPanel statusBarPanel1;
		private System.Windows.Forms.MenuItem menuItem3;
		private System.Windows.Forms.MenuItem menuItem4;
		private System.Windows.Forms.MenuItem menuItem5;
		private System.Windows.Forms.MenuItem menuItem6;
		private System.Windows.Forms.PictureBox pictureBox1;
		private DockingManagerExtenderDemo.UserControlDockingExtended userControlDockingExtended1;
		private System.ComponentModel.IContainer components;
		#endregion

		public DockingExtendedForm()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			//
			this.dataGrid1.Dock = DockStyle.Fill;			
			if(!DesignMode)
			{
				this.Text = Application.CompanyName + " - " + Application.ProductName + " " + Application.ProductVersion.Substring(0,3);
			}
		}


		#region Windows Form Designer generated code
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(DockingExtendedForm));
			this.dockingManagerExtender = new DockingManagerExtender.DockingManagerExtender(this.components);
			this.dataGrid1 = new System.Windows.Forms.DataGrid();
			this.statusBar1 = new System.Windows.Forms.StatusBar();
			this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel();
			this.panel1 = new System.Windows.Forms.Panel();
			this.panel2 = new System.Windows.Forms.Panel();
			this.panel3 = new System.Windows.Forms.Panel();
			this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
			this.pictureBox1 = new System.Windows.Forms.PictureBox();
			this.userControlDockingExtended1 = new DockingManagerExtenderDemo.UserControlDockingExtended();
			this.mainMenu1 = new System.Windows.Forms.MainMenu();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.menuItem6 = new System.Windows.Forms.MenuItem();
			this.menuItem5 = new System.Windows.Forms.MenuItem();
			this.menuItem2 = new System.Windows.Forms.MenuItem();
			this.menuItem3 = new System.Windows.Forms.MenuItem();
			this.menuItem4 = new System.Windows.Forms.MenuItem();
			this.toolBar1 = new System.Windows.Forms.ToolBar();
			this.toolBarButton1 = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton2 = new System.Windows.Forms.ToolBarButton();
			this.imageList1 = new System.Windows.Forms.ImageList(this.components);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit();
			this.SuspendLayout();
			// 
			// dockingManagerExtender
			// 
			this.dockingManagerExtender.AutomaticStatePersistence = true;
			this.dockingManagerExtender.ContainerControl = this;
			this.dockingManagerExtender.InnerControl = this.dataGrid1;
			this.dockingManagerExtender.OuterControl = this.statusBar1;
			this.dockingManagerExtender.PlainTabBorder = false;
			this.dockingManagerExtender.VisualStyle = Crownwood.Magic.Common.VisualStyle.IDE;
			// 
			// dataGrid1
			// 
			this.dockingManagerExtender.SetADockingEnable(this.dataGrid1, false);
			this.dockingManagerExtender.SetCloseButton(this.dataGrid1, false);
			this.dockingManagerExtender.SetCloseOnHide(this.dataGrid1, false);
			this.dataGrid1.DataMember = "";
			this.dockingManagerExtender.SetDockingStyle(this.dataGrid1, System.Windows.Forms.DockStyle.Left);
			this.dockingManagerExtender.SetFullTitle(this.dataGrid1, "dataGrid1");
			this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dockingManagerExtender.SetIcon(this.dataGrid1, null);
			this.dataGrid1.Location = new System.Drawing.Point(72, 168);
			this.dataGrid1.Name = "dataGrid1";
			this.dataGrid1.Size = new System.Drawing.Size(384, 168);
			this.dockingManagerExtender.SetTabbedMode(this.dataGrid1, true);
			this.dataGrid1.TabIndex = 9;
			this.dockingManagerExtender.SetTitle(this.dataGrid1, "dataGrid1");
			// 
			// statusBar1
			// 
			this.statusBar1.Location = new System.Drawing.Point(0, 344);
			this.statusBar1.Name = "statusBar1";
			this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
																						  this.statusBarPanel1});
			this.statusBar1.ShowPanels = true;
			this.statusBar1.Size = new System.Drawing.Size(504, 22);
			this.statusBar1.TabIndex = 8;
			this.statusBar1.Text = "Ready";
			// 
			// statusBarPanel1
			// 
			this.statusBarPanel1.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
			this.statusBarPanel1.Icon = ((System.Drawing.Icon)(resources.GetObject("statusBarPanel1.Icon")));
			this.statusBarPanel1.Text = "Ready";
			this.statusBarPanel1.Width = 488;
			// 
			// panel1
			// 
			this.dockingManagerExtender.SetADockingEnable(this.panel1, true);
			this.panel1.BackColor = System.Drawing.Color.Red;
			this.dockingManagerExtender.SetCloseButton(this.panel1, true);
			this.dockingManagerExtender.SetCloseOnHide(this.panel1, false);
			this.dockingManagerExtender.SetDockingStyle(this.panel1, System.Windows.Forms.DockStyle.Left);
			this.dockingManagerExtender.SetFullTitle(this.panel1, "Red - Panel");
			this.dockingManagerExtender.SetIcon(this.panel1, ((System.Drawing.Icon)(resources.GetObject("panel1.Icon"))));
			this.panel1.Location = new System.Drawing.Point(32, 40);
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(64, 56);
			this.dockingManagerExtender.SetTabbedMode(this.panel1, true);
			this.panel1.TabIndex = 4;
			this.dockingManagerExtender.SetTitle(this.panel1, "Red");
			// 
			// panel2
			// 
			this.dockingManagerExtender.SetADockingEnable(this.panel2, true);
			this.panel2.BackColor = System.Drawing.Color.Yellow;
			this.dockingManagerExtender.SetCloseButton(this.panel2, true);
			this.dockingManagerExtender.SetCloseOnHide(this.panel2, false);
			this.dockingManagerExtender.SetDockingStyle(this.panel2, System.Windows.Forms.DockStyle.Left);
			this.dockingManagerExtender.SetFullTitle(this.panel2, "Yellow - Panel");
			this.dockingManagerExtender.SetIcon(this.panel2, ((System.Drawing.Icon)(resources.GetObject("panel2.Icon"))));
			this.panel2.Location = new System.Drawing.Point(208, 48);
			this.panel2.Name = "panel2";
			this.panel2.Size = new System.Drawing.Size(64, 80);
			this.dockingManagerExtender.SetTabbedMode(this.panel2, true);
			this.panel2.TabIndex = 5;
			this.dockingManagerExtender.SetTitle(this.panel2, "Yellow");
			// 
			// panel3
			// 
			this.dockingManagerExtender.SetADockingEnable(this.panel3, true);
			this.panel3.BackColor = System.Drawing.Color.Teal;
			this.dockingManagerExtender.SetCloseButton(this.panel3, true);
			this.dockingManagerExtender.SetCloseOnHide(this.panel3, false);
			this.dockingManagerExtender.SetDockingStyle(this.panel3, System.Windows.Forms.DockStyle.Right);
			this.dockingManagerExtender.SetFullTitle(this.panel3, "Teal - Panel");
			this.dockingManagerExtender.SetIcon(this.panel3, ((System.Drawing.Icon)(resources.GetObject("panel3.Icon"))));
			this.panel3.Location = new System.Drawing.Point(280, 40);
			this.panel3.Name = "panel3";
			this.panel3.Size = new System.Drawing.Size(112, 88);
			this.dockingManagerExtender.SetTabbedMode(this.panel3, false);
			this.panel3.TabIndex = 6;
			this.dockingManagerExtender.SetTitle(this.panel3, "Teal");
			// 
			// propertyGrid1
			// 
			this.dockingManagerExtender.SetADockingEnable(this.propertyGrid1, true);
			this.dockingManagerExtender.SetCloseButton(this.propertyGrid1, true);
			this.dockingManagerExtender.SetCloseOnHide(this.propertyGrid1, false);
			this.propertyGrid1.CommandsVisibleIfAvailable = true;
			this.dockingManagerExtender.SetDockingStyle(this.propertyGrid1, System.Windows.Forms.DockStyle.Right);
			this.dockingManagerExtender.SetFullTitle(this.propertyGrid1, "Docking Manager - Properties");
			this.dockingManagerExtender.SetIcon(this.propertyGrid1, ((System.Drawing.Icon)(resources.GetObject("propertyGrid1.Icon"))));
			this.propertyGrid1.LargeButtons = false;
			this.propertyGrid1.LineColor = System.Drawing.SystemColors.ScrollBar;
			this.propertyGrid1.Location = new System.Drawing.Point(432, 40);
			this.propertyGrid1.Name = "propertyGrid1";
			this.propertyGrid1.SelectedObject = this.dockingManagerExtender;
			this.propertyGrid1.Size = new System.Drawing.Size(48, 96);
			this.dockingManagerExtender.SetTabbedMode(this.propertyGrid1, false);
			this.propertyGrid1.TabIndex = 10;
			this.propertyGrid1.Text = "propertyGrid1";
			this.dockingManagerExtender.SetTitle(this.propertyGrid1, "Docking Manager");
			this.propertyGrid1.ViewBackColor = System.Drawing.SystemColors.Window;
			this.propertyGrid1.ViewForeColor = System.Drawing.SystemColors.WindowText;
			// 
			// pictureBox1
			// 
			this.dockingManagerExtender.SetADockingEnable(this.pictureBox1, true);
			this.pictureBox1.BackColor = System.Drawing.Color.White;
			this.dockingManagerExtender.SetCloseButton(this.pictureBox1, true);
			this.dockingManagerExtender.SetCloseOnHide(this.pictureBox1, false);
			this.dockingManagerExtender.SetDockingStyle(this.pictureBox1, System.Windows.Forms.DockStyle.Left);
			this.dockingManagerExtender.SetFullTitle(this.pictureBox1, ".Net Logo");
			this.dockingManagerExtender.SetIcon(this.pictureBox1, null);
			this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
			this.pictureBox1.Location = new System.Drawing.Point(16, 112);
			this.pictureBox1.Name = "pictureBox1";
			this.pictureBox1.Size = new System.Drawing.Size(200, 170);
			this.dockingManagerExtender.SetTabbedMode(this.pictureBox1, false);
			this.pictureBox1.TabIndex = 11;
			this.pictureBox1.TabStop = false;
			this.dockingManagerExtender.SetTitle(this.pictureBox1, ".net");
			// 
			// userControlDockingExtended1
			// 
			this.dockingManagerExtender.SetADockingEnable(this.userControlDockingExtended1, true);
			this.dockingManagerExtender.SetCloseButton(this.userControlDockingExtended1, true);
			this.dockingManagerExtender.SetCloseOnHide(this.userControlDockingExtended1, false);
			this.dockingManagerExtender.SetDockingStyle(this.userControlDockingExtended1, System.Windows.Forms.DockStyle.Left);
			this.dockingManagerExtender.SetFullTitle(this.userControlDockingExtended1, "UserControl");
			this.dockingManagerExtender.SetIcon(this.userControlDockingExtended1, null);
			this.userControlDockingExtended1.Location = new System.Drawing.Point(352, 136);
			this.userControlDockingExtended1.Name = "userControlDockingExtended1";
			this.userControlDockingExtended1.Size = new System.Drawing.Size(96, 112);
			this.dockingManagerExtender.SetTabbedMode(this.userControlDockingExtended1, false);
			this.userControlDockingExtended1.TabIndex = 12;
			this.dockingManagerExtender.SetTitle(this.userControlDockingExtended1, "UserControl");
			// 
			// mainMenu1
			// 
			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem1,
																					  this.menuItem3});
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 0;
			this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem6,
																					  this.menuItem5,
																					  this.menuItem2});
			this.menuItem1.Text = "File";
			// 
			// menuItem6
			// 
			this.menuItem6.Index = 0;
			this.menuItem6.Text = "Reset Automatic State Persistence ";
			this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
			// 
			// menuItem5
			// 
			this.menuItem5.Index = 1;
			this.menuItem5.Text = "-";
			// 
			// menuItem2
			// 
			this.menuItem2.Index = 2;
			this.menuItem2.Text = "&Exit";
			this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
			// 
			// menuItem3
			// 
			this.menuItem3.Index = 1;
			this.menuItem3.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem4});
			this.menuItem3.Text = "?";
			// 
			// menuItem4
			// 
			this.menuItem4.Index = 0;
			this.menuItem4.Text = "&About";
			this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
			// 
			// toolBar1
			// 
			this.toolBar1.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
			this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																						this.toolBarButton1,
																						this.toolBarButton2});
			this.toolBar1.DropDownArrows = true;
			this.toolBar1.ImageList = this.imageList1;
			this.toolBar1.Location = new System.Drawing.Point(0, 0);
			this.toolBar1.Name = "toolBar1";
			this.toolBar1.ShowToolTips = true;
			this.toolBar1.Size = new System.Drawing.Size(504, 28);
			this.toolBar1.TabIndex = 7;
			this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
			// 
			// toolBarButton1
			// 
			this.toolBarButton1.ImageIndex = 0;
			this.toolBarButton1.ToolTipText = "Close";
			// 
			// toolBarButton2
			// 
			this.toolBarButton2.ImageIndex = 1;
			this.toolBarButton2.ToolTipText = "Reset Automatic State Persistence ";
			// 
			// imageList1
			// 
			this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth24Bit;
			this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
			this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
			this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// DockingExtendedForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(504, 366);
			this.Controls.Add(this.userControlDockingExtended1);
			this.Controls.Add(this.pictureBox1);
			this.Controls.Add(this.propertyGrid1);
			this.Controls.Add(this.dataGrid1);
			this.Controls.Add(this.statusBar1);
			this.Controls.Add(this.toolBar1);
			this.Controls.Add(this.panel1);
			this.Controls.Add(this.panel2);
			this.Controls.Add(this.panel3);
			this.Menu = this.mainMenu1;
			this.Name = "DockingExtendedForm";
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion
		
		#region events
		private void menuItem2_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			if (e.Button == this.toolBarButton1)
			{
				this.Close();
			}
			else if (e.Button == this.toolBarButton2)
			{
				Reset();
			}
		}

		private void menuItem6_Click(object sender, System.EventArgs e)
		{
			Reset();
		}
		private void Reset()
		{
			switch (MessageBox.Show("Would you like to reset your custom layout back to default layout?\n\r Remark: You have to restart application until new setting can take effect.","Automatic State Persistence",MessageBoxButtons.YesNo))
			{
				case DialogResult.Yes:
					this.dockingManagerExtender.ResetAutoPersistent(false);
					this.userControlDockingExtended1.DockingManager.ResetAutoPersistent(false);
					break;
			}
		}
		private void menuItem4_Click(object sender, System.EventArgs e)
		{
			new Raccoom.Windows.Forms.RcmFormAbout().ShowDialog(this);			
		}

		#endregion

		[STAThread]
		static void Main() 
		{
			Application.Run(new DockingExtendedForm());			
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Switzerland Switzerland
My interest is in the future because I am going to spend the rest of my life there. (Charles Kettering)

Biography

  • 1996 - 1998 PC Board PPL, HTML, DHTML, Javascript and ASP
  • 1999 - 2001 coding Centura against Sql Database (SqlBase,MSSQL,Oracle)
  • 2002 - 2004 C# Windows Forms
  • 2005 - 2006 C# ASP.NET, Windows Forms
  • 2006 - 2009 C#, WCF, WF, WPF
  • 2010 - 2012 C#, Dynamics CRM, Sharepoint, Silverlight
  • 2013 - 2013 C#, WCF DS (OData), WF, WPF
  • 2014 - 2016 C#, Azure PaaS, Identity, OWIN, OData, Web Api
  • 2017 - now C#, aspnet.core, IdentityServer4, TypeScript & Angular @ Azure IaaS or PaaS

Interests

  • family & friends
  • chilaxing ,)
  • coding

Comments and Discussions