private void removeLayoutTemplatesToolStripMenuItem_Click(object sender, EventArgs e)
{
const string TEMPLATE = "template";
var listItems = new List<string>();
LayoutTemplateManager.Instance.LayoutTemplates.ForEach(x => listItems.Add(x.ToString()));
var zQuery = new QueryPanelDialog("Remove Layout Templates", 450, false);
zQuery.SetIcon(Properties.Resources.CardMakerIcon);
zQuery.AddLabel("Select the templates to remove.", 20);
zQuery.AddListBox("Templates", listItems.ToArray(), null, true, 120, TEMPLATE);
zQuery.AllowResize();
if (DialogResult.OK == zQuery.ShowDialog(this))
{
var arrayRemove = zQuery.GetIndices(TEMPLATE);
if (0 == arrayRemove.Length)
{
return;
}
var trimmedList = new List<LayoutTemplate>();
int removalIdx = 0;
List<LayoutTemplate> listOldTemplates = LayoutTemplateManager.Instance.LayoutTemplates;
for (int nIdx = 0; nIdx < listOldTemplates.Count; nIdx++)
{
if (removalIdx < arrayRemove.Length && nIdx == arrayRemove[removalIdx])
{
removalIdx++;
// delete failures are logged
LayoutTemplateManager.Instance.DeleteLayoutTemplate(CardMakerInstance.StartupPath, listOldTemplates[nIdx]);
}
else
{
trimmedList.Add(listOldTemplates[nIdx]);
}
}
LayoutTemplateManager.Instance.LayoutTemplates = trimmedList;
}
}