Привет всем, я сделал простую форму, которая имитирует эффект jQuery "GROWL", видимый здесь http://www.sandbox.timbenniks.com/projects/jquery-notice/
Однако я столкнулся с проблемой. Если у меня есть несколько обращений к форме, чтобы отобразить «рычание», то она просто обновляет ту же форму любым вызовом, который я ей отправляю. Другими словами, я могу отображать только одну форму за раз, вместо того, чтобы одна выпадала, а над ней появлялась новая.
Вот мой простой код формы для формы "GROWL":
Public Class msgWindow
Public howLong As Integer
Public theType As String
Private loading As Boolean
Protected Overrides Sub OnPaint(ByVal pe As System.Windows.Forms.PaintEventArgs)
Dim pn As New Pen(Color.DarkGreen)
If theType = "OK" Then
pn.Color = Color.DarkGreen
ElseIf theType = "ERR" Then
pn.Color = Color.DarkRed
Else
pn.Color = Color.DarkOrange
End If
pn.Width = 2
pe.Graphics.DrawRectangle(pn, 0, 0, Me.Width, Me.Height)
pn = Nothing
End Sub
Public Sub showMessageBox(ByVal typeOfBox As String, ByVal theMessage As String)
Me.Opacity = 0
Me.Show()
Me.SetDesktopLocation(My.Computer.Screen.WorkingArea.Width - 350, 15)
Me.loading = True
theType = typeOfBox
lblSaying.Text = theMessage
If typeOfBox = "OK" Then
Me.BackColor = Color.FromArgb(192, 255, 192)
ElseIf typeOfBox = "ERR" Then
Me.BackColor = Color.FromArgb(255, 192, 192)
Else
Me.BackColor = Color.FromArgb(255, 255, 192)
End If
If Len(theMessage) <= 30 Then
howLong = 4000
ElseIf Len(theMessage) >= 31 And Len(theMessage) <= 80 Then
howLong = 7000
ElseIf Len(theMessage) >= 81 And Len(theMessage) <= 100 Then
howLong = 12000
Else
howLong = 17000
End If
Me.opacityTimer.Start()
End Sub
Private Sub opacityTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles opacityTimer.Tick
If Me.loading Then
Me.Opacity += 0.07
If Me.Opacity >= 0.8 Then
Me.opacityTimer.Stop()
Me.opacityTimer.Dispose()
Pause(howLong)
Me.loading = False
Me.opacityTimer.Start()
End If
Else
Me.Opacity -= 0.08
If Me.Opacity <= 0 Then
Me.opacityTimer.Stop()
Me.Close()
End If
End If
End Sub
Public Sub Pause(ByVal Milliseconds As Integer)
Dim dTimer As Date
dTimer = Now.AddMilliseconds(Milliseconds)
Do While dTimer > Now
Application.DoEvents()
Loop
End Sub
End Class
Я вызываю форму этим простым вызовом:
Call msgWindow.showMessageBox("OK", "Finished searching images.")
Кто-нибудь знает способ, где я могу иметь такую же настройку, но позволил бы мне добавлять любое количество форм, не обновляя одну и ту же форму снова и снова?
Как всегда, любая помощь будет отличной! :)
David