Задайте вопросЗадайте вопрос
 

Отвеченоanimations in WPF and special effects like blinds

  • 26 октября 2007 г. 8:47Willie007 Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     

     

    Hi,

    In the past I created an effect horizontal blinds where parts of the screen where showing up line by line just like opening blinds in a house. That was easy because i used a bitmap..

     

    I converted my code to the WPF enviroment where all things are elements and no bitmaps. It looks good and smooth. No blinking during updates or transparency problems as with window forms...

     

    Now I come to the point where I want to add animations to a WPF window. Moving from left to right or something is very easily with the leftproperty bound to the animation.

     

    But now comes the brainbracker...

    How can i create an effect that will show an effect like a blind on the content of a canvas where the canvas itself contains elements like text, video etc...?

    is there a way to apply a visible clip path on top of the canvas to show an effect.

     

    I know its friday and my brain starts converting to the weekend virtual machine part, but i would like to crack this problem before it is so far....

     

    Thanks for you ideas.

Ответы

  • 30 октября 2007 г. 10:29Willie007 Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     Отвечено

    This is how i got my vertical split function to work.

    I connect it to the clip of a canvas that must become visible.

     

    Code Block

    Dim Page as Canvas

     

     

    private Sub VerticalSplitEffect

    Dim c As Double = 25

    Dim x As Double = Page.Width

    Dim y As Double = Page.Height

    Dim Cnt As Double = Math.Ceiling(x / c)

    Dim G As New GeometryGroup

    Dim ID As String

    Dim AnimClipRegion As Geometry = Nothing

    For i As Double = 0 To Cnt - 1

     AnimClipRegion = New RectangleGeometry(New Rect(0, 0, 0, 0), 0, 0) 'create new one

     ID = CreateNewID()

     Page.RegisterName(ID, AnimClipRegion)

     G.Children.Add(AnimClipRegion)

     Dim AnimationRect As New Animation.RectAnimation(New Rect(i * c, 0, 0, y), New Rect(i * c, 0, c, y), New Duration(TimeSpan.FromMilliseconds(Duration)), Animation.FillBehavior.Stop)

     Windows.Media.Animation.Storyboard.SetTargetName(AnimationRect, ID)

     Windows.Media.Animation.Storyboard.SetTargetProperty(AnimationRect, New PropertyPath (RectangleGeometry.RectProperty))

     StoryBoardAnimator.Children.Add(AnimationRect)

    Next

    Page.Clip = G

    End Sub

     

     

    Private Function CreateNewID() As String

    On Error Resume Next

    Return Guid.NewGuid.ToString("N")

    End Function

     

Все ответы

  • 26 октября 2007 г. 11:15Jeremiah Morrill Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    If you are talking about transition type effects, like horizontal blinds, fades and wipes, check out Kevin's bag o tricks - Mix edition http://wpf.netfx3.com/files/folders/controls/entry10297.aspx

     

    The transition presenter in there has those and a million more.

  • 30 октября 2007 г. 10:29Willie007 Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     Отвечено

    This is how i got my vertical split function to work.

    I connect it to the clip of a canvas that must become visible.

     

    Code Block

    Dim Page as Canvas

     

     

    private Sub VerticalSplitEffect

    Dim c As Double = 25

    Dim x As Double = Page.Width

    Dim y As Double = Page.Height

    Dim Cnt As Double = Math.Ceiling(x / c)

    Dim G As New GeometryGroup

    Dim ID As String

    Dim AnimClipRegion As Geometry = Nothing

    For i As Double = 0 To Cnt - 1

     AnimClipRegion = New RectangleGeometry(New Rect(0, 0, 0, 0), 0, 0) 'create new one

     ID = CreateNewID()

     Page.RegisterName(ID, AnimClipRegion)

     G.Children.Add(AnimClipRegion)

     Dim AnimationRect As New Animation.RectAnimation(New Rect(i * c, 0, 0, y), New Rect(i * c, 0, c, y), New Duration(TimeSpan.FromMilliseconds(Duration)), Animation.FillBehavior.Stop)

     Windows.Media.Animation.Storyboard.SetTargetName(AnimationRect, ID)

     Windows.Media.Animation.Storyboard.SetTargetProperty(AnimationRect, New PropertyPath (RectangleGeometry.RectProperty))

     StoryBoardAnimator.Children.Add(AnimationRect)

    Next

    Page.Clip = G

    End Sub

     

     

    Private Function CreateNewID() As String

    On Error Resume Next

    Return Guid.NewGuid.ToString("N")

    End Function