暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

驗貨報告大圖.vb 3.4KB

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