| 
 | 1 | +<!--  Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information.  -->  | 
 | 2 | +<local:ColorPaletteSamplerToolkitSampleBase x:Class="ColorAnalyzerExperiment.Samples.AccentColorSample"  | 
 | 3 | +                                            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  | 
 | 4 | +                                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  | 
 | 5 | +                                            xmlns:behaviors="using:CommunityToolkit.WinUI.Behaviors"  | 
 | 6 | +                                            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"  | 
 | 7 | +                                            xmlns:helpers="using:CommunityToolkit.WinUI.Helpers"  | 
 | 8 | +                                            xmlns:interactivity="using:Microsoft.Xaml.Interactivity"  | 
 | 9 | +                                            xmlns:local="using:ColorAnalyzerExperiment.Samples"  | 
 | 10 | +                                            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  | 
 | 11 | +                                            mc:Ignorable="d">  | 
 | 12 | + | 
 | 13 | +    <local:ColorPaletteSamplerToolkitSampleBase.Resources>  | 
 | 14 | +        <helpers:ColorPaletteSampler x:Name="ColorPaletteSampler"  | 
 | 15 | +                                     Source="{x:Bind SampledImage}">  | 
 | 16 | +            <helpers:AccentColorPaletteSelector x:Name="AccentPalette"  | 
 | 17 | +                                                MinColorCount="3" />  | 
 | 18 | +        </helpers:ColorPaletteSampler>  | 
 | 19 | +    </local:ColorPaletteSamplerToolkitSampleBase.Resources>  | 
 | 20 | + | 
 | 21 | +    <!--  | 
 | 22 | +        ConstrastHelper is used in this sample to auto-adjust text Foreground to ensure  | 
 | 23 | +        readability against dynamic background. This is not the ContrastHelper sample.  | 
 | 24 | +        (though it is a fantastic example use case for it!)  | 
 | 25 | +    -->  | 
 | 26 | +    <Grid Margin="20">  | 
 | 27 | +        <Grid.ColumnDefinitions>  | 
 | 28 | +            <ColumnDefinition Width="*" />  | 
 | 29 | +            <ColumnDefinition Width="*" />  | 
 | 30 | +        </Grid.ColumnDefinitions>  | 
 | 31 | + | 
 | 32 | +        <Grid Margin="20"  | 
 | 33 | +              VerticalAlignment="Center">  | 
 | 34 | +            <Image x:Name="SampledImage"  | 
 | 35 | +                   HorizontalAlignment="Center"  | 
 | 36 | +                   Source="{x:Bind SelectedImage, Mode=OneWay}"  | 
 | 37 | +                   Stretch="Uniform">  | 
 | 38 | +                <interactivity:Interaction.Behaviors>  | 
 | 39 | +                    <interactivity:EventTriggerBehavior EventName="ImageOpened">  | 
 | 40 | +                        <interactivity:CallMethodAction MethodName="UpdatePalette"  | 
 | 41 | +                                                        TargetObject="{x:Bind ColorPaletteSampler}" />  | 
 | 42 | +                    </interactivity:EventTriggerBehavior>  | 
 | 43 | +                </interactivity:Interaction.Behaviors>  | 
 | 44 | +            </Image>  | 
 | 45 | +        </Grid>  | 
 | 46 | + | 
 | 47 | +        <Grid Grid.Column="1"  | 
 | 48 | +              MaxWidth="400"  | 
 | 49 | +              MaxHeight="250"  | 
 | 50 | +              Margin="20"  | 
 | 51 | +              HorizontalAlignment="Stretch"  | 
 | 52 | +              VerticalAlignment="Stretch">  | 
 | 53 | +            <Grid.ColumnDefinitions>  | 
 | 54 | +                <ColumnDefinition />  | 
 | 55 | +                <ColumnDefinition />  | 
 | 56 | +            </Grid.ColumnDefinitions>  | 
 | 57 | +            <Grid.RowDefinitions>  | 
 | 58 | +                <RowDefinition />  | 
 | 59 | +                <RowDefinition Height="0.6*" />  | 
 | 60 | +                <RowDefinition Height="0.4*" />  | 
 | 61 | +            </Grid.RowDefinitions>  | 
 | 62 | + | 
 | 63 | +            <!--  Primary Accent Color  -->  | 
 | 64 | +            <Border Grid.ColumnSpan="2"  | 
 | 65 | +                    Margin="4"  | 
 | 66 | +                    Padding="2">  | 
 | 67 | +                <Border.Background>  | 
 | 68 | +                    <SolidColorBrush Color="{x:Bind AccentPalette.SelectedColors[0], FallbackValue=Transparent, Mode=OneWay}" />  | 
 | 69 | +                </Border.Background>  | 
 | 70 | +                <TextBlock helpers:ContrastHelper.Opponent="{x:Bind AccentPalette.SelectedColors[0], FallbackValue=Transparent, Mode=OneWay}"  | 
 | 71 | +                           Text="Primary Accent" />  | 
 | 72 | +            </Border>  | 
 | 73 | + | 
 | 74 | +            <!--  Secondary Accent Color  -->  | 
 | 75 | +            <Border Grid.Row="1"  | 
 | 76 | +                    Margin="4"  | 
 | 77 | +                    Padding="2">  | 
 | 78 | +                <Border.Background>  | 
 | 79 | +                    <SolidColorBrush Color="{x:Bind AccentPalette.SelectedColors[1], FallbackValue=Transparent, Mode=OneWay}" />  | 
 | 80 | +                </Border.Background>  | 
 | 81 | +                <TextBlock helpers:ContrastHelper.Opponent="{x:Bind AccentPalette.SelectedColors[1], FallbackValue=Transparent, Mode=OneWay}"  | 
 | 82 | +                           Text="Secondary Accent" />  | 
 | 83 | +            </Border>  | 
 | 84 | + | 
 | 85 | +            <!--  Tertiary Accent Color  -->  | 
 | 86 | +            <Border Grid.Row="1"  | 
 | 87 | +                    Grid.Column="1"  | 
 | 88 | +                    Margin="4"  | 
 | 89 | +                    Padding="2">  | 
 | 90 | +                <Border.Background>  | 
 | 91 | +                    <SolidColorBrush Color="{x:Bind AccentPalette.SelectedColors[2], FallbackValue=Transparent, Mode=OneWay}" />  | 
 | 92 | +                </Border.Background>  | 
 | 93 | +                <TextBlock helpers:ContrastHelper.Opponent="{x:Bind AccentPalette.SelectedColors[2], FallbackValue=Transparent, Mode=OneWay}"  | 
 | 94 | +                           Text="Tertiary Accent" />  | 
 | 95 | +            </Border>  | 
 | 96 | + | 
 | 97 | +            <!--  Accent Colors Gradient  -->  | 
 | 98 | +            <Rectangle Grid.Row="3"  | 
 | 99 | +                       Grid.ColumnSpan="2"  | 
 | 100 | +                       Margin="4">  | 
 | 101 | +                <Rectangle.Fill>  | 
 | 102 | +                    <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">  | 
 | 103 | +                        <GradientStopCollection>  | 
 | 104 | +                            <GradientStop Offset="0" Color="{x:Bind AccentPalette.SelectedColors[0], FallbackValue=Transparent, Mode=OneWay}" />  | 
 | 105 | +                            <GradientStop Offset="0.6" Color="{x:Bind AccentPalette.SelectedColors[1], FallbackValue=Transparent, Mode=OneWay}" />  | 
 | 106 | +                            <GradientStop Offset="1" Color="{x:Bind AccentPalette.SelectedColors[2], FallbackValue=Transparent, Mode=OneWay}" />  | 
 | 107 | +                        </GradientStopCollection>  | 
 | 108 | +                    </LinearGradientBrush>  | 
 | 109 | +                </Rectangle.Fill>  | 
 | 110 | +            </Rectangle>  | 
 | 111 | +        </Grid>  | 
 | 112 | +    </Grid>  | 
 | 113 | +</local:ColorPaletteSamplerToolkitSampleBase>  | 
0 commit comments