private void addCardLayoutFromTemplateToolStripMenuItem_Click(object sender, EventArgs e)
{
const string TEMPLATE = "template";
const string NAME = "name";
const string COUNT = "count";
var listItems = new List<string>();
LayoutTemplateManager.Instance.LayoutTemplates.ForEach(x => listItems.Add(x.ToString()));
var zQuery = new QueryPanelDialog("Select Layout Template", 450, false);
zQuery.SetIcon(Resources.CardMakerIcon);
zQuery.AddTextBox("New Layout Name", "New Layout", false, NAME);
zQuery.AddNumericBox("Number to create", 1, 1, 256, COUNT);
zQuery.AddListBox("Template", listItems.ToArray(), null, false, 120, TEMPLATE);
zQuery.AllowResize();
while(DialogResult.OK == zQuery.ShowDialog(this))
{
int nSelectedIndex = zQuery.GetIndex(TEMPLATE);
if(-1 == nSelectedIndex)
{
MessageBox.Show("Please select a layout template");
continue;
}
ProjectLayout zSelectedLayout = LayoutTemplateManager.Instance.LayoutTemplates[nSelectedIndex].Layout;
for (int nCount = 0; nCount < zQuery.GetDecimal(COUNT); nCount++)
{
var zLayout = new ProjectLayout(zQuery.GetString(NAME));
zLayout.DeepCopy(zSelectedLayout);
ProjectManager.Instance.AddLayout(zLayout);
}
break;
}
}