/// <summary> /// Opens a <see cref="BrowserDialog"/> form, waits for successful /// design and updates slideshow with the designed <see cref="BrowserTreeNode"/>. /// </summary> /// <param name="node">Contains the node that is /// modified or null if this should be a new slide.</param> private void OpenBrowserDesignerForm(BrowserTreeNode node) { BrowserDialog dlg = new BrowserDialog(); if (node != null) { dlg.BrowserNode = node; } if (dlg.ShowDialog() == DialogResult.OK) { BrowserTreeNode newNode = dlg.BrowserNode; if (node != null) { newNode.UrlToID.Clear(); newNode.UrlToID.Add(newNode.OriginURL, Convert.ToInt32(node.Name)); node = newNode; } else { this.AddBrowserSlide(newNode); } this.SlideShowModified(); } }
//private BrowserDialog window; /// <summary> /// /// </summary> /// <param name="searchTerm"></param> /// <param name="searchEngineType"></param> /// <returns></returns> public async Task <List <SearchItem> > GetSearchLinks(string searchTerm, SearchEngineTypes searchEngineType = SearchEngineTypes.DuckDuckGo) { var list = new List <SearchItem>(); var url = "https://{0}.com?q={1}"; url = string.Format(url, searchEngineType, searchTerm); var window = new BrowserDialog(); window.Width = 0; window.Height = 0; window.Top = -50000; // offsreen but visible window.Visibility = Visibility.Visible; if (!window.NavigateAndWaitForCompletion(url)) { return(null); } await window.Dispatcher.DelayAsync(1000, (p) => { dynamic document = window.Browser.Document; var html = document.Body.InnerHtml as string; window?.Close(); if (string.IsNullOrEmpty((html))) { return; } var doc = new HtmlDocument(); doc.LoadHtml(html); var links = doc.DocumentNode.SelectNodes("//*/h2/a[1]"); if (links == null) { return; } foreach (var link in links) { var searchItem = new SearchItem(); url = link.Attributes["href"]?.Value; if (url.Contains("?uddg=")) { url = StringUtils.ExtractString(url, "?uddg=", "x", allowMissingEndDelimiter: true); } searchItem.Url = StringUtils.UrlDecode(url); searchItem.Title = link.InnerText; list.Add(searchItem); } }, DispatcherPriority.ApplicationIdle); return(list); }
private void OutputDirBtn_Click(object sender, EventArgs e) { if (BrowserDialog.ShowDialog() == DialogResult.OK) { OutputDir.Text = BrowserDialog.SelectedPath; } }
protected override void StartSvnOperation() { if (BrowserDialog.ShowModalYesNo(Resources.IfCloseFeatureMessage)) { base.StartSvnOperation(); } }
/// <summary> /// Get Path from Folder Explorer /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void direxplore_Click(object sender, EventArgs e) { DialogResult result = BrowserDialog.ShowDialog(); if (result == DialogResult.OK) { mDirPath.Text = BrowserDialog.SelectedPath; } }
private void btnPickBrowser_Click(object sender, EventArgs e) { var dialog = new BrowserDialog(); if (dialog.ShowDialog() == DialogResult.OK) { MessageBox.Show($"You picked {dialog.SelectedBrowser.Name}.\r\nThe executable path is {dialog.SelectedBrowser.ExecutablePath}\r\nThe version is {dialog.SelectedBrowser.Version.ProductVersion}"); } }
public void RegisterWithApiHandler(BloomApiHandler apiHandler) { apiHandler.RegisterEndpointHandler("dialog/close", (ApiRequest request) => { // Closes the current dialog. BrowserDialog.CloseDialog(); request.PostSucceeded(); }, true); }
public void OpenBrowser(string url) { // Something keeps settings this back to IE9, force reset it to latest every time the window opens EmbeddedBrowserUtil.SetBrowserEmulationVersionToLatestIE(); Application.Current.Dispatcher.BeginInvoke(new Action(() => { browserDialog = new BrowserDialog(); browserDialog.Show(url); })); }
private async Task <DialogResult> GetGoogleService(Action <string, string> setPath) { if (_googleDocGenerator == null) { OAuth2Parameters parameters = new OAuth2Parameters { ClientId = "261863669828-1k61kiqfjcci0psjr5e00vcpnsnllnug.apps.googleusercontent.com", ClientSecret = "IDtucbpfYi3C7zWxsJUX4HbV", RedirectUri = "urn:ietf:wg:oauth:2.0:oob", Scope = "https://spreadsheets.google.com/feeds https://docs.google.com/feeds", ResponseType = "code" }; string authorizationUrl = OAuthUtil.CreateOAuth2AuthorizationUrl(parameters); var browserDialog = new BrowserDialog(TimeSpan.FromSeconds(30), new Uri(authorizationUrl)); try { if (await browserDialog.ShowAsync(code => parameters.AccessCode = code) != DialogResult.OK) { return(DialogResult.Cancel); } } catch (Exception e) { ShowDialogWindow(DialogIcon.Critical, DialogRes.Exception, e.ToString()); throw; } OAuthUtil.GetAccessToken(parameters); _googleOAuth2Parameters = parameters; var service = new SpreadsheetsService("MySpreadsheetIntegration-v1") { RequestFactory = new GOAuth2RequestFactory(null, "MySpreadsheetIntegration-v1", parameters) }; _googleDocGenerator = new GoogleDocGenerator(service); } else { if (_googleOAuth2Parameters.TokenExpiry <= DateTime.Now) { OAuthUtil.RefreshAccessToken(_googleOAuth2Parameters); } } SelectGoogleDocumentDialog selectDocumentDialog = new SelectGoogleDocumentDialog(_showDialogAction, _googleDocGenerator); DialogResult dialogResult = await selectDocumentDialog.ShowAsync(setPath); return(dialogResult); }
/// <summary> /// Converts an HTML string to Markdown. /// </summary> /// <remarks> /// This routine relies on a browser window /// and an HTML file that handles the actual /// parsing: Editor\HtmlToMarkdown.htm /// </remarks> /// <param name="html"></param> /// <returns></returns> public static string HtmlToMarkdown(string html, bool noErrorUI = false) { if (string.IsNullOrEmpty(html)) { return(""); } #if false var config = new ReverseMarkdown.Config { GithubFlavored = true, UnknownTags = ReverseMarkdown.Config.UnknownTagsOption.PassThrough, // Include the unknown tag completely in the result (default as well) SmartHrefHandling = true // remove markdown output for links where appropriate }; var converter = new ReverseMarkdown.Converter(config); string markdown = converter.Convert(html); // if (!string.IsNullOrEmpty(markdown)) // markdown = markdown.Replace("\n\n", "\r\n").Replace("\r\n\r\n", "\r\n"); return(markdown ?? html); #else // Old code that uses JavaScript in a WebBrowser Control string markdown = null; string htmlFile = Path.Combine(App.InitialStartDirectory, "Editor\\htmltomarkdown.htm"); var form = new BrowserDialog(); form.ShowInTaskbar = false; form.Width = 1; form.Height = 1; form.Left = -10000; form.Show(); bool exists = File.Exists(htmlFile); form.NavigateAndWaitForCompletion(htmlFile); WindowUtilities.DoEvents(); try { dynamic doc = form.Browser.Document; markdown = doc.ParentWindow.htmltomarkdown(html); } catch (Exception ex) { mmApp.Log("Failed to convert Html to Markdown", ex); if (!noErrorUI) { MessageBox.Show("Unable to convert Html to Markdown. Returning Html.", "Html to Markdown Conversion Failed.", MessageBoxButton.OK, MessageBoxImage.Warning); } } form.Close(); form = null; return(markdown ?? html); #endif }
private bool NavigateTo(string uri) { try { BrowserDialog.Show(new Uri(uri)); //TODO: add WebBrowserWindow and WebBrowserDialog for OOP version and use that to show URLs return(true); } catch { return(false); } }
public override void Execute(object parameter) { PivotViewerItem item = (PivotViewerItem)parameter; string filename = (string)item["Filename"][0]; string href = (string)item["Href"][0]; bool isVideo = href.Contains("?video="); bool isImage = href.Contains("?image="); Uri uri = new Uri("http://gallery.clipflair.net/" + ((isImage)? "image" : "activity") + "/" + filename); BrowserDialog.Show(uri); }
/// <summary> /// Converts an HTML string to Markdown. /// </summary> /// <remarks> /// This routine relies on a browser window /// and an HTML file that handles the actual /// parsing: Editor\HtmlToMarkdown.htm /// </remarks> /// <param name="html"></param> /// <returns></returns> public static string HtmlToMarkdown(string html) { if (string.IsNullOrEmpty(html)) { return(""); } #if false var config = new ReverseMarkdown.Config(githubFlavored: true); var converter = new ReverseMarkdown.Converter(config); string markdown = converter.Convert(html); return(markdown ?? html); #else // Old code that uses JavaScript in a WebBrowser Control string markdown = null; string htmlFile = Path.Combine(Environment.CurrentDirectory, "Editor\\htmltomarkdown.htm"); var form = new BrowserDialog(); form.ShowInTaskbar = false; form.Width = 1; form.Height = 1; form.Left = -10000; form.Show(); bool exists = File.Exists(htmlFile); form.Navigate(htmlFile); WindowUtilities.DoEvents(); for (int i = 0; i < 200; i++) { dynamic doc = form.Browser.Document; if (!form.IsLoaded) { Task.Delay(10); WindowUtilities.DoEvents(); } else { markdown = doc.ParentWindow.htmltomarkdown(html); break; } } form.Close(); form = null; return(markdown ?? html); #endif }
private void imgContent_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (ImageView.ActionURL != null) { BrowserDialog.Show(ImageView.ActionURL); e.Handled = true; //event should already be handled by inner content, but marking it as handled anyway in case inner content hasn't } if (ImageView.ActionTime != null) { ImageView.Time = (TimeSpan)ImageView.ActionTime; e.Handled = true; //event should already be handled by inner content, but marking it as handled anyway in case inner content hasn't } }
/// <summary> /// Converts an HTML string to Markdown. /// </summary> /// <remarks> /// This routine relies on a browser window /// and an HTML file that handles the actual /// parsing: Editor\HtmlToMarkdown.htm /// </remarks> /// <param name="html"></param> /// <returns></returns> public static string HtmlToMarkdown(string html, bool noErrorUI = false) { if (string.IsNullOrEmpty(html)) { return(""); } #if false var config = new ReverseMarkdown.Config(githubFlavored: true); var converter = new ReverseMarkdown.Converter(config); string markdown = converter.Convert(html); return(markdown ?? html); #else // Old code that uses JavaScript in a WebBrowser Control string markdown = null; string htmlFile = Path.Combine(Environment.CurrentDirectory, "Editor\\htmltomarkdown.htm"); var form = new BrowserDialog(); form.ShowInTaskbar = false; form.Width = 1; form.Height = 1; form.Left = -10000; form.Show(); bool exists = File.Exists(htmlFile); form.NavigateAndWaitForCompletion(htmlFile); WindowUtilities.DoEvents(); try { dynamic doc = form.Browser.Document; markdown = doc.ParentWindow.htmltomarkdown(html); } catch (Exception ex) { mmApp.Log("Failed to convert Html to Markdown", ex); if (!noErrorUI) { MessageBox.Show("Unable to convert Html to Markdown. Returning Html.", "Html to Markdown Conversion Failed.", MessageBoxButton.OK, MessageBoxImage.Warning); } } form.Close(); form = null; return(markdown ?? html); #endif }
private void PopulateFileList() { FileList = Directory.GetFiles(".", "*.png", SearchOption.AllDirectories); BrowserDialog.Description = "Please navigate to the folder that contains your images."; BrowserDialog.RootFolder = Environment.SpecialFolder.MyComputer; CurrentDir.Text = string.Empty; if (BrowserDialog.ShowDialog() == DialogResult.OK) { this.toolStripStatusLabel1.Text = "Populating image choices ..."; this.toolStripProgressBar1.Style = ProgressBarStyle.Marquee; ImageListBaseDir = BrowserDialog.SelectedPath; CurrentDir.Text = ImageListBaseDir; backgroundWorker1.RunWorkerAsync(); } }
public override void Execute(object parameter) { PivotViewerItem item = (PivotViewerItem)parameter; IList nameData = item["Name"]; string name = (nameData != null && nameData.Count > 0)? (string)nameData[0] : ""; if (name == null) { name = ""; //just to be safe } Uri uri = new Uri("http://api.addthis.com/oexchange/0.8/offer?url=" + (string)item["Href"][0] + "&title=" + name ); BrowserDialog.Show(uri); }
/// <summary> /// Converts an HTML string to Markdown. /// </summary> /// <remarks> /// This routine relies on a browser window /// and an HTML file that handles the actual /// parsing: Editor\HtmlToMarkdown.htm /// </remarks> /// <param name="html"></param> /// <returns></returns> public static string HtmlToMarkdown(string html) { string markdown = null; string htmlFile = Path.Combine(Environment.CurrentDirectory, "Editor\\htmltomarkdown.htm"); var form = new BrowserDialog(); form.ShowInTaskbar = false; form.Width = 1; form.Height = 1; form.Left = -10000; form.Show(); bool exists = File.Exists(htmlFile); form.Navigate(htmlFile); WindowUtilities.DoEvents(); for (int i = 0; i < 200; i++) { dynamic doc = form.Browser.Document; if (!form.IsLoaded) { Task.Delay(10); WindowUtilities.DoEvents(); } else { markdown = doc.ParentWindow.htmltomarkdown(html); break; } } form.Close(); form = null; return(markdown ?? html); }
// Firebase version of the login dialog. Uses BrowserDialog, since Firebase login is only supported in browsers. public static void ShowFirebaseLoginDialog(IBloomWebSocketServer webSocketServer) { try { var url = GetLoginDialogUrl(); // Precondition: we must be on the UI thread for Gecko to work. using (var dlg = new BrowserDialog(url)) { dlg.WebSocketServer = webSocketServer; dlg.CloseMessage = "close"; dlg.Width = 400; // This is more than we usually need. But it saves scrolling when doing an email sign-up. dlg.Height = 510; dlg.ShowDialog(); } } catch (Exception ex) { Logger.WriteError("*** FirebaseLoginDialog threw an exception", ex); } }
private void DefaultSaveFolder_Click(object sender, RoutedEventArgs e) { DefaultSaveFolder = BrowserDialog.SelectFile(this); }
/// <summary> /// Shows a problem dialog. /// </summary> /// <param name="controlForScreenshotting"></param> /// <param name="exception"></param> /// <param name="detailedMessage"></param> /// <param name="levelOfProblem"></param> public static void ShowProblemDialog(Control controlForScreenshotting, Exception exception, string detailedMessage = "", string levelOfProblem = "user") { // Before we do anything that might be "risky", put the problem in the log. LogProblem(exception, detailedMessage, levelOfProblem); if (_showingProblemReport) { // If a problem is reported when already reporting a problem, that could // be an unbounded recursion that freezes the program and prevents the original // problem from being reported. So minimally report the recursive problem and stop // the recursion in its tracks. // // Alternatively, can happen if multiple async BloomAPI calls go out and return errors. // It's probably not helpful to have multiple problem report dialogs at the same time // in this case either (even if there are theoretically a finite (not infinite) number of them) const string msg = "MULTIPLE CALLS to ShowProblemDialog. Suppressing the subsequent calls"; Console.Write(msg); Logger.WriteEvent(msg); return; // Abort } _showingProblemReport = true; _currentException = exception; _detailedMessage = detailedMessage; if (controlForScreenshotting == null) { controlForScreenshotting = Form.ActiveForm; } if (controlForScreenshotting == null) // still possible if we come from a "Details" button { controlForScreenshotting = FatalExceptionHandler.ControlOnUIThread; } ResetScreenshotFile(); // Originally, we used SafeInvoke for both the screenshot and the new dialog display. SafeInvoke was great // for trying to get a screenshot, but having the actual dialog inside // of it was causing problems for handling any errors in showing the dialog. // Now we use SafeInvoke only inside of this extracted method. TryGetScreenshot(controlForScreenshotting); SafeInvoke.InvokeIfPossible("Show Problem Dialog", controlForScreenshotting, false, () => { // Uses a browser dialog to show the problem report try { var query = "?" + levelOfProblem; var problemDialogRootPath = BloomFileLocator.GetBrowserFile(false, "problemDialog", "loader.html"); var url = problemDialogRootPath.ToLocalhost() + query; // Precondition: we must be on the UI thread for Gecko to work. using (var dlg = new BrowserDialog(url)) { dlg.ShowDialog(); } } catch (Exception problemReportException) { Logger.WriteError("*** ProblemReportApi threw an exception trying to display", problemReportException); // At this point our problem reporter has failed for some reason, so we want the old WinForms handler // to report both the original error for which we tried to open our dialog and this new one where // the dialog itself failed. // In order to do that, we create a new exception with the original exception (if there was one) as the // inner exception. We include the message of the exception we just caught. Then we call the // old WinForms fatal exception report directly. // In any case, both of the errors will be logged by now. var message = "Bloom's error reporting failed: " + problemReportException.Message; ErrorReport.ReportFatalException(new ApplicationException(message, _currentException ?? problemReportException)); } finally { _showingProblemReport = false; } }); }
public override void Execute(object parameter) { Uri uri = new Uri((string)((PivotViewerItem)parameter)["Href"][0]); BrowserDialog.Show(uri); }
public void ShowHelp() { BrowserDialog.Show(new Uri(CLIPFLAIR_TUTORIALS)); }