private void Browse_OnClick(object sender, RoutedEventArgs e)
        {
            using (CommonOpenFileDialog dialog = new CommonOpenFileDialog()) {
                dialog.IsFolderPicker   = true;
                dialog.DefaultDirectory = Directory.Exists(this.OutputPath.Text)
                    ? this.OutputPath.Text
                    : ShellFunctions.GetUserFolder(ShellFunctions.UserFolder.Downloads);

                if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
                {
                    this.OutputPath.Text = dialog.FileName;
                }
            }
        }
示例#2
0
        private void LoadAllSettings()
        {
            RadioButton target_rating = this.Rating.Children.OfType <RadioButton>()
                                        .FirstOrDefault(n => n.Name == "Radio" + Settings.Default.CurrentRating);

            if (target_rating != null)
            {
                target_rating.IsChecked = true;
            }

            RadioButton target_format = this.Format.Children.OfType <RadioButton>()
                                        .FirstOrDefault(n => n.Name == "Radio" + Settings.Default.CurrentFormat);

            if (target_format != null)
            {
                target_format.IsChecked = true;
            }

            this.StartSequence.Text = Settings.Default.StartSequence.ToString();

            // There has to be a better way?
            for (int i = 0; i < this.Source.Items.Count; i++)
            {
                if (this.Source.Items[i].ToString() == Settings.Default.CurrentSource)
                {
                    this.Source.SelectedIndex = i;
                    break;
                }
            }

            this.OutputPath.Text = string.IsNullOrEmpty(Settings.Default.CurrentPath)
                ? ShellFunctions.GetUserFolder(ShellFunctions.UserFolder.Pictures)
                : Settings.Default.CurrentPath;

            // Needs to be loaded after CurrentSource to avoid crashes in TextChanged handler
            this.Tags.Text = Settings.Default.CurrentTags;

            if (AvailableImageBoards.First(board => board.Name == "Danbooru") is ApiImageBoard danbooru)
            {
                danbooru.Credentials
                    = new ApiImageBoard.ApiCredentials {
                    Username = Settings.Default.DanbooruUsername,
                    ApiKey   = Settings.Default.DanbooruKey
                    };
            }
        }