Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions AIDevGallery/Controls/ModelPicker/ModelOrApiPicker.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@
AutomationProperties.Name="More info"
Content="{x:Bind utils:AppUtils.GetHardwareAcceleratorString((models:HardwareAccelerator))}"
Style="{StaticResource TertiaryButtonStyle}"
ToolTipService.ToolTip="More info">
ToolTipService.ToolTip="More info"
Background="{ThemeResource ButtonBackground}">
<Button.Flyout>
<Flyout ShouldConstrainToRootBounds="False">
<TextBlock
Expand Down Expand Up @@ -204,7 +205,7 @@
Style="{StaticResource AccentButtonStyle}">
<StackPanel Orientation="Vertical" Spacing="4">
<FontIcon FontSize="14" Glyph="&#xE72A;" />
<TextBlock Text="Run sample" />
<TextBlock Text="Run sample" TextWrapping="Wrap"/>
</StackPanel>
</Button>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
xmlns:ui="using:CommunityToolkit.WinUI"
xmlns:utils="using:AIDevGallery.Utils"
xmlns:vm="using:AIDevGallery.ViewModels"
xmlns:controls="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d">

<Grid>
Expand All @@ -40,7 +41,7 @@
Grid.Row="1"
TextWrapping="Wrap"
Text="To use a custom model, convert it to a WindowsML-compatible format using the AI Toolkit conversion tool. Note: Currently, only select models are supported for conversion in AI Toolkit, with additional models coming soon." />
<StackPanel Orientation="Horizontal" Spacing="12">
<controls:WrapPanel Orientation="Horizontal" HorizontalSpacing="12" VerticalSpacing="12">
<Button
x:Name="OpenAIToolkitButton"
Click="OpenAIToolkitButton_Click"
Expand All @@ -65,7 +66,7 @@
<TextBlock Text="View documentation" Margin="5,0,0,0" />
</StackPanel>
</Button>
</StackPanel>
</controls:WrapPanel>
</StackPanel>
<StackPanel
Margin="0,12"
Expand Down Expand Up @@ -149,7 +150,8 @@
Content="{x:Bind utils:AppUtils.GetHardwareAcceleratorString((models:HardwareAccelerator))}"
Style="{StaticResource TertiaryButtonStyle}"
Tapped="StopPropagatingHandler"
ToolTipService.ToolTip="More info">
ToolTipService.ToolTip="More info"
Background="{ThemeResource ButtonBackground}">
<Button.Flyout>
<Flyout ShouldConstrainToRootBounds="False">
<TextBlock
Expand Down Expand Up @@ -321,7 +323,8 @@
AutomationProperties.Name="More info"
Content="{x:Bind utils:AppUtils.GetHardwareAcceleratorString((models:HardwareAccelerator))}"
Style="{StaticResource TertiaryButtonStyle}"
ToolTipService.ToolTip="More info">
ToolTipService.ToolTip="More info"
Background="{ThemeResource ButtonBackground}">
<Button.Flyout>
<Flyout ShouldConstrainToRootBounds="False">
<TextBlock
Expand Down
12 changes: 7 additions & 5 deletions AIDevGallery/Pages/APIs/APIOverview.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
ItemsSource="{x:Bind wcrAPIs, Mode=OneWay}"
SelectionMode="None">
<ItemsView.Layout>
<UniformGridLayout MinColumnSpacing="12" MinRowSpacing="12" />
<FlowLayout MinColumnSpacing="12" MinRowSpacing="12" />
</ItemsView.Layout>
<ItemsView.ItemTemplate>
<DataTemplate x:DataType="models:ApiDefinition">
Expand All @@ -128,8 +128,8 @@
AutomationProperties.Name="{x:Bind Name}"
CornerRadius="8">
<Grid
Width="260"
Height="186"
MinHeight="186"
MinWidth="260"
Padding="20,6,12,6"
VerticalAlignment="Stretch"
ColumnSpacing="20"
Expand All @@ -139,8 +139,8 @@
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<FontIcon
Margin="0,24,0,8"
Expand All @@ -156,10 +156,12 @@
<TextBlock
Grid.Row="2"
Margin="0,8,0,0"
VerticalAlignment="Top"
VerticalAlignment="Center"
FontWeight="SemiBold"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Text="{x:Bind Description}"
TextTrimming="CharacterEllipsis"
LineStackingStrategy="MaxHeight"
TextWrapping="Wrap" />
</Grid>
</ItemContainer>
Expand Down
31 changes: 27 additions & 4 deletions AIDevGallery/Pages/APIs/APISelectionPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using AIDevGallery.Models;
using AIDevGallery.Samples;
using AIDevGallery.Telemetry.Events;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Navigation;
using System.Collections.Generic;
Expand Down Expand Up @@ -41,6 +42,28 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
};
}

private static string GetContentText(object? content)
{
return content switch
{
string s => s,
TextBlock tb => tb.Text,
_ => string.Empty
};
}

private static TextBlock CreateWrappedText(string text)
{
return new TextBlock
{
Text = text,
TextWrapping = TextWrapping.Wrap,
MaxLines = 3,
TextTrimming = TextTrimming.None,
Margin = new Thickness(0, 0, 8, 0)
};
}

private void SetupAPIs()
{
if (ModelTypeHelpers.ParentMapping.TryGetValue(ModelType.WCRAPIs, out List<ModelType>? innerItems))
Expand All @@ -51,19 +74,19 @@ private void SetupAPIs()
{
if (!string.IsNullOrWhiteSpace(apiDefinition.Category))
{
NavigationViewItem? existingItem = NavView.MenuItems.OfType<NavigationViewItem>().FirstOrDefault(i => i.Content is string name && name == apiDefinition.Category);
NavigationViewItem? existingItem = NavView.MenuItems.OfType<NavigationViewItem>().FirstOrDefault(i => GetContentText(i.Content) == apiDefinition.Category);

if (existingItem == null)
{
existingItem = new NavigationViewItem() { Content = apiDefinition.Category, Icon = new FontIcon() { Glyph = "\uF0E2" }, SelectsOnInvoked = false, IsExpanded = true };
existingItem = new NavigationViewItem() { Content = CreateWrappedText(apiDefinition.Category), Icon = new FontIcon() { Glyph = "\uF0E2" }, SelectsOnInvoked = false, IsExpanded = true };
NavView.MenuItems.Add(existingItem);
}

existingItem.MenuItems.Add(new NavigationViewItem() { Content = apiDefinition.Name, Icon = new FontIcon() { Glyph = apiDefinition.IconGlyph }, Tag = item });
existingItem.MenuItems.Add(new NavigationViewItem() { Content = CreateWrappedText(apiDefinition.Name), Icon = new FontIcon() { Glyph = apiDefinition.IconGlyph }, Tag = item });
}
else
{
NavView.MenuItems.Add(new NavigationViewItem() { Content = apiDefinition.Name, Icon = new FontIcon() { Glyph = apiDefinition.IconGlyph }, Tag = item });
NavView.MenuItems.Add(new NavigationViewItem() { Content = CreateWrappedText(apiDefinition.Name), Icon = new FontIcon() { Glyph = apiDefinition.IconGlyph }, Tag = item });
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion AIDevGallery/Pages/Scenarios/ScenarioPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
x:Name="WinMlModelOptionsButton"
Padding="0"
Visibility="Collapsed"
AutomationProperties.Name="WinMl Model Options Button">
AutomationProperties.Name="WinMl Model Options">
<Button.Flyout>
<Flyout
x:Name="WinMLOptionsFlyout"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
xmlns:shared="using:AIDevGallery.Samples.SharedCode"
mc:Ignorable="d">
<Grid>
<shared:SemanticComboBox x:Name="MySemanticComboBox" Items="{x:Bind ShoppingCategories}"/>
<shared:SemanticComboBox x:Name="MySemanticComboBox"
Items="{x:Bind ShoppingCategories}"
IsTabStop="False"/>
</Grid>
</samples:BaseSamplePage>
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Image
x:Name="DefaultImage"
MaxWidth="800"
MaxHeight="500" />
MaxHeight="500"/>
</Viewbox>
<ProgressRing
x:Name="Loader"
Expand All @@ -41,8 +41,11 @@
<Button
x:Name="UploadButton"
Padding="8"
Margin="4"
AutomationProperties.Name="Select image"
Click="UploadButton_Click"
IsTabStop="True"
UseSystemFocusVisuals="True"
ToolTipService.ToolTip="Select image">

<FontIcon FontSize="16" Glyph="&#xEE71;" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private async Task DetectObjects(string filePath)
UploadButton.Visibility = Visibility.Collapsed;

DefaultImage.Source = new BitmapImage(new Uri(filePath));
NarratorHelper.AnnounceImageChanged(DefaultImage, "Image changed: new upload."); // <exclude-line>
NarratorHelper.AnnounceImageChanged(DefaultImage, "Photo changed: new upload."); // <exclude-line>

Bitmap image = new(filePath);

Expand Down Expand Up @@ -228,7 +228,7 @@ private async Task DetectObjects(string filePath)
UploadButton.Visibility = Visibility.Visible;
});

NarratorHelper.AnnounceImageChanged(DefaultImage, "Image changed: objects detected."); // <exclude-line>
NarratorHelper.AnnounceImageChanged(DefaultImage, "Photo changed: objects detected."); // <exclude-line>
image.Dispose();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<shared:SmartTextBox
x:Name="SmartTextBox"
Text="This is the Smart Text Box control. It exposes generative AI actions through a selection flyout menu. Try it out by highlighting some text to display the menu."
Margin="0,32,0,0"/>
Margin="0,32,0,0"
IsTabStop="False"/>
</Grid>
</samples:BaseSamplePage>
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ private async void LoadButton_Click(object sender, RoutedEventArgs e)

await DescribeTheImage();
}

LoadImageButton.Focus(FocusState.Programmatic);
}

private async void Button_Click(object sender, RoutedEventArgs e)
Expand Down