Exemplo n.º 1
0
def makeAnimation(top):
    xamlStr = """
<Storyboard xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
    <DoubleAnimationUsingKeyFrames>
        <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="{0}">
            <EasingDoubleKeyFrame.EasingFunction>
                <QuadraticEase EasingMode="EaseOut"/>
            </EasingDoubleKeyFrame.EasingFunction>
        </EasingDoubleKeyFrame>
        <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="{1}">
            <EasingDoubleKeyFrame.EasingFunction>
                <QuadraticEase EasingMode="EaseIn"/>
            </EasingDoubleKeyFrame.EasingFunction>
        </EasingDoubleKeyFrame>
        <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="{2}">
            <EasingDoubleKeyFrame.EasingFunction>
                <QuadraticEase EasingMode="EaseOut"/>
            </EasingDoubleKeyFrame.EasingFunction>
        </EasingDoubleKeyFrame>
        <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="{3}">
            <EasingDoubleKeyFrame.EasingFunction>
                <QuadraticEase EasingMode="EaseIn"/>
            </EasingDoubleKeyFrame.EasingFunction>
        </EasingDoubleKeyFrame>
    </DoubleAnimationUsingKeyFrames>
</Storyboard>
""".format(top - 30, top, top - 30, top)

    sr = StringReader(xamlStr)
    sb = XamlServices.Load(sr)
    sr.Dispose()

    Storyboard.SetTarget(sb.Children[0], harriet.Window.Window)
    Storyboard.SetTargetProperty(sb.Children[0], PropertyPath("Top"))
    return sb
Exemplo n.º 2
0
def _getStoryboardAppliedToWindowProperty(xamlStr, propertyPath):
    with StringReader(xamlStr) as sr:
        sb = XamlServices.Load(sr)

    Storyboard.SetTarget(sb.Children[0], harriet.Window.Window)
    Storyboard.SetTargetProperty(sb.Children[0], PropertyPath(propertyPath))

    return sb
Exemplo n.º 3
0
def _makeFadeStoryboard(start, end, duration):
    xamlStr = """
<Storyboard xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
    <DoubleAnimation From="{0:.2f}" To="{1:.2f}" Duration="0:0:{2:.2f}" />
</Storyboard>
""".format(start, end, duration)

    with StringReader(xamlStr) as sr:
        sb = XamlServices.Load(sr)

    Storyboard.SetTarget(sb.Children[0], harriet.Window.Window)
    Storyboard.SetTargetProperty(sb.Children[0],
                                 PropertyPath("(UIElement.Opacity)"))

    return sb
Exemplo n.º 4
0
def makeEndAnimation():
    xamlStr = """
<Storyboard xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
    <DoubleAnimationUsingKeyFrames>
        <DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
        <EasingDoubleKeyFrame KeyTime="0:0:0.15" Value="1.2">
            <EasingDoubleKeyFrame.EasingFunction>
                <QuadraticEase EasingMode="EaseOut"/>
            </EasingDoubleKeyFrame.EasingFunction>
        </EasingDoubleKeyFrame>
        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1.0">
            <EasingDoubleKeyFrame.EasingFunction>
                <QuadraticEase EasingMode="EaseIn"/>
            </EasingDoubleKeyFrame.EasingFunction>
        </EasingDoubleKeyFrame>
    </DoubleAnimationUsingKeyFrames>
    <DoubleAnimationUsingKeyFrames>
        <DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
        <EasingDoubleKeyFrame KeyTime="0:0:0.15" Value="0.84">
            <EasingDoubleKeyFrame.EasingFunction>
                <QuadraticEase EasingMode="EaseOut"/>
            </EasingDoubleKeyFrame.EasingFunction>
        </EasingDoubleKeyFrame>
        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1.0">
            <EasingDoubleKeyFrame.EasingFunction>
                <QuadraticEase EasingMode="EaseIn"/>
            </EasingDoubleKeyFrame.EasingFunction>
        </EasingDoubleKeyFrame>
    </DoubleAnimationUsingKeyFrames>
</Storyboard>
"""

    sr = StringReader(xamlStr)
    sb = XamlServices.Load(sr)
    sr.Dispose()

    #FIXME: 入れる先が用意されてないのでダメ
    Storyboard.SetTarget(sb.Children[0], harriet.Character)
    Storyboard.SetTarget(sb.Children[1], harriet.Character)

    Storyboard.SetTargetProperty(
        sb.Children[0], PropertyPath("RenderTransform.Children[2].ScaleX"))
    Storyboard.SetTargetProperty(
        sb.Children[1], PropertyPath("RenderTransform.Children[2].ScaleY"))

    return sb
Exemplo n.º 5
0
def getOpacityMaskAndStoryboard(duration):
    xamlStr = """
<Rectangle xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           Width="10" Height="10">
    <Rectangle.Resources>
        <Storyboard x:Key="Appear">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(GradientBrush.GradientStops)[0].(GradientStop.Offset)"
                                           Storyboard.TargetName="OpacityBrush">
                <EasingDoubleKeyFrame KeyTime="0:0:0" Value="-0.1"/>
                <EasingDoubleKeyFrame KeyTime="0:0:{0}" Value="1">
                    <EasingDoubleKeyFrame.EasingFunction>
                        <CubicEase EasingMode="EaseInOut"/>
                    </EasingDoubleKeyFrame.EasingFunction>
                </EasingDoubleKeyFrame>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(GradientBrush.GradientStops)[1].(GradientStop.Offset)"
                                           Storyboard.TargetName="OpacityBrush">
                <EasingDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
                <EasingDoubleKeyFrame KeyTime="0:0:{0}" Value="1.1">
                    <EasingDoubleKeyFrame.EasingFunction>
                        <CubicEase EasingMode="EaseInOut"/>
                    </EasingDoubleKeyFrame.EasingFunction>
                </EasingDoubleKeyFrame>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </Rectangle.Resources>
    <Rectangle.OpacityMask>
        <LinearGradientBrush x:Name="OpacityBrush" EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Offset="0" Color="Black" />
            <GradientStop Offset="0" Color="Transparent" />
        </LinearGradientBrush>
    </Rectangle.OpacityMask>
</Rectangle>
""".format(duration)

    with StringReader(xamlStr) as sr:
        rect = XamlServices.Load(sr)

    sb = rect.TryFindResource("Appear")
    opMask = rect.OpacityMask
    return opMask, sb