1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
| Private Sub pbim_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pbim.MouseMove
difgpw = picsw - (Math.Abs(picslx) + gbw)
difgph = picsh - (Math.Abs(picsly) + gbh)
picsh = pbim.Height
picsw = pbim.Width
picslx = pbim.Location.X
picsly = pbim.Location.Y
zmp = myy - MousePosition.Y
varax = ((1780 * e.X) / picsw) - 5
varby = ((2200 * e.Y) / picsh) - 30
If rbcc.Checked = True Then
If image1 IsNot Nothing Then image1.Dispose()
image1 = New Bitmap(image2)
g = Graphics.FromImage(image1)
Try
If txtrt.Text = "" Then
ang = 1
Else
ang = txtrt.Text
End If
Catch ex As Exception
ang = 1
End Try
TextBox2.Text = ofdm.FileName.ToString
Dim angrad As Double = (ang * (Math.PI / 100)) + 100
poMatrix = New System.Drawing.Drawing2D.Matrix()
poMatrix.Rotate(ang)
transState = g.Save()
g.Transform = poMatrix
g.TranslateTransform(varax, varby, System.Drawing.Drawing2D.MatrixOrder.Append)
Dim string_format As New StringFormat
string_format.Alignment = StringAlignment.Center
string_format.LineAlignment = StringAlignment.Center
g.DrawString(txtcc.Text, New Font("Arial", 10.0F), Brushes.Black, 0, 0, string_format)
pbim.Image = image1
pbim.Refresh()
g.Dispose()
ElseIf rbd.Checked = True Or rbp.Checked = True Or rbl.Checked = True Or rbhpr.Checked = True Or rbhpu.Checked = True Then
If pbhpr.Visible = True Then
newimage = pbhpr.Image
ElseIf pbhpu.Visible = True Then
newimage = pbhpu.Image
ElseIf pbp.Visible = True Then
newimage = pbp.Image
ElseIf pbl.Visible = True Then
newimage = pbl.Image
ElseIf pbd.Visible = True Then
newimage = pbd.Image
End If
image1 = New Bitmap(image2)
g = Graphics.FromImage(image1)
Try
g.DrawImage(newimage, varax, varby, 50, 70)
g.Save()
pbim.Image = image1
Catch ex As Exception
MsgBox(ex.Message, vbOK)
End Try
End If
If btnalc.Text = "Sauvegarder" Then
image3 = New Bitmap(image2)
g = Graphics.FromImage(image3)
g.DrawRectangle(Pens.Red, varax, varby, 250, 200)
pbim.Image = image3
pbim.Refresh()
End If
If TabControl1.SelectedIndex = 1 Then
Dim bm As New Bitmap(180, 120)
Using gr As Graphics = Graphics.FromImage(bm)
Dim src_rect As New Rectangle(varax, varby, 250, 200)
Dim dst_rect As New Rectangle(-1, -1, 180, 120)
gr.DrawImage(pbim.Image, dst_rect, src_rect, GraphicsUnit.Pixel)
End Using
pblou.Image = bm
End If
If difgph < 1 Then
pbim.Location = New Point(picslx, picsly + 1)
pbim.Refresh()
End If
If difgpw < 1 Then
pbim.Location = New Point(picslx + 1, picsly)
pbim.Refresh()
End If
If MouseButtons = Windows.Forms.MouseButtons.Left Then
pbim.Location = New Point(MousePosition.X - mcx, MousePosition.Y - mcy)
ElseIf MouseButtons = Windows.Forms.MouseButtons.Right Then
If zmp <= 50 And zmp > 0 Then
If varaa <= 0 Then
pbim.Location = New Point(vara + 5, varb)
pbim.Height = picsh + 10
pbim.Width = picsw + 10
End If
If varbb <= 0 Then
pbim.Location = New Point(vara, varb + 5)
pbim.Height = picsh + 10
pbim.Width = picsw + 10
End If
If varaa >= 295 Then
pbim.Location = New Point(vara - 5, varb)
pbim.Height = picsh + 10
pbim.Width = picsw + 10
End If
If varbb <= 335 Then
pbim.Location = New Point(vara, varb - 5)
pbim.Height = picsh + 10
pbim.Width = picsw + 10
End If
ElseIf zmp <= 0 And zmp > -50 And pbim.Height > 499 Then
If varaa <= 0 Then
pbim.Location = New Point(vara + 5, varb)
pbim.Height = picsh - 50
pbim.Width = picsw - 50
End If
If varbb <= 0 Then
pbim.Location = New Point(vara, varb + 5)
pbim.Height = picsh - 50
pbim.Width = picsw - 50
End If
If varaa >= 295 Then
pbim.Location = New Point(vara - 5, varb)
pbim.Height = picsh - 50
pbim.Width = picsw - 50
End If
If varbb <= 335 Then
pbim.Location = New Point(vara, varb - 5)
pbim.Height = picsh - 50
pbim.Width = picsw - 50
End If
End If
End If
End Sub |
Partager