public void ListAssemblies(string location, bool isSvn, string autoInstallName = null)
        {
            this.AbleToList = false;
            var bgWorker = new BackgroundWorker();

            if (!isSvn)
            {
                bgWorker.DoWork += delegate { FoundAssemblies = LeagueSharpAssemblies.GetAssemblies(location); };
            }
            else
            {
                bgWorker.DoWork += delegate
                {
                    var updatedDir = GitUpdater.Update(location, Logs.MainLog, Directories.RepositoryDir);
                    if (LeagueSharpAssemblies.BlockedRepos.Any(x => x.IndexOf(location, StringComparison.OrdinalIgnoreCase) >= 0))
                    {
                        FoundAssemblies = new List <LeagueSharpAssembly>();
                    }
                    else
                    {
                        FoundAssemblies = LeagueSharpAssemblies.GetAssemblies(updatedDir, location);
                    }

                    foreach (var assembly in FoundAssemblies.ToArray())
                    {
                        var assemblies =
                            Config.Instance.SelectedProfile.InstalledAssemblies.Where(
                                y => y.Name == assembly.Name && y.SvnUrl == assembly.SvnUrl).ToList();
                        assemblies.ForEach(a => FoundAssemblies.Remove(a));
                    }

                    foreach (var assembly in FoundAssemblies)
                    {
                        if (autoInstallName != null && assembly.Name.ToLower() == autoInstallName.ToLower())
                        {
                            assembly.InstallChecked = true;
                        }
                    }
                };
            }

            bgWorker.RunWorkerCompleted += delegate
            {
                if (controller != null)
                {
                    controller.CloseAsync();
                    controller = null;
                }

                AbleToList = true;
                Application.Current.Dispatcher.Invoke(() => installTabControl.SelectedIndex++);
                if (autoInstallName != null)
                {
                    InstallSelected();
                }
            };

            bgWorker.RunWorkerAsync();
        }
        public async Task ListAssemblies(string location, bool isSvn, bool silent, string autoInstallName = null)
        {
            this.AbleToList = false;

            if (!isSvn)
            {
                this.FoundAssemblies = LeagueSharpAssemblies.GetAssemblies(location);
            }
            else
            {
                await Task.Factory.StartNew(
                    () =>
                {
                    var updatedDir = GitUpdater.Update(location);

                    if (Config.Instance.BlockedRepositories.Any(location.StartsWith))
                    {
                        this.FoundAssemblies = new List <LeagueSharpAssembly>();
                    }
                    else
                    {
                        this.FoundAssemblies = LeagueSharpAssemblies.GetAssemblies(updatedDir, location);
                    }

                    foreach (var assembly in this.FoundAssemblies.ToArray())
                    {
                        var assemblies =
                            Config.Instance.SelectedProfile.InstalledAssemblies.Where(
                                y => y.Name == assembly.Name && y.SvnUrl == assembly.SvnUrl).ToList();
                        assemblies.ForEach(a => this.FoundAssemblies.Remove(a));
                    }

                    if (autoInstallName != null)
                    {
                        foreach (var assembly in this.FoundAssemblies)
                        {
                            if (assembly.Name.ToLower() == autoInstallName.ToLower())
                            {
                                assembly.InstallChecked = true;

                                Application.Current.Dispatcher.Invoke(() => { this.search.Text = autoInstallName; });
                            }
                        }
                    }
                });
            }

            this.AbleToList = true;
            this.installTabControl.SelectedIndex++;

            if (autoInstallName != null)
            {
                await this.InstallSelected(silent);
            }
        }
