aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Touch/Controls/TouchBusyIndicator.xaml
blob: fa6a83d50356cc29eb2949f8c5fa0f5fee6cacc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highli
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:converters="clr-namespace:Tango.Touch.Converters"
                    xmlns:local="clr-namespace:Tango.Touch.Controls">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary>
            <converters:ArcEndPointConverter x:Key="ArcEndPointConverter" />
            <converters:ArcSizeConverter x:Key="ArcSizeConverter" />
            <converters:RotateTransformCentreConverter x:Key="RotateTransformCentreConverter" />
            <converters:NotZeroConverter x:Key="NotZeroConverter" />
            <converters:RotateTransformConverter x:Key="RotateTransformConverter" />
            <converters:StartPointConverter x:Key="StartPointConverter" />
            <converters:LargeArcConverter x:Key="LargeArcConverter" />
        </ResourceDictionary>

        <ResourceDictionary Source="../Resources/Colors.xaml" />
    </ResourceDictionary.MergedDictionaries>


    <Style TargetType="{x:Type local:TouchBusyIndicator}">
        <Setter Property="Foreground" Value="{StaticResource TangoPrimaryAccentBrush}" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Width" Value="20" />
        <Setter Property="Height" Value="20" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:TouchBusyIndicator}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="IsIndeterminateStoryboard" TargetName="RotateTransform" TargetProperty="Angle" RepeatBehavior="Forever">
                            <DoubleAnimation From="0" To="359" Duration="0:0:2" />
                        </Storyboard>
                        <Storyboard x:Key="IsFullyIndeterminateScaleStoryboard">
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FullyIndeterminateGridScaleTransform"
                                                           Storyboard.TargetProperty="ScaleX"
                                                           RepeatBehavior="Forever">
                                <SplineDoubleKeyFrame KeyTime="0" Value="0.0" />
                                <SplineDoubleKeyFrame KeyTime="0:0:1" Value="1.0" />
                                <SplineDoubleKeyFrame KeyTime="0:0:4" Value="0.0" />
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimation Storyboard.TargetName="RotateTransform"
                                             Storyboard.TargetProperty="Angle" 
                                             RepeatBehavior="Forever"
                                             From="00" To="359" Duration="0:0:1.25" />
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid x:Name="TemplateRoot" ClipToBounds="False">
                        <Grid x:Name="FullyIndeterminateGrid">
                            <Grid.RenderTransform>
                                <ScaleTransform x:Name="FullyIndeterminateGridScaleTransform" ScaleX="0" />
                            </Grid.RenderTransform>
                        </Grid>
                        <Grid x:Name="PathGrid" Margin="2" />
                        <Canvas>
                            <Ellipse Fill="{TemplateBinding Background}" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" />
                            <Path x:Name="Path" Stroke="{TemplateBinding Foreground}" StrokeThickness="{Binding RelativeSource={RelativeSource TemplatedParent},Path=StrokeThickness}" 
                                  Canvas.Top="2" Canvas.Left="2"
                                  RenderTransformOrigin="0, 0">
                                <Path.Data>
                                    <PathGeometry>
                                        <PathFigure StartPoint="{Binding ElementName=PathGrid, Path=ActualWidth, Converter={StaticResource StartPointConverter}, Mode=OneWay}">
                                            <ArcSegment Size="{Binding ElementName=PathGrid, Path=ActualWidth, Converter={StaticResource ArcSizeConverter}, Mode=OneWay}"
                                                        SweepDirection="Clockwise">
                                                <ArcSegment.IsLargeArc>
                                                    <MultiBinding Converter="{StaticResource LargeArcConverter}">
                                                        <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Value" />
                                                        <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Minimum" />
                                                        <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Maximum" />
                                                        <Binding ElementName="FullyIndeterminateGridScaleTransform" Path="ScaleX" />
                                                    </MultiBinding>
                                                </ArcSegment.IsLargeArc>
                                                <ArcSegment.Point>
                                                    <MultiBinding Converter="{StaticResource ArcEndPointConverter}">
                                                        <Binding ElementName="PathGrid" Path="ActualWidth" />
                                                        <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Value" />
                                                        <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Minimum" />
                                                        <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Maximum" />
                                                        <Binding ElementName="FullyIndeterminateGridScaleTransform" Path="ScaleX" />
                                                    </MultiBinding>
                                                </ArcSegment.Point>
                                            </ArcSegment>
                                        </PathFigure>
                                    </PathGeometry>
                                </Path.Data>
                                <Path.RenderTransform>
                                    <TransformGroup>
                                        <RotateTransform x:Name="RotateTransform"
                                                         CenterX="{Binding ElementName=PathGrid, Path=ActualWidth, Converter={StaticResource RotateTransformCentreConverter}, Mode=OneWay}" 
                                                         CenterY="{Binding ElementName=PathGrid, Path=ActualWidth, Converter={StaticResource RotateTransformCentreConverter}, Mode=OneWay}">
                                            <RotateTransform.Angle>
                                                <MultiBinding Converter="{StaticResource RotateTransformConverter}">
                                                    <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Value" />
                                                    <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Minimum" />
                                                    <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Maximum" />
                                                </MultiBinding>
                                            </RotateTransform.Angle>
                                        </RotateTransform>
                                    </TransformGroup>
                                </Path.RenderTransform>
                            </Path>
                        </Canvas>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsIndeterminate, RelativeSource={RelativeSource Self}}" Value="True" />
                                <Condition Binding="{Binding IsVisible, RelativeSource={RelativeSource Self}}" Value="True" />
                                <Condition Binding="{Binding Value, RelativeSource={RelativeSource Self}, Converter={StaticResource NotZeroConverter}}" Value="True" />
                            </MultiDataTrigger.Conditions>
                            <MultiDataTrigger.EnterActions>
                                <RemoveStoryboard BeginStoryboardName="IsFullyIndeterminateStoryboard" />
                                <BeginStoryboard Storyboard="{StaticResource IsIndeterminateStoryboard}"
                                                 Name="IsIndeterminateStoryboard"/>
                            </MultiDataTrigger.EnterActions>
                            <MultiDataTrigger.ExitActions>
                                <RemoveStoryboard BeginStoryboardName="IsIndeterminateStoryboard" />
                            </MultiDataTrigger.ExitActions>
                        </MultiDataTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsIndeterminate" Value="True" />
                                <Condition Property="Value" Value="0" />
                                <Condition Property="IsVisible" Value="True" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.EnterActions>
                                <RemoveStoryboard BeginStoryboardName="IsIndeterminateStoryboard" />
                                <BeginStoryboard Storyboard="{StaticResource IsFullyIndeterminateScaleStoryboard}"
                                                 Name="IsFullyIndeterminateStoryboard"/>
                            </MultiTrigger.EnterActions>
                            <MultiTrigger.ExitActions>
                                <RemoveStoryboard BeginStoryboardName="IsFullyIndeterminateStoryboard" />
                            </MultiTrigger.ExitActions>
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>