private void OnSelectedIndexChangedCategoryListBox(object sender, EventArgs e) { this._currentTemplateItem = null; this._templateListView.Items.Clear(); TemplateCategory selectedItem = this._categoryListBox.SelectedItem as TemplateCategory; if (selectedItem != null) { foreach (ListViewItem item in selectedItem.Items) { this._templateListView.Items.Add(item); } if (selectedItem.Items.Count != 0) { this._templateListView.Items[0].Selected = true; } } }
private void OnSelectedIndexChangedTemplateListView(object sender, EventArgs e) { this._currentTemplateItem = null; this._internalChange = true; try { this._fileNameText.Clear(); this._classInfoCheckBox.Checked = false; this._classInfoCheckBox.Enabled = false; this._classLabel.Visible = false; this._classText.Clear(); this._classText.Visible = false; this._namespaceLabel.Visible = false; this._namespaceText.Clear(); this._namespaceText.Visible = false; } finally { this._internalChange = false; } bool flag = false; bool flag2 = false; if (this._templateListView.SelectedItems.Count != 0) { this._currentTemplateItem = (TemplateListViewItem) this._templateListView.SelectedItems[0]; this._internalChange = true; try { string codeLanguageFileExtension; if ((this._currentTemplateItem.DocumentType.TemplateFlags & TemplateFlags.IsCode) != TemplateFlags.None) { codeLanguageFileExtension = this.GetCodeLanguageFileExtension(); } else { codeLanguageFileExtension = this._currentTemplateItem.DocumentType.Extension.ToLower(); } this._fileNameText.Text = this._currentTemplateItem.DocumentType.TemplateInstanceFileName + "." + codeLanguageFileExtension; if ((this._location == null) && (this._locationText.Text.Trim().Length == 0)) { PreferencesStore store; string folderPath = string.Empty; IPreferencesService service = (IPreferencesService) this.GetService(typeof(IPreferencesService)); if (service.GetPreferencesStore(typeof(AddFileDialog), out store)) { folderPath = store.GetValue("Location", string.Empty); } if (folderPath.Length == 0) { folderPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); } this._locationText.Text = folderPath; this._locationText.Select(0, 0); } if (this._languageCombo.Items.Count == 0) { this._languageCombo.Items.AddRange(this._codeLanguages.ToArray()); } flag = (this._currentTemplateItem.DocumentType.TemplateFlags & TemplateFlags.HasCode) != TemplateFlags.None; if ((this._languageCombo.SelectedIndex == -1) && flag) { this._languageCombo.SelectedItem = this._defaultLanguage; } if (flag) { flag2 = (this._currentTemplateItem.DocumentType.TemplateFlags & (TemplateFlags.CodeRequiresClassName | TemplateFlags.CodeRequiresNamespace)) != TemplateFlags.None; if (flag2) { this._classInfoCheckBox.Checked = true; this._classLabel.Visible = true; this._classText.Visible = true; this._namespaceLabel.Visible = true; this._namespaceText.Visible = true; } else { this._classInfoCheckBox.Enabled = true; } } } finally { this._internalChange = false; } } if (flag) { if (flag2) { this._classInfoCheckBox.Text = "&Specify class information"; } else { this._classInfoCheckBox.Text = "&Specify optional class information"; } } this._codeGroup.Visible = flag; this._languageLabel.Visible = flag; this._languageCombo.Visible = flag; this._classInfoCheckBox.Visible = flag; this.UpdateUIState(); }
private void LoadTemplates() { IDocumentTypeManager service = (IDocumentTypeManager) this.GetService(typeof(IDocumentTypeManager)); TemplateCategory category = new TemplateCategory("(General)"); this._templateCategories = new HybridDictionary(true); this._templateCategories.Add("General", category); ICollection creatableDocumentTypes = service.CreatableDocumentTypes; if ((creatableDocumentTypes != null) && (creatableDocumentTypes.Count != 0)) { ImageList list = new ImageList(); ImageList list2 = new ImageList(); list.ImageSize = new Size(0x20, 0x20); list.ColorDepth = ColorDepth.Depth32Bit; this._templateListView.LargeImageList = list; list2.ImageSize = new Size(0x10, 0x10); list2.ColorDepth = ColorDepth.Depth32Bit; this._templateListView.SmallImageList = list2; ImageList.ImageCollection images = list.Images; ImageList.ImageCollection images2 = list2.Images; foreach (DocumentType type in creatableDocumentTypes) { images.Add(type.LargeIcon); images2.Add(type.SmallIcon); TemplateListViewItem item = new TemplateListViewItem(type, images.Count - 1); string templateCategory = type.TemplateCategory; if ((templateCategory == null) || (templateCategory.Length == 0)) { category.Items.Add(item); continue; } TemplateCategory category2 = (TemplateCategory) this._templateCategories[templateCategory]; if (category2 != null) { category2.Items.Add(item); } else { category2 = new TemplateCategory(templateCategory); category2.Items.Add(item); this._templateCategories.Add(templateCategory, category2); } } } foreach (TemplateCategory category3 in this._templateCategories.Values) { this._categoryListBox.Items.Add(category3); } this._categoryListBox.SelectedItem = category; if (this._fileNameText.Enabled) { this._fileNameText.Focus(); } }