Advertisement
VladislavSavvateev

MainForm of Lucky Picture!

Jul 26th, 2015
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.07 KB | None | 0 0
  1. Imports Google.API.Search
  2. Imports System.Drawing.Imaging
  3. Public Class MainForm
  4.  
  5.     Private Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
  6.         If txtRequest.Text = "" Then
  7.             MsgBox("Ты ж даже ничего не задал!", MsgBoxStyle.Critical, "*_*")
  8.         Else
  9.             Try
  10.                 Dim Engine As New GimageSearchClient("")    ' Создаём переменную с новым классом
  11.                 Picture.ImageLocation = Engine.Search(txtRequest.Text, 1).Item(0).Url   ' Наполняем PictureBox картинкой
  12.                 btnSave.Enabled = True
  13.                 If cbCopyLink.Checked Then
  14.                     Clipboard.SetText(Picture.ImageLocation)
  15.                 End If
  16.             Catch ex As Net.WebException
  17.                 MsgBox("И как ты собираешься искать? Без интернета?!", MsgBoxStyle.Critical, "*_*")
  18.             End Try
  19.         End If
  20.     End Sub
  21.  
  22.     Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
  23.         SaveFile.Filter = "Все файлы|*.*"
  24.         If Picture.Image.RawFormat.Equals(ImageFormat.Bmp) Then
  25.             SaveFile.Filter = "BMP|*.bmp"
  26.         End If
  27.         If Picture.Image.RawFormat.Equals(ImageFormat.Emf) Then
  28.             SaveFile.Filter = "EMF|*.emf"
  29.         End If
  30.         If Picture.Image.RawFormat.Equals(ImageFormat.Exif) Then
  31.             SaveFile.Filter = "EXIF|*.exif"
  32.         End If
  33.         If Picture.Image.RawFormat.Equals(ImageFormat.Gif) Then
  34.             SaveFile.Filter = "GIF|*.gif"
  35.         End If
  36.         If Picture.Image.RawFormat.Equals(ImageFormat.Icon) Then
  37.             SaveFile.Filter = "Icon|*.ico"
  38.         End If
  39.         If Picture.Image.RawFormat.Equals(ImageFormat.Jpeg) Then
  40.             SaveFile.Filter = "JPEG|*.jpg"
  41.         End If
  42.         If Picture.Image.RawFormat.Equals(ImageFormat.Png) Then
  43.             SaveFile.Filter = "PNG|*.png"
  44.         End If
  45.         If Picture.Image.RawFormat.Equals(ImageFormat.Tiff) Then
  46.             SaveFile.Filter = "TIFF|*.tiff"
  47.         End If
  48.         If Picture.Image.RawFormat.Equals(ImageFormat.Wmf) Then
  49.             SaveFile.Filter = "WMF|*.wmf"
  50.         End If
  51.         If SaveFile.ShowDialog = Windows.Forms.DialogResult.OK Then
  52.             Picture.Image.Save(SaveFile.FileName)
  53.         End If
  54.     End Sub
  55.  
  56.     Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
  57.         MsgBox("ЙОУ, САВОК СНОВА В ДЕЛЕ!", MsgBoxStyle.Exclamation, "*_*")
  58.     End Sub
  59.  
  60.     Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  61.         If My.Computer.Network.IsAvailable = False Then
  62.             MsgBox("И как ты собираешься искать? Без интернета?!", MsgBoxStyle.Critical, "*_*")
  63.             End
  64.         End If
  65.     End Sub
  66.  
  67.     Private Sub Picture_Click(sender As Object, e As EventArgs) Handles Picture.Click
  68.         PicturePreview.PictureBox1.Image = Picture.Image
  69.         PicturePreview.ShowDialog()
  70.     End Sub
  71. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement