diff --git a/AIDevGallery/Controls/Card.xaml b/AIDevGallery/Controls/Card.xaml index b33e6669..42d1b7d2 100644 --- a/AIDevGallery/Controls/Card.xaml +++ b/AIDevGallery/Controls/Card.xaml @@ -48,6 +48,7 @@ VerticalAlignment="Center" FontSize="14" FontWeight="SemiBold" + AutomationProperties.Level="1" Text="{x:Bind Title, Mode=OneWay}" /> - + @@ -92,9 +92,9 @@ Orientation="Horizontal" Visibility="Visible"> diff --git a/AIDevGallery/MainWindow.xaml b/AIDevGallery/MainWindow.xaml index d0bcb242..25e269c0 100644 --- a/AIDevGallery/MainWindow.xaml +++ b/AIDevGallery/MainWindow.xaml @@ -19,7 +19,7 @@ - + diff --git a/AIDevGallery/MainWindow.xaml.cs b/AIDevGallery/MainWindow.xaml.cs index 9b8c2e8f..d913160b 100644 --- a/AIDevGallery/MainWindow.xaml.cs +++ b/AIDevGallery/MainWindow.xaml.cs @@ -1,7 +1,8 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. using AIDevGallery.Controls; +using AIDevGallery.Controls.ModelPickerViews; using AIDevGallery.Helpers; using AIDevGallery.Models; using AIDevGallery.Pages; @@ -20,6 +21,7 @@ using System.Threading; using System.Threading.Tasks; using Windows.System; +using Windows.UI.ViewManagement; using WinUIEx; namespace AIDevGallery; @@ -29,6 +31,7 @@ internal sealed partial class MainWindow : WindowEx private AppContentIndexer? _indexer; private CancellationTokenSource? _searchCts; // Added for search cancellation public ModelOrApiPicker ModelPicker => modelOrApiPicker; + private UISettings uiSettings; public MainWindow(object? obj = null) { @@ -62,6 +65,13 @@ public MainWindow(object? obj = null) } App.AppData.PropertyChanged += AppData_PropertyChanged; + uiSettings = new UISettings(); + } + + private void MainWindow_Loaded(object? sender, RoutedEventArgs e) + { + uiSettings.ColorValuesChanged += Accessibility_HighContrastChanged; + UpdateResources(); } private async Task LoadAppSearchIndex() @@ -452,4 +462,33 @@ public static void IndexAppSearchIndexStatic() var mainWindow = (MainWindow)App.MainWindow; mainWindow?.IndexContentsWithAppContentSearch(); } + + private void Accessibility_HighContrastChanged(object sender, object e) + { + UpdateResources(); + } + + private void UpdateResources() + { + var dispatcherQueue = this.DispatcherQueue; + dispatcherQueue.TryEnqueue(() => + { + var appResources = Application.Current.Resources; + + if (appResources["GitHubIconImage"] is Microsoft.UI.Xaml.Media.Imaging.SvgImageSource svg) + { + svg.UriSource = new Uri($"ms-appx:///Assets/ModelIcons/GitHub{AppUtils.GetThemeAssetSuffix()}.svg"); + } + else + { + appResources["GitHubIconImage"] = + new Microsoft.UI.Xaml.Media.Imaging.SvgImageSource( + new Uri($"ms-appx:///Assets/ModelIcons/GitHub{AppUtils.GetThemeAssetSuffix()}.svg")); + } + + ModelPickerDefinition.Definitions["onnx"].Icon = $"ms-appx:///Assets/ModelIcons/CustomModel{AppUtils.GetThemeAssetSuffix()}.png"; + ModelPickerDefinition.Definitions["ollama"].Icon = $"ms-appx:///Assets/ModelIcons/Ollama{AppUtils.GetThemeAssetSuffix()}.png"; + ModelPickerDefinition.Definitions["openai"].Icon = $"ms-appx:///Assets/ModelIcons/OpenAI{AppUtils.GetThemeAssetSuffix()}.png"; + }); + } } \ No newline at end of file diff --git a/AIDevGallery/Pages/APIs/APIPage.xaml b/AIDevGallery/Pages/APIs/APIPage.xaml index 664ec8cb..6ce2c751 100644 --- a/AIDevGallery/Pages/APIs/APIPage.xaml +++ b/AIDevGallery/Pages/APIs/APIPage.xaml @@ -155,45 +155,6 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/AIDevGallery/Pages/HomePage.xaml b/AIDevGallery/Pages/HomePage.xaml index 584dfad4..6f9eed24 100644 --- a/AIDevGallery/Pages/HomePage.xaml +++ b/AIDevGallery/Pages/HomePage.xaml @@ -47,7 +47,8 @@ - + - + Value="0" + AutomationProperties.Name="{x:Bind GetAutomationName(MinLengthSlider.Name, MinLengthSlider.Value), Mode=OneWay}" /> + Value="{x:Bind defaultMaxLength, Mode=OneTime}" + AutomationProperties.Name="{x:Bind GetAutomationName(MaxLengthSlider.Name, MaxLengthSlider.Value), Mode=OneWay}" /> + Value="{x:Bind defaultTopP, Mode=OneTime}" + AutomationProperties.Name="{x:Bind GetAutomationName(TopPSlider.Name, TopPSlider.Value), Mode=OneWay}" /> + Value="{x:Bind defaultTopK, Mode=OneTime}" + AutomationProperties.Name="{x:Bind GetAutomationName(TopKSlider.Name, TopKSlider.Value), Mode=OneWay}" /> + Value="{x:Bind defaultTemperature, Mode=OneTime}" + AutomationProperties.Name="{x:Bind GetAutomationName(TemperatureSlider.Name, TemperatureSlider.Value), Mode=OneWay}" /> diff --git a/AIDevGallery/Samples/Open Source Models/Language Models/CustomSystemPrompt.xaml.cs b/AIDevGallery/Samples/Open Source Models/Language Models/CustomSystemPrompt.xaml.cs index d2a7eb42..96ac2829 100644 --- a/AIDevGallery/Samples/Open Source Models/Language Models/CustomSystemPrompt.xaml.cs +++ b/AIDevGallery/Samples/Open Source Models/Language Models/CustomSystemPrompt.xaml.cs @@ -136,6 +136,8 @@ private void CleanUp() chatClient?.Dispose(); } + public string GetAutomationName(string name, double value) => $"{name} {value:F0}"; + public ChatOptions GetDefaultChatOptions(IChatClient? chatClient) { var chatOptions = chatClient?.GetService();