Embed it into an existing application

1.      Locate the Form which is a container for multiple-document interface (MDI) child forms. Change its base class from Form to LinsUI.FlexMDIForm. For example, if MyMDIForm class is your MDI container,

// The old code

public partial class MyMDIForm : Form

{

}

 

// The new code

using LinsUI;

public partial class MyMDIForm : LinsUI.FlexMDIForm

{

}

2.      Open Program.cs file, set the default path for the layout settings file, the default path for the help file, and the default path for the icons.

[STAThread]

   static void Main()

{

// Get the entry assembly

Assembly assem = Assembly.GetEntryAssembly();

// Get the application location

string csAssemName = assem.Location;

// Get the applicationb name

string csProjectName = assem.GetName().Name;

// Get the path where the application is located

string csDirectory = Path.GetDirectoryName(csAssemName);

int nIndex = csDirectory.LastIndexOf("Samples");

string csSampleDirectory = csDirectory.Substring(0, nIndex) + "Samples\\";

// Set the default path for saving the layout settings file,

FlexUISettings.AppSettingPath = Path.Combine(csDirectory, csProjectName);

// Set the default path for get the Help file

FlexUISettings.DefaultHelpFilePath = Path.Combine(csSampleDirectory, "Helps");

// Set the default path for icons

FlexManager.DefaultIconsPath = Path.Combine(csSampleDirectory, "Icons");

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new MDIForm());

}

3.      Change the base class of all child forms from Form to LinsUI.FlexForm, and assign every form a unique ID which should be between FlexConstants.m_nUserDefinedControlStartID and FlexConstants.m_nUserDefinedControlEndID. For example,

// The old code

public partial class MyChildForm : Form

{

public MyChildForm()

{

InitializeComponent();

}

} 

 

// The new code

using LinsUI;

public partial class MyChildForm : LinsUI.FlexForm

{

public MyChildForm ()

{

InitializeComponent();

// Assign a unique ID which should be between FlexConstants.m_nUserDefinedControlStartID and

// FlexConstants.m_nUserDefinedControlEndID

this.ID = FlexConstants.m_nUserDefinedControlStartID + 1;         

}

}

Inside InitializeComponent(), assign the dock style.

using LinsUI;

private void InitializeComponent()

{

//

// your existing code

//  

// Assign the dock style.

this.FlexDock = LinsUI.FLEX_DOCKING_ALIGN.LEFT;

}

You can create the derived form any where as following,

public partial class MyMDIForm : LinsUI.FlexMDIForm

{

public MyMDIForm ()

{

SuspendLayout();

InitializeComponent();

// Create a child form.

MyChildForm myChildForm =  new MyChildForm();

// Show the form.

myChildForm.ShowForm();

ResumeLayout( false );

PerformLayout();

}

}

Note: You do not need to assign a parent to the derived form. So remove all the code like this.Controls.Add( myChildForm ).

4.      Change the base class of all panels from Panel to LinsUI.FlexPanel, and assign the panel a unique ID which should be between FlexConstants.m_nUserDefinedControlStartID and FlexConstants.m_nUserDefinedControlEndID. For example,

// The old code

public partial class MyPanel : Panel

{

public MyPanel()

{

InitializeComponent();

}

}

 

// The new code

using LinsUI;

public partial class MyPanel : LinsUI.FlexPanel

{

public MyPanel ()

{

InitializeComponent();

// Assign a unique ID which should be between FlexConstants.m_nUserDefinedControlStartID and

// FlexConstants.m_nUserDefinedControlEndID

this.ID = FlexConstants.m_nUserDefinedControlStartID + 2;         

}

}

Inside InitializeComponent(), assign the dock style.

using LinsUI;

private void InitializeComponent()

{     //

// your existing code

//  

//Assign the dock style.

this.FlexDock = LinsUI.FLEX_DOCKING_ALIGN.RIGHT;

}

You can create the derived panel any where as following,

public partial class MyMDIForm : LinsUI.FlexMDIForm

