public TemplateInfoViewModel(TemplateListView view) { ThreadHelper.ThrowIfNotOnUIThread(); this.view = view; activeProject = GetActiveProject(); ProjectItem ttFolder = GetTTFolder(); if (ttFolder != null) { TemplatesInfoList = new VesObservableCollection <TemplateInfoRecord>(); ProjectItems templates = ttFolder.ProjectItems; if (templates.Count > 0) { foreach (ProjectItem template in templates) { string fileName = template.Name; if (fileName.Substring(fileName.Length - Math.Min(3, fileName.Length)) == ".tt") { TemplatesInfoList.Add(new TemplateInfoRecord { Checked = false, Name = template.Name, NameWithoutExt = Path.GetFileNameWithoutExtension(template.Name), Path = template.Properties.Item("FullPath").Value.ToString() }); } } } else { MessageBox.Show("Brak szablonów w folderze TT"); view.Close(); } } else { DialogResult dialogResult = MessageBox.Show("Czy chcesz utworzyć folder szablonów ?", "Brak folderu TT", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { Project project = GetActiveProject(); project.ProjectItems.AddFolder("TT"); } view.Close(); } }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void Execute(object sender, EventArgs e) { TemplateListView window = new TemplateListView(); window.Show(); }