/// <summary> /// Handles the Click event of the EditTemplatesButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void EditTemplatesButton_Click(object sender, EventArgs e) { // Prepare the edit templates dialog EditApplyTemplates editTemplates = new EditApplyTemplates(); ApplyTemplate comboTemplate = null; foreach (object comboObject in this.SelectedTemplate.Items) { comboTemplate = comboObject as ApplyTemplate; if (!string.IsNullOrEmpty(comboTemplate.FileLocation)) { editTemplates.ProjectTemplatesItems.Add(comboTemplate); } } // Show the dialog and check the result if (editTemplates.ShowDialog() == DialogResult.OK) { // Remember which item is selected Guid selectedId = (this.SelectedTemplate.SelectedItem as ApplyTemplate).Id; // Remove any templates which are not part of the Studio default list int itemCount = 0; while (itemCount < this.SelectedTemplate.Items.Count) { comboTemplate = this.SelectedTemplate.Items[itemCount] as ApplyTemplate; if (comboTemplate.Uri == null) { this.SelectedTemplate.Items.RemoveAt(itemCount); } else { itemCount++; } } // Add in each template from the dialog foreach (object o in editTemplates.ProjectTemplatesItems) { this.SelectedTemplate.Items.Add(o); } // Add a default template if necessary if (this.SelectedTemplate.Items.Count == 0) { this.SelectedTemplate.Items.Add(new ApplyTemplate("<none>")); } // Select the previously selected template this.SelectTemplate(selectedId); } }
/// <summary> /// Handles the Click event of the EditTemplatesButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void EditTemplatesButton_Click(object sender, EventArgs e) { // Prepare the edit templates dialog EditApplyTemplates editTemplates = new EditApplyTemplates(); ApplyTemplate comboTemplate = null; foreach (object comboObject in this.SelectedTemplate.Items) { comboTemplate = comboObject as ApplyTemplate; if (!string.IsNullOrEmpty(comboTemplate.FileLocation)) { editTemplates.ProjectTemplatesItems.Add(comboTemplate); } } // Show the dialog and check the result if (editTemplates.ShowDialog() == DialogResult.OK) { // Remember which item is selected Guid selectedId = (this.SelectedTemplate.SelectedItem as ApplyTemplate).Id; // Remove any templates which are not part of the Studio default list int itemCount = 0; while (itemCount < this.SelectedTemplate.Items.Count) { comboTemplate = this.SelectedTemplate.Items[itemCount] as ApplyTemplate; if (comboTemplate.Uri == null) { this.SelectedTemplate.Items.RemoveAt(itemCount); } else { itemCount++; } } // Add in each template from the dialog foreach (object o in editTemplates.ProjectTemplatesItems) { this.SelectedTemplate.Items.Add(o); } // Add a default template if necessary if (this.SelectedTemplate.Items.Count == 0) { this.SelectedTemplate.Items.Add(new ApplyTemplate("<none>")); } // Select the previously selected template this.SelectTemplate(selectedId); } }