{

public MyMDIForm ()

{

SuspendLayout();

InitializeComponent();

// Create a panel.

MyPanel myPanel =  new MyPanel();

// Show the panel.

myPanel.ShowPanel();

ResumeLayout( false );

PerformLayout();

}

}

Note: You do not need to assign a parent to the derived panel. So remove all the code like this.Controls.Add( myPanel ).

5.      Change the base class of all toolbars from ToolStrip to LinsUI.FlexToolStrip, and assign the toolbar a unique ID which should be between FlexConstants.m_nUserDefinedControlStartID and FlexConstants.m_nUserDefinedControlEndID. For example,

// The old code

public partial class MyToolStrip : ToolStrip

{

public MyToolStrip()

{

InitializeComponent();

}

}

 

// The new code

using LinsUI;

public partial class MyToolStrip : LinsUI.FlexToolStrip

{

public MyToolStrip ()

{

InitializeComponent();

// Assign a unique ID which should be between FlexConstants.m_nUserDefinedControlStartID and

// FlexConstants.m_nUserDefinedControlEndID

this.ID = FlexConstants.m_nUserDefinedControlStartID + 3;         

}

}

Inside InitializeComponent(), assign the dock style.

using LinsUI;

private void InitializeComponent()

{     //

// your existing code

//

// Assign the dock style.

this.FlexDock = LinsUI.FLEX_DOCKING_ALIGN.RIGHT;

}

You can create the derived toolbar any where as following,

public partial class MyMDIForm : LinsUI.FlexMDIForm

{

public MyMDIForm ()

{

SuspendLayout();

InitializeComponent();

// Create a toolbar.

MyToolStrip myToolbar =  new MyToolStrip();

// Show the toolbar.

myToolbar. ShowToolStrip(); 

ResumeLayout( false );

PerformLayout();

}

}

Note: You do not need to assign a parent to the derived toolbar. So remove all the code like this.Controls.Add( myToolbar ).

6.      Change the base class of all menu bars from MenuStrip to LinsUI.LinsMenuStrip, and assign the menu bar a unique ID which should be between FlexConstants.m_nUserDefinedControlStartID and FlexConstants.m_nUserDefinedControlEndID. For example,

// The old code

public partial class MyMenuStrip : ToolStrip

{

public MyToolStrip()

{

InitializeComponent();

}

}

 

// The new code

using LinsUI;

public partial class MyMenuStrip : LinsUI.LinsMenuStrip

{

public MyMenuStrip()

{

InitializeComponent();

//Assign a unique ID which should be between FlexConstants.m_nUserDefinedControlStartID and

//FlexConstants.m_nUserDefinedControlEndID

this.ID = FlexConstants.m_nUserDefinedControlStartID + 3;         

}

}

Example 1:

You can assign the derived menu bar as the main menu as following,

public partial class MyMDIForm : LinsUI.FlexMDIForm

{

public MyMDIForm ()

{

SuspendLayout();

InitializeComponent(); 

// Create a menu bar.

MyMenuStrip myMenubar =  new MyMenuStrip();

// Show the menu bar.

myMenubar. ShowMenuStrip();

// Set myMenubar as the main menu.

SetMenuStrip( myMenubar );

ResumeLayout( false );

PerformLayout();

}

}

Example 2:

Or you can assign the derived menu bar as a panel’s menu bar,

public partial class MyPanel : LinsUI.FlexPanel

{

public MyPanel()

{

SuspendLayout();

InitializeComponent();

// Assign a unique ID which should be between FlexConstants.m_nUserDefinedControlStartID and

// FlexConstants.m_nUserDefinedControlEndID

this.ID = FlexConstants.m_nUserDefinedControlStartID + 1;         

// Create a menu bar.

MyMenuStrip myMenubar =  new MyMenuStrip();

// Show the menu bar.

myMenubar. ShowMenuStrip();

// Set myMenubar as the menu bar of this panel.

SetMenuStrip( myMenubar ); 

ResumeLayout( false );

PerformLayout();

}

}

Note: You do not need to assign a parent to the derived menu bar. So remove all the code like this.Controls.Add( myMenubar ).

After you do all of above, you are ready to use the LinsUI Layout Manager.