|
| 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 | +<Page x:Class="ColorAnalyzerExperiment.Samples.AccentAnalyzerSample" |
| 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 | + <Page.Resources> |
| 14 | + <helpers:AccentAnalyzer x:Name="AccentAnalyzer" |
| 15 | + Source="{x:Bind AccentedImage}" /> |
| 16 | + </Page.Resources> |
| 17 | + |
| 18 | + <Grid> |
| 19 | + <Grid.ColumnDefinitions> |
| 20 | + <ColumnDefinition Width="*" /> |
| 21 | + <ColumnDefinition Width="*" /> |
| 22 | + </Grid.ColumnDefinitions> |
| 23 | + |
| 24 | + <StackPanel Padding="20" |
| 25 | + VerticalAlignment="Center"> |
| 26 | + <Image x:Name="AccentedImage" |
| 27 | + HorizontalAlignment="Center" |
| 28 | + Source="/ColorAnalyzerExperiment.Samples/Assets/StockImages/Bloom.jpg" |
| 29 | + Stretch="Uniform"> |
| 30 | + <interactivity:Interaction.Behaviors> |
| 31 | + <interactivity:EventTriggerBehavior EventName="ImageOpened"> |
| 32 | + <interactivity:CallMethodAction MethodName="UpdateAccent" |
| 33 | + TargetObject="{x:Bind AccentAnalyzer}" /> |
| 34 | + </interactivity:EventTriggerBehavior> |
| 35 | + </interactivity:Interaction.Behaviors> |
| 36 | + </Image> |
| 37 | + <TextBlock HorizontalAlignment="Center" |
| 38 | + Text="{x:Bind AccentAnalyzer.Colorfulness, Mode=OneWay}" /> |
| 39 | + </StackPanel> |
| 40 | + |
| 41 | + <Grid Grid.Column="1" |
| 42 | + Height="400" |
| 43 | + MaxWidth="600" |
| 44 | + Margin="20"> |
| 45 | + <Grid.ColumnDefinitions> |
| 46 | + <ColumnDefinition /> |
| 47 | + <ColumnDefinition /> |
| 48 | + <ColumnDefinition /> |
| 49 | + </Grid.ColumnDefinitions> |
| 50 | + <Grid.RowDefinitions> |
| 51 | + <RowDefinition Height="4*" /> |
| 52 | + <RowDefinition Height="2*" /> |
| 53 | + <RowDefinition Height="*" /> |
| 54 | + <RowDefinition Height="2*" /> |
| 55 | + </Grid.RowDefinitions> |
| 56 | + |
| 57 | + <!-- Dominant --> |
| 58 | + <Border Grid.RowSpan="3" |
| 59 | + Grid.Column="0" |
| 60 | + Margin="4" |
| 61 | + Padding="2"> |
| 62 | + <Border.Background> |
| 63 | + <SolidColorBrush Color="{x:Bind AccentAnalyzer.DominantColor, Mode=OneWay}" /> |
| 64 | + </Border.Background> |
| 65 | + <TextBlock Foreground="Black" |
| 66 | + Text="Dominant" /> |
| 67 | + </Border> |
| 68 | + |
| 69 | + <!-- Base --> |
| 70 | + <Border Grid.Row="4" |
| 71 | + Grid.ColumnSpan="4" |
| 72 | + Margin="4" |
| 73 | + Padding="2"> |
| 74 | + <Border.Background> |
| 75 | + <SolidColorBrush Color="{x:Bind AccentAnalyzer.BaseColor, Mode=OneWay}" /> |
| 76 | + </Border.Background> |
| 77 | + <TextBlock Foreground="Black" |
| 78 | + Text="Base" /> |
| 79 | + </Border> |
| 80 | + |
| 81 | + <!-- Primary --> |
| 82 | + <Border Grid.Row="0" |
| 83 | + Grid.Column="1" |
| 84 | + Margin="4" |
| 85 | + Padding="2"> |
| 86 | + <Border.Background> |
| 87 | + <SolidColorBrush Color="{x:Bind AccentAnalyzer.PrimaryAccentColor, Mode=OneWay}" /> |
| 88 | + </Border.Background> |
| 89 | + <TextBlock Foreground="Black" |
| 90 | + Text="Primary" /> |
| 91 | + </Border> |
| 92 | + <!-- Secondary --> |
| 93 | + <Border Grid.Row="1" |
| 94 | + Grid.Column="1" |
| 95 | + Margin="4" |
| 96 | + Padding="2"> |
| 97 | + <Border.Background> |
| 98 | + <SolidColorBrush Color="{x:Bind AccentAnalyzer.SecondaryAccentColor, Mode=OneWay}" /> |
| 99 | + </Border.Background> |
| 100 | + <TextBlock Foreground="Black" |
| 101 | + Text="Secondary" /> |
| 102 | + </Border> |
| 103 | + <!-- Tertiary --> |
| 104 | + <Border Grid.Row="2" |
| 105 | + Grid.Column="1" |
| 106 | + Margin="4" |
| 107 | + Padding="2"> |
| 108 | + <Border.Background> |
| 109 | + <SolidColorBrush Color="{x:Bind AccentAnalyzer.TertiaryAccentColor, Mode=OneWay}" /> |
| 110 | + </Border.Background> |
| 111 | + <TextBlock Foreground="Black" |
| 112 | + Text="Tertiary" /> |
| 113 | + </Border> |
| 114 | + |
| 115 | + <!-- Gradient --> |
| 116 | + <Rectangle Grid.RowSpan="3" |
| 117 | + Grid.Column="2" |
| 118 | + Margin="4"> |
| 119 | + <Rectangle.Fill> |
| 120 | + <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> |
| 121 | + <GradientStopCollection> |
| 122 | + <GradientStop Offset="0" Color="{x:Bind AccentAnalyzer.PrimaryAccentColor, Mode=OneWay}" /> |
| 123 | + <GradientStop Offset="0.74" Color="{x:Bind AccentAnalyzer.SecondaryAccentColor, Mode=OneWay}" /> |
| 124 | + <GradientStop Offset="1" Color="{x:Bind AccentAnalyzer.TertiaryAccentColor, Mode=OneWay}" /> |
| 125 | + </GradientStopCollection> |
| 126 | + </LinearGradientBrush> |
| 127 | + </Rectangle.Fill> |
| 128 | + </Rectangle> |
| 129 | + </Grid> |
| 130 | + </Grid> |
| 131 | +</Page> |
0 commit comments