Windows: Improve Animator
This commit is contained in:
parent
cd75459a27
commit
b759d18b6b
@ -1,51 +1,63 @@
|
|||||||
Imports System.Drawing
|
Imports System.Drawing
|
||||||
Imports System.Windows.Forms
|
Imports System.Windows.Forms
|
||||||
|
|
||||||
Public Class Animator
|
Public Class Animator
|
||||||
Public Const DEFAULT_FONT_OPACITY = 0.5
|
Private Const DEFAULT_POPUP_OPACITY = 0.5
|
||||||
Public Const DEFAULT_FORM_SIZE = 30
|
Private Const DEFAULT_POPUP_SIZE = 30
|
||||||
Public Const DEFAULT_FORM_FADE_SPEED = 10
|
Private Const DEFAULT_POPUP_FADE_SPEED = 10
|
||||||
Public Const DEFAULT_FORM_FADE_INTERVAL = 250
|
Private Const DEFAULT_POPUP_FADE_INTERVAL = 250
|
||||||
|
|
||||||
Public Property FormSize As Integer
|
''' <summary>
|
||||||
Public Property FadeInterval As Integer
|
''' Time the popup stays visible between the animations
|
||||||
Public Property FadeSpeed As Integer
|
''' </summary>
|
||||||
Public Property FormOpacity As Double
|
Public Property AnimationInterval As Integer
|
||||||
Public Property FormColor As Color
|
''' <summary>
|
||||||
|
''' Basevalue for calculating the time the popup takes to animate
|
||||||
|
''' </summary>
|
||||||
|
Public Property AnimationSpeed As Integer
|
||||||
|
''' <summary>
|
||||||
|
''' Opacity the popup animates to (From 0.0 to .., back to 0.0)
|
||||||
|
''' </summary>
|
||||||
|
Public Property PopupOpacity As Double
|
||||||
|
''' <summary>
|
||||||
|
''' Color of the popup
|
||||||
|
''' </summary>
|
||||||
|
''' <returns></returns>
|
||||||
|
Public Property PopupColor As Color
|
||||||
|
''' <summary>
|
||||||
|
''' Size of the popup in width and height
|
||||||
|
''' </summary>
|
||||||
|
Public Property PopupSize As Size
|
||||||
|
|
||||||
Public Sub New()
|
Public Sub New()
|
||||||
_FormSize = DEFAULT_FORM_SIZE
|
_PopupSize = New Size(DEFAULT_POPUP_SIZE, DEFAULT_POPUP_SIZE)
|
||||||
_FadeSpeed = DEFAULT_FORM_FADE_SPEED
|
_AnimationSpeed = DEFAULT_POPUP_FADE_SPEED
|
||||||
_FadeInterval = DEFAULT_FORM_FADE_INTERVAL
|
_AnimationInterval = DEFAULT_POPUP_FADE_INTERVAL
|
||||||
_FormOpacity = DEFAULT_FONT_OPACITY
|
_PopupOpacity = DEFAULT_POPUP_OPACITY
|
||||||
_FormColor = Color.FromArgb(255, 214, 49)
|
_PopupColor = Color.FromArgb(255, 214, 49)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Public Sub Highlight(Position As Point)
|
Public Sub Highlight(Position As Point)
|
||||||
Dim oForm = GetPopup(Position)
|
Dim oForm = GetPopup(Position, PopupSize)
|
||||||
oForm.Show()
|
oForm.Show()
|
||||||
FadeIn(oForm, _FormOpacity, _FadeSpeed / 2)
|
FadeIn(oForm, _PopupOpacity, _AnimationSpeed / 2)
|
||||||
Dim oTimer As New Timer With {.Interval = _FadeInterval}
|
Task.Delay(_AnimationInterval)
|
||||||
AddHandler oTimer.Tick, Sub()
|
FadeOut(oForm, _AnimationSpeed * 2)
|
||||||
FadeOut(oForm, _FadeSpeed * 2)
|
|
||||||
oTimer.Stop()
|
|
||||||
End Sub
|
|
||||||
oTimer.Start()
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Function GetPopup(CursorPosition As Point) As frmPopup
|
Private Function GetPopup(CursorPosition As Point, PopupSize As Size) As frmPopup
|
||||||
Dim oFormLocation = New Point(CursorPosition.X - (_FormSize / 2), CursorPosition.Y - (_FormSize / 2))
|
Dim oFormLocation = New Point(
|
||||||
Dim oFormSize = New Size(_FormSize, _FormSize)
|
CursorPosition.X - (PopupSize.Width / 2),
|
||||||
|
CursorPosition.Y - (PopupSize.Height / 2))
|
||||||
|
|
||||||
Return New frmPopup() With {
|
Return New frmPopup() With {
|
||||||
.Location = oFormLocation,
|
.Location = oFormLocation,
|
||||||
.StartPosition = FormStartPosition.Manual,
|
.StartPosition = FormStartPosition.Manual,
|
||||||
.Size = oFormSize,
|
.Size = PopupSize,
|
||||||
.MaximumSize = oFormSize,
|
.MaximumSize = PopupSize,
|
||||||
.MinimumSize = oFormSize,
|
.MinimumSize = PopupSize,
|
||||||
.Opacity = 0,
|
.Opacity = 0,
|
||||||
.ShowInTaskbar = False,
|
.ShowInTaskbar = False,
|
||||||
.BackColor = _FormColor
|
.BackColor = _PopupColor
|
||||||
}
|
}
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
@ -53,7 +65,6 @@ Public Class Animator
|
|||||||
While o.Opacity < finalOpacity
|
While o.Opacity < finalOpacity
|
||||||
Await Task.Delay(interval)
|
Await Task.Delay(interval)
|
||||||
o.Opacity += 0.05
|
o.Opacity += 0.05
|
||||||
Debug.WriteLine("Fading in, Opacity: " & o.Opacity)
|
|
||||||
End While
|
End While
|
||||||
|
|
||||||
o.Opacity = finalOpacity
|
o.Opacity = finalOpacity
|
||||||
@ -63,10 +74,8 @@ Public Class Animator
|
|||||||
While o.Opacity > 0.0
|
While o.Opacity > 0.0
|
||||||
Await Task.Delay(interval)
|
Await Task.Delay(interval)
|
||||||
o.Opacity -= 0.05
|
o.Opacity -= 0.05
|
||||||
Debug.WriteLine("Fading out, Opacity: " & o.Opacity)
|
|
||||||
End While
|
End While
|
||||||
|
|
||||||
o.Opacity = 0
|
o.Opacity = 0
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
6
Windows/Animator/frmPopup.Designer.vb
generated
6
Windows/Animator/frmPopup.Designer.vb
generated
@ -1,6 +1,8 @@
|
|||||||
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
|
Imports System.Windows.Forms
|
||||||
|
|
||||||
|
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
|
||||||
Partial Class frmPopup
|
Partial Class frmPopup
|
||||||
Inherits System.Windows.Forms.Form
|
Inherits Form
|
||||||
|
|
||||||
'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
|
'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
|
||||||
<System.Diagnostics.DebuggerNonUserCode()> _
|
<System.Diagnostics.DebuggerNonUserCode()> _
|
||||||
|
|||||||
2
Windows/My Project/Resources.Designer.vb
generated
2
Windows/My Project/Resources.Designer.vb
generated
@ -22,7 +22,7 @@ Namespace My.Resources
|
|||||||
'''<summary>
|
'''<summary>
|
||||||
''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
|
''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
|
||||||
'''</summary>
|
'''</summary>
|
||||||
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0"), _
|
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0"), _
|
||||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||||
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
|
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
|
||||||
|
|||||||
@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
value : The object must be serialized with
|
value : The object must be serialized with
|
||||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
@ -60,6 +60,7 @@
|
|||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
-->
|
-->
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
<xsd:complexType>
|
<xsd:complexType>
|
||||||
<xsd:choice maxOccurs="unbounded">
|
<xsd:choice maxOccurs="unbounded">
|
||||||
@ -68,9 +69,10 @@
|
|||||||
<xsd:sequence>
|
<xsd:sequence>
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
</xsd:sequence>
|
</xsd:sequence>
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
</xsd:element>
|
</xsd:element>
|
||||||
<xsd:element name="assembly">
|
<xsd:element name="assembly">
|
||||||
@ -85,9 +87,10 @@
|
|||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
</xsd:sequence>
|
</xsd:sequence>
|
||||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
</xsd:element>
|
</xsd:element>
|
||||||
<xsd:element name="resheader">
|
<xsd:element name="resheader">
|
||||||
@ -109,9 +112,9 @@
|
|||||||
<value>2.0</value>
|
<value>2.0</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<resheader name="reader">
|
<resheader name="reader">
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
</root>
|
</root>
|
||||||
Loading…
x
Reference in New Issue
Block a user