public override int GetHashCode() { int hash = 1; if (ModelName.Length != 0) { hash ^= ModelName.GetHashCode(); } if (ProtoFile.Length != 0) { hash ^= ProtoFile.GetHashCode(); } if (WeightFile.Length != 0) { hash ^= WeightFile.GetHashCode(); } if (ResizeScale != 0F) { hash ^= ResizeScale.GetHashCode(); } if (InputOffsetY != 0) { hash ^= InputOffsetY.GetHashCode(); } if (InputOffsetX != 0) { hash ^= InputOffsetX.GetHashCode(); } if (CropHeight != 0) { hash ^= CropHeight.GetHashCode(); } if (CropWidth != 0) { hash ^= CropWidth.GetHashCode(); } if (MeanB != 0) { hash ^= MeanB.GetHashCode(); } if (MeanG != 0) { hash ^= MeanG.GetHashCode(); } if (MeanR != 0) { hash ^= MeanR.GetHashCode(); } if (IsBgr != false) { hash ^= IsBgr.GetHashCode(); } if (ModelType.Length != 0) { hash ^= ModelType.GetHashCode(); } return(hash); }
private async void btnRun_Click(object sender, EventArgs e) { if (btnRun.Text == "Cancelar") { _tokenSource.Cancel(); return; } picPreview.ImageLocation = null; _generateImages = new(); _resizeScale = new(this.GetWidth, this.GetHeight, rdbPorcent.Checked, chkPreserveOrientation.Checked, chkAspectRatio.Checked); _outputFiles = new(); lstFiles.Items.Clear(); lblCountInputs.Text = "0"; lblCountOutputs.Text = "0"; if (File.Exists(txtInputPath.Text)) { lblCountInputs.Text = "1"; // Apenas 1 arquivo selecionado var rp = this.GetResizePaths(txtInputPath.Text); var outFile = _generateImages.Save(rp.InputFile, _resizeScale, rp.pathOutput, rp.pathBackup); AddFileList(SavePackage(outFile).IsNull(outFile)); } else { if (!chkFilterJPG.Checked && !chkFilterPNG.Checked) { MessageBox.Show("Antes de continuar, é necessário selecionar um tipo de arquivo!", "Tipo de Arquivo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } _tokenSource = new CancellationTokenSource(); var token = _tokenSource.Token; try { // subfolders _countSubFolders = Directory.GetDirectories(txtInputPath.Text, "*", SearchOption.AllDirectories) .Where(n => !n.Contains("__output") && !n.Contains("__backup")).Count(); lblFolderCount.Text = _countSubFolders.ToString(); lblFolderCount.Visible = _countSubFolders > 0; btnRun.Text = "Cancelar"; this.Refresh(); progBar.Value = 0; progBar.Maximum = 100; // 100% var progress = new Progress <int>(value => { progBar.Value = value; if (value == 100) { _countSubFolders--; lblFolderCount.Text = _countSubFolders.ToString(); lblFolderCount.Refresh(); } lblCountInputs.Text = (Convert.ToInt32(lblCountInputs.Text) + 1).ToString(); if ((!rdbOutputCbz.Checked && !rdbOutputPdf.Checked) || value == 100) { lblCountOutputs.Text = (Convert.ToInt32(lblCountOutputs.Text) + 1).ToString(); } }); await Task.Run(() => { CarregarImagens(txtInputPath.Text, _userOp.SeekImageExtensions, _userOp.OutputType, progress, token); }); btnRun.Text = "Começar"; } catch (OperationCanceledException) { btnRun.Text = "Cancelado (Recomeçar)"; } finally { lblFolderCount.Visible = false; var outFiles = _outputFiles.Count > 0 ? _outputFiles : _generateImages.Outputs; progBar.Value = 0; progBar.Maximum = outFiles.Count; foreach (var item in outFiles) { AddFileList(item); progBar.Value++; } _tokenSource.Dispose(); } } }