|  | 
| 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.  --> | 
|  | 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 | 2 | <Page x:Class="ColorAnalyzerExperiment.Samples.AccentAnalyzerSample" | 
| 3 | 3 |       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | 
| 4 | 4 |       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | 
|  | 
| 11 | 11 |       mc:Ignorable="d"> | 
| 12 | 12 | 
 | 
| 13 | 13 |     <Page.Resources> | 
| 14 |  | -        <helpers:AccentAnalyzer x:Name="AccentAnalyzer" | 
| 15 |  | -                                Source="{x:Bind AccentedImage}" /> | 
|  | 14 | +        <helpers:ColorPaletteSampler x:Name="ColorPaletteSampler" | 
|  | 15 | +                                     Source="{x:Bind SampledImage}"> | 
|  | 16 | +            <helpers:AccentColorPaletteSelector x:Name="AccentPalette" | 
|  | 17 | +                                                MinColorCount="3" /> | 
|  | 18 | +            <helpers:ColorWeightPaletteSelector x:Name="WeightedColorPalette" | 
|  | 19 | +                                                MinColorCount="1" /> | 
|  | 20 | +            <helpers:BaseColorPaletteSelector x:Name="BasePalette" | 
|  | 21 | +                                              MinColorCount="1" /> | 
|  | 22 | +        </helpers:ColorPaletteSampler> | 
| 16 | 23 |     </Page.Resources> | 
| 17 | 24 | 
 | 
|  | 25 | +    <!-- | 
|  | 26 | +        ConstrastHelper used to auto-adjust text Foreground against the dynamic background per WCAG. | 
|  | 27 | +        This is not a ContrastHelper sample, but is used here to ensure text is always readable. | 
|  | 28 | +    --> | 
| 18 | 29 |     <Grid> | 
| 19 | 30 |         <Grid.ColumnDefinitions> | 
| 20 | 31 |             <ColumnDefinition Width="*" /> | 
|  | 
| 23 | 34 | 
 | 
| 24 | 35 |         <StackPanel Padding="20" | 
| 25 | 36 |                     VerticalAlignment="Center"> | 
| 26 |  | -            <Image x:Name="AccentedImage" | 
|  | 37 | +            <Image x:Name="SampledImage" | 
| 27 | 38 |                    HorizontalAlignment="Center" | 
| 28 | 39 |                    Source="/ColorAnalyzerExperiment.Samples/Assets/StockImages/Flowers.jpg" | 
| 29 | 40 |                    Stretch="Uniform"> | 
| 30 | 41 |                 <interactivity:Interaction.Behaviors> | 
| 31 | 42 |                     <interactivity:EventTriggerBehavior EventName="ImageOpened"> | 
| 32 |  | -                        <interactivity:CallMethodAction MethodName="UpdateAccent" | 
| 33 |  | -                                                        TargetObject="{x:Bind AccentAnalyzer}" /> | 
|  | 43 | +                        <interactivity:CallMethodAction MethodName="UpdatePalette" | 
|  | 44 | +                                                        TargetObject="{x:Bind ColorPaletteSampler}" /> | 
| 34 | 45 |                     </interactivity:EventTriggerBehavior> | 
| 35 | 46 |                 </interactivity:Interaction.Behaviors> | 
| 36 | 47 |             </Image> | 
| 37 |  | -            <TextBlock HorizontalAlignment="Center" | 
| 38 |  | -                       Text="{x:Bind AccentAnalyzer.Colorfulness, Mode=OneWay}" /> | 
| 39 | 48 |         </StackPanel> | 
| 40 | 49 | 
 | 
| 41 | 50 |         <Grid Grid.Column="1" | 
|  | 
| 60 | 69 |                     Margin="4" | 
| 61 | 70 |                     Padding="2"> | 
| 62 | 71 |                 <Border.Background> | 
| 63 |  | -                    <SolidColorBrush Color="{x:Bind AccentAnalyzer.DominantColor, Mode=OneWay}" /> | 
|  | 72 | +                    <SolidColorBrush Color="{x:Bind WeightedColorPalette.SelectedColors[0], FallbackValue=Transparent, Mode=OneWay}" /> | 
| 64 | 73 |                 </Border.Background> | 
| 65 |  | -                <TextBlock helpers:ContrastHelper.Opponent="{x:Bind AccentAnalyzer.DominantColor, Mode=OneWay}" | 
|  | 74 | +                <TextBlock helpers:ContrastHelper.Opponent="{x:Bind WeightedColorPalette.SelectedColors[0], FallbackValue=Transparent, Mode=OneWay}" | 
| 66 | 75 |                            Text="Dominant" /> | 
| 67 | 76 |             </Border> | 
| 68 | 77 | 
 | 
|  | 
| 72 | 81 |                     Margin="4" | 
| 73 | 82 |                     Padding="2"> | 
| 74 | 83 |                 <Border.Background> | 
| 75 |  | -                    <SolidColorBrush Color="{x:Bind AccentAnalyzer.BaseColor, Mode=OneWay}" /> | 
|  | 84 | +                    <SolidColorBrush Color="{x:Bind BasePalette.SelectedColors[0], FallbackValue=Transparent, Mode=OneWay}" /> | 
| 76 | 85 |                 </Border.Background> | 
| 77 | 86 |                 <TextBlock Text="Base"> | 
| 78 | 87 |                     <TextBlock.Foreground> | 
| 79 |  | -                        <!--  ConstrastHelper used to auto-adjust text Foreground against the dynamic background per WCAG  --> | 
|  | 88 | + | 
| 80 | 89 |                         <SolidColorBrush helpers:ContrastHelper.MinRatio="5" | 
| 81 |  | -                                         helpers:ContrastHelper.Opponent="{x:Bind AccentAnalyzer.BaseColor, Mode=OneWay}" | 
| 82 |  | -                                         Color="{x:Bind AccentAnalyzer.PrimaryAccentColor, Mode=OneWay}" /> | 
|  | 90 | +                                         helpers:ContrastHelper.Opponent="{x:Bind BasePalette.SelectedColors[0], FallbackValue=Transparent, Mode=OneWay}" | 
|  | 91 | +                                         Color="{x:Bind AccentPalette.SelectedColors[0], FallbackValue=Transparent, Mode=OneWay}" /> | 
| 83 | 92 |                     </TextBlock.Foreground> | 
| 84 | 93 |                 </TextBlock> | 
| 85 | 94 |             </Border> | 
|  | 
| 90 | 99 |                     Margin="4" | 
| 91 | 100 |                     Padding="2"> | 
| 92 | 101 |                 <Border.Background> | 
| 93 |  | -                    <SolidColorBrush Color="{x:Bind AccentAnalyzer.PrimaryAccentColor, Mode=OneWay}" /> | 
|  | 102 | +                    <SolidColorBrush Color="{x:Bind AccentPalette.SelectedColors[0], FallbackValue=Transparent, Mode=OneWay}" /> | 
| 94 | 103 |                 </Border.Background> | 
| 95 |  | -                <TextBlock helpers:ContrastHelper.Opponent="{x:Bind AccentAnalyzer.PrimaryAccentColor, Mode=OneWay}" | 
|  | 104 | +                <TextBlock helpers:ContrastHelper.Opponent="{x:Bind AccentPalette.SelectedColors[0], FallbackValue=Transparent, Mode=OneWay}" | 
| 96 | 105 |                            Text="Primary" /> | 
| 97 | 106 |             </Border> | 
| 98 | 107 |             <!--  Secondary  --> | 
|  | 
| 101 | 110 |                     Margin="4" | 
| 102 | 111 |                     Padding="2"> | 
| 103 | 112 |                 <Border.Background> | 
| 104 |  | -                    <SolidColorBrush Color="{x:Bind AccentAnalyzer.SecondaryAccentColor, Mode=OneWay}" /> | 
|  | 113 | +                    <SolidColorBrush Color="{x:Bind AccentPalette.SelectedColors[1], FallbackValue=Transparent, Mode=OneWay}" /> | 
| 105 | 114 |                 </Border.Background> | 
| 106 |  | -                <TextBlock helpers:ContrastHelper.Opponent="{x:Bind AccentAnalyzer.SecondaryAccentColor, Mode=OneWay}" | 
|  | 115 | +                <TextBlock helpers:ContrastHelper.Opponent="{x:Bind AccentPalette.SelectedColors[1], FallbackValue=Transparent, Mode=OneWay}" | 
| 107 | 116 |                            Text="Secondary" /> | 
| 108 | 117 |             </Border> | 
| 109 | 118 |             <!--  Tertiary  --> | 
|  | 
| 112 | 121 |                     Margin="4" | 
| 113 | 122 |                     Padding="2"> | 
| 114 | 123 |                 <Border.Background> | 
| 115 |  | -                    <SolidColorBrush Color="{x:Bind AccentAnalyzer.TertiaryAccentColor, Mode=OneWay}" /> | 
|  | 124 | +                    <SolidColorBrush Color="{x:Bind AccentPalette.SelectedColors[2], FallbackValue=Transparent, Mode=OneWay}" /> | 
| 116 | 125 |                 </Border.Background> | 
| 117 |  | -                <TextBlock helpers:ContrastHelper.Opponent="{x:Bind AccentAnalyzer.TertiaryAccentColor, Mode=OneWay}" | 
|  | 126 | +                <TextBlock helpers:ContrastHelper.Opponent="{x:Bind AccentPalette.SelectedColors[2], FallbackValue=Transparent, Mode=OneWay}" | 
| 118 | 127 |                            Text="Tertiary" /> | 
| 119 | 128 |             </Border> | 
| 120 | 129 | 
 | 
|  | 
| 125 | 134 |                 <Rectangle.Fill> | 
| 126 | 135 |                     <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> | 
| 127 | 136 |                         <GradientStopCollection> | 
| 128 |  | -                            <GradientStop Offset="0" Color="{x:Bind AccentAnalyzer.PrimaryAccentColor, Mode=OneWay}" /> | 
| 129 |  | -                            <GradientStop Offset="0.74" Color="{x:Bind AccentAnalyzer.SecondaryAccentColor, Mode=OneWay}" /> | 
| 130 |  | -                            <GradientStop Offset="1" Color="{x:Bind AccentAnalyzer.TertiaryAccentColor, Mode=OneWay}" /> | 
|  | 137 | +                            <GradientStop Offset="0" Color="{x:Bind AccentPalette.SelectedColors[0], FallbackValue=Transparent, Mode=OneWay}" /> | 
|  | 138 | +                            <GradientStop Offset="0.74" Color="{x:Bind AccentPalette.SelectedColors[1], FallbackValue=Transparent, Mode=OneWay}" /> | 
|  | 139 | +                            <GradientStop Offset="1" Color="{x:Bind AccentPalette.SelectedColors[2], FallbackValue=Transparent, Mode=OneWay}" /> | 
| 131 | 140 |                         </GradientStopCollection> | 
| 132 | 141 |                     </LinearGradientBrush> | 
| 133 | 142 |                 </Rectangle.Fill> | 
|  | 
0 commit comments