public void HomePage(IDictionary <string, string> queryParameters) { if (queryParameters == null || !queryParameters.Any()) { return; } var movieId = string.Empty; if (queryParameters.ContainsKey("movieid")) { movieId = queryParameters["movieid"] ?? string.Empty; } if (string.IsNullOrWhiteSpace(movieId)) { return; } var tmdbMovieTask = Task.Run(() => { return(GetTmdbMovieAsync(movieId)); }); tmdbMovieTask.Wait(); var movie = tmdbMovieTask.Result; if (movie != null && !string.IsNullOrWhiteSpace(movie.homepage)) { BrowserLauncher.Open(_config.Platform, movie.homepage); } }
static void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e) { if (e.Reason == SessionSwitchReason.SessionLogon) { BrowserLauncher.OpenDashboard(_appHost); } }
public void ShowDevTools(IDictionary <string, string> queryParameters) { if (_config != null && !string.IsNullOrWhiteSpace(_config.DevToolsUrl)) { BrowserLauncher.Open(_config.Platform, _config.DevToolsUrl); } }
static void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e) { if (e.Reason == SessionSwitchReason.SessionLogon) { BrowserLauncher.OpenDashboard(_appHost.UserManager, _appHost.ServerConfigurationManager, _appHost, _logger); } }
private void Run() { if (!_appHost.CanLaunchWebBrowser) { return; } // Always launch the startup wizard if possible when it has not been completed if (!_config.Configuration.IsStartupWizardCompleted && _appConfig.HostWebClient()) { BrowserLauncher.OpenWebApp(_appHost); return; } // Do nothing if the web app is configured to not run automatically if (!_config.Configuration.AutoRunWebApp || _startupOptions.NoAutoRunWebApp) { return; } // Launch the swagger page if the web client is not hosted, otherwise open the web client if (_appConfig.HostWebClient()) { BrowserLauncher.OpenWebApp(_appHost); } else { BrowserLauncher.OpenSwaggerPage(_appHost); } }
public void ShowDevTools() { if (_config != null && !string.IsNullOrWhiteSpace(_config.DevToolsUrl)) { BrowserLauncher.Open(_config.Platform, _config.DevToolsUrl); } }
protected override void DoExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector config) { //check XSP is available var configuration = (AspNetAppProjectConfiguration)GetConfiguration(config); var cmd = CreateExecutionCommand(config, configuration); IConsole console = null; var operationMonitor = new AggregatedOperationMonitor(monitor); try { if (configuration.ExternalConsole) { console = context.ExternalConsoleFactory.CreateConsole(!configuration.PauseConsoleOutput); } else { console = context.ConsoleFactory.CreateConsole(!configuration.PauseConsoleOutput); } string url = String.Format("http://{0}:{1}", this.XspParameters.Address, this.XspParameters.Port); bool isXsp = true; //FIXME: fix this when it might not be true if (isXsp) { console = new XspBrowserLauncherConsole(console, delegate { BrowserLauncher.LaunchDefaultBrowser(url); }); } monitor.Log.WriteLine("Running web server..."); var op = context.ExecutionHandler.Execute(cmd, console); operationMonitor.AddOperation(op); //handles cancellation if (!isXsp) { BrowserLauncher.LaunchDefaultBrowser(url); } op.WaitForCompleted(); monitor.Log.WriteLine("The web server exited with code: {0}", op.ExitCode); } catch (Exception ex) { monitor.ReportError("Could not launch web server.", ex); } finally { operationMonitor.Dispose(); if (console != null) { console.Dispose(); } } }
public TvShowsViewModel() { launcher = new BrowserLauncher(ConfigurationData.LinksFilepath); OnDisplayTvShowDetailsCommand = new RelayCommand <TvShow>(OnDisplayTvShowDetails); OnHyperLink1NavigateCommand = new RelayCommand <TvShow>(OnHyperLink1Navigate); OnHyperLink2NavigateCommand = new RelayCommand <TvShow>(OnHyperLink2Navigate); OnHyperLink3NavigateCommand = new RelayCommand <TvShow>(OnHyperLink3Navigate); OnHyperLink4NavigateCommand = new RelayCommand <TvShow>(OnHyperLink4Navigate); OnHyperLink5NavigateCommand = new RelayCommand <TvShow>(OnHyperLink5Navigate); OnHyperLinkMultiNavigateCommand = new RelayCommand <Websites>(OnHyperLinkMultiNavigate); }
public TvShowsViewModel() { launcher = new BrowserLauncher(ConfigurationData.LinksFilepath); OnDisplayTvShowDetailsCommand = new RelayCommand<TvShow>(OnDisplayTvShowDetails); OnHyperLink1NavigateCommand = new RelayCommand<TvShow>(OnHyperLink1Navigate); OnHyperLink2NavigateCommand = new RelayCommand<TvShow>(OnHyperLink2Navigate); OnHyperLink3NavigateCommand = new RelayCommand<TvShow>(OnHyperLink3Navigate); OnHyperLink4NavigateCommand = new RelayCommand<TvShow>(OnHyperLink4Navigate); OnHyperLink5NavigateCommand = new RelayCommand<TvShow>(OnHyperLink5Navigate); OnHyperLinkMultiNavigateCommand = new RelayCommand<Websites>(OnHyperLinkMultiNavigate); }
// Create the popup menu, on right click. static void OnTrayIconPopup(object o, EventArgs args) { Menu popupMenu = new Menu(); var menuItemBrowse = new ImageMenuItem("Browse Library"); menuItemBrowse.Image = new Gtk.Image(Stock.MediaPlay, IconSize.Menu); popupMenu.Add(menuItemBrowse); menuItemBrowse.Activated += delegate { BrowserLauncher.OpenWebClient(_appHost.UserManager, _appHost.ServerConfigurationManager, _appHost, _logger); }; var menuItemConfigure = new ImageMenuItem("Configure Media Browser"); menuItemConfigure.Image = new Gtk.Image(Stock.Edit, IconSize.Menu); popupMenu.Add(menuItemConfigure); menuItemConfigure.Activated += delegate { BrowserLauncher.OpenDashboard(_appHost.UserManager, _appHost.ServerConfigurationManager, _appHost, _logger); }; var menuItemApi = new ImageMenuItem("View Api Docs"); menuItemApi.Image = new Gtk.Image(Stock.Network, IconSize.Menu); popupMenu.Add(menuItemApi); menuItemApi.Activated += delegate { BrowserLauncher.OpenSwagger(_appHost.ServerConfigurationManager, _appHost, _logger); }; var menuItemCommunity = new ImageMenuItem("Visit Community"); menuItemCommunity.Image = new Gtk.Image(Stock.Help, IconSize.Menu); popupMenu.Add(menuItemCommunity); menuItemCommunity.Activated += delegate { BrowserLauncher.OpenCommunity(_logger); }; var menuItemGithub = new ImageMenuItem("Visit Github"); menuItemGithub.Image = new Gtk.Image(Stock.Network, IconSize.Menu); popupMenu.Add(menuItemGithub); menuItemGithub.Activated += delegate { BrowserLauncher.OpenGithub(_logger); }; var menuItemQuit = new ImageMenuItem("Exit"); menuItemQuit.Image = new Gtk.Image(Stock.Quit, IconSize.Menu); popupMenu.Add(menuItemQuit); menuItemQuit.Activated += delegate { Shutdown(); }; popupMenu.ShowAll(); popupMenu.Popup(); }
/// <summary> /// Launches the startup wizard. /// </summary> private void LaunchStartupWizard() { var user = _userManager.Users.FirstOrDefault(u => u.Configuration.IsAdministrator); try { BrowserLauncher.OpenDashboardPage("wizardstart.html", user, _configurationManager, _appHost, _logger); } catch (Exception ex) { _logger.ErrorException("Error launching startup wizard", ex); MessageBox.Show("There was an error launching the Media Browser startup wizard. Please ensure a web browser is installed on the machine and is configured as the default browser.", "Media Browser"); } }
static void ReadKeysUntilAbort(string url) { System.Console.TreatControlCAsInput = true; Console.WriteLine("Press enter to launch a browser or ctrl-c to shutdown."); do { ConsoleKeyInfo key = Console.ReadKey(/*intercept*/ true); if (key.Key == ConsoleKey.Enter) { BrowserLauncher.Launch(url); } else if ((key.Modifiers & ConsoleModifiers.Control) == ConsoleModifiers.Control && key.Key == ConsoleKey.C) { return; } // Otherwise keep going. } while (true); }
protected override bool OnBeforeBrowse(IWebBrowser ChromiumBrowser, IBrowser browser, IFrame frame, IRequest request, bool userGesture, bool isRedirect) { var isUrlExternal = _config?.UrlSchemes?.IsUrlRegisteredExternalBrowserScheme(request.Url); if (isUrlExternal.HasValue && isUrlExternal.Value) { BrowserLauncher.Open(request.Url); return(true); } var isUrlCommand = _config?.UrlSchemes?.IsUrlRegisteredCommandScheme(request.Url); if (isUrlCommand.HasValue && isUrlCommand.Value) { _commandTaskRunner.RunAsync(request.Url); return(true); } return(false); }
public void HomePage(string movieId) { if (string.IsNullOrWhiteSpace(movieId)) { return; } var tmdbMovieTask = Task.Run(() => { return(GetTmdbMovieAsync(movieId)); }); tmdbMovieTask.Wait(); var movie = tmdbMovieTask.Result; if (movie != null && !string.IsNullOrWhiteSpace(movie.homepage)) { BrowserLauncher.Open(_config.Platform, movie.homepage); } }
/// <summary> /// Runs this instance. /// </summary> public void Run() { if (!_appHost.CanLaunchWebBrowser) { return; } if (!_config.Configuration.IsStartupWizardCompleted) { BrowserLauncher.OpenWebApp(_appHost); } else if (_config.Configuration.AutoRunWebApp) { var options = ((ApplicationHost)_appHost).StartupOptions; if (!options.NoAutoRunWebApp) { BrowserLauncher.OpenWebApp(_appHost); } } }
/// <summary> /// Runs this instance. /// </summary> public void Run() { if (!_appHost.CanLaunchWebBrowser) { return; } if (_appHost.IsFirstRun) { BrowserLauncher.OpenWizard(_appHost); } else if (_config.Configuration.IsStartupWizardCompleted && _config.Configuration.AutoRunWebApp) { var options = ((ApplicationHost)_appHost).StartupOptions; if (!options.ContainsOption("-noautorunwebapp")) { BrowserLauncher.OpenWebApp(_appHost); } } }
protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref CefDictionaryValue extraInfo, ref bool noJavascriptAccess) { _browser.InvokeAsyncIfPossible(() => _browser.OnBeforePopup(new BeforePopupEventArgs(frame, targetUrl, targetFrameName))); var isUrlExternal = _config?.UrlSchemes?.IsUrlRegisteredExternalBrowserScheme(targetUrl); if (isUrlExternal.HasValue && isUrlExternal.Value) { BrowserLauncher.Open(_config.Platform, targetUrl); return(true); } var isUrlCommand = _config?.UrlSchemes?.IsUrlRegisteredCommandScheme(targetUrl); if (isUrlCommand.HasValue && isUrlCommand.Value) { _commandTaskRunner.RunAsync(targetUrl); return(true); } return(false); }
private void BtnChrome_Clicked(object?sender, EventArgs e) { try { NativeMessagingConfigurer.InstallNativeMessagingHost(Browser.Chrome); } catch (Exception ex) { Log.Debug(ex, "Error installing native host"); GtkHelper.ShowMessageBox(this, TextResource.GetText("MSG_NATIVE_HOST_FAILED")); return; } try { BrowserLauncher.LaunchGoogleChrome(Links.ChromeExtensionUrl); } catch (Exception ex) { Log.Debug(ex, "Error launching Google Chrome"); GtkHelper.ShowMessageBox(this, $"{TextResource.GetText("MSG_BROWSER_LAUNCH_FAILED")} Google Chrome"); } }
private void BtnFirefox_Click(object sender, RoutedEventArgs e) { try { NativeMessagingConfigurer.InstallNativeMessagingHost(Browser.Firefox); } catch (Exception ex) { Log.Debug(ex, "Error installing native host"); MessageBox.Show(TextResource.GetText("MSG_NATIVE_HOST_FAILED")); return; } try { BrowserLauncher.LaunchFirefox(Links.FirefoxExtensionUrl); } catch (Exception ex) { Log.Debug(ex, "Error launching Firefox"); MessageBox.Show($"{TextResource.GetText("MSG_BROWSER_LAUNCH_FAILED")} Firefox"); } }
/// <inheritdoc/> protected override bool OnBeforeBrowse(CefBrowser browser, CefFrame frame, CefRequest request, bool userGesture, bool isRedirect) { if (_config is not null) { var isUrlExternal = _config.UrlSchemes?.IsUrlRegisteredExternalBrowserScheme(request.Url); if (isUrlExternal.HasValue && isUrlExternal.Value) { BrowserLauncher.Open(_config.Platform, request.Url); return(true); } } // Sample: http://chromely.com/democontroller/showdevtools // Expected to execute controller route action without return value var route = _routeProvider.GetRoute(request.Url); if (route is not null && !route.HasReturnValue) { _requestHandler.Execute(request.Url); return(true); } return(false); }
void cmdSwagger_Click(object sender, EventArgs e) { BrowserLauncher.OpenSwagger(_configurationManager, _appHost, _logger); }
void cmdGtihub_Click(object sender, EventArgs e) { BrowserLauncher.OpenGithub(_logger); }
void cmdConfigure_Click(object sender, EventArgs e) { BrowserLauncher.OpenDashboard(_userManager, _configurationManager, _appHost, _logger); }
void cmdCommunity_Click(object sender, EventArgs e) { BrowserLauncher.OpenCommunity(_logger); }
void cmdBrowse_Click(object sender, EventArgs e) { BrowserLauncher.OpenWebClient(_userManager, _configurationManager, _appHost, _logger); }
static void Main(string[] args) { var arguments = new Arguments { ApplicationPath = ConfigurationManager.AppSettings["GitPriseWebPath"] }; var showHelp = false; var p = new OptionSet() { { "a|app|applicationPath:", "path to GitPrise web application", v => arguments.ApplicationPath = v }, { "rn|repositoryName:", "repository name in local browsing mode", v => arguments.RepositoryName = v }, { "rp|repositoryPath:", "repository path in local browsing mode", v => arguments.RepositoryPath = v }, { "p|port:", "server port", (int v) => arguments.Port = v }, { "nb|noBrowser", "doesn't auto start the browser", v => arguments.StartBrowser = (v == null) }, { "h|?|help", "shows help", v => showHelp = (v != null) }, }; try { p.Parse(args); } catch (Exception ex) { Console.WriteLine(string.Format( "Error parsing command line arguments:{0}{1}", Environment.NewLine, ex)); return; } if (showHelp || ArgumentsAreInvalid(arguments)) { ShowHelp(p); return; } var launcher = new BrowserLauncher(arguments.Port, arguments.RepositoryName, arguments.RepositoryPath); var result = GitPriseWebServer.CheckPortAvailability(arguments.Port); if (result == AvailabilityResult.InUseByGitPrise) { launcher.Launch(); return; } if (result == AvailabilityResult.Unknown) { Console.WriteLine("Port is in use by an unknown application - please use a different port or shutdown the application that's using the port."); return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm(arguments, launcher)); }
void cmdStandardDocs_Click(object sender, EventArgs e) { BrowserLauncher.OpenStandardApiDocumentation(_configurationManager, _appHost, _logger); }
protected override void DoExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector config) { //check XSP is available var configuration = (AspNetAppProjectConfiguration)GetConfiguration(config); var cmd = CreateExecutionCommand(config, configuration); IConsole console = null; var operationMonitor = new AggregatedOperationMonitor(monitor); bool isXsp = true; //FIXME: fix this when it might not be true - should delegate to the ExecutionHandler try { //HACK: check XSP exists first, because error UX is cleaner w/o displaying a blank console pad. if (isXsp) { try { AspNetExecutionHandler.GetXspPath((AspNetExecutionCommand)cmd); } catch (UserException ex) { MessageService.ShowError( GettextCatalog.GetString("Could not launch ASP.NET web server"), ex.Message); throw; } } if (configuration.ExternalConsole) { console = context.ExternalConsoleFactory.CreateConsole(!configuration.PauseConsoleOutput); } else { console = context.ConsoleFactory.CreateConsole(!configuration.PauseConsoleOutput); } string url = String.Format("http://{0}:{1}", this.XspParameters.Address, this.XspParameters.Port); if (isXsp) { console = new XspBrowserLauncherConsole(console, delegate { BrowserLauncher.LaunchDefaultBrowser(url); }); } monitor.Log.WriteLine("Running web server..."); var op = context.ExecutionHandler.Execute(cmd, console); operationMonitor.AddOperation(op); //handles cancellation if (!isXsp) { BrowserLauncher.LaunchDefaultBrowser(url); } op.WaitForCompleted(); monitor.Log.WriteLine("The web server exited with code: {0}", op.ExitCode); } catch (Exception ex) { if (!(ex is UserException)) { LoggingService.LogError("Could not launch ASP.NET web server.", ex); } monitor.ReportError("Could not launch web server.", ex); } finally { operationMonitor.Dispose(); if (console != null) { console.Dispose(); } } }
void cmdConfigure_Click(object sender, EventArgs e) { BrowserLauncher.OpenDashboard(_appHost); }
void cmdPremiere_Click(object sender, EventArgs e) { BrowserLauncher.OpenEmbyPremiere(_appHost); }
void cmdBrowse_Click(object sender, EventArgs e) { BrowserLauncher.OpenWebClient(_appHost); }
void notifyIcon1_DoubleClick(object sender, EventArgs e) { BrowserLauncher.OpenDashboard(_appHost); }