Creating a Custom ToolStrip
You can implement your own toolstrip to use with C1XmlEditor by using the C1XmlEditorToolStripBase as a base class and adding buttons.
The following code is an example of a toolbar with three buttons: Cut, Copy, and Paste.
using C1.Win.XmlEditor;
using C1.Win.XmlEditor.ToolStrips;
namespace C1XmlEditorCustomToolStrip
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public enum CommandButton
{
Cut,
Copy,
Paste
}
public class MyToolStrip : XmlEditorToolStripBase
{
protected override void OnInitialize()
{
AddButton(C1.Win.XmlEditor.ToolStrips.CommandButton.Cut);
AddButton(C1.Win.XmlEditor.ToolStrips.CommandButton.Copy);
AddButton(C1.Win.XmlEditor.ToolStrips.CommandButton.Paste);
}
}
public class XmlEditorToolStripButton : ToolStripButton
{
public C1XmlEditor Editor { get; set; }
public CommandButton Command { get; set; }
}
private void Form1_Load(object sender, EventArgs e)
{
// Using MyToolStrip in an application:
MyToolStrip toolStrip = new MyToolStrip();
this.Controls.Add(toolStrip);
toolStrip.Editor = c1XmlEditor1;
}
}
}
|