Ejemplo n.º 3
0
        public void ListAssemblies(string location, bool isSvn, string autoInstallName = null)
        {
            AbleToList = false;
            var bgWorker = new BackgroundWorker();

            if (!isSvn)
            {
                bgWorker.DoWork += delegate { FoundAssemblies = LeagueSharpAssemblies.GetAssemblies(location); };
            }
            else
            {
                bgWorker.DoWork += delegate
                {
                    var updatedDir = SvnUpdater.Update(location, Logs.MainLog, Directories.RepositoryDir);
                    FoundAssemblies = LeagueSharpAssemblies.GetAssemblies(Path.Combine(updatedDir, "trunk"), location);
                    foreach (var assembly in FoundAssemblies)
                    {
                        if (autoInstallName != null && assembly.Name.ToLower() == autoInstallName.ToLower())
                        {
                            assembly.InstallChecked = true;
                        }
                    }
                };
            }

            bgWorker.RunWorkerCompleted += delegate
            {
                if (controller != null)
                {
                    controller.CloseAsync();
                    controller = null;
                }

                AbleToList = true;
                System.Windows.Application.Current.Dispatcher.Invoke(() => installTabControl.SelectedIndex++);
                if (autoInstallName != null)
                {
                    InstallSelected();
                }
            };

            bgWorker.RunWorkerAsync();
        }
        private async Task Bootstrap()
        {
            #region UI

            this.Header.Text = "LEAGUESHARP " + Assembly.GetExecutingAssembly().GetName().Version;

            this.Browser.Visibility             = Visibility.Hidden;
            this.TosBrowser.Visibility          = Visibility.Hidden;
            this.GeneralSettingsItem.IsSelected = true;

            foreach (var gameSetting in Config.Instance.Settings.GameSettings)
            {
                gameSetting.PropertyChanged += this.GameSettingOnPropertyChanged;
            }

            #region ColumnWidth

            PropertyDescriptor pd = DependencyPropertyDescriptor.FromProperty(
                DataGridColumn.ActualWidthProperty,
                typeof(DataGridColumn));

            foreach (var column in this.InstalledAssembliesDataGrid.Columns)
            {
                pd.AddValueChanged(column, this.ColumnWidthPropertyChanged);
            }

            this.ColumnCheck.Width    = Config.Instance.ColumnCheckWidth;
            this.ColumnName.Width     = Config.Instance.ColumnNameWidth;
            this.ColumnType.Width     = Config.Instance.ColumnTypeWidth;
            this.ColumnVersion.Width  = Config.Instance.ColumnVersionWidth;
            this.ColumnLocation.Width = Config.Instance.ColumnLocationWidth;

            #endregion

            this.NewsTabItem.Visibility       = Visibility.Hidden;
            this.AssembliesTabItem.Visibility = Visibility.Hidden;
            this.SettingsTabItem.Visibility   = Visibility.Hidden;
            this.AssemblyDB.Visibility        = Visibility.Hidden;
            this.DataContext = this;

            #region ContextMenu.DevMenu

            this.DevMenu.Visibility      = Config.Instance.ShowDevOptions ? Visibility.Visible : Visibility.Collapsed;
            this.Config.PropertyChanged += (o, args) =>
            {
                if (args.PropertyName == "ShowDevOptions")
                {
                    this.DevMenu.Visibility = Config.Instance.ShowDevOptions
                                                      ? Visibility.Visible
                                                      : Visibility.Collapsed;
                }
            };

            #endregion

            #endregion

            Updater.MainWindow = this;

            await this.CheckForUpdates(true, true, false);

            await LeagueSharpAssemblies.UpdateBlockedRepos();

            Updater.GetRepositories(
                delegate(List <string> list)
            {
                if (list.Count > 0)
                {
                    Config.Instance.KnownRepositories.Clear();
                    foreach (var repo in list)
                    {
                        Config.Instance.KnownRepositories.Add(repo);
                    }
                }
            });

            Config.Instance.FirstRun = false;

            //Try to login with the saved credentials.
            if (!Auth.Login(Config.Instance.Username, Config.Instance.Password).Item1)
            {
                await this.ShowLoginDialog();
            }
            else
            {
                this.OnLogin(Config.Instance.Username);
            }

            #region ToS

            if (!Config.Instance.TosAccepted)
            {
                this.RightWindowCommands.Visibility = Visibility.Collapsed;
            }
            else
            {
                this.MainTabControl.SelectedIndex = 1;
            }

            #endregion

            // wait for tos accept
            await Task.Factory.StartNew(
                () =>
            {
                while (Config.Instance.TosAccepted == false)
                {
                    Thread.Sleep(100);
                }
            });

            Console.WriteLine("Tos Accepted");

            var allAssemblies = new List <LeagueSharpAssembly>();
            foreach (var profile in Config.Instance.Profiles)
            {
                allAssemblies.AddRange(profile.InstalledAssemblies);
            }

            allAssemblies = allAssemblies.Distinct().ToList();

            GitUpdater.ClearUnusedRepos(allAssemblies);
            await this.PrepareAssemblies(allAssemblies, Config.Instance.FirstRun || Config.Instance.UpdateOnLoad, true);

            this.MainTabControl.SelectedIndex = 2;
        }