diff --git a/Windows/Animator.vb b/Windows/Animator.vb new file mode 100644 index 00000000..7f5d50d2 --- /dev/null +++ b/Windows/Animator.vb @@ -0,0 +1,72 @@ +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 + + 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 + + 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) + End Sub + + Public Sub Highlight(Position As Point) + Dim oForm = GetPopup(Position) + 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() + 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) + + Return New frmPopup() With { + .Location = oFormLocation, + .StartPosition = FormStartPosition.Manual, + .Size = oFormSize, + .MaximumSize = oFormSize, + .MinimumSize = oFormSize, + .Opacity = 0, + .ShowInTaskbar = False, + .BackColor = _FormColor + } + End Function + + Private Async Sub FadeIn(ByVal o As Form, finalOpacity As Double, ByVal Optional interval As Integer = 80) + While o.Opacity < finalOpacity + Await Task.Delay(interval) + o.Opacity += 0.05 + Debug.WriteLine("Fading in, Opacity: " & o.Opacity) + End While + + o.Opacity = finalOpacity + End Sub + + Private Async Sub FadeOut(ByVal o As Form, ByVal Optional interval As Integer = 80) + 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 new file mode 100644 index 00000000..c4b94623 --- /dev/null +++ b/Windows/Animator/frmPopup.Designer.vb @@ -0,0 +1,41 @@ + _ +Partial Class frmPopup + Inherits System.Windows.Forms.Form + + 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Wird vom Windows Form-Designer benötigt. + Private components As System.ComponentModel.IContainer + + 'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich. + 'Das Bearbeiten ist mit dem Windows Form-Designer möglich. + 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. + _ + Private Sub InitializeComponent() + Me.SuspendLayout() + ' + 'frmPopup + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.BackColor = System.Drawing.Color.Yellow + Me.ClientSize = New System.Drawing.Size(30, 30) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None + Me.MaximumSize = New System.Drawing.Size(30, 30) + Me.MinimumSize = New System.Drawing.Size(30, 30) + Me.Name = "frmPopup" + Me.Text = "frmPopup" + Me.ResumeLayout(False) + + End Sub +End Class diff --git a/Windows/Animator/frmPopup.resx b/Windows/Animator/frmPopup.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/Windows/Animator/frmPopup.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.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 diff --git a/Windows/Animator/frmPopup.vb b/Windows/Animator/frmPopup.vb new file mode 100644 index 00000000..5a5f2724 --- /dev/null +++ b/Windows/Animator/frmPopup.vb @@ -0,0 +1,3 @@ +Public Class frmPopup + +End Class \ No newline at end of file diff --git a/Windows/Windows.vbproj b/Windows/Windows.vbproj index 851b21ec..51646f4e 100644 --- a/Windows/Windows.vbproj +++ b/Windows/Windows.vbproj @@ -74,6 +74,13 @@ + + + frmPopup.vb + + + Form + @@ -97,6 +104,9 @@ + + frmPopup.vb + VbMyResourcesResXFileCodeGenerator Resources.Designer.vb