コード例 #1
0
        private void SourceFoldersSearchButton_Click(object sender, RoutedEventArgs e)
        {
            if (!(this.DataContext is SettingsManager context))
            {
                return;
            }

            var addedCount = context.Executables.SearchAllFoldersForExecutablesAndAddThemAll();

            var labelText = TryFindResource("ExecutableFoldersSearchResultLabelText") as String;

            labelText = labelText.Replace("$", addedCount.ToString(CultureInfo.InvariantCulture));

            // Create Dialog with message
            var msgDialog = new GenericMessageDialog()
            {
                Title = TryFindResource("ExecutableFoldersSearchResultTitleText") as String,
                Owner = this
            };

            msgDialog.SetMessage(labelText);

            // Show dialog
            msgDialog.ShowAsync(ContentDialogPlacement.Popup);
        }
コード例 #2
0
        private async void AddExecutableFolderButton_Click(object sender, RoutedEventArgs e)
        {
            if (!(this.DataContext is SettingsManager context))
            {
                return;
            }

            using (var folderDialog = new CommonOpenFileDialog())
            {
                folderDialog.Title                     = TryFindResource("ExecutableSelectFolderDialogText") as String;
                folderDialog.IsFolderPicker            = true;
                folderDialog.AddToMostRecentlyUsedList = false;
                folderDialog.AllowNonFileSystemItems   = false;
                folderDialog.EnsureFileExists          = true;
                folderDialog.EnsurePathExists          = true;
                folderDialog.EnsureReadOnly            = false;
                folderDialog.EnsureValidNames          = true;
                folderDialog.Multiselect               = false;
                folderDialog.ShowPlacesList            = true;

                folderDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
                folderDialog.DefaultDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);

                if (folderDialog.ShowDialog() == CommonFileDialogResult.Ok)
                {
                    var selectedFolder = folderDialog.FileName;

                    if (context.Executables.Settings.SourceFolders.Contains(selectedFolder))
                    {
                        // Create Dialog with error message
                        var msgDialog = new GenericMessageDialog()
                        {
                            Title = TryFindResource("SourceFoldersAlreadyExistsErrorTitle") as String,
                            Owner = this
                        };
                        msgDialog.SetMessage(TryFindResource("SourceFoldersAlreadyExistsErrorText") as String);

                        // Show dialog
                        var msgDialogResult = await msgDialog.ShowAsync(ContentDialogPlacement.Popup).ConfigureAwait(true);

                        // Repeat action
                        if (msgDialogResult == ContentDialogResult.Primary)
                        {
                            AddExecutableFolderButton_Click(null, null);
                        }
                        else
                        {
                            return;
                        }
                    }
                    else
                    {
                        context.Executables.Settings.SourceFolders.Add(selectedFolder);
                    }
                }
            }
        }
コード例 #3
0
        private async void SetFileAssocButton_Click(object sender, RoutedEventArgs e)
        {
            if (!(this.DataContext is SettingsManager context))
            {
                return;
            }

            FileAssociations.SetRoflToSelf();

            var msgDialog = new GenericMessageDialog()
            {
                Title = TryFindResource("FileAssociationMessageTitleText") as String,
                Owner = this
            };

            msgDialog.SetMessage(TryFindResource("FileAssociationMessageBodyText") as String);

            // Show dialog
            await msgDialog.ShowAsync(ContentDialogPlacement.Popup).ConfigureAwait(true);
        }
コード例 #4
0
        private void SourceFoldersSearchButton_Click(object sender, RoutedEventArgs e)
        {
            if (!(this.DataContext is SettingsManager context))
            {
                return;
            }

            var results     = context.Executables.SearchAllFoldersForExecutablesAndAddThemAll();
            int addedCount  = results.Item1;
            var skippedDirs = results.Item2;

            var labelText = TryFindResource("ExecutableFoldersSearchResultLabelText") as String;

            labelText = labelText.Replace("$", addedCount.ToString(CultureInfo.InvariantCulture));

            if (skippedDirs.Length > 0)
            {
                labelText += "\n\n" + TryFindResource("ExecutableFoldersSearchResultErrorText") as String;
                foreach (string dir in skippedDirs)
                {
                    labelText += "\n" + dir;
                }
            }

            // Create Dialog with message
            var msgDialog = new GenericMessageDialog()
            {
                Title = TryFindResource("ExecutableFoldersSearchResultTitleText") as String,
                Owner = this
            };

            msgDialog.SetMessage(labelText);

            // Show dialog
            msgDialog.ShowAsync(ContentDialogPlacement.Popup);
        }
