public DownloadRequest(String searchQuery, String downloadPath, Boolean autoDownload, RequestImageType imageType = RequestImageType.Image) { SearchQuery = DerpiAPI.CheckSearchRequest(searchQuery) ? searchQuery : String.Empty; DownloadPath = PathUtils.IsValidPath(downloadPath, PathType.File) ? downloadPath : Globals.CurrentDownloadPath; AutoDownload = autoDownload; ImageType = imageType; }
private void OnTextChanged() { Replace(ReplaceDictionary); ValidSearchQuery = DerpiAPI.CheckSearchRequest(Text); BackColor = ValidSearchQuery || String.IsNullOrEmpty(Text) ? Color.White : Color.IndianRed; }
private void OnAddTaskButton_Click(Object sender, EventArgs e) { if (!DerpiAPI.CheckSearchRequest(_searchQueryTextBox.Text)) { return; } AddTaskControl?.Invoke(new DownloadRequest(_searchQueryTextBox.Text, _downloadPathTextBox.Text, _queueAutoDownloadCheckBox.Checked)); if (!IsManualClose || ModifierKeys == Keys.Control || ModifierKeys == Keys.Shift) { Close(); } _searchQueryTextBox.Text = String.Empty; }
private async void SaveAPIButton_Click(Object sender, EventArgs e) { if (!_apiTextBox.CheckValidFormat()) { return; } if (_apiTextBox.Text != Globals.APIKey.GetValue()) { String apiKey = _apiTextBox.Text; Boolean apiTextBoxCurrentEnabled = _apiTextBox.Enabled; Boolean saveAPIButtonCurrentEnabled = _saveAPIButton.Enabled; Boolean changeAPIButtonCurrentEnabled = _changeAPIButton.Enabled; Boolean resetAPIButtonCurrentEnabled = _resetAPIButton.Enabled; DisableButtons(); void RestoreButtonsEnabledState() { _apiTextBox.Enabled = apiTextBoxCurrentEnabled; _saveAPIButton.Enabled = saveAPIButtonCurrentEnabled; _changeAPIButton.Enabled = changeAPIButtonCurrentEnabled; _resetAPIButton.Enabled = resetAPIButtonCurrentEnabled; } if (!await DerpiAPI.CheckValidAPIAsync(apiKey).ConfigureAwait(true)) { RestoreButtonsEnabledState(); ChangeAPI(); new MessageForm(Globals.Localization.EnteredAPIKeyInvalid, Globals.Localization.APIKeyInvalid, Images.Basic.Error, Images.Basic.Error) .ShowDialog(); return; } RestoreButtonsEnabledState(); Globals.APIKey.SetValue(apiKey); } _saveAPIButton.Enabled = false; _apiTextBox.Enabled = false; }
public APITextBox() { ValidateFunc = obj => DerpiAPI.CheckAPI(Text); MaxLength = DerpiAPI.LengthAPI; CheckValidFormat(); }
public static Task <String> GetJsonForSearchAsync([NotNull] String search, Int32 page = 1, String apiKey = null, Boolean isInvoke = true, CancellationToken token = default) { return(GetJsonAsync(DerpiAPI.CastToAPISearchRequest(search, page, apiKey), isInvoke, token)); }
public static Task <String> GetJsonMyWatchedAsync(Int32 page = 1, String apiKey = null, Boolean isInvoke = true, CancellationToken token = default) { return(GetJsonAsync(DerpiAPI.CastToAPIMyWatchedRequest(page, apiKey), isInvoke, token)); }
private void ImageDataSupplement(Image image) { image.query = DerpiAPI.CastSearchRequest(SearchQuery, true); }