internal List <Result> InstallFromWeb(string url) { var filename = url.Split("/").Last(); var name = filename.Split(string.Format(".{0}", zip)).First(); var plugin = new UserPlugin { ID = "", Name = name, Version = string.Empty, Author = Context.API.GetTranslation("plugin_pluginsmanager_unknown_author"), UrlDownload = url }; var result = new Result { Title = string.Format(Context.API.GetTranslation("plugin_pluginsmanager_install_from_web"), filename), SubTitle = plugin.UrlDownload, IcoPath = icoPath, Action = e => { if (e.SpecialKeyState.CtrlPressed) { SearchWeb.OpenInBrowserTab(plugin.UrlDownload); return(ShouldHideWindow); } if (Settings.WarnFromUnknownSource) { if (!InstallSourceKnown(plugin.UrlDownload) && MessageBox.Show(string.Format(Context.API.GetTranslation("plugin_pluginsmanager_install_unknown_source_warning"), Environment.NewLine), Context.API.GetTranslation("plugin_pluginsmanager_install_unknown_source_warning_title"), MessageBoxButton.YesNo) == MessageBoxResult.No) { return(false); } } Application.Current.MainWindow.Hide(); _ = InstallOrUpdate(plugin); return(ShouldHideWindow); } }; return(new List <Result> { result }); }
private void OnPluginNameClick(object sender, MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Left) { var website = viewModel.SelectedPlugin.PluginPair.Metadata.Website; if (!string.IsNullOrEmpty(website)) { var uri = new Uri(website); if (Uri.CheckSchemeName(uri.Scheme)) { SearchWeb.NewTabInBrowser(website); } } } }
internal async ValueTask <List <Result> > RequestInstallOrUpdate(string searchName, CancellationToken token) { if (!PluginsManifest.UserPlugins.Any()) { await UpdateManifestAsync(); } token.ThrowIfCancellationRequested(); var searchNameWithoutKeyword = searchName.Replace(Settings.HotKeyInstall, string.Empty, StringComparison.OrdinalIgnoreCase).Trim(); if (Uri.IsWellFormedUriString(searchNameWithoutKeyword, UriKind.Absolute) && searchNameWithoutKeyword.Split('.').Last() == zip) { return(InstallFromWeb(searchNameWithoutKeyword)); } var results = PluginsManifest .UserPlugins .Select(x => new Result { Title = $"{x.Name} by {x.Author}", SubTitle = x.Description, IcoPath = icoPath, Action = e => { if (e.SpecialKeyState.CtrlPressed) { SearchWeb.OpenInBrowserTab(x.Website); return(ShouldHideWindow); } Application.Current.MainWindow.Hide(); _ = InstallOrUpdate(x); // No need to wait return(ShouldHideWindow); }, ContextData = x }); return(Search(results, searchNameWithoutKeyword)); }
private Paragraph Hyperlink(string textBeforeUrl, string url) { var paragraph = new Paragraph(); paragraph.Margin = new Thickness(0); var link = new Hyperlink { IsEnabled = true }; link.Inlines.Add(url); link.NavigateUri = new Uri(url); link.RequestNavigate += (s, e) => SearchWeb.OpenInBrowserTab(e.Uri.ToString()); link.Click += (s, e) => SearchWeb.OpenInBrowserTab(url); paragraph.Inlines.Add(textBeforeUrl); paragraph.Inlines.Add(link); paragraph.Inlines.Add("\n"); return(paragraph); }
private void OnRequestNavigate(object sender, RequestNavigateEventArgs e) { SearchWeb.NewTabInBrowser(e.Uri.AbsoluteUri); e.Handled = true; }
private void InitializeKeyCommands() { EscCommand = new RelayCommand(_ => { if (!SelectedIsFromQueryResults()) { SelectedResults = Results; } else { MainWindowVisibility = Visibility.Collapsed; } }); SelectNextItemCommand = new RelayCommand(_ => { SelectedResults.SelectNextResult(); }); SelectPrevItemCommand = new RelayCommand(_ => { SelectedResults.SelectPrevResult(); }); SelectNextPageCommand = new RelayCommand(_ => { SelectedResults.SelectNextPage(); }); SelectPrevPageCommand = new RelayCommand(_ => { SelectedResults.SelectPrevPage(); }); SelectFirstResultCommand = new RelayCommand(_ => SelectedResults.SelectFirstResult()); StartHelpCommand = new RelayCommand(_ => { SearchWeb.NewTabInBrowser("https://github.com/Flow-Launcher/Flow.Launcher/wiki/Flow-Launcher/"); }); OpenResultCommand = new RelayCommand(index => { var results = SelectedResults; if (index != null) { results.SelectedIndex = int.Parse(index.ToString()); } var result = results.SelectedItem?.Result; if (result != null) // SelectedItem returns null if selection is empty. { bool hideWindow = result.Action != null && result.Action(new ActionContext { SpecialKeyState = GlobalHotkey.Instance.CheckModifiers() }); if (hideWindow) { MainWindowVisibility = Visibility.Collapsed; } if (SelectedIsFromQueryResults()) { _userSelectedRecord.Add(result); _history.Add(result.OriginQuery.RawQuery); } else { SelectedResults = Results; } } }); LoadContextMenuCommand = new RelayCommand(_ => { if (SelectedIsFromQueryResults()) { SelectedResults = ContextMenu; } else { SelectedResults = Results; } }); LoadHistoryCommand = new RelayCommand(_ => { if (SelectedIsFromQueryResults()) { SelectedResults = History; History.SelectedIndex = _history.Items.Count - 1; } else { SelectedResults = Results; } }); }