public static void DispatchLink(string uri) { try { if (uri.StartsWith("project://")) { string file = uri.Substring("project://".Length); Gdk.ModifierType mtype = Mono.TextEditor.GtkWorkarounds.GetCurrentKeyModifiers(); bool inWorkspace = (mtype & Gdk.ModifierType.ControlMask) != 0; // Notify the RecentFiles that this item does not exist anymore. // Possible other solution would be to check the recent projects list on focus in // and update them accordingly. if (!System.IO.File.Exists(file)) { MessageService.ShowError(GettextCatalog.GetString("File not found {0}", file)); FileService.NotifyFileRemoved(file); return; } IdeApp.Workspace.OpenWorkspaceItem(file, !inWorkspace); } else if (uri.StartsWith("monodevelop://")) { var cmdId = uri.Substring("monodevelop://".Length); IdeApp.CommandService.DispatchCommand(cmdId, MonoDevelop.Components.Commands.CommandSource.WelcomePage); } else { DesktopService.ShowUrl(uri); } } catch (Exception ex) { LoggingService.LogInternalError(GettextCatalog.GetString("Could not open the url '{0}'", uri), ex); } }
void ShowDocumentation() { if (HasDocumentationLink()) { DesktopService.ShowUrl(DocumentationLink); } }
public virtual void JumpToPosition() { if (HasDocumentationLink()) { DesktopService.ShowUrl(DocumentationLink); } if (!file.IsNullOrEmpty) { if (System.IO.File.Exists(file)) { var project = WorkspaceObject as Project; IdeApp.Workbench.OpenDocument(file, project, Math.Max(1, line), Math.Max(1, column)); } else { var pad = IdeApp.Workbench.GetPad <ErrorListPad> ()?.Content as ErrorListPad; pad?.FocusOutputView(); } } else if (parentObject != null) { Pad pad = IdeApp.Workbench.GetPad <ProjectSolutionPad> (); ProjectSolutionPad spad = pad.Content as ProjectSolutionPad; ITreeNavigator nav = spad.TreeView.GetNodeAtObject(parentObject, true); if (nav != null) { nav.ExpandToNode(); nav.Selected = true; nav.Expanded = true; } } TaskService.InformJumpToTask(this); }
void DispatchLink(string uri) { try { if (uri.StartsWith("project://")) { string projectUri = uri.Substring("project://".Length); Uri fileuri = new Uri(projectUri); Gdk.ModifierType mtype; bool inWorkspace = Gtk.Global.GetCurrentEventState(out mtype) && (mtype & Gdk.ModifierType.ControlMask) != 0; IdeApp.Workspace.OpenWorkspaceItem(fileuri.LocalPath, !inWorkspace); } else if (uri.StartsWith("monodevelop://")) { var cmdId = uri.Substring("monodevelop://".Length); var cmd = IdeApp.CommandService.GetCommand(cmdId); IdeApp.CommandService.DispatchCommand(cmdId, MonoDevelop.Components.Commands.CommandSource.WelcomePage); } else { DesktopService.ShowUrl(uri); } } catch (Exception ex) { MessageService.ShowException(ex, GettextCatalog.GetString("Could not open the url '{0}'", uri)); } }
void AlertButtonClicked(object sender, AlertButtonEventArgs e) { if (e.Button == downloadButton) { DesktopService.ShowUrl(downloadUrl); } }
void Install(Gtk.Alignment commandBox, Button installButton, Update update) { if (update.InstallAction == null) { DesktopService.ShowUrl(update.Url); return; } installButton.Hide(); if (installing) { Gtk.Label lab = new Gtk.Label(GettextCatalog.GetString("Waiting")); commandBox.Child.Destroy(); commandBox.Add(lab); lab.Show(); installQueue.Enqueue(delegate { lab.Hide(); RunInstall(commandBox, update); }); return; } RunInstall(commandBox, update); }
void EventBoxLink_KeyPressEvent(object o, KeyPressEventArgs args) { if (args.Event.Key == Gdk.Key.KP_Enter || args.Event.Key == Gdk.Key.KP_Space) { DesktopService.ShowUrl(exceptionHelpLink); } }
void InnerExceptionHelpLinkLabel_KeyPressEvent(object o, KeyPressEventArgs args) { if (args.Event.Key == Gdk.Key.KP_Enter || args.Event.Key == Gdk.Key.KP_Space) { DesktopService.ShowUrl(innerExceptionHelpLink); } }
protected override void Run() { string token = GetCurrentToken(); string baseToken = GetBaseToken(token); if (string.IsNullOrEmpty(token)) { DesktopService.ShowUrl(string.Format("file://{0}/{1}", apiBase, classReferencePage)); return; } // Fallback to class reference root if no token found var baseUrls = new[] { token, token.Replace('.', '-'), baseToken }; foreach (string baseUrl in baseUrls) { string url = string.Format("{0}/{1}.html", apiBase, baseUrl); if (File.Exists(url)) { DesktopService.ShowUrl(string.Format("file://{0}", url)); return; } // Open local match } // Fall back to online search DesktopService.ShowUrl(string.Format("{0}/{1}?q={2}", onlineApiBase, searchPage, baseToken)); }
public void OpenBug(BugInfo b) { string url = useSSL ? "https" : "http"; url += "://" + host + "/show_bug.cgi?id=" + b.Id; DesktopService.ShowUrl(url); }
void AddPackage(PackageLicenseViewModel package) { var titleBox = new VBox(); titleBox.Spacing = 0; titleBox.MarginBottom = 4; titleBox.PackStart(new Label { Markup = string.Format("<span weight='bold'>{0}</span> – {1}", package.Id, package.Author), }); var licenseLabel = new LinkLabel(GettextCatalog.GetString("View License")); licenseLabel.Uri = package.LicenseUrl; licenseLabel.LinkClicked += (sender, e) => DesktopService.ShowUrl(e.Target.AbsoluteUri); titleBox.PackStart(licenseLabel); var rowBox = new HBox(); rowBox.Margin = rowMargin; var icon = new ImageView(ImageService.GetIcon("md-package", Gtk.IconSize.Dnd)); if (package.IconUrl != null && !string.IsNullOrEmpty(package.IconUrl.AbsoluteUri)) { imageLoader.LoadFrom(package.IconUrl, icon); } rowBox.PackStart(icon); rowBox.PackStart(titleBox, true); packagesList.PackStart(rowBox); }
void OnShowReference(object o, EventArgs args) { string reference = null; if (GetSelectedErrorReference(out reference) && reference != null) { DesktopService.ShowUrl(reference); } }
protected override void Run() { var url = GetUrl(); if (url != null) { DesktopService.ShowUrl(url); } }
public static IProcessAsyncOperation LaunchDefaultBrowser(string url) { try { DesktopService.ShowUrl(url); return(NullProcessAsyncOperation.Success); } catch (Exception ex) { MessageService.ShowError(GettextCatalog.GetString("Error launching web browser"), ex.ToString()); return(NullProcessAsyncOperation.Failure); } }
internal static void ShowTipWindow() { var tipLoader = new TipLoader(); if (!tipLoader.LoadTips().Result) { return; } var oldMainWindow = NSApplication.SharedApplication.KeyWindow ?? NSApplication.SharedApplication.MainWindow ?? GtkQuartz.GetWindow(MessageService.RootWindow); using (var tipWindow = InflateFromNibResource <TipWindow> ("__xammac_content_TipWindow.nib")) { tipWindow.ParentWindow = oldMainWindow; tipWindow.MakeKeyAndOrderFront(tipWindow); tipWindow.ShowAtStartup = StartupHandler.ShowAtStartup; FilePath sharedAssetsPath = Mono.Addins.AddinManager.CurrentAddin.GetFilePath("content"); tipWindow.HandleUrlOpen = s => { if (s.IsFile) { return(false); } DesktopService.ShowUrl(s.ToString()); return(true); }; void nextMessage(object sender, EventArgs e) { string html; string basePath = sharedAssetsPath; try { var tip = tipLoader.GetNextTip(); basePath = System.IO.Path.GetDirectoryName(tip.Filename); html = new TipView(tip, sharedAssetsPath).GenerateString(); } catch (Exception ex) { html = $"<h1>Error</h1><p>{ex.ToString ()}</p>"; } tipWindow.LoadHtml(html, basePath); } tipWindow.NextTipClicked += nextMessage; nextMessage(null, null); tipWindow.Run(); StartupHandler.ShowAtStartup = tipWindow.ShowAtStartup; } GtkQuartz.FocusWindow(GtkQuartz.GetGtkWindow(oldMainWindow) ?? MessageService.RootWindow); }
public void HandleLinkAction(string uri) { // HACK: Necessary for win32; I have no idea why if (PlatformID.Unix != Environment.OSVersion.Platform) { Console.WriteLine("WelcomePage: Handling URI: " + uri); } if (uri.StartsWith("project://")) { if (loadingProject) { return; } string projectUri = uri.Substring(10); Uri fileuri = new Uri(projectUri); try { loadingProject = true; Gdk.ModifierType mtype; bool inWorkspace = Gtk.Global.GetCurrentEventState(out mtype) && (mtype & Gdk.ModifierType.ControlMask) != 0; IAsyncOperation oper = IdeApp.Workspace.OpenWorkspaceItem(fileuri.LocalPath, !inWorkspace); oper.WaitForCompleted(); } finally { loadingProject = false; } } else if (uri.StartsWith("monodevelop://")) { // Launch MonoDevelop Gui Commands switch (uri.Substring(14)) { case "NewProject": IdeApp.CommandService.DispatchCommand(FileCommands.NewProject); break; case "OpenFile": IdeApp.CommandService.DispatchCommand(FileCommands.OpenFile); break; } } else { //Launch the Uri externally try { DesktopService.ShowUrl(uri); } catch (Exception ex) { MessageService.ShowException(ex, GettextCatalog.GetString("Could not open the url '{0}'", uri)); } } }
public static async Task LaunchBrowser(string appUrl, string launchUrl, Task processTask) { launchUrl = launchUrl ?? ""; Uri launchUri; //Check if lanuchUrl is valid absolute url and use it if it is... if (!Uri.TryCreate(launchUrl, UriKind.Absolute, out launchUri)) { //Otherwise check if appUrl is valid absolute and lanuchUrl is relative then concat them... Uri appUri; if (!Uri.TryCreate(appUrl, UriKind.Absolute, out appUri)) { LoggingService.LogWarning("Failed to launch browser because invalid launch and app urls."); return; } if (!Uri.TryCreate(launchUrl, UriKind.Relative, out launchUri)) { LoggingService.LogWarning("Failed to launch browser because invalid launch url."); return; } launchUri = new Uri(appUri, launchUri); } //Try to connect every 50ms while process is running while (!processTask.IsCompleted) { await Task.Delay(50); using (var tcpClient = new TcpClient()) { try { tcpClient.Connect(launchUri.Host, launchUri.Port); // pause briefly to allow the server process to initialize await Task.Delay(TimeSpan.FromSeconds(1)); break; } catch { } } } if (processTask.IsCompleted) { LoggingService.LogDebug("Failed to launch browser because process exited before server started listening."); return; } // Process is still alive hence we succesfully connected inside loop to web server, launch browser DesktopService.ShowUrl(launchUri.AbsoluteUri); }
protected async override void Run() { try { var gistUrl = await GistCommandHelper.CreateGist(); DesktopService.ShowUrl(gistUrl); IdeApp.Workbench.StatusBar.ShowMessage(Stock.Ok, "Gist created."); } catch (Exception e) { LoggingService.LogError("Unable to create Gist.", e); IdeApp.Workbench.StatusBar.ShowMessage(Stock.Cancel, "Failed to create gist."); } }
public static void DispatchLink(string uri) { try { if (uri.StartsWith("project://")) { string file = uri.Substring("project://".Length); Gdk.ModifierType mtype = GtkWorkarounds.GetCurrentKeyModifiers(); bool inWorkspace = (mtype & Gdk.ModifierType.ControlMask) != 0; if (Platform.IsMac && !inWorkspace) { inWorkspace = (mtype & Gdk.ModifierType.Mod2Mask) != 0; } // Notify the RecentFiles that this item does not exist anymore. // Possible other solution would be to check the recent projects list on focus in // and update them accordingly. if (!System.IO.File.Exists(file)) { var res = MessageService.AskQuestion( GettextCatalog.GetString("{0} could not be opened", file), GettextCatalog.GetString("Do you want to remove the reference to it from the Recent list?"), AlertButton.No, AlertButton.Yes); if (res == AlertButton.Yes) { FileService.NotifyFileRemoved(file); } return; } IdeApp.Workspace.OpenWorkspaceItem(file, !inWorkspace); } else if (uri.StartsWith("monodevelop://")) { var cmdId = uri.Substring("monodevelop://".Length); IdeApp.CommandService.DispatchCommand(cmdId, MonoDevelop.Components.Commands.CommandSource.WelcomePage); } else { DesktopService.ShowUrl(uri); } } catch (Exception ex) { LoggingService.LogInternalError(GettextCatalog.GetString("Could not open the url '{0}'", uri), ex); } }
Widget CreateInnerExceptionMessage() { var hboxMain = new HBox(); vboxAroundInnerExceptionMessage = new VBox(); var hbox = new HBox(); var icon = new ImageView(WarningIconPixbufInner); icon.Yalign = 0; hbox.PackStart(icon, false, false, 0); InnerExceptionTypeLabel = new Label(); InnerExceptionTypeLabel.UseMarkup = true; InnerExceptionTypeLabel.Xalign = 0; InnerExceptionTypeLabel.Selectable = true; InnerExceptionTypeLabel.CanFocus = false; hbox.PackStart(InnerExceptionTypeLabel, false, true, 4); InnerExceptionMessageLabel = new Label(); InnerExceptionMessageLabel.Wrap = true; InnerExceptionMessageLabel.Selectable = true; InnerExceptionMessageLabel.CanFocus = false; InnerExceptionMessageLabel.Xalign = 0; InnerExceptionMessageLabel.ModifyFont(Pango.FontDescription.FromString(Platform.IsWindows ? "9" : "11")); InnerExceptionHelpLinkLabel = new Label(); InnerExceptionHelpLinkLabel.UseMarkup = true; InnerExceptionHelpLinkLabel.Wrap = true; InnerExceptionHelpLinkLabel.LineWrapMode = Pango.WrapMode.Char; InnerExceptionHelpLinkLabel.Selectable = true; InnerExceptionHelpLinkLabel.CanFocus = false; InnerExceptionHelpLinkLabel.Xalign = 0; InnerExceptionHelpLinkLabel.ModifyFont(Pango.FontDescription.FromString(Platform.IsWindows ? "9" : "11")); InnerExceptionHelpLinkLabel.SetLinkHandler((str) => DesktopService.ShowUrl(str)); vboxAroundInnerExceptionMessage.PackStart(hbox, false, true, 0); vboxAroundInnerExceptionMessage.PackStart(InnerExceptionMessageLabel, true, true, 10); vboxAroundInnerExceptionMessage.PackStart(InnerExceptionHelpLinkLabel, true, true, 2); hboxMain.PackStart(vboxAroundInnerExceptionMessage, true, true, 10); hboxMain.ShowAll(); return(hboxMain); }
public static void ShowDotNetCoreNotInstalledError(DotNetCoreNotFoundException ex) { var message = new GenericMessage(ex.Message, ex.Details); var downloadButton = new AlertButton(GettextCatalog.GetString("Go to download")); message.Icon = Stock.Error; message.Buttons.Add(downloadButton); message.Buttons.Add(AlertButton.Ok); message.DefaultButton = 1; var dialog = new AlertDialog(message); dialog.TransientFor = IdeApp.Workbench.RootWindow; var result = dialog.Run(); if (result == downloadButton) { DesktopService.ShowUrl("https://www.microsoft.com/net/core"); } }
void DispatchLink(string uri) { try { if (uri.StartsWith("project://")) { string file = uri.Substring("project://".Length); Gdk.ModifierType mtype = Mono.TextEditor.GtkWorkarounds.GetCurrentKeyModifiers(); bool inWorkspace = (mtype & Gdk.ModifierType.ControlMask) != 0; IdeApp.Workspace.OpenWorkspaceItem(file, !inWorkspace); } else if (uri.StartsWith("monodevelop://")) { var cmdId = uri.Substring("monodevelop://".Length); IdeApp.CommandService.DispatchCommand(cmdId, MonoDevelop.Components.Commands.CommandSource.WelcomePage); } else { DesktopService.ShowUrl(uri); } } catch (Exception ex) { LoggingService.LogInternalError(GettextCatalog.GetString("Could not open the url '{0}'", uri), ex); } }
void Install(HBox labelBox, Button installButton, Update update) { if (update.InstallAction == null) { DesktopService.ShowUrl(update.Url); return; } installButton.Hide(); if (installing) { Gtk.Label lab = new Gtk.Label(GettextCatalog.GetString("Waiting")); labelBox.PackStart(lab, false, false, 0); lab.Show(); installQueue.Enqueue(delegate { lab.Hide(); RunInstall(labelBox, update); }); return; } RunInstall(labelBox, update); }
void LoadUpdates(List <Update> updates) { if (updates == null || updates.Count == 0) { SetMessage(GettextCatalog.GetString("No updates available")); return; } foreach (var c in productBox.Children) { productBox.Remove(c); c.Destroy(); } productBox.Spacing = 0; foreach (var update in updates) { var updateBox = new VBox() { Spacing = 2 }; var labelBox = new HBox(); updateBox.PackStart(labelBox, false, false, 0); string warning = null; switch (update.Level) { case UpdateLevel.Alpha: warning = GettextCatalog.GetString("ALPHA"); break; case UpdateLevel.Beta: warning = GettextCatalog.GetString("BETA"); break; case UpdateLevel.Test: warning = GettextCatalog.GetString("TEST"); break; } if (warning != null) { warning = "<b><span color=\"#DD1111\">" + warning + "</span></b>"; } var updateExpander = new Expander(""); updateExpander.LabelWidget = new Label() { Markup = string.Format("<b>{0}</b>\n{1} ({2:yyyy-MM-dd}) {3}", update.Name, update.Version, update.Date, warning ?? ""), }; labelBox.PackStart(updateExpander, true, true, 0); var downloadButton = new Button() { Label = GettextCatalog.GetString("Download") }; //NOTE: grab the variable from the loop var so the closure captures it var url = update.Url; downloadButton.Clicked += delegate { DesktopService.ShowUrl(url); }; labelBox.PackStart(downloadButton, false, false, 0); var sb = new StringBuilder(); for (int i = 0; i < update.Releases.Count; i++) { var release = update.Releases[i]; if (i > 0) { if (i == 1) { sb.AppendLine(); sb.AppendLine("This release also includes previous updates:"); } sb.AppendLine(); sb.AppendFormat("{0} ({1:yyyy-MM-dd})\n", release.Version, release.Date); sb.AppendLine(); } sb.Append(release.Notes.Trim('\t', ' ', '\n', '\r')); sb.AppendLine(); } var buffer = new TextBuffer(null); buffer.Text = sb.ToString(); var textView = new TextView(buffer); textView.WrapMode = WrapMode.Word; textView.Editable = false; textView.LeftMargin = textView.RightMargin = 4; updateBox.PackStart(textView, false, false, 0); bool startsExpanded = false; updateExpander.Expanded = startsExpanded; updateExpander.Activated += delegate { textView.Visible = updateExpander.Expanded; }; updateBox.BorderWidth = 4; productBox.PackStart(updateBox, false, false, 0); updateBox.ShowAll(); //this has to be set false after the ShowAll textView.Visible = startsExpanded; var sep = new HSeparator(); productBox.PackStart(sep, false, false, 0); sep.Show(); } notebook1.CurrentPage = PAGE_UPDATES; }
void HandleLink(string url) { DesktopService.ShowUrl(url); }
static void OnShowUrl(string url) { DesktopService.ShowUrl(url); }
void ExceptionHelpLinkLabel_Clicked(object sender, EventArgs e) => DesktopService.ShowUrl(exceptionHelpLink);
void EventBoxLink_ExceptionHelpLink(object o, ButtonPressEventArgs args) => DesktopService.ShowUrl(exceptionHelpLink);
Widget CreateExceptionHeader() { var icon = new ImageView(WarningIconPixbuf); icon.Yalign = 0; ExceptionTypeLabel = new Label { Xalign = 0.0f, Selectable = true, CanFocus = false }; ExceptionMessageLabel = new Label { Wrap = true, Xalign = 0.0f, Selectable = true, CanFocus = false }; ExceptionHelpLinkLabel = new Label { Wrap = true, Xalign = 0.0f, Selectable = true, CanFocus = false, UseMarkup = true, LineWrapMode = Pango.WrapMode.Char }; ExceptionHelpLinkLabel.Name = "exception_help_link_label"; Gtk.Rc.ParseString(@"style ""exception-help-link-label"" { GtkWidget::link-color = ""#ffffff"" GtkWidget::visited-link-color = ""#ffffff"" } widget ""*.exception_help_link_label"" style ""exception-help-link-label"" "); var textColor = Styles.ExceptionCaughtDialog.HeaderTextColor.ToGdkColor(); ExceptionHelpLinkLabel.ModifyBase(StateType.Prelight, Styles.ExceptionCaughtDialog.HeaderBackgroundColor.ToGdkColor()); ExceptionHelpLinkLabel.SetLinkHandler((str) => DesktopService.ShowUrl(str)); ExceptionTypeLabel.ModifyFg(StateType.Normal, textColor); ExceptionMessageLabel.ModifyFg(StateType.Normal, textColor); ExceptionHelpLinkLabel.ModifyFg(StateType.Normal, textColor); if (Platform.IsWindows) { ExceptionTypeLabel.ModifyFont(Pango.FontDescription.FromString("bold 19")); ExceptionMessageLabel.ModifyFont(Pango.FontDescription.FromString("10")); ExceptionHelpLinkLabel.ModifyFont(Pango.FontDescription.FromString("10")); } else { ExceptionTypeLabel.ModifyFont(Pango.FontDescription.FromString("21")); ExceptionMessageLabel.ModifyFont(Pango.FontDescription.FromString("12")); ExceptionHelpLinkLabel.ModifyFont(Pango.FontDescription.FromString("12")); } //Force rendering of background with EventBox var eventBox = new EventBox(); var hBox = new HBox(); var leftVBox = new VBox(); rightVBox = new VBox(); leftVBox.PackStart(icon, false, false, (uint)(Platform.IsWindows ? 5 : 0)); // as we change frame.BorderWidth below, we need to compensate rightVBox.PackStart(ExceptionTypeLabel, false, false, (uint)(Platform.IsWindows ? 0 : 2)); rightVBox.PackStart(ExceptionMessageLabel, true, true, (uint)(Platform.IsWindows ? 6 : 5)); rightVBox.PackStart(ExceptionHelpLinkLabel, false, false, 2); hBox.PackStart(leftVBox, false, false, (uint)(Platform.IsWindows ? 5 : 0)); // as we change frame.BorderWidth below, we need to compensate hBox.PackStart(rightVBox, true, true, (uint)(Platform.IsWindows ? 5 : 10)); var frame = new Frame(); frame.Add(hBox); frame.BorderWidth = (uint)(Platform.IsWindows ? 5 : 10); // on Windows we need to have smaller border due to ExceptionTypeLabel vertical misalignment frame.Shadow = ShadowType.None; frame.ShadowType = ShadowType.None; eventBox.Add(frame); eventBox.ShowAll(); eventBox.ModifyBg(StateType.Normal, Styles.ExceptionCaughtDialog.HeaderBackgroundColor.ToGdkColor()); return(eventBox); }
void InnerExceptionHelpLinkLabel_Pressed(object sender, EventArgs e) => DesktopService.ShowUrl(innerExceptionHelpLink);