PageRenderTime 13ms CodeModel.GetById 8ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/V4/Quickstarts/Modularity/Desktop/ModularityWithUnity/ModularityWithUnity.Desktop/ModularityStyles.xaml

#
XAML | 85 lines | 73 code | 8 blank | 4 comment | 0 complexity | 3560c083c95cbc72e73f01aec05688e5 MD5 | raw file
 1<ResourceDictionary
 2    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
 3    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 4    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
 5    xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
 6    xmlns:ModularityWithUnity="clr-namespace:ModularityWithUnity.Desktop">
 7
 8    <SolidColorBrush x:Key="ModuleControl.NotStarted.BackgroundBrush-Simple" Color="White"/>
 9    <SolidColorBrush x:Key="ModuleControl.NotStarted.BorderBrush-Simple" Color="Gray"/>
10    <SolidColorBrush x:Key="ModuleControl.NotStarted.ForegroundBrush-Simple" Color="Gray"/>
11
12    <SolidColorBrush x:Key="ModuleControl.Downloading.BackgroundBrush-Simple" Color="White"/>
13    <SolidColorBrush x:Key="ModuleControl.Downloading.BorderBrush-Simple" Color="LightBlue"/>
14    <SolidColorBrush x:Key="ModuleControl.Downloading.ForegroundBrush-Simple" Color="Black"/>
15
16    <LinearGradientBrush x:Key="ModuleControl.Downloaded.BackgroundBrush-Simple" EndPoint="0.5,1" StartPoint="0.5,0">
17        <GradientStop Color="White" Offset="0.02"/>
18        <GradientStop Color="LightBlue" Offset="1"/>
19    </LinearGradientBrush>
20    <SolidColorBrush x:Key="ModuleControl.Downloaded.BorderBrush-Simple" Color="LightBlue"/>
21    <SolidColorBrush x:Key="ModuleControl.Downloaded.ForegroundBrush-Simple" Color="Black"/>
22
23    <SolidColorBrush x:Key="ModuleControl.Constructed.BackgroundBrush-Simple" Color="White"/>
24    <SolidColorBrush x:Key="ModuleControl.Constructed.BorderBrush-Simple" Color="Black"/>
25    <SolidColorBrush x:Key="ModuleControl.Constructed.ForegroundBrush-Simple" Color="Black"/>
26
27    <LinearGradientBrush x:Key="ModuleControl.Initialized.BackgroundBrush-Simple" EndPoint="0.5,1" StartPoint="0.5,0">
28        <GradientStop Color="#FFBCE4A5" Offset="0.02"/>
29        <GradientStop Color="#FF579D2F" Offset="1"/>
30    </LinearGradientBrush>
31    <SolidColorBrush x:Key="ModuleControl.Initialized.BorderBrush-Simple" Color="#FF36621D"/>
32    <SolidColorBrush x:Key="ModuleControl.Initialized.ForegroundBrush-Simple" Color="Black"/>
33
34    <ControlTemplate x:Key="ModuleControlTemplate-Simple" TargetType="ModularityWithUnity:ModuleControl">
35        <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}">
36            <i:Interaction.Triggers>
37                <!-- DataTriggers only work when the dependency property value changes. -->
38                <!-- For the quickstart, some modules may initialize before the UI data-binds. -->
39                <!-- To accomodate this, the data triggers below bind to a hidden control value that is bound late enough. -->
40                <ei:DataTrigger Binding="{Binding ElementName=ModuleStatusTextBlock, Path=Text}" Value="NotStarted">
41                    <ei:ChangePropertyAction PropertyName="Background" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.NotStarted.BackgroundBrush-Simple}"/>
42                    <ei:ChangePropertyAction PropertyName="Foreground" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.NotStarted.ForegroundBrush-Simple}"/>
43                    <ei:ChangePropertyAction PropertyName="BorderBrush" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.NotStarted.BorderBrush-Simple}"/>
44                    <ei:ChangePropertyAction PropertyName="FontSize" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="12"/>
45                </ei:DataTrigger>
46                <ei:DataTrigger Binding="{Binding ElementName=ModuleStatusTextBlock, Path=Text}" Value="Downloading">
47                    <ei:ChangePropertyAction PropertyName="Background" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}"  Value="{StaticResource ModuleControl.Downloading.BackgroundBrush-Simple}"/>
48                    <ei:ChangePropertyAction PropertyName="Foreground" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.Downloading.ForegroundBrush-Simple}"/>
49                    <ei:ChangePropertyAction PropertyName="BorderBrush" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.Downloading.BorderBrush-Simple}"/>
50                </ei:DataTrigger>
51                <ei:DataTrigger Binding="{Binding ElementName=ModuleStatusTextBlock, Path=Text}" Value="Downloaded">
52                    <ei:ChangePropertyAction PropertyName="Background" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}"  Value="{StaticResource ModuleControl.Downloaded.BackgroundBrush-Simple}"/>
53                    <ei:ChangePropertyAction PropertyName="Foreground" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.Downloaded.ForegroundBrush-Simple}"/>
54                    <ei:ChangePropertyAction PropertyName="BorderBrush" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.Downloaded.BorderBrush-Simple}"/>
55                </ei:DataTrigger>
56                <ei:DataTrigger Binding="{Binding ElementName=ModuleStatusTextBlock, Path=Text}" Value="Constructed">
57                    <ei:ChangePropertyAction PropertyName="Background" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.Constructed.BackgroundBrush-Simple}"/>
58                    <ei:ChangePropertyAction PropertyName="Foreground" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.Constructed.ForegroundBrush-Simple}"/>
59                    <ei:ChangePropertyAction PropertyName="BorderBrush" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.Constructed.BorderBrush-Simple}"/>
60                    <ei:ChangePropertyAction PropertyName="FontSize" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="12"/>
61                </ei:DataTrigger>
62                <ei:DataTrigger Binding="{Binding ElementName=ModuleStatusTextBlock, Path=Text}" Value="Initialized">
63                    <ei:ChangePropertyAction PropertyName="Background" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}"  Value="{StaticResource ModuleControl.Initialized.BackgroundBrush-Simple}"/>
64                    <ei:ChangePropertyAction PropertyName="Foreground" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.Initialized.ForegroundBrush-Simple}"/>
65                    <ei:ChangePropertyAction PropertyName="BorderBrush" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="{StaticResource ModuleControl.Initialized.BorderBrush-Simple}"/>
66                    <ei:ChangePropertyAction PropertyName="FontSize" TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" Value="15"/>
67                </ei:DataTrigger>
68            </i:Interaction.Triggers>
69            <Grid>
70                <ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RenderTransformOrigin="0.5,0.5" />
71                <!-- This must come after the DataTriggers so that it is bound later and causes the triggers to fire and grab initial state -->
72                <TextBlock Visibility="Collapsed" x:Name="ModuleStatusTextBlock" Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataContext.ModuleInitializationStatus}" />
73            </Grid>
74        </Border>
75    </ControlTemplate>
76
77    <Style x:Key="ModuleControlStyle-Simple" TargetType="ModularityWithUnity:ModuleControl">
78        <Setter Property="Background" Value="{StaticResource ModuleControl.NotStarted.BackgroundBrush-Simple}"/>
79        <Setter Property="Foreground" Value="{StaticResource ModuleControl.NotStarted.ForegroundBrush-Simple}"/>
80        <Setter Property="BorderBrush" Value="{StaticResource ModuleControl.NotStarted.BorderBrush-Simple}"/>
81        <Setter Property="BorderThickness" Value="1" />
82        <Setter Property="Template" Value="{StaticResource ModuleControlTemplate-Simple}"/>
83    </Style>
84
85</ResourceDictionary>