Skip to content

Commit 9917304

Browse files
committed
Added demo images to accent analyzer sample
1 parent b1f968c commit 9917304

File tree

7 files changed

+57
-12
lines changed

7 files changed

+57
-12
lines changed
Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
1-
<Project>
1+
<Project>
22
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" Condition="Exists('$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))')" />
3-
3+
44
<PropertyGroup>
55
<ToolkitComponentName>Helpers.AccentAnalyzer</ToolkitComponentName>
66
</PropertyGroup>
77

88
<!-- Sets this up as a toolkit component's sample project -->
99
<Import Project="$(ToolingDirectory)\ToolkitComponent.SampleProject.props" />
10+
<ItemGroup>
11+
<None Remove="Assets\StockImages\Bloom.jpg" />
12+
<None Remove="Assets\StockImages\Headphones.jpg" />
13+
<None Remove="Assets\StockImages\Paint.jpg" />
14+
</ItemGroup>
15+
<ItemGroup>
16+
<Content Update="Assets\StockImages\Bloom.jpg">
17+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
18+
</Content>
19+
<Content Update="Assets\StockImages\Headphones.jpg">
20+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
21+
</Content>
22+
<Content Update="Assets\StockImages\Paint.jpg">
23+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
24+
</Content>
25+
</ItemGroup>
1026
</Project>

components/AccentAnalyzer/samples/AccentAnalyzerSample.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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. -->
22
<Page x:Class="AccentAnalyzerExperiment.Samples.AccentAnalyzerSample"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@@ -27,7 +27,7 @@
2727
MaxHeight="256"
2828
Margin="20"
2929
HorizontalAlignment="Center"
30-
Source="/Helpers.AccentAnalyzerExperiment.Samples/Assets/icon.png"
30+
Source="/Helpers.AccentAnalyzerExperiment.Samples/Assets/StockImages/Bloom.jpg"
3131
Stretch="Uniform">
3232
<interactivity:Interaction.Behaviors>
3333
<interactivity:EventTriggerBehavior EventName="ImageOpened">
Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
1-
<UserControl x:Class="AccentAnalyzerExperiment.Samples.AccentAnalyzerSampleOptionsPane"
1+
<UserControl x:Class="AccentAnalyzerExperiment.Samples.AccentAnalyzerSampleOptionsPane"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
55
xmlns:local="using:AccentAnalyzerExperiment.Samples"
66
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
77
mc:Ignorable="d">
88

9-
<StackPanel Orientation="Horizontal">
10-
<TextBox x:Name="UrlTextbox"
11-
MaxWidth="300"
12-
PlaceholderText="Enter a url" />
13-
<Button Click="Button_Click"
14-
Content="Set Image" />
9+
<StackPanel MaxWidth="400">
10+
<StackPanel Orientation="Horizontal">
11+
<TextBox x:Name="UrlTextbox"
12+
PlaceholderText="Enter a url" />
13+
<Button Click="Button_Click"
14+
Content="Set Image" />
15+
</StackPanel>
16+
17+
<GridView ItemsSource="{x:Bind StockImages, Mode=OneWay}" SelectionMode="Single" IsItemClickEnabled="True" ItemClick="GridView_ItemClick"
18+
>
19+
<GridView.ItemTemplate>
20+
<DataTemplate x:DataType="x:String">
21+
<Image Stretch="UniformToFill" MaxWidth="128">
22+
<Image.Source>
23+
<BitmapImage UriSource="{x:Bind}"/>
24+
</Image.Source>
25+
</Image>
26+
</DataTemplate>
27+
</GridView.ItemTemplate>
28+
</GridView>
1529
</StackPanel>
1630
</UserControl>

components/AccentAnalyzer/samples/AccentAnalyzerSampleOptionsPane.xaml.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,25 @@ public AccentAnalyzerSampleOptionsPane(AccentAnalyzerSample sample)
2020
this.InitializeComponent();
2121

2222
_sample = new AccentAnalyzerSample.XamlNamedPropertyRelay(sample);
23+
24+
string[] images = ["Bloom.jpg", "Headphones.jpg", "Paint.jpg"];
25+
StockImages = images.Select(x => $"ms-appx:///Assets/StockImages/{x}").ToList();
2326
}
2427

2528
private void Button_Click(object sender, RoutedEventArgs e)
2629
{
27-
_sample.AccentedImage.Source = new BitmapImage(new Uri(UrlTextbox.Text));
30+
SetImage(new Uri(UrlTextbox.Text));
31+
}
32+
33+
public IList<string> StockImages { get; }
34+
35+
private void GridView_ItemClick(object sender, ItemClickEventArgs e)
36+
{
37+
SetImage(new Uri((string)e.ClickedItem));
38+
}
39+
40+
private void SetImage(Uri uri)
41+
{
42+
_sample.AccentedImage.Source = new BitmapImage(uri);
2843
}
2944
}
269 KB
Loading
18.2 KB
Loading
149 KB
Loading

0 commit comments

Comments
 (0)