public static bool?Show(string message, DialogIcon icon = DialogIcon.None, DialogOptions option = DialogOptions.Ok)
        {
            var dialog = new GenericMessageDialog(message, icon, option);

            dialog.Owner = Application.Current.MainWindow;
            return(dialog.ShowDialog());
        }
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var savedCredentials = UserCredentialService.GetStoredUserCredentials();

            if (LegacyBootstrapper.UserConfig?.LoginInfo.AutoLogin == true && savedCredentials != null)
            {
                NavigationFrame.IsEnabled = false;
                try
                {
                    var response = await LegacyBootstrapper.WebSocketApi.DoLogin(savedCredentials.Email, savedCredentials.Password);

                    if (response.Result)
                    {
                        GameService.SetCredentials(savedCredentials.Email, savedCredentials.Password);
                        LegacyBootstrapper.CurrentUser = response.User;
                        NavigationFrame.Navigate(new Uri("Pages/OverviewPage.xaml", UriKind.Relative));
                    }
                    else
                    {
                        GenericMessageDialog.Show(Properties.Resources.AutoLoginFailed, DialogIcon.Error);
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error(ex, ex.Message);
                    GenericMessageDialog.Show(Properties.Resources.AutoLoginError, DialogIcon.Error);
                }

                NavigationFrame.IsEnabled = true;
            }
        }
        private async void OnSendResetKeyClick(object sender, RoutedEventArgs e)
        {
            if (!Misc.IsValidEmailAdress(EmailAddressField.InputContent))
            {
                GenericMessageDialog.Show(Properties.Resources.ResetPasswordInvalidEmail, DialogIcon.Error, DialogOptions.Ok);
                return;
            }

            IsEnabled = false;

            try
            {
                var response = await LegacyBootstrapper.WebSocketApi.DoForgotPwd(EmailAddressField.InputContent);

                if (response.Result)
                {
                    ResetKeyField.IsEnabled    = true;
                    ResetPasswordBtn.IsEnabled = true;

                    GenericMessageDialog.Show(response.Message, DialogIcon.None, DialogOptions.Ok);
                }
                else
                {
                    GenericMessageDialog.Show($"{Properties.Resources.ResetPasswordFailed} {response.Message}", DialogIcon.Error, DialogOptions.Ok);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, ex.Message);
                GenericMessageDialog.Show(Properties.Resources.ResetPasswordError, DialogIcon.Error, DialogOptions.Ok);
            }

            IsEnabled = true;
        }
        public void RefreshList()
        {
            if (!Monitor.TryEnter(_syncLock))
            {
                return;
            }

            try
            {
                ScenarioListView.Items.Clear();
                foreach (var filePath in Directory.GetFiles(_scenarioDirectoryPath, "*.age4scn", SearchOption.AllDirectories))
                {
                    var txt = filePath.Replace(_scenarioDirectoryPath, string.Empty).Replace(".age4scn", string.Empty);
                    if (txt.StartsWith(@"/") || txt.StartsWith(@"\"))
                    {
                        txt = txt.Substring(1);
                    }

                    ScenarioListView.Items.Add(new System.Windows.Controls.ListViewItem
                    {
                        Content = txt,
                        Tag     = filePath
                    });
                }
            }
            catch (Exception ex)
            {
                GenericMessageDialog.Show(Properties.Resources.GenericUnexpectedErrorMessage, DialogIcon.Error, DialogOptions.Ok);
                Logger.Error(ex, ex.Message);
            }
            finally
            {
                Monitor.Exit(_syncLock);
            }
        }
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                await GameScanner.InitializeFromCelesteManifest();

                var progress    = new Progress <ScanProgress>();
                var subProgress = new Progress <ScanSubProgress>();

                progress.ProgressChanged    += ProgressChanged;
                subProgress.ProgressChanged += SubProgressChanged;

                if (await Task.Run(async() => await GameScanner.ScanAndRepair(progress, subProgress, _useParallelDownloader ? 4 : 1)))
                {
                    CurrentFileLabel.Content  = string.Empty;
                    MainProgressLabel.Content = Properties.Resources.GameScannerDoneLabel;
                    FileProgress.ProgressBar.IsIndeterminate = false;
                    GenericMessageDialog.Show(Properties.Resources.GameScannerDoneMessage, DialogIcon.None, DialogOptions.Ok);
                    DialogResult = true;
                }
                else
                {
                    FailGameScan(Properties.Resources.GameScannerDidNotPass);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, ex.Message);
                FailGameScan(Properties.Resources.GameScannerFailed);
            }
        }
示例#6
0
        private void LauncherOpenBtn_Click(object sender, RoutedEventArgs e)
        {
            IsEnabled = false;
            try
            {
                var launcherPath = Assembly.GetEntryAssembly().Location;

                if (!File.Exists(launcherPath))
                {
                    GenericMessageDialog.Show(Properties.Resources.WindowsFirewallHelperLauncherNotFound, DialogIcon.Error, DialogOptions.Ok);
                    Close();
                    return;
                }

                //outbound_tcp
                var rule = FirewallHelper.RuleExist("celeste_launcher_outbound_tcp");
                if (rule)
                {
                    FirewallHelper.RemoveRules("celeste_launcher_outbound_tcp");
                }

                FirewallHelper.AddApplicationRule("celeste_launcher_outbound_tcp", launcherPath,
                                                  FirewallDirection.Outbound, FirewallProtocol.TCP);
            }
            catch (Exception ex)
            {
                Logger.Error(ex, ex.Message);
                GenericMessageDialog.Show(Properties.Resources.GenericUnexpectedErrorMessage, DialogIcon.Error, DialogOptions.Ok);
            }

            LoadFirewallRules();

            IsEnabled = true;
        }
示例#7
0
        private void MultiplayerOpenBtn_Click(object sender, RoutedEventArgs e)
        {
            IsEnabled = false;
            try
            {
                //inbound_udp
                var rule = FirewallHelper.RuleExist("celeste_port1000_inbound_udp");
                if (rule)
                {
                    FirewallHelper.RemoveRules("celeste_port1000_inbound_udp");
                }

                FirewallHelper.AddPortRule("celeste_port1000_inbound_udp", 1000,
                                           FirewallDirection.Inbound, FirewallProtocol.UDP);

                //outbound_udp
                rule = FirewallHelper.RuleExist("celeste_port1000_outbound_udp");
                if (rule)
                {
                    FirewallHelper.RemoveRules("celeste_port1000_outbound_udp");
                }

                FirewallHelper.AddPortRule("celeste_port1000_outbound_udp", 1000,
                                           FirewallDirection.Outbound, FirewallProtocol.UDP);
            }
            catch (Exception ex)
            {
                Logger.Error(ex, ex.Message);
                GenericMessageDialog.Show(Properties.Resources.GenericUnexpectedErrorMessage, DialogIcon.Error, DialogOptions.Ok);
            }

            LoadFirewallRules();

            IsEnabled = true;
        }
示例#8
0
        private async void AddFriendClick(object sender, RoutedEventArgs e)
        {
            try
            {
                IsEnabled = false;

                var result = await _friendService.SendFriendRequest(UsernameInputField.InputContent);

                if (result)
                {
                    DialogResult = true;
                    Close();
                }
                else
                {
                    GenericMessageDialog.Show(string.Format(Properties.Resources.SendFriendRequestFailed, UsernameInputField.InputContent),
                                              DialogIcon.Warning,
                                              DialogOptions.Ok);
                }
            }
            catch
            {
                GenericMessageDialog.Show(Properties.Resources.GenericUnexpectedErrorMessage,
                                          DialogIcon.Error,
                                          DialogOptions.Ok);
            }
            finally
            {
                IsEnabled = true;
            }
        }
        private async void StartUpdate(object sender, RoutedEventArgs e)
        {
            try
            {
                UpdateBtn.Visibility = Visibility.Collapsed;
                UpdateProgressionControls.Visibility = Visibility.Visible;

                _cts.Cancel();
                _cts = new CancellationTokenSource();

                var progress = new Progress <int>();

                progress.ProgressChanged += (s, value) =>
                {
                    ProgressBar.ProgressBar.Value = value;
                };

                await UpdateService.DownloadAndInstallUpdate(LegacyBootstrapper.UserConfig.IsSteamVersion, progress, _cts.Token);

                GenericMessageDialog.Show(Properties.Resources.LauncherUpdaterUpdateSuccess, DialogIcon.Warning, DialogOptions.Ok);

                Process.Start(Assembly.GetEntryAssembly().Location);

                Environment.Exit(0);
            }
            catch (Exception ex)
            {
                Logger.Error(ex, ex.Message);
                GenericMessageDialog.Show(Properties.Resources.LauncherUpdaterError, DialogIcon.Error, DialogOptions.Ok);
                Environment.Exit(1);
            }
        }
 private void FailGameScan(string reason)
 {
     FileProgress.ProgressBar.Foreground      = Brushes.Red;
     ScanTotalProgress.ProgressBar.Foreground = Brushes.Red;
     CurrentFileLabel.Content      = string.Empty;
     MainProgressLabel.Content     = string.Empty;
     TaskbarItemInfo.ProgressState = System.Windows.Shell.TaskbarItemProgressState.Error;
     GenericMessageDialog.Show(reason, DialogIcon.Error, DialogOptions.Ok);
 }
        private void OnAddScenarioClick(object sender, RoutedEventArgs e)
        {
            _folderListener.EnableRaisingEvents = false;

            try
            {
                using (var dlg = new System.Windows.Forms.OpenFileDialog
                {
                    Filter = $@"{Properties.Resources.ScenarioEditorFilePickerFileTypes} (*.age4scn)|*.age4scn",
                    CheckFileExists = true,
                    Title = Properties.Resources.ScenarioEditorFilePickerTitle,
                    Multiselect = true
                })
                {
                    if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    {
                        return;
                    }

                    foreach (var filename in dlg.FileNames)
                    {
                        var selectedDestinationPath =
                            Path.Combine(_scenarioDirectoryPath, Path.GetFileName(filename) ?? string.Empty);

                        if (File.Exists(selectedDestinationPath))
                        {
                            var userSelectedToOverwrite = GenericMessageDialog.Show(
                                string.Format(Properties.Resources.ScenarioEditorOverwritePrompt, selectedDestinationPath),
                                DialogIcon.None,
                                DialogOptions.YesNo);

                            if (userSelectedToOverwrite != true)
                            {
                                return;
                            }
                        }

                        File.Copy(filename, selectedDestinationPath, true);
                    }

                    RefreshList();
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, ex.Message);
                GenericMessageDialog.Show(Properties.Resources.GenericUnexpectedErrorMessage, DialogIcon.Error, DialogOptions.Ok);
            }
            finally
            {
                _folderListener.EnableRaisingEvents = true;
            }
        }
示例#12
0
        private void ConfirmBtnClick(object sender, RoutedEventArgs e)
        {
            var selectedNetworkInterface = NetworkInterfaceListView.SelectedItem as ListViewItem;

            if (selectedNetworkInterface == null)
            {
                GenericMessageDialog.Show(Properties.Resources.NetworkDeviceSelectorNoDeviceSelected, DialogIcon.Error, DialogOptions.Ok);
                return;
            }

            SelectedInterface = (NetworkInterface)selectedNetworkInterface.Tag;

            DialogResult = true;
            Close();
        }
        private void ScanBtnClick(object sender, RoutedEventArgs e)
        {
            var spartanDirectory = Directory.Exists(PathLocation.Text) ? PathLocation.Text : Path.GetDirectoryName(PathLocation.Text);

            if (!Directory.Exists(spartanDirectory))
            {
                GenericMessageDialog.Show(Properties.Resources.GamePathInvalidPath, DialogIcon.Error, DialogOptions.Ok);
            }
            else
            {
                Close();

                LegacyBootstrapper.UserConfig.GameFilesPath = spartanDirectory;
                LegacyBootstrapper.UserConfig.Save(LegacyBootstrapper.UserConfigFilePath);
                GameScannerService.StartGameScanner(spartanDirectory, LegacyBootstrapper.UserConfig.IsSteamVersion);
            }
        }
示例#14
0
        private void ScanBtnClick(object sender, RoutedEventArgs e)
        {
            var spartanDirectory = Directory.Exists(PathLocation.Text) ? PathLocation.Text : Path.GetDirectoryName(PathLocation.Text);

            if (!Directory.Exists(spartanDirectory))
            {
                GenericMessageDialog.Show(Properties.Resources.GamePathInvalidPath, DialogIcon.Error, DialogOptions.Ok);
            }
            else
            {
                Close();

                LegacyBootstrapper.UserConfig.GameFilesPath = spartanDirectory;
                LegacyBootstrapper.UserConfig.Save(LegacyBootstrapper.UserConfigFilePath);
                var scanner = new GameScannerWindow(spartanDirectory, LegacyBootstrapper.UserConfig.IsSteamVersion, FastDownloadOption.IsChecked ?? false);
                scanner.Owner = Owner;
                scanner.ShowDialog();
            }
        }
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                var progress = new Progress <int>();
                progress.ProgressChanged += (s, o) => { ProgressIndicator.ProgressBar.Value = o; };

                await ProcDump.DoDownloadAndInstallProcDump(progress);
            }
            catch (Exception exception)
            {
                Logger.Error(exception, exception.Message);
                GenericMessageDialog.Show(Properties.Resources.ProcdumpInstallError, DialogIcon.Error, DialogOptions.Ok);
            }
            finally
            {
                Close();
            }
        }
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var osInfo = OsVersionInfo.GetOsVersionInfo();

            if (osInfo.Major < 6 || osInfo.Major == 6 && osInfo.Minor < 2)
            {
                GenericMessageDialog.Show(string.Format(Properties.Resources.WindowsFeatureHelperUnsupportedOS, osInfo.FullName),
                                          DialogIcon.Warning);

                Close();
                return;
            }

            try
            {
                foreach (var feature in await Dism.GetWindowsFeatureInfo(new[] { "DirectPlay", "NetFx3" }))
                {
                    if (string.Equals(feature.Key, "DirectPlay", StringComparison.CurrentCultureIgnoreCase))
                    {
                        var(statusText, colorLabel, canBeEnabled) = GetLabelStatusForDismFeature(feature.Value);

                        DirectPlayStatusLabel.Text       = statusText;
                        DirectPlayStatusLabel.Foreground = new SolidColorBrush(colorLabel);
                        EnableDirectPlayBtn.IsEnabled    = canBeEnabled;
                    }
                    else if (string.Equals(feature.Key, "NetFx3", StringComparison.CurrentCultureIgnoreCase))
                    {
                        var(statusText, colorLabel, canBeEnabled) = GetLabelStatusForDismFeature(feature.Value);

                        NetFrameworkStatusLabel.Text       = statusText;
                        NetFrameworkStatusLabel.Foreground = new SolidColorBrush(colorLabel);
                        EnableNetFrameworkBtn.IsEnabled    = canBeEnabled;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, ex.Message);
                NetFrameworkStatusLabel.Text       = Properties.Resources.WindowsFeatureHelperFeatureNotSupportedError;
                NetFrameworkStatusLabel.Foreground = new SolidColorBrush(Colors.Red);
            }
        }
        private async void EnableNetFrameworkBtnClick(object sender, RoutedEventArgs e)
        {
            IsEnabled = false;
            try
            {
                var feature = await Dism.EnableWindowsFeatures("NetFx3", OnDismInstallProgress);

                var(statusText, colorLabel, canBeEnabled) = GetLabelStatusForDismFeature(feature);

                NetFrameworkStatusLabel.Text       = statusText;
                NetFrameworkStatusLabel.Foreground = new SolidColorBrush(colorLabel);
                EnableNetFrameworkBtn.IsEnabled    = canBeEnabled;
            }
            catch (Exception ex)
            {
                Logger.Error(ex, ex.Message);
                GenericMessageDialog.Show(Properties.Resources.GenericUnexpectedErrorMessage, DialogIcon.Error, DialogOptions.Ok);
            }
            IsEnabled = true;
        }
        private async void OnResetPasswordClick(object sender, RoutedEventArgs e)
        {
            if (!Misc.IsValidEmailAdress(EmailAddressField.InputContent))
            {
                GenericMessageDialog.Show(Properties.Resources.ResetPasswordInvalidEmail, DialogIcon.Error, DialogOptions.Ok);
                return;
            }

            if (ResetKeyField.InputContent.Length != 32)
            {
                GenericMessageDialog.Show(Properties.Resources.ResetPasswordInvalidKey, DialogIcon.Error, DialogOptions.Ok);
                return;
            }

            IsEnabled = false;

            try
            {
                var response = await LegacyBootstrapper.WebSocketApi.DoResetPwd(EmailAddressField.InputContent, ResetKeyField.InputContent);

                if (response.Result)
                {
                    GenericMessageDialog.Show(response.GetLocalizedMessage(), DialogIcon.None, DialogOptions.Ok);

                    DialogResult = true;
                    Close();
                    return;
                }

                GenericMessageDialog.Show(response.GetLocalizedMessage(), DialogIcon.Error, DialogOptions.Ok);
            }
            catch (Exception ex)
            {
                Logger.Error(ex, ex.Message);
                GenericMessageDialog.Show(Properties.Resources.ResetPasswordError, DialogIcon.Error, DialogOptions.Ok);
            }

            IsEnabled = true;
        }
示例#19
0
        private void ConfirmBtnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                var currentApplicationFullPath = Assembly.GetEntryAssembly().Location;
                if (currentApplicationFullPath.EndsWith("AOEOnline.exe", StringComparison.OrdinalIgnoreCase))
                {
                    GenericMessageDialog.Show(Properties.Resources.SteamConverterAlreadySteamGame, DialogIcon.None, DialogOptions.Ok);
                    Close();
                    return;
                }

                var currentWorkingDirectory = Path.GetDirectoryName(currentApplicationFullPath);

                if (!File.Exists($"{currentWorkingDirectory}\\Spartan.exe"))
                {
                    GenericMessageDialog.Show(Properties.Resources.SteamConverterIncorrectInstallationDirectory, DialogIcon.None, DialogOptions.Ok);
                    Close();
                    return;
                }

                LegacyBootstrapper.UserConfig.GameFilesPath = currentWorkingDirectory;
                LegacyBootstrapper.UserConfig.Save(LegacyBootstrapper.UserConfigFilePath);

                Steam.ConvertToSteam(LegacyBootstrapper.UserConfig.GameFilesPath);

                GenericMessageDialog.Show(Properties.Resources.SteamConverterSuccess, DialogIcon.None, DialogOptions.Ok);

                Process.Start(Assembly.GetEntryAssembly().Location
                              .Replace(Path.GetFileName(currentApplicationFullPath), "AOEOnline.exe"));

                Environment.Exit(0);
            }
            catch (Exception ex)
            {
                Logger.Error(ex, ex.Message);
                GenericMessageDialog.Show(Properties.Resources.GenericUnexpectedErrorMessage, DialogIcon.Error, DialogOptions.Ok);
            }
        }
        private void OnRemoveScenarioClick(object sender, RoutedEventArgs e)
        {
            _folderListener.EnableRaisingEvents = false;
            try
            {
                if (ScenarioListView.SelectedItems.Count < 1)
                {
                    return;
                }

                foreach (ListViewItem lvi in ScenarioListView.SelectedItems)
                {
                    if (File.Exists((string)lvi.Tag))
                    {
                        var userSelectedToDeleteFile = GenericMessageDialog.Show(
                            string.Format(Properties.Resources.ScenarioEditorDeleteScenarioPrompt, lvi.Content),
                            DialogIcon.None,
                            DialogOptions.YesNo);

                        if (userSelectedToDeleteFile == true)
                        {
                            File.Delete((string)lvi.Tag);
                        }
                    }
                }

                RefreshList();
            }
            catch (Exception ex)
            {
                Logger.Error(ex, ex.Message);
                GenericMessageDialog.Show(Properties.Resources.GenericUnexpectedErrorMessage, DialogIcon.Error, DialogOptions.Ok);
            }
            finally
            {
                _folderListener.EnableRaisingEvents = true;
            }
        }
示例#21
0
        private void AddFriendClick(object sender, RoutedEventArgs e)
        {
            var friendList = DataContext as FriendListViewModel;

            if (friendList?.FriendListCount >= FriendService.MaxAllowedFriends)
            {
                GenericMessageDialog.Show(Properties.Resources.FriendListMaxFriendsReached,
                                          DialogIcon.Warning,
                                          DialogOptions.Ok);
                return;
            }

            var addFriendDialog = new AddFriendDialog(_friendService);

            addFriendDialog.Owner = this;

            var userSelectedAddFriend = addFriendDialog.ShowDialog();

            if (userSelectedAddFriend == true)
            {
                UpdateFriendList();
            }
        }
        private async void ConfirmBtnClick(object sender, RoutedEventArgs e)
        {
            var currentPassword      = CurrentPasswordField.PasswordInputBox.Password;
            var newPassword          = NewPasswordField.PasswordInputBox.Password;
            var confirmedNewPassword = ConfirmedPasswordField.PasswordInputBox.Password;

            if (newPassword != confirmedNewPassword)
            {
                GenericMessageDialog.Show(Properties.Resources.ChangePasswordMismatch,
                                          DialogIcon.Error,
                                          DialogOptions.Ok);

                return;
            }

            if (currentPassword == newPassword)
            {
                GenericMessageDialog.Show(Properties.Resources.ChangePasswordSamePassword,
                                          DialogIcon.Error,
                                          DialogOptions.Ok);

                return;
            }

            if (newPassword.Length < 8 || newPassword.Length > 32)
            {
                GenericMessageDialog.Show(Properties.Resources.ChangePasswordInvalidLength,
                                          DialogIcon.Error,
                                          DialogOptions.Ok);

                return;
            }

            if (!Misc.IsValidPassword(newPassword))
            {
                GenericMessageDialog.Show(Properties.Resources.ChangePasswordInvalidPassword,
                                          DialogIcon.Error,
                                          DialogOptions.Ok);

                return;
            }

            IsEnabled = false;

            try
            {
                var changePasswordResponse = await LegacyBootstrapper.WebSocketApi.DoChangePassword(currentPassword, newPassword);

                if (changePasswordResponse.Result)
                {
                    GenericMessageDialog.Show(Properties.Resources.ChangePasswordSuccess,
                                              DialogIcon.None,
                                              DialogOptions.Ok);

                    Close();
                    return;
                }

                GenericMessageDialog.Show($"{Properties.Resources.ChangePasswordError} {changePasswordResponse.Message}",
                                          DialogIcon.Error,
                                          DialogOptions.Ok);
            }
            catch (Exception ex)
            {
                Logger.Error(ex, ex.Message);
                GenericMessageDialog.Show(Properties.Resources.GenericUnexpectedErrorMessage,
                                          DialogIcon.Error,
                                          DialogOptions.Ok);
            }
            finally
            {
                IsEnabled = true;
            }
        }
示例#23
0
        private void LoadFirewallRules()
        {
            try
            {
                //Launcher
                var launcherPath = Assembly.GetEntryAssembly().Location;

                if (!File.Exists(launcherPath))
                {
                    GenericMessageDialog.Show(Properties.Resources.WindowsFirewallHelperLauncherNotFound, DialogIcon.Error, DialogOptions.Ok);
                    Close();
                    return;
                }

                var rule = (StandardRuleWin7)FirewallHelper.FindRule("celeste_launcher_outbound_tcp");
                if (rule == null)
                {
                    LauncherOutboundStatus.Content    = Properties.Resources.WindowsFirewallHelperRuleNotFound;
                    LauncherOutboundStatus.Foreground = new SolidColorBrush(Colors.Red);
                }
                else
                {
                    if (rule.Protocol != FirewallProtocol.TCP || rule.ApplicationName != launcherPath ||
                        rule.LocalPortType != FirewallPortType.All || rule.Direction != FirewallDirection.Outbound)
                    {
                        LauncherOutboundStatus.Content    = Properties.Resources.WindowsFirewallHelperRuleInvalid;
                        LauncherOutboundStatus.Foreground = new SolidColorBrush(Colors.Red);
                    }
                    else
                    {
                        LauncherOutboundStatus.Content    = Properties.Resources.WindowsFirewallHelperRuleOpen;
                        LauncherOutboundStatus.Foreground = new SolidColorBrush(Colors.Green);
                    }
                }

                var path = !string.IsNullOrWhiteSpace(LegacyBootstrapper.UserConfig?.GameFilesPath)
                    ? LegacyBootstrapper.UserConfig?.GameFilesPath
                    : GameScannerManager.GetGameFilesRootPath();

                var spartanPath = Path.Combine(path, "Spartan.exe");

                if (!File.Exists(spartanPath))
                {
                    GenericMessageDialog.Show(Properties.Resources.WindowsFirewallHelperSpartanNotFound, DialogIcon.Error, DialogOptions.Ok);
                    Close();
                    return;
                }

                //Spartan
                var rule1 = (StandardRuleWin7)FirewallHelper.FindRule("celeste_spartan_inbound_tcp");
                var rule2 = (StandardRuleWin7)FirewallHelper.FindRule("celeste_spartan_inbound_udp");
                if (rule1 == null || rule2 == null)
                {
                    SpartanInboundStatus.Content    = Properties.Resources.WindowsFirewallHelperRuleNotFound;
                    SpartanInboundStatus.Foreground = new SolidColorBrush(Colors.Red);
                }
                else
                {
                    if (rule1.Protocol != FirewallProtocol.TCP || rule1.ApplicationName != spartanPath ||
                        rule1.LocalPortType != FirewallPortType.All || rule1.Direction != FirewallDirection.Inbound ||
                        rule2.Protocol != FirewallProtocol.UDP || rule2.ApplicationName != spartanPath ||
                        rule2.LocalPortType != FirewallPortType.All || rule2.Direction != FirewallDirection.Inbound)
                    {
                        SpartanInboundStatus.Content    = Properties.Resources.WindowsFirewallHelperRuleInvalid;
                        SpartanInboundStatus.Foreground = new SolidColorBrush(Colors.Red);
                    }
                    else
                    {
                        SpartanInboundStatus.Content    = Properties.Resources.WindowsFirewallHelperRuleOpen;
                        SpartanInboundStatus.Foreground = new SolidColorBrush(Colors.Green);
                    }
                }

                rule1 = (StandardRuleWin7)FirewallHelper.FindRule("celeste_spartan_outbound_tcp");
                rule2 = (StandardRuleWin7)FirewallHelper.FindRule("celeste_spartan_outbound_udp");
                if (rule1 == null || rule2 == null)
                {
                    SpartanOutboundStatus.Content    = Properties.Resources.WindowsFirewallHelperRuleNotFound;
                    SpartanOutboundStatus.Foreground = new SolidColorBrush(Colors.Red);
                }
                else
                {
                    if (rule1.Protocol != FirewallProtocol.TCP || rule1.ApplicationName != spartanPath ||
                        rule1.LocalPortType != FirewallPortType.All || rule1.Direction != FirewallDirection.Outbound ||
                        rule2.Protocol != FirewallProtocol.UDP || rule2.ApplicationName != spartanPath ||
                        rule2.LocalPortType != FirewallPortType.All || rule2.Direction != FirewallDirection.Outbound)
                    {
                        SpartanOutboundStatus.Content    = Properties.Resources.WindowsFirewallHelperRuleInvalid;
                        SpartanOutboundStatus.Foreground = new SolidColorBrush(Colors.Red);
                    }
                    else
                    {
                        SpartanOutboundStatus.Content    = Properties.Resources.WindowsFirewallHelperRuleOpen;
                        SpartanOutboundStatus.Foreground = new SolidColorBrush(Colors.Green);
                    }
                }

                //Port 1000
                rule = (StandardRuleWin7)FirewallHelper.FindRule("celeste_port1000_inbound_udp");
                if (rule == null)
                {
                    MultiplayerInboundStatus.Content    = Properties.Resources.WindowsFirewallHelperRuleNotFound;
                    MultiplayerInboundStatus.Foreground = new SolidColorBrush(Colors.Red);
                }
                else
                {
                    if (rule.Protocol != FirewallProtocol.UDP || rule.LocalPorts.All(key => key != 1000) ||
                        rule.LocalPortType != FirewallPortType.Specific || rule.Direction != FirewallDirection.Inbound)
                    {
                        MultiplayerInboundStatus.Content    = Properties.Resources.WindowsFirewallHelperRuleInvalid;
                        MultiplayerInboundStatus.Foreground = new SolidColorBrush(Colors.Red);
                    }
                    else
                    {
                        MultiplayerInboundStatus.Content    = Properties.Resources.WindowsFirewallHelperRuleOpen;
                        MultiplayerInboundStatus.Foreground = new SolidColorBrush(Colors.Green);
                    }
                }

                rule = (StandardRuleWin7)FirewallHelper.FindRule("celeste_port1000_outbound_udp");
                if (rule == null)
                {
                    MultiplayerOutboundStatus.Content    = Properties.Resources.WindowsFirewallHelperRuleNotFound;
                    MultiplayerOutboundStatus.Foreground = new SolidColorBrush(Colors.Red);
                }
                else
                {
                    if (rule.Protocol != FirewallProtocol.UDP || rule.LocalPorts.All(key => key != 1000) ||
                        rule.LocalPortType != FirewallPortType.Specific || rule.Direction != FirewallDirection.Outbound)
                    {
                        MultiplayerOutboundStatus.Content    = Properties.Resources.WindowsFirewallHelperRuleInvalid;
                        MultiplayerOutboundStatus.Foreground = new SolidColorBrush(Colors.Red);
                    }
                    else
                    {
                        MultiplayerOutboundStatus.Content    = Properties.Resources.WindowsFirewallHelperRuleOpen;
                        MultiplayerOutboundStatus.Foreground = new SolidColorBrush(Colors.Green);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, ex.Message);
                GenericMessageDialog.Show(Properties.Resources.GenericUnexpectedErrorMessage, DialogIcon.Error, DialogOptions.Ok);
            }
        }
示例#24
0
        private void SpartanOpenBtn_Click(object sender, RoutedEventArgs e)
        {
            IsEnabled = false;
            try
            {
                var path = !string.IsNullOrWhiteSpace(LegacyBootstrapper.UserConfig?.GameFilesPath)
                    ? LegacyBootstrapper.UserConfig?.GameFilesPath
                    : GameScannerManager.GetGameFilesRootPath();

                var spartanPath = Path.Combine(path, "Spartan.exe");

                if (!File.Exists(spartanPath))
                {
                    GenericMessageDialog.Show(Properties.Resources.WindowsFirewallHelperSpartanNotFound, DialogIcon.Error, DialogOptions.Ok);
                    Close();
                    return;
                }

                //inbound_tcp
                var rule = FirewallHelper.RuleExist("celeste_spartan_inbound_tcp");
                if (rule)
                {
                    FirewallHelper.RemoveRules("celeste_spartan_inbound_tcp");
                }

                FirewallHelper.AddApplicationRule("celeste_spartan_inbound_tcp", spartanPath,
                                                  FirewallDirection.Inbound, FirewallProtocol.TCP);

                //outbound_tcp
                rule = FirewallHelper.RuleExist("celeste_spartan_outbound_tcp");
                if (rule)
                {
                    FirewallHelper.RemoveRules("celeste_spartan_outbound_tcp");
                }

                FirewallHelper.AddApplicationRule("celeste_spartan_outbound_tcp", spartanPath,
                                                  FirewallDirection.Outbound, FirewallProtocol.TCP);

                //inbound_udp
                rule = FirewallHelper.RuleExist("celeste_spartan_inbound_udp");
                if (rule)
                {
                    FirewallHelper.RemoveRules("celeste_spartan_inbound_udp");
                }

                FirewallHelper.AddApplicationRule("celeste_spartan_inbound_udp", spartanPath,
                                                  FirewallDirection.Inbound, FirewallProtocol.UDP);

                //outbound_udp
                rule = FirewallHelper.RuleExist("celeste_spartan_outbound_udp");
                if (rule)
                {
                    FirewallHelper.RemoveRules("celeste_spartan_outbound_udp");
                }

                FirewallHelper.AddApplicationRule("celeste_spartan_outbound_udp", spartanPath,
                                                  FirewallDirection.Outbound, FirewallProtocol.UDP);
            }
            catch (Exception ex)
            {
                Logger.Error(ex, ex.Message);
                GenericMessageDialog.Show(Properties.Resources.GenericUnexpectedErrorMessage, DialogIcon.Error, DialogOptions.Ok);
            }

            LoadFirewallRules();

            IsEnabled = true;
        }
示例#25
0
 private void FastDownloadOption_Checked(object sender, RoutedEventArgs e)
 {
     GenericMessageDialog.Show(Properties.Resources.GameScannerFastDownloadWarning, DialogIcon.None, DialogOptions.Ok);
 }