示例#1
0
        private async void ChangeModpack(object sender, SelectionChangedEventArgs e)
        {
            this.ViewModel.CanStart    = false;
            this.ViewModel.CanDownload = false;
            this.ViewModel.ServerInfo  = string.Empty;
            try
            {
                var server = ArmaHelpers.ServerInfo(this.ViewModel.SelectedModpack);
                var info   = server.GetServerInfo();
                await this.Dispatcher.InvokeAsync(
                    () => this.ViewModel.ServerInfo += GetLogFor(info) + Environment.NewLine,
                    DispatcherPriority.Background);

                var players = server.GetPlayerList();
                await this.Dispatcher.InvokeAsync(
                    () =>
                    this.ViewModel.ServerInfo +=
                    "Players: " + string.Join(", ", players.Select(p => p.Name)) + Environment.NewLine,
                    DispatcherPriority.Background);
            }
            catch (SourceServerException ex)
            {
                this.log.Warning(
                    ex,
                    "Couldn't connect to server {ip}",
                    this.ViewModel.SelectedModpack.IP + ":" + this.ViewModel.SelectedModpack.Port);
                await this.Dispatcher.InvokeAsync(
                    () => this.ViewModel.ServerInfo += "Unavailable" + Environment.NewLine,
                    DispatcherPriority.Background);
            }
        }
示例#2
0
        private void Start(object sender, RoutedEventArgs e)
        {
            HockeyClient.Current.TrackEvent(nameof(Start));
            var additional = new List <string>();

            if (!string.IsNullOrWhiteSpace(this.ViewModel.UserAddons))
            {
                try
                {
                    additional.AddRange(
                        new DirectoryInfo(this.ViewModel.UserAddons).GetDirectories()
                        .Where(d => d.Name.StartsWith("@"))
                        .Select(d => d.FullName));
                }
                catch (UnauthorizedAccessException ex)
                {
                    this.log.Warning(
                        ex,
                        "Could not access directory with additinal mods at {path}",
                        this.ViewModel.UserAddons);
                    MessageBox.Show(
                        $"Access to additinal addon folder at {this.ViewModel.UserAddons} was denied."
                        + Environment.NewLine + ex.Message,
                        "Folder access denied",
                        MessageBoxButton.OK,
                        MessageBoxImage.Error);
                }
                catch (DirectoryNotFoundException ex)
                {
                    this.log.Warning(ex, "Additional addon direcotry not found at {path}", this.ViewModel.UserAddons);
                    MessageBox.Show(
                        $"Additional addon directory not found at {this.ViewModel.UserAddons}" + Environment.NewLine
                        + ex.Message,
                        "Folder access denied",
                        MessageBoxButton.OK,
                        MessageBoxImage.Error);
                }
            }

            ArmaHelpers.StartArma(
                this.ViewModel.SelectedModpack,
                this.ViewModel.SelectedModpack.Addons.Select(a => this.ViewModel.Repo.Addons.Find(b => b.Name == a)),
                new DirectoryInfo(this.ViewModel.Path),
                this.ViewModel.Params,
                this.Connect.IsChecked == true,
                additional,
                this.ViewModel.Set64Bit,
                this.ViewModel.BattleEye);
        }