public static async Task InstallAssembly(AssemblyEntry assembly, bool silent)
        {
            if (Config.Instance.SelectedProfile.InstalledAssemblies.Any(a => a.Name == assembly.Name))
            {
                return;
            }

            try
            {
                var projectName     = Path.GetFileNameWithoutExtension(new Uri(assembly.GithubUrl).AbsolutePath);
                var repositoryMatch = Regex.Match(assembly.GithubUrl, @"^(http[s]?)://(?<host>.*?)/(?<author>.*?)/(?<repo>.*?)(/{1}|$)");
                var repositoryUrl   = $"https://{repositoryMatch.Groups["host"]}/{repositoryMatch.Groups["author"]}/{repositoryMatch.Groups["repo"]}";

                var installer = new InstallerWindow {
                    Owner = MainWindow.Instance
                };

                if (silent)
                {
                    await installer.ListAssemblies(repositoryUrl, true, true, HttpUtility.UrlDecode(projectName));

                    installer.Close();
                    return;
                }

                installer.ShowProgress(repositoryUrl, true, HttpUtility.UrlDecode(projectName));
                installer.ShowDialog();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Esempio n. 2
0
        private void InstallButton_Click(object sender, RoutedEventArgs e)
        {
            var window = new InstallerWindow {
                Owner = this
            };

            window.ShowDialog();
        }
Esempio n. 3
0
        public static void InstallAssembly(Match m)
        {
            var gitHubUser     = m.Groups[2].ToString();
            var repositoryName = m.Groups[3].ToString();
            var assemblyName   = m.Groups[4].ToString();

            var w = new InstallerWindow {
                Owner = MainWindow.Instance
            };

            w.ShowProgress($"https://github.com/{gitHubUser}/{repositoryName}", true, assemblyName != string.Empty ? m.Groups[4].ToString() : null);
            w.ShowDialog();
        }
        private void GithubAssembliesItem_OnClick(object sender, RoutedEventArgs e)
        {
            if (InstalledAssembliesDataGrid.SelectedItems.Count <= 0)
            {
                return;
            }
            var selectedAssembly = (LeagueSharpAssembly)InstalledAssembliesDataGrid.SelectedItems[0];

            if (selectedAssembly.SvnUrl != "")
            {
                var window = new InstallerWindow {
                    Owner = this
                };
                window.ListAssemblies(selectedAssembly.SvnUrl, true);
                window.ShowDialog();
            }
        }
Esempio n. 5
0
        private async void InstallFromDbItem_OnClick(object sender, RoutedEventArgs e)
        {
            if (this.AssembliesDBDataGrid.SelectedItems.Count == 0)
            {
                return;
            }

            foreach (var result in this.AssembliesDBDataGrid.SelectedItems.Cast <AssemblyEntry>())
            {
                if (this.Config.SelectedProfile.InstalledAssemblies.Any(a => a.Name == result.Name.WebDecode()))
                {
                    await this.ShowMessageAsync("Installer", $"{result.Name} is already installed");

                    continue;
                }

                await InstallerWindow.InstallAssembly(result, false);
            }
        }
Esempio n. 6
0
        private async void InstallFromDbItem_OnClick(object sender, RoutedEventArgs e)
        {
            if (this.AssembliesDBDataGrid.SelectedItems.Count == 0)
            {
                return;
            }

            foreach (var result in this.AssembliesDBDataGrid.SelectedItems.Cast <AssemblyEntry>())
            {
                if (this.Config.SelectedProfile.InstalledAssemblies.Any(a => a.Name == HttpUtility.UrlDecode(result.Name)))
                {
                    await this.ShowMessageAsync("Installer", $"{result.Name} is already installed");

                    continue;
                }

                await InstallerWindow.InstallAssembly(result, false);

                //await Application.Current.Dispatcher.InvokeAsync(() => InstallerWindow.InstallAssembly(result, false));
            }
        }
Esempio n. 7
0
        public static async Task InstallAssembly(AssemblyEntry assembly, bool silent)
        {
            if (Config.Instance.SelectedProfile.InstalledAssemblies.Any(a => a.Name == assembly.Name))
            {
                return;
            }

            try
            {
                var projectName     = Path.GetFileNameWithoutExtension(new Uri(assembly.GithubUrl).AbsolutePath).WebDecode();
                var repositoryMatch = Regex.Match(assembly.GithubUrl, @"^(http[s]?)://(?<host>.*?)/(?<author>.*?)/(?<repo>.*?)(/{1}|$)");
                var repositoryUrl   = $"https://{repositoryMatch.Groups["host"]}/{repositoryMatch.Groups["author"]}/{repositoryMatch.Groups["repo"]}";

                // HACK: :^)
                var redirect = Config.Instance.BlockedRepositories.Where(r => r.HasRedirect).FirstOrDefault(r => repositoryUrl.StartsWith(r.Url));
                if (redirect != null)
                {
                    repositoryUrl = redirect.Redirect;
                }

                var installer = new InstallerWindow {
                    Owner = MainWindow.Instance
                };

                if (silent)
                {
                    await installer.ListAssemblies(repositoryUrl, true, true, projectName);

                    installer.Close();
                    return;
                }

                installer.ShowProgress(repositoryUrl, true, projectName);
                installer.ShowDialog();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Esempio n. 8
0
 private void GithubAssembliesItem_OnClick(object sender, RoutedEventArgs e)
 {
     if (InstalledAssembliesDataGrid.SelectedItems.Count <= 0)
     {
         return;
     }
     var selectedAssembly = (LeagueSharpAssembly)InstalledAssembliesDataGrid.SelectedItems[0];
     if (selectedAssembly.SvnUrl != "")
     {
         var window = new InstallerWindow { Owner = this };
         window.ListAssemblies(selectedAssembly.SvnUrl, true);
         window.ShowDialog();
     }
 }
Esempio n. 9
0
 private void InstallButton_Click(object sender, RoutedEventArgs e)
 {
     var window = new InstallerWindow { Owner = this };
     window.ShowDialog();
 }
        public static async Task InstallAssembly(AssemblyEntry assembly, bool silent)
        {
            if (Config.Instance.SelectedProfile.InstalledAssemblies.Any(a => a.Name == assembly.Name))
            {
                return;
            }

            try
            {
                var projectName = Path.GetFileNameWithoutExtension(new Uri(assembly.GithubUrl).AbsolutePath);
                var repositoryMatch = Regex.Match(assembly.GithubUrl, @"^(http[s]?)://(?<host>.*?)/(?<author>.*?)/(?<repo>.*?)(/{1}|$)");
                var repositoryUrl = $"https://{repositoryMatch.Groups["host"]}/{repositoryMatch.Groups["author"]}/{repositoryMatch.Groups["repo"]}";

                var installer = new InstallerWindow { Owner = MainWindow.Instance };

                if (silent)
                {
                    await installer.ListAssemblies(repositoryUrl, true, true, HttpUtility.UrlDecode(projectName));
                    installer.Close();
                    return;
                }

                installer.ShowProgress(repositoryUrl, true, HttpUtility.UrlDecode(projectName));
                installer.ShowDialog();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        public static void InstallAssembly(Match m)
        {
            var gitHubUser = m.Groups[2].ToString();
            var repositoryName = m.Groups[3].ToString();
            var assemblyName = m.Groups[4].ToString();

            var w = new InstallerWindow { Owner = MainWindow.Instance };
            w.ShowProgress($"https://github.com/{gitHubUser}/{repositoryName}", true, assemblyName != "" ? m.Groups[4].ToString() : null);
            w.ShowDialog();
        }
Esempio n. 12
0
        public static void HandleUrl(string url, MetroWindow window)
        {
            url = WebUtility.UrlDecode(url.Remove(0, FullName.Length));

            var r = Regex.Matches(url, "(project|profile)/([^/]*)/([^/]*)/([^/]*)/?");
            foreach (Match m in r)
            {
                var linkType = m.Groups[1].ToString();
                var gitHubUser = m.Groups[2].ToString();
                var repositoryName = m.Groups[3].ToString();
                var assemblyName = m.Groups[4].ToString();

                switch (linkType)
                {
                    case "project":
                        var w = new InstallerWindow { Owner = window };
                        w.ListAssemblies(
                            string.Format("https://github.com/{0}/{1}", gitHubUser, repositoryName), true,
                            assemblyName != "" ? m.Groups[4].ToString() : null);
                        w.ShowDialog();
                        break;

                    case "profile":
                        break;
                }
            }
        }
Esempio n. 13
0
        public static async Task HandleUrl(string url, MetroWindow window)
        {
            url = WebUtility.UrlDecode(url.Remove(0, FullName.Length));

            var r = Regex.Matches(url, "(project|projectGroup)/([^/]*)/([^/]*)/([^/]*)/?");
            foreach (Match m in r)
            {
                var linkType = m.Groups[1].ToString();

                switch (linkType)
                {
                    case "project":
                        var gitHubUser = m.Groups[2].ToString();
                        var repositoryName = m.Groups[3].ToString();
                        var assemblyName = m.Groups[4].ToString();

                        var w = new InstallerWindow { Owner = window };
                        w.ListAssemblies(
                            string.Format("https://github.com/{0}/{1}", gitHubUser, repositoryName),
                            true,
                            assemblyName != "" ? m.Groups[4].ToString() : null);
                        w.ShowDialog();
                        break;

                    case "projectGroup":

                        var remaining = url.Remove(0, 13);
                        var assemblies = new List<LeagueSharpAssembly>();

                        while (remaining.IndexOf("/", StringComparison.InvariantCulture) != -1)
                        {
                            var data = remaining.Split(new[] { '/' });
                            if (data.Length < 3)
                            {
                                break;
                            }

                            var assembly = new LeagueSharpAssembly(
                                data[2],
                                "",
                                string.Format("https://github.com/{0}/{1}", data[0], data[1]));
                            assemblies.Add(assembly);
                            for (var i = 0; i < 3; i++)
                            {
                                remaining = remaining.Remove(
                                    0,
                                    remaining.IndexOf("/", StringComparison.InvariantCulture) + 1);
                            }
                        }

                        if (assemblies.Count > 0)
                        {
                            assemblies.ForEach(
                                assembly => Config.Instance.SelectedProfile.InstalledAssemblies.Add(assembly));
                            await ((MainWindow)window).PrepareAssemblies(assemblies, true, true, false);
                            ((MainWindow)window).ShowTextMessage(
                                Utility.GetMultiLanguageText("Installer"),
                                Utility.GetMultiLanguageText("SuccessfullyInstalled"));
                        }
                        break;
                }
            }
        }