diff --git a/AIDevGallery/Samples/WCRAPIs/AppIndexCapability.xaml.cs b/AIDevGallery/Samples/WCRAPIs/AppIndexCapability.xaml.cs index bd5c2d62..cf8a60dc 100644 --- a/AIDevGallery/Samples/WCRAPIs/AppIndexCapability.xaml.cs +++ b/AIDevGallery/Samples/WCRAPIs/AppIndexCapability.xaml.cs @@ -4,7 +4,7 @@ using AIDevGallery.Models; using AIDevGallery.Samples.Attributes; using Microsoft.UI.Xaml.Navigation; -using Microsoft.Windows.AI.Search.Experimental.AppContentIndex; +using Microsoft.Windows.Search.AppContentIndex; using System; using System.Collections.Generic; using System.Diagnostics; @@ -79,7 +79,7 @@ protected override void OnNavigatedFrom(NavigationEventArgs e) private void CleanUp() { - _indexer?.RemoveAll(); + _indexer?.RemoveAllContentItems(); _indexer?.Dispose(); _indexer = null; } diff --git a/AIDevGallery/Samples/WCRAPIs/KnowledgeRetrieval.xaml.cs b/AIDevGallery/Samples/WCRAPIs/KnowledgeRetrieval.xaml.cs index a3eef942..b564ef51 100644 --- a/AIDevGallery/Samples/WCRAPIs/KnowledgeRetrieval.xaml.cs +++ b/AIDevGallery/Samples/WCRAPIs/KnowledgeRetrieval.xaml.cs @@ -10,7 +10,7 @@ using Microsoft.UI.Xaml.Input; using Microsoft.UI.Xaml.Media; using Microsoft.UI.Xaml.Navigation; -using Microsoft.Windows.AI.Search.Experimental.AppContentIndex; +using Microsoft.Windows.Search.AppContentIndex; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -58,7 +58,7 @@ internal sealed partial class KnowledgeRetrieval : BaseSamplePage // This is some text data that we want to add to the index: private Dictionary simpleTextData = new Dictionary { - { "item1", "Preparing a hearty vegetable stew begins with chopping fresh carrots, onions, and celery. Sauté them in olive oil until fragrant, then add diced tomatoes, herbs, and vegetable broth. Simmer gently for an hour, allowing flavors to meld into a comforting dish perfect for cold evenings." }, + { "item1", "Preparing a hearty vegetable stew begins with chopping fresh carrots, onions, and celery. Saut� them in olive oil until fragrant, then add diced tomatoes, herbs, and vegetable broth. Simmer gently for an hour, allowing flavors to meld into a comforting dish perfect for cold evenings." }, { "item2", "Modern exhibition design combines narrative flow with spatial strategy. Lighting emphasizes focal objects while circulation paths avoid bottlenecks. Materials complement artifacts without visual competition. Interactive elements invite engagement but remain intuitive. Environmental controls protect sensitive works. Success balances scholarship, aesthetics, and visitor experience through thoughtful, cohesive design choices." }, { "item3", "Domestic cats communicate through posture, tail flicks, and vocalizations. Play mimics hunting behaviors like stalking and pouncing, supporting agility and mental stimulation. Scratching maintains claws and marks territory, so provide sturdy posts. Balanced diets, hydration, and routine veterinary care sustain health. Safe retreats and vertical spaces reduce stress and encourage exploration." }, { "item4", "Snowboarding across pristine slopes combines agility, balance, and speed. Riders carve smooth turns on powder, adjust stance for control, and master jumps in terrain parks. Essential gear includes boots, bindings, and helmets for safety. Embrace crisp alpine air while perfecting tricks and enjoying the thrill of winter adventure." }, @@ -148,7 +148,7 @@ private void CleanUp() { CancelResponse(); _model?.Dispose(); - _indexer?.RemoveAll(); + _indexer?.RemoveAllContentItems(); _indexer?.Dispose(); _indexer = null; } @@ -228,9 +228,8 @@ private async Task> BuildContextFromUserPrompt(string queryText) foreach (var match in textMatches) { Debug.WriteLine(match.ContentId); - if (match.ContentKind == QueryMatchContentKind.AppManagedText) + if (match is AppManagedTextQueryMatch textResult) { - AppManagedTextQueryMatch textResult = (AppManagedTextQueryMatch)match; string matchingData = simpleTextData[match.ContentId]; int offset = textResult.TextOffset; int length = textResult.TextLength; @@ -630,7 +629,7 @@ private void RemoveItemFromIndex(string id) } // Remove item from index - _indexer.Remove(id); + _indexer.RemoveContentItem(id); } private void IndexTextData(string id, string value) diff --git a/AIDevGallery/Samples/WCRAPIs/SemanticSearch.xaml.cs b/AIDevGallery/Samples/WCRAPIs/SemanticSearch.xaml.cs index ebc6be47..d1b1ab11 100644 --- a/AIDevGallery/Samples/WCRAPIs/SemanticSearch.xaml.cs +++ b/AIDevGallery/Samples/WCRAPIs/SemanticSearch.xaml.cs @@ -8,7 +8,7 @@ using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Media.Imaging; using Microsoft.UI.Xaml.Navigation; -using Microsoft.Windows.AI.Search.Experimental.AppContentIndex; +using Microsoft.Windows.Search.AppContentIndex; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -48,7 +48,7 @@ internal sealed partial class SemanticSearch : BaseSamplePage // This is some text data that we want to add to the index: private Dictionary simpleTextData = new Dictionary { - { "item1", "Preparing a hearty vegetable stew begins with chopping fresh carrots, onions, and celery. Sauté them in olive oil until fragrant, then add diced tomatoes, herbs, and vegetable broth. Simmer gently for an hour, allowing flavors to meld into a comforting dish perfect for cold evenings." }, + { "item1", "Preparing a hearty vegetable stew begins with chopping fresh carrots, onions, and celery. Saut� them in olive oil until fragrant, then add diced tomatoes, herbs, and vegetable broth. Simmer gently for an hour, allowing flavors to meld into a comforting dish perfect for cold evenings." }, { "item2", "Modern exhibition design combines narrative flow with spatial strategy. Lighting emphasizes focal objects while circulation paths avoid bottlenecks. Materials complement artifacts without visual competition. Interactive elements invite engagement but remain intuitive. Environmental controls protect sensitive works. Success balances scholarship, aesthetics, and visitor experience through thoughtful, cohesive design choices." }, { "item3", "Domestic cats communicate through posture, tail flicks, and vocalizations. Play mimics hunting behaviors like stalking and pouncing, supporting agility and mental stimulation. Scratching maintains claws and marks territory, so provide sturdy posts. Balanced diets, hydration, and routine veterinary care sustain health. Safe retreats and vertical spaces reduce stress and encourage exploration." }, { "item4", "Snowboarding across pristine slopes combines agility, balance, and speed. Riders carve smooth turns on powder, adjust stance for control, and master jumps in terrain parks. Essential gear includes boots, bindings, and helmets for safety. Embrace crisp alpine air while perfecting tricks and enjoying the thrill of winter adventure." }, @@ -127,7 +127,7 @@ protected override void OnNavigatedFrom(NavigationEventArgs e) private void CleanUp() { - _indexer?.RemoveAll(); + _indexer?.RemoveAllContentItems(); _indexer?.Dispose(); _indexer = null; } @@ -271,15 +271,18 @@ private void SearchBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuery foreach (var match in textMatches) { Debug.WriteLine(match.ContentId); - if (match.ContentKind == QueryMatchContentKind.AppManagedText) + if (match is AppManagedTextQueryMatch textResult) { - AppManagedTextQueryMatch textResult = (AppManagedTextQueryMatch)match; string matchingData = simpleTextData[match.ContentId]; int offset = textResult.TextOffset; int length = textResult.TextLength; string matchingString = matchingData.Substring(offset, length); textResults += matchingString + "\n\n"; } + else if (match is AppManagedOcrTextQueryMatch ocrMatch) + { + textResults += ocrMatch.OcrText + "\n\n"; + } } // Create text query @@ -291,10 +294,8 @@ private void SearchBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuery foreach (var match in imageMatches) { Debug.WriteLine(match.ContentId); - if (match.ContentKind == QueryMatchContentKind.AppManagedImage) + if (match is AppManagedImageQueryMatch imageResult) { - AppManagedImageQueryMatch imageResult = (AppManagedImageQueryMatch)match; - if (simpleImageData.TryGetValue(imageResult.ContentId, out var imagePath)) { imageResults.Add(imagePath); @@ -467,7 +468,7 @@ private void RemoveItemFromIndex(string id) } // Remove item from index - _indexer.Remove(id); + _indexer.RemoveContentItem(id); } private void IndexTextData(string id, string value)