public Form1() { InitializeComponent(); progressPanel1.Hide(); ToplamDurumProgressBar.Hide(); durumLabel.Hide(); // Tinify.Key = Util.APIKEY; }
private async void CompresserBtn_Click(object sender, EventArgs e) { if (resimYol.Count != 0 && (!string.IsNullOrWhiteSpace(metroTextBox1.Text))) { try { progressPanel1.Show(); ToplamDurumProgressBar.Show(); kayitYeri = KlasorOlustur(); indirilenDosyaListBox.Items.Clear(); int i = 0; int boyut = 100 / resimYol.Count; foreach (var resim in resimYol) { ToplamDurumProgressBar.Percentage = boyut * i; Image img = Image.FromFile(resim.Value); var resultData = await Tinify.FromBuffer(Util.ImgToByte(img)).ToBuffer(); Image responseImage = Util.ByteToImage(resultData); responseImage.Save(kayitYeri + "\\" + resim.Key); indirilenDosyaListBox.Items.Add(resim.Key); i++; ToplamDurumProgressBar.Percentage = boyut * i; } } catch (Exception t) { MessageBox.Show(t.Message); ToplamDurumProgressBar.Hide(); } finally { ToplamDurumProgressBar.Percentage = 100; progressPanel1.Hide(); resimYol.Clear(); dosyaListBox.Items.Clear(); } } else { MessageBox.Show("Klasör Seçili değil veya API Key alanı boş!"); } }
private void klasorAcBtn_Click(object sender, EventArgs e) { try { if (indirilenDosyaListBox.Items.Count != 0) { indirilenDosyaListBox.Items.Clear(); ToplamDurumProgressBar.Hide(); Process.Start(kayitYeri); } else { MessageBox.Show("Klasör Boş"); } } catch { MessageBox.Show("Klasör Bulunamadı!"); } }