설명 없음
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

驗貨報告大圖.vb 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. Option Strict Off
  2. Imports System.Data.SqlClient
  3. Imports System.IO
  4. Public Class 驗貨報告大圖
  5. Dim conn As New SqlConnection
  6. Dim cmd As New SqlCommand
  7. Dim dr As SqlDataReader
  8. Private m_Leftx As Integer = 152
  9. Private m_Lefty As Integer = 0
  10. Dim m_MousePosX As Integer
  11. Dim m_MousePosY As Integer
  12. Dim m_DeltaX As Integer
  13. Dim m_DeltaY As Integer
  14. Private Sub 驗貨報告大圖_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  15. FormBorderStyle = FormBorderStyle.SizableToolWindow 'ControlBox = False
  16. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  17. SQL1 = "SELECT TOP(1) 驗貨報告 FROM 驗貨報告圖庫 WHERE 驗貨報告編號 LIKE '" & 驗貨報告 & "'"
  18. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  19. PictureBox1.Image = Nothing
  20. While dr.Read() = True
  21. Dim bytes As Byte() = New Byte(-1) {} : bytes = DirectCast(dr.Item("驗貨報告"), Byte()) : Dim oStream As New MemoryStream(bytes)
  22. PictureBox1.Image = Bitmap.FromStream(oStream)
  23. End While
  24. conn.Close() : PictureBox1.SizeMode = 4
  25. End Sub
  26. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  27. PictureBox1.Image.RotateFlip(RotateFlipType.Rotate90FlipNone) : PictureBox1.Refresh() : PictureBox1.SizeMode = 4
  28. End Sub
  29. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  30. PictureBox1.Image.RotateFlip(RotateFlipType.Rotate270FlipNone) : PictureBox1.Refresh() : PictureBox1.SizeMode = 4
  31. End Sub
  32. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  33. PictureBox1.Image.RotateFlip(RotateFlipType.Rotate180FlipY) : PictureBox1.Refresh() : PictureBox1.SizeMode = 4
  34. End Sub
  35. Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
  36. PictureBox1.Image.RotateFlip(RotateFlipType.Rotate180FlipX) : PictureBox1.Refresh() : PictureBox1.SizeMode = 4
  37. End Sub
  38. Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
  39. Dim image = PictureBox1.Image
  40. Dim g As Graphics = PictureBox1.CreateGraphics
  41. g.DrawImage(image, New Rectangle(0, 0, image.Width * 1.01, image.Height * 1.01))
  42. image = Nothing
  43. End Sub
  44. Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
  45. PictureBox1.Refresh()
  46. End Sub
  47. '@#处理鼠标按键抬起的事件,根据鼠标按下时保存的鼠标位置,和当前鼠标的位置,
  48. '计算鼠标移动偏移量,借此调用移动图片的函数,移动图片
  49. Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles PictureBox1.MouseUp
  50. m_DeltaX = m_MousePosX - e.X
  51. m_DeltaY = m_MousePosY - e.Y
  52. m_Leftx = m_Leftx - m_DeltaX
  53. m_Lefty = m_Lefty - m_DeltaY
  54. Picturemove(sender, e)
  55. Me.Cursor = Cursors.Arrow
  56. End Sub
  57. '@#当鼠标按下时,将鼠标变成手形,并且记录下当前鼠标的位置
  58. Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles PictureBox1.MouseDown
  59. Me.Cursor = Cursors.Hand
  60. m_MousePosX = e.X
  61. m_MousePosY = e.Y
  62. End Sub
  63. '@#根据偏移量计算出的图片位置,重画图片
  64. Private Sub Picturemove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
  65. Dim myBit As New Bitmap(PictureBox1.Image)
  66. Dim myPicGrh As Graphics = Me.PictureBox1.CreateGraphics
  67. myPicGrh.Clear(Me.PictureBox1.BackColor)
  68. myPicGrh.DrawImageUnscaled(myBit, m_Leftx - 152, m_Lefty)
  69. myBit.Dispose()
  70. myPicGrh.Dispose()
  71. End Sub
  72. End Class