WPF - SkewTransform
這篇測試一下SkewTransform的功能,做了一個"丟猴"的按鈕,有興趣的朋友可以跑程式測試看看
測試的程式碼是下面這些,另外由於這邊貼XAML真的是很頭大,到點部落看完整的文章吧
測試的程式碼是下面這些,另外由於這邊貼XAML真的是很頭大,到點部落看完整的文章吧
Class Window1
Dim st As New SkewTransform
Dim myT As Threading.DispatcherTimer
Dim R As New Random
Dim tmpTop As Double = 0
Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btn1.Click
''Timer相關設定
myT = New Threading.DispatcherTimer
myT.Interval = New TimeSpan(0, 0, 0, 0, 100)
AddHandler myT.Tick, AddressOf Timer_Tick
myT.Start()
End Sub
Private Sub Timer_Tick(ByVal sender As Object, ByVal e As EventArgs)
If Canvas.GetTop(btn1) >= cv.ActualHeight Then
myT.Stop()
End If
Randomize()
st.AngleX = (0.5 - R.NextDouble) * 30
st.AngleY = (0.5 - R.NextDouble) * 50
System.Threading.Thread.Sleep(30)
btn1.RenderTransform = st
Canvas.SetLeft(btn1, R.NextDouble * 50)
tmpTop = tmpTop + R.NextDouble * 10
Canvas.SetTop(btn1, tmpTop)
End Sub
End Class
留言