コード例 #5
0
        private async void UpdateCheckButton_Click(object sender, RoutedEventArgs e)
        {
            if (!(this.DataContext is SettingsManager context))
            {
                return;
            }

            string latestVersion;

            try
            {
                latestVersion = await GithubConnection.GetLatestVersion().ConfigureAwait(true);
            }
            catch (HttpRequestException ex)
            {
                // Http request failed, show error and stop
                // Create Dialog with error message
                var msgDialog = new GenericMessageDialog()
                {
                    Title = TryFindResource("UpdateExceptionTitleText") as String,
                    Owner = this
                };
                msgDialog.SetMessage(TryFindResource("UpdateHTTPExceptionBodyText") as String);

                // Show dialog
                await msgDialog.ShowAsync(ContentDialogPlacement.Popup).ConfigureAwait(true);

                return;
            }

            if (String.IsNullOrEmpty(latestVersion))
            {
                // Either github returned nothing or got an http error code
                // Http request failed, show error and stop
                // Create Dialog with error message
                var msgDialog = new GenericMessageDialog()
                {
                    Title = TryFindResource("UpdateExceptionTitleText") as String,
                    Owner = this
                };
                msgDialog.SetMessage(TryFindResource("UpdateGitHubErrorBodyText") as String);

                // Show dialog
                await msgDialog.ShowAsync(ContentDialogPlacement.Popup).ConfigureAwait(true);

                return;
            }

            var assemblyName    = Assembly.GetEntryAssembly()?.GetName();
            var assemblyVersion = assemblyName.Version.ToString(3);

            if (latestVersion.Equals(assemblyVersion, StringComparison.OrdinalIgnoreCase))
            {
                context.TemporaryValues["UpdateAvailable"] = false;
                UpdateAvailableButton.Visibility           = Visibility.Collapsed;

                var msgDialog = new GenericMessageDialog()
                {
                    Title = TryFindResource("UpdateMostRecentTitleText") as String,
                    Owner = this
                };
                msgDialog.SetMessage(TryFindResource("UpdateMostRecentBodyText") as String);
                await msgDialog.ShowAsync(ContentDialogPlacement.Popup).ConfigureAwait(true);
            }
            else
            {
                context.TemporaryValues["UpdateAvailable"] = true;
                UpdateAvailableButton.Visibility           = Visibility.Visible;

                var msgDialog = new GenericMessageDialog()
                {
                    Title = TryFindResource("UpdateNewerTitleText") as String,
                    Owner = this,
                    IsSecondaryButtonEnabled = true,
                    SecondaryButtonText      = TryFindResource("CancelButtonText") as String
                };
                msgDialog.SetMessage(TryFindResource("UpdateNewerBodyText") as String + $"\n{assemblyVersion} -> {latestVersion}");
                var response = await msgDialog.ShowAsync(ContentDialogPlacement.Popup).ConfigureAwait(true);

                if (response == ContentDialogResult.Primary)
                {
                    Process.Start((TryFindResource("GitHubReleasesLink") as Uri).ToString());
                }
            }

            return;
        }
コード例 #6
0
        private async void UpdateCheckButton_Click(object sender, RoutedEventArgs e)
        {
            string latestVersion;

            try
            {
                latestVersion = await GithubConnection.GetLatestVersion().ConfigureAwait(true);
            }
            catch (HttpRequestException ex)
            {
                // Http request failed, show error and stop
                // Create Dialog with error message
                var msgDialog = new GenericMessageDialog()
                {
                    Title = TryFindResource("UpdateExceptionTitleText") as String,
                    Owner = this
                };
                msgDialog.SetMessage(TryFindResource("UpdateHTTPExceptionBodyText") as String);

                // Show dialog
                await msgDialog.ShowAsync(ContentDialogPlacement.Popup).ConfigureAwait(true);

                return;
            }

            if (String.IsNullOrEmpty(latestVersion))
            {
                // Either github returned nothing or got an http error code
                // Http request failed, show error and stop
                // Create Dialog with error message
                var msgDialog = new GenericMessageDialog()
                {
                    Title = TryFindResource("UpdateExceptionTitleText") as String,
                    Owner = this
                };
                msgDialog.SetMessage(TryFindResource("UpdateGitHubErrorBodyText") as String);

                // Show dialog
                await msgDialog.ShowAsync(ContentDialogPlacement.Popup).ConfigureAwait(true);

                return;
            }

            var assemblyName    = Assembly.GetEntryAssembly()?.GetName();
            var assemblyVersion = assemblyName.Version.ToString(3);

            if (latestVersion.Equals(assemblyVersion, StringComparison.OrdinalIgnoreCase))
            {
                var msgDialog = new GenericMessageDialog()
                {
                    Title = TryFindResource("UpdateMostRecentTitleText") as String,
                    Owner = this
                };
                msgDialog.SetMessage(TryFindResource("UpdateMostRecentBodyText") as String);
                await msgDialog.ShowAsync(ContentDialogPlacement.Popup).ConfigureAwait(true);
            }
            else
            {
                var msgDialog = new GenericMessageDialog()
                {
                    Title = TryFindResource("UpdateNewerTitleText") as String,
                    Owner = this
                };
                msgDialog.SetMessage(TryFindResource("UpdateNewerBodyText") as String + $"\n{assemblyVersion} -> {latestVersion}");
                var response = await msgDialog.ShowAsync(ContentDialogPlacement.Popup).ConfigureAwait(true);

                if (response == ContentDialogResult.Primary)
                {
                    Process.Start($"https://github.com/fraxiinus/ReplayBook/releases");
                }
            }

            return;
        }