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 (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 = 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); } }
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(); dialog.Dispose(); } 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, 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 (); } }