private void addCardLayoutFromTemplateToolStripMenuItem_Click(object sender, EventArgs e) { const string TEMPLATE = "template"; const string NAME = "name"; const string COUNT = "count"; var listTemplateNames = new List <string>(); LayoutTemplateManager.Instance.LayoutTemplates.ForEach(x => listTemplateNames.Add(x.ToString())); var zQuery = new QueryPanelDialog("Select Layout Template", 600, false); zQuery.SetIcon(Resources.CardMakerIcon); zQuery.AddTextBox("New Layout Name", "New Layout", false, NAME); zQuery.AddNumericBox("Number to create", 1, 1, 256, COUNT); var zTxtFilter = zQuery.AddTextBox("Template Filter", string.Empty, false, TEMPLATE + NAME); var zListBoxTemplates = zQuery.AddListBox("Template", listTemplateNames.ToArray(), null, false, 240, TEMPLATE); zListBoxTemplates.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Left; zTxtFilter.TextChanged += (o, args) => { var txtBox = (TextBox)o; zListBoxTemplates.Items.Clear(); if (string.IsNullOrWhiteSpace(txtBox.Text)) { listTemplateNames.ForEach(zTemplate => zListBoxTemplates.Items.Add(zTemplate)); } else { listTemplateNames.Where(sTemplateName => sTemplateName.ToLower().Contains(txtBox.Text.ToLower())).ToList().ForEach(zTemplate => zListBoxTemplates.Items.Add(zTemplate)); } }; zQuery.AllowResize(); while (DialogResult.OK == zQuery.ShowDialog(this)) { var nSelectedIndex = listTemplateNames.IndexOf(zQuery.GetString(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; } }
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, 240, TEMPLATE) .Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; 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; } }
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; } }