diff --git a/Windows/Animator.vb b/Windows/Animator.vb index 7f5d50d2..48bb442c 100644 --- a/Windows/Animator.vb +++ b/Windows/Animator.vb @@ -1,51 +1,63 @@ Imports System.Drawing Imports System.Windows.Forms - Public Class Animator - Public Const DEFAULT_FONT_OPACITY = 0.5 - Public Const DEFAULT_FORM_SIZE = 30 - Public Const DEFAULT_FORM_FADE_SPEED = 10 - Public Const DEFAULT_FORM_FADE_INTERVAL = 250 + Private Const DEFAULT_POPUP_OPACITY = 0.5 + Private Const DEFAULT_POPUP_SIZE = 30 + Private Const DEFAULT_POPUP_FADE_SPEED = 10 + Private Const DEFAULT_POPUP_FADE_INTERVAL = 250 - Public Property FormSize As Integer - Public Property FadeInterval As Integer - Public Property FadeSpeed As Integer - Public Property FormOpacity As Double - Public Property FormColor As Color + ''' + ''' Time the popup stays visible between the animations + ''' + Public Property AnimationInterval As Integer + ''' + ''' Basevalue for calculating the time the popup takes to animate + ''' + Public Property AnimationSpeed As Integer + ''' + ''' Opacity the popup animates to (From 0.0 to .., back to 0.0) + ''' + Public Property PopupOpacity As Double + ''' + ''' Color of the popup + ''' + ''' + Public Property PopupColor As Color + ''' + ''' Size of the popup in width and height + ''' + Public Property PopupSize As Size Public Sub New() - _FormSize = DEFAULT_FORM_SIZE - _FadeSpeed = DEFAULT_FORM_FADE_SPEED - _FadeInterval = DEFAULT_FORM_FADE_INTERVAL - _FormOpacity = DEFAULT_FONT_OPACITY - _FormColor = Color.FromArgb(255, 214, 49) + _PopupSize = New Size(DEFAULT_POPUP_SIZE, DEFAULT_POPUP_SIZE) + _AnimationSpeed = DEFAULT_POPUP_FADE_SPEED + _AnimationInterval = DEFAULT_POPUP_FADE_INTERVAL + _PopupOpacity = DEFAULT_POPUP_OPACITY + _PopupColor = Color.FromArgb(255, 214, 49) End Sub Public Sub Highlight(Position As Point) - Dim oForm = GetPopup(Position) + Dim oForm = GetPopup(Position, PopupSize) oForm.Show() - FadeIn(oForm, _FormOpacity, _FadeSpeed / 2) - Dim oTimer As New Timer With {.Interval = _FadeInterval} - AddHandler oTimer.Tick, Sub() - FadeOut(oForm, _FadeSpeed * 2) - oTimer.Stop() - End Sub - oTimer.Start() + FadeIn(oForm, _PopupOpacity, _AnimationSpeed / 2) + Task.Delay(_AnimationInterval) + FadeOut(oForm, _AnimationSpeed * 2) End Sub - Private Function GetPopup(CursorPosition As Point) As frmPopup - Dim oFormLocation = New Point(CursorPosition.X - (_FormSize / 2), CursorPosition.Y - (_FormSize / 2)) - Dim oFormSize = New Size(_FormSize, _FormSize) + Private Function GetPopup(CursorPosition As Point, PopupSize As Size) As frmPopup + Dim oFormLocation = New Point( + CursorPosition.X - (PopupSize.Width / 2), + CursorPosition.Y - (PopupSize.Height / 2)) Return New frmPopup() With { .Location = oFormLocation, .StartPosition = FormStartPosition.Manual, - .Size = oFormSize, - .MaximumSize = oFormSize, - .MinimumSize = oFormSize, + .Size = PopupSize, + .MaximumSize = PopupSize, + .MinimumSize = PopupSize, .Opacity = 0, .ShowInTaskbar = False, - .BackColor = _FormColor + .BackColor = _PopupColor } End Function @@ -53,7 +65,6 @@ Public Class Animator While o.Opacity < finalOpacity Await Task.Delay(interval) o.Opacity += 0.05 - Debug.WriteLine("Fading in, Opacity: " & o.Opacity) End While o.Opacity = finalOpacity @@ -63,10 +74,8 @@ Public Class Animator While o.Opacity > 0.0 Await Task.Delay(interval) o.Opacity -= 0.05 - Debug.WriteLine("Fading out, Opacity: " & o.Opacity) End While o.Opacity = 0 End Sub - End Class diff --git a/Windows/Animator/frmPopup.Designer.vb b/Windows/Animator/frmPopup.Designer.vb index c4b94623..09bb5b0d 100644 --- a/Windows/Animator/frmPopup.Designer.vb +++ b/Windows/Animator/frmPopup.Designer.vb @@ -1,6 +1,8 @@ - _ +Imports System.Windows.Forms + + Partial Class frmPopup - Inherits System.Windows.Forms.Form + Inherits Form 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. _ diff --git a/Windows/My Project/Resources.Designer.vb b/Windows/My Project/Resources.Designer.vb index 2fde54bd..82955370 100644 --- a/Windows/My Project/Resources.Designer.vb +++ b/Windows/My Project/Resources.Designer.vb @@ -22,7 +22,7 @@ Namespace My.Resources ''' ''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. ''' - _ diff --git a/Windows/My Project/Resources.resx b/Windows/My Project/Resources.resx index af7dbebb..1af7de15 100644 --- a/Windows/My Project/Resources.resx +++ b/Windows/My Project/Resources.resx @@ -46,7 +46,7 @@ mimetype: application/x-microsoft.net.object.binary.base64 value : The object must be serialized with - : System.Serialization.Formatters.Binary.BinaryFormatter + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.soap.base64 @@ -60,6 +60,7 @@ : and then encoded with base64 encoding. --> + @@ -68,9 +69,10 @@ - + + @@ -85,9 +87,10 @@ - + + @@ -109,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file