PageRenderTime 73ms CodeModel.GetById 30ms RepoModel.GetById 4ms app.codeStats 0ms

/wp-toolkit/PhoneToolkitSample/Samples/TransitionsSample.xaml.vb

https://bitbucket.org/jeremejevs/milk-manager
Visual Basic | 147 lines | 125 code | 18 blank | 4 comment | 0 complexity | 26ff704659d3c23f72b6d203c338342b MD5 | raw file
  1. ' (c) Copyright Microsoft Corporation.
  2. ' This source is subject to the Microsoft Public License (Ms-PL).
  3. ' Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
  4. ' All other rights reserved.
  5. Imports System.Windows.Data
  6. Imports System.Globalization
  7. Imports System.Collections.Generic
  8. Imports System.Windows
  9. Namespace Samples
  10. Partial Public Class TransitionsSample
  11. Inherits PhoneApplicationPage
  12. Public Sub New()
  13. DataContext = Me
  14. InitializeComponent()
  15. End Sub
  16. Public ReadOnly Property Families As IList(Of String)
  17. Get
  18. Return New List(Of String) From {"Roll",
  19. "Rotate",
  20. "Slide",
  21. "Swivel",
  22. "Turnstile"}
  23. End Get
  24. End Property
  25. Private Function RotateTransitionElement(ByVal mode As String) As RotateTransition
  26. Dim rotateTransitionMode =
  27. CType(System.Enum.Parse(GetType(RotateTransitionMode), mode, False), RotateTransitionMode)
  28. Return New RotateTransition With {.Mode = rotateTransitionMode}
  29. End Function
  30. Private Function SlideTransitionElement(ByVal mode As String) As SlideTransition
  31. Dim slideTransitionMode =
  32. CType(System.Enum.Parse(GetType(SlideTransitionMode), mode, False), SlideTransitionMode)
  33. Return New SlideTransition With {.Mode = slideTransitionMode}
  34. End Function
  35. Private Function SwivelTransitionElement(ByVal mode As String) As SwivelTransition
  36. Dim swivelTransitionMode =
  37. CType(System.Enum.Parse(GetType(SwivelTransitionMode), mode, False), SwivelTransitionMode)
  38. Return New SwivelTransition With {.Mode = swivelTransitionMode}
  39. End Function
  40. Private Function TurnstileTransitionElement(ByVal mode As String) As TurnstileTransition
  41. Dim turnstileTransitionMode =
  42. CType(System.Enum.Parse(GetType(TurnstileTransitionMode), mode, False), TurnstileTransitionMode)
  43. Return New TurnstileTransition With {.Mode = turnstileTransitionMode}
  44. End Function
  45. Private Function TransitionElement(ByVal family As String, ByVal mode As String) As TransitionElement
  46. Select Case family
  47. Case "Rotate"
  48. Return RotateTransitionElement(mode)
  49. Case "Slide"
  50. Return SlideTransitionElement(mode)
  51. Case "Swivel"
  52. Return SwivelTransitionElement(mode)
  53. Case "Turnstile"
  54. Return TurnstileTransitionElement(mode)
  55. End Select
  56. Return Nothing
  57. End Function
  58. Private Sub See(ByVal sender As Object, ByVal e As RoutedEventArgs)
  59. Dim _family = CStr(Family.SelectedItem)
  60. Dim _mode = CStr(Mode.SelectedItem)
  61. Dim transitionElement As TransitionElement = Nothing
  62. If _family.Equals("Roll") Then
  63. transitionElement = New RollTransition
  64. Else
  65. transitionElement = Me.TransitionElement(_family, _mode)
  66. End If
  67. Dim phoneApplicationPage = CType(((CType(Application.Current.RootVisual, PhoneApplicationFrame))).Content, PhoneApplicationPage)
  68. Dim transition = transitionElement.GetTransition(phoneApplicationPage)
  69. AddHandler transition.Completed, Sub() transition.Stop()
  70. transition.Begin()
  71. End Sub
  72. Private Sub Forward(ByVal sender As Object, ByVal e As RoutedEventArgs)
  73. NavigationService.Navigate(New Uri("/Samples/NavigationTransitionSample1.xaml", UriKind.Relative))
  74. End Sub
  75. Private Sub FamilySelectionChanged(ByVal sender As Object, ByVal e As System.Windows.Controls.SelectionChangedEventArgs)
  76. Dim _family = CStr(Family.SelectedItem)
  77. Mode.Visibility = If(_family.Equals("Roll"), System.Windows.Visibility.Collapsed, System.Windows.Visibility.Visible)
  78. End Sub
  79. End Class
  80. Public Class EnumConverter
  81. Implements IValueConverter
  82. Public Function Convert(ByVal value As Object, ByVal targetType As Type,
  83. ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
  84. Dim s = TryCast(value, String)
  85. If s Is Nothing Then
  86. Return Nothing
  87. End If
  88. Select Case s
  89. Case "Roll"
  90. Return New List(Of String)
  91. Case "Rotate"
  92. Return New List(Of String) From {"In90Clockwise",
  93. "In90Counterclockwise",
  94. "In180Clockwise",
  95. "In180Counterclockwise",
  96. "Out90Clockwise",
  97. "Out90Counterclockwise",
  98. "Out180Clockwise",
  99. "Out180Counterclockwise"}
  100. Case "Slide"
  101. Return New List(Of String) From {"SlideUpFadeIn",
  102. "SlideUpFadeOut",
  103. "SlideDownFadeIn",
  104. "SlideDownFadeOut",
  105. "SlideLeftFadeIn",
  106. "SlideLeftFadeOut",
  107. "SlideRightFadeIn",
  108. "SlideRightFadeOut"}
  109. Case "Swivel"
  110. Return New List(Of String) From {"FullScreenIn",
  111. "FullScreenOut",
  112. "ForwardIn",
  113. "ForwardOut",
  114. "BackwardIn",
  115. "BackwardOut"}
  116. Case "Turnstile"
  117. Return New List(Of String) From {"ForwardIn",
  118. "ForwardOut",
  119. "BackwardIn",
  120. "BackwardOut"}
  121. End Select
  122. Return Nothing
  123. End Function
  124. Public Function ConvertBack(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object,
  125. ByVal culture As CultureInfo) As Object Implements System.Windows.Data.IValueConverter.ConvertBack
  126. Throw New NotSupportedException
  127. End Function
  128. End Class
  129. End Namespace