Imports System.Threading

Partial Public Class SilverlightTransformaciones
  Inherits UserControl
  Private Shared cont As Integer = 2, inc As Integer = -15
  Private Shared k As Double = 1, inc_k As Double = -0.2
  Private Shared angulo As Double = 0, inc_a As Double = 30

  Public Sub New()
    InitializeComponent()
  End Sub

  Private Sub Mouse_Clicked(sender As Object, e As MouseButtonEventArgs)
    ' Traslación
    'transforHexagono.X = transforHexagono.X + inc
    'transforHexagono.Y = transforHexagono.Y + inc
    'If inc > 0 Then
    '  cont += 1
    '  If cont = 2 Then inc = -15
    'Else
    '  If inc < 0 Then
    '    cont -= 1
    '    If cont = -2 Then inc = +15
    '  End If
    'End If

    ' El código anterior es equivalente a:
    'transforHexagono.X = transforHexagono.X + inc
    'transforHexagono.Y = transforHexagono.Y + inc
    'If inc > 0 AndAlso Interlocked.Increment(cont) = 2 Then
    '  inc = -15
    'ElseIf inc < 0 AndAlso Interlocked.Decrement(cont) = -2 Then
    '  inc = +15
    'End If

    '' Escalado
    'transforHexagono.CenterX = Hexagono.ActualWidth / 2
    'transforHexagono.CenterY = Hexagono.ActualHeight / 2
    'k += inc_k
    'transforHexagono.ScaleX = k
    'transforHexagono.ScaleY = k
    'If inc_k > 0 AndAlso Interlocked.Increment(cont) = 2 Then
    '  inc_k = -0.2
    'ElseIf inc_k < 0 AndAlso Interlocked.Decrement(cont) = -2 Then
    '  inc_k = +0.2
    'End If

    '' Rotación
    'transforHexagono.CenterX = Hexagono.ActualWidth / 2
    'transforHexagono.CenterY = Hexagono.ActualHeight / 2
    'angulo += inc_a
    'transforHexagono.Angle = angulo

    '' Sesgar
    'transforHexagono.CenterX = Hexagono.ActualWidth / 2
    'transforHexagono.CenterY = Hexagono.ActualHeight / 2
    'angulo += inc_a
    'transforHexagono.AngleX = angulo
    'transforHexagono.AngleY = angulo
    'inc_a = -inc_a

    Dim matriz As New Matrix(1.2, 0.2, -0.8, 1.2, 80, -80)
    Dim mt As New MatrixTransform()
    mt.Matrix = matriz
    Hexagono.RenderTransform = mt
  End Sub
End Class
