Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. <Browsable(True), Description("Set the Form Name")> Public Property FormName As Form
  2. Get
  3. Return _formName
  4. End Get
  5. Set(ByVal value As Form)
  6. _formName = value
  7. End Set
  8. End Property
  9.  
  10. Public Function openForm(ByVal frm As String, Optional ByVal focusCtrl As Control = Nothing, Optional ByVal isFullscreen As Boolean = True, Optional ByVal isDialog As Boolean = False) As Form
  11. Dim obj As Form = TryCast(Activator.CreateInstance(Type.GetType("Management_System." + frm)), Form)
  12. Dim myAnimator As New FormAnimator(obj, FormAnimator.AnimationTypes.Blend, fadingTime)
  13. obj.StartPosition = FormStartPosition.CenterScreen
  14. If isDialog Then
  15. obj.ShowDialog()
  16. focusCtrl.Focus()
  17. Else
  18. Dim frms = Application.OpenForms
  19. Dim isOpened As Boolean = False
  20. For Each q In frms
  21. If q.GetType().Name = obj.Name Then
  22. obj = CType(q, Form)
  23. isOpened = True
  24. Exit For
  25. Else
  26. isOpened = False
  27. End If
  28. Next
  29. If isOpened = True Then
  30. If isFullscreen Then
  31. obj.WindowState = FormWindowState.Maximized
  32. Else
  33. obj.WindowState = FormWindowState.Normal
  34. End If
  35. If obj.Visible Then
  36. obj.BringToFront()
  37. Else
  38. obj.Show()
  39. End If
  40. Else
  41. obj.Show()
  42. obj.BringToFront()
  43. End If
  44. End If
  45. Return obj
  46. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement