AceInfinity
Emeritus, Contributor
Here's a cool module I created a few minutes ago. I got the idea with some cool fading effects... Maybe you'll like it :)
If you want something fancy, try this Module I came up with:
Usage:
If you want something fancy, try this Module I came up with:
Code:
Imports System.Threading
Module FormSwitcher
<System.Runtime.CompilerServices.Extension()> _
Public Sub SwitchForm(OriginalForm As Form, NewForm As Form)
NewForm.Opacity = 0
NewForm.Show()
NewForm.Location = OriginalForm.Location
OriginalForm.MatchSize(NewForm.Size)
For d As Double = 1.0 To 0.0 Step -0.25
OriginalForm.Opacity = d
NewForm.Opacity = 1 - d
Thread.Sleep(100)
Next
OriginalForm.Hide()
OriginalForm.Opacity = 1
End Sub
<System.Runtime.CompilerServices.Extension()> _
Private Sub MatchSize(OriginalForm As Form, NewSize As Size)
Dim S As Size = OriginalForm.Size
Dim Stepper As Integer = 0
If S.Width <> NewSize.Width Then Stepper = If(S.Width < NewSize.Width, 1, -1)
If Stepper <> 0 Then
For i As Integer = S.Width To NewSize.Width Step Stepper
OriginalForm.Width = i
Next
End If
If S.Height <> NewSize.Height Then Stepper = If(S.Height < NewSize.Height, 1, -1)
If Stepper <> 0 Then
For i As Integer = S.Height To NewSize.Height Step Stepper
OriginalForm.Height = i
Next
End If
End Sub
End Module
Usage:
Code:
Me.SwitchForm(Form2)