protected virtual void ShowMasterSelectionDialog(object sender, EventArgs e) { string pattern, title; if (ActiveViewEngine == "Razor") { pattern = "*.cshtml"; title = GettextCatalog.GetString("Select a Layout file..."); } else { pattern = "*.master"; title = GettextCatalog.GetString("Select a Master Page..."); } var dialog = new MonoDevelop.Ide.Projects.ProjectFileSelectorDialog(project, null, pattern) { Title = title, TransientFor = this, }; try { if (MessageService.RunCustomDialog(dialog) == (int)ResponseType.Ok) { masterEntry.Text = project.LocalToVirtualPath(dialog.SelectedFile.FilePath); } } finally { dialog.Destroy(); } }
public override void ModifyTags (MonoDevelop.Projects.SolutionItem policyParent, MonoDevelop.Projects.Project project, string language, string identifier, string fileName, ref Dictionary<string,string> tags) { base.ModifyTags (policyParent, project, language, identifier, fileName, ref tags); if (fileName == null) return; tags ["AspNetMaster"] = ""; tags ["AspNetMasterContent"] = ""; AspNetAppProject aspProj = project as AspNetAppProject; if (aspProj == null) throw new InvalidOperationException ("MasterContentFileDescriptionTemplate is only valid for ASP.NET projects"); ProjectFile masterPage = null; var dialog = new MonoDevelop.Ide.Projects.ProjectFileSelectorDialog (aspProj, null, "*.master"); try { dialog.Title = GettextCatalog.GetString ("Select a Master Page..."); int response = MonoDevelop.Ide.MessageService.RunCustomDialog (dialog); if (response == (int)Gtk.ResponseType.Ok) masterPage = dialog.SelectedFile; } finally { dialog.Destroy (); } if (masterPage == null) return; tags ["AspNetMaster"] = aspProj.LocalToVirtualPath (masterPage); try { var pd = TypeSystemService.ParseFile (project, masterPage.FilePath) as AspNetParsedDocument; if (pd == null) return; //var visitor = new ContentPlaceHolderVisitor (); //pd.RootNode.AcceptVisit (visitor); List<string> placeHolderIds = new List<string> (); BuildPlaceholderList (placeHolderIds, pd.XDocument); var sb = new System.Text.StringBuilder (); foreach (string id in placeHolderIds) { sb.Append ("<asp:Content ContentPlaceHolderID=\""); sb.Append (id); sb.Append ("\" ID=\""); sb.Append (id); sb.Append ("Content\" runat=\"server\">\n</asp:Content>\n"); } tags["AspNetMasterContent"] = sb.ToString (); } catch (Exception ex) { //no big loss if we just insert blank space //it's just a template for the user to start editing LoggingService.LogWarning ("Error generating AspNetMasterContent for template", ex); } }
protected virtual void ShowMasterSelectionDialog(object sender, System.EventArgs e) { var dialog = new MonoDevelop.Ide.Projects.ProjectFileSelectorDialog(project, null, "*.master") { Title = MonoDevelop.Core.GettextCatalog.GetString("Select a Master Page..."), TransientFor = this, }; try { if (MessageService.RunCustomDialog(dialog) == (int)Gtk.ResponseType.Ok) { masterEntry.Text = project.LocalToVirtualPath(dialog.SelectedFile.FilePath); } } finally { dialog.Destroy(); } }
public override void InsertCompletionText(CompletionListWindow window, ref KeyActions ka, Gdk.Key closeChar, char keyChar, Gdk.ModifierType modifier) { string text; var dialog = new MonoDevelop.Ide.Projects.ProjectFileSelectorDialog(proj, "", pattern); try { if (MessageService.RunCustomDialog(dialog) != (int)Gtk.ResponseType.Ok || dialog.SelectedFile == null) { return; } text = pathFunc(dialog.SelectedFile); } finally { dialog.Destroy(); } window.CompletionWidget.SetCompletionText(window.CodeCompletionContext, "", text); }
public override Task <KeyActions> InsertCompletionText(CompletionListWindow window, KeyActions ka, KeyDescriptor descriptor) { string text; var dialog = new MonoDevelop.Ide.Projects.ProjectFileSelectorDialog(proj, "", pattern); try { if (MessageService.RunCustomDialog(dialog) != (int)Gtk.ResponseType.Ok || dialog.SelectedFile == null) { return(Task.FromResult(ka)); } text = pathFunc(dialog.SelectedFile); } finally { dialog.Destroy(); dialog.Dispose(); } window.CompletionWidget.SetCompletionText(window.CodeCompletionContext, "", text); return(Task.FromResult(ka)); }
public override void ModifyTags(SolutionFolderItem policyParent, Project project, string language, string identifier, string fileName, ref Dictionary <string, string> tags) { base.ModifyTags(policyParent, project, language, identifier, fileName, ref tags); if (fileName == null) { return; } tags ["AspNetMaster"] = ""; tags ["AspNetMasterContent"] = ""; var aspProj = project.GetService <AspNetAppProjectFlavor> (); if (aspProj == null) { throw new InvalidOperationException("MasterContentFileDescriptionTemplate is only valid for ASP.NET projects"); } ProjectFile masterPage = null; var dialog = new MonoDevelop.Ide.Projects.ProjectFileSelectorDialog(project, null, "*.master"); try { dialog.Title = GettextCatalog.GetString("Select a Master Page..."); int response = MonoDevelop.Ide.MessageService.RunCustomDialog(dialog); if (response == (int)Gtk.ResponseType.Ok) { masterPage = dialog.SelectedFile; } } finally { dialog.Destroy(); dialog.Dispose(); } if (masterPage == null) { return; } tags ["AspNetMaster"] = aspProj.LocalToVirtualPath(masterPage); try { var pd = IdeApp.TypeSystemService.ParseFile(project, masterPage.FilePath).Result as WebFormsParsedDocument; if (pd == null) { return; } var sb = new System.Text.StringBuilder(); foreach (string id in pd.XDocument.GetAllPlaceholderIds()) { sb.Append("<asp:Content ContentPlaceHolderID=\""); sb.Append(id); sb.Append("\" ID=\""); sb.Append(id); sb.Append("Content\" runat=\"server\">\n</asp:Content>\n"); } tags["AspNetMasterContent"] = sb.ToString(); } catch (Exception ex) { //no big loss if we just insert blank space //it's just a template for the user to start editing LoggingService.LogWarning("Error generating AspNetMasterContent for template", ex); } }
protected virtual void ShowMasterSelectionDialog (object sender, System.EventArgs e) { var dialog = new MonoDevelop.Ide.Projects.ProjectFileSelectorDialog (project, null, "*.master") { Title = MonoDevelop.Core.GettextCatalog.GetString ("Select a Master Page..."), TransientFor = this, }; try { if (MessageService.RunCustomDialog (dialog) == (int) Gtk.ResponseType.Ok) masterEntry.Text = project.LocalToVirtualPath (dialog.SelectedFile.FilePath); } finally { dialog.Destroy (); } }
protected virtual void ShowMasterSelectionDialog (object sender, EventArgs e) { string pattern, title; if (ActiveViewEngine == "Razor") { pattern = "*.cshtml"; title = GettextCatalog.GetString ("Select a Layout file..."); } else { pattern = "*.master"; title = GettextCatalog.GetString ("Select a Master Page..."); } var dialog = new MonoDevelop.Ide.Projects.ProjectFileSelectorDialog (project, null, pattern) { Title = title, TransientFor = this, }; try { if (MessageService.RunCustomDialog (dialog) == (int) ResponseType.Ok) masterEntry.Text = aspFlavor.LocalToVirtualPath (dialog.SelectedFile.FilePath); } finally { dialog.Destroy (); dialog.Dispose (); } }
public override void ModifyTags(MonoDevelop.Projects.SolutionItem policyParent, MonoDevelop.Projects.Project project, string language, string identifier, string fileName, ref Dictionary <string, string> tags) { base.ModifyTags(policyParent, project, language, identifier, fileName, ref tags); if (fileName == null) { return; } tags["AspNetMaster"] = ""; tags["AspNetMasterContent"] = ""; AspNetAppProject aspProj = project as AspNetAppProject; if (aspProj == null) { throw new InvalidOperationException("MasterContentFileDescriptionTemplate is only valid for ASP.NET projects"); } ProjectFile masterPage = null; string masterContent = ""; var dialog = new MonoDevelop.Ide.Projects.ProjectFileSelectorDialog(aspProj, null, "*.master"); try { dialog.Title = GettextCatalog.GetString("Select a Master Page..."); int response = MonoDevelop.Ide.MessageService.RunCustomDialog(dialog); if (response == (int)Gtk.ResponseType.Ok) { masterPage = dialog.SelectedFile; } } finally { dialog.Destroy(); } if (masterPage == null) { return; } tags["AspNetMaster"] = aspProj.LocalToVirtualPath(masterPage); try { AspNetParsedDocument pd = ProjectDomService.GetParsedDocument(ProjectDomService.GetProjectDom(project), masterPage.FilePath) as AspNetParsedDocument; if (pd == null) { return; } ContentPlaceHolderVisitor visitor = new ContentPlaceHolderVisitor(); pd.RootNode.AcceptVisit(visitor); System.Text.StringBuilder sb = new System.Text.StringBuilder(); foreach (string id in visitor.PlaceHolders) { sb.Append("<asp:Content ContentPlaceHolderID=\""); sb.Append(id); sb.Append("\" ID=\""); sb.Append(id); sb.Append("Content\" runat=\"server\">\n</asp:Content>\n"); } tags["AspNetMasterContent"] = sb.ToString(); } catch (Exception ex) { //no big loss if we just insert blank space //it's just a template for the user to start editing } }