From 23628f4875b5fb002cc8728d0fd390bae700da17 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Jun 2025 04:28:05 +0000 Subject: [PATCH 1/3] Initial plan for issue From 3bce9987b59035439f32924f1372f8092b758ae4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Jun 2025 04:31:29 +0000 Subject: [PATCH 2/3] Initial analysis: VoiceAccessUserControl files do not exist, planning to create them Co-authored-by: t-pbadoni_microsoft <209624198+t-pbadoni_microsoft@users.noreply.github.com> --- .../web/winhttp/WinhttpProxySample/BasicProxyMain.cpp | 4 ++-- .../cpp/FSRM_Get_Enum_Properties.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Samples/Win7Samples/web/winhttp/WinhttpProxySample/BasicProxyMain.cpp b/Samples/Win7Samples/web/winhttp/WinhttpProxySample/BasicProxyMain.cpp index 97fd24a4c..c1d118aba 100644 --- a/Samples/Win7Samples/web/winhttp/WinhttpProxySample/BasicProxyMain.cpp +++ b/Samples/Win7Samples/web/winhttp/WinhttpProxySample/BasicProxyMain.cpp @@ -272,7 +272,7 @@ Return Value: --*/ -{ +{ DWORD dwError = ERROR_SUCCESS; DWORD cbHost = 0; DWORD cbPath = 0; @@ -502,7 +502,7 @@ wmain( if (pProxyResolver != NULL) { delete pProxyResolver; - pProxyResolver = NULL; + pProxyResolver = NULL; } if (pwszHost != NULL) diff --git a/Samples/Win7Samples/winbase/FSRM/EnumClassificationProperties/cpp/FSRM_Get_Enum_Properties.cpp b/Samples/Win7Samples/winbase/FSRM/EnumClassificationProperties/cpp/FSRM_Get_Enum_Properties.cpp index da04f2474..2367f6298 100644 --- a/Samples/Win7Samples/winbase/FSRM/EnumClassificationProperties/cpp/FSRM_Get_Enum_Properties.cpp +++ b/Samples/Win7Samples/winbase/FSRM/EnumClassificationProperties/cpp/FSRM_Get_Enum_Properties.cpp @@ -222,7 +222,7 @@ HRESULT DisplayPropertyDefinition( return hr; } - + /*++ Routine EnumerateProperties From 79016ab5fb127c1d5f2fdb169178547849dce59a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Jun 2025 04:37:48 +0000 Subject: [PATCH 3/3] Implement VoiceAccessUserControl with mode display functionality Co-authored-by: t-pbadoni_microsoft <209624198+t-pbadoni_microsoft@users.noreply.github.com> --- .../voiceaccess/VoiceAccessUserControl.cpp | 209 ++++++++++++++++++ .../voiceaccess/VoiceAccessUserControl.xaml | 88 ++++++++ .../winui/speech/cs/voiceaccess/App.cs | 28 +++ .../winui/speech/cs/voiceaccess/README.md | 113 ++++++++++ .../winui/speech/cs/voiceaccess/Test.cs | 131 +++++++++++ .../speech/cs/voiceaccess/VoiceAccess.csproj | 72 ++++++ .../speech/cs/voiceaccess/VoiceAccess.sln | 24 ++ .../voiceaccess/VoiceAccessUserControl.xaml | 88 ++++++++ .../VoiceAccessUserControl.xaml.cs | 182 +++++++++++++++ .../cs/voiceaccess/VoiceAccessWindow.xaml | 15 ++ .../cs/voiceaccess/VoiceAccessWindow.xaml.cs | 23 ++ 11 files changed, 973 insertions(+) create mode 100644 Samples/Win7Samples/winui/speech/cpp/voiceaccess/VoiceAccessUserControl.cpp create mode 100644 Samples/Win7Samples/winui/speech/cpp/voiceaccess/VoiceAccessUserControl.xaml create mode 100644 Samples/Win7Samples/winui/speech/cs/voiceaccess/App.cs create mode 100644 Samples/Win7Samples/winui/speech/cs/voiceaccess/README.md create mode 100644 Samples/Win7Samples/winui/speech/cs/voiceaccess/Test.cs create mode 100644 Samples/Win7Samples/winui/speech/cs/voiceaccess/VoiceAccess.csproj create mode 100644 Samples/Win7Samples/winui/speech/cs/voiceaccess/VoiceAccess.sln create mode 100644 Samples/Win7Samples/winui/speech/cs/voiceaccess/VoiceAccessUserControl.xaml create mode 100644 Samples/Win7Samples/winui/speech/cs/voiceaccess/VoiceAccessUserControl.xaml.cs create mode 100644 Samples/Win7Samples/winui/speech/cs/voiceaccess/VoiceAccessWindow.xaml create mode 100644 Samples/Win7Samples/winui/speech/cs/voiceaccess/VoiceAccessWindow.xaml.cs diff --git a/Samples/Win7Samples/winui/speech/cpp/voiceaccess/VoiceAccessUserControl.cpp b/Samples/Win7Samples/winui/speech/cpp/voiceaccess/VoiceAccessUserControl.cpp new file mode 100644 index 000000000..4c51c994d --- /dev/null +++ b/Samples/Win7Samples/winui/speech/cpp/voiceaccess/VoiceAccessUserControl.cpp @@ -0,0 +1,209 @@ +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright © Microsoft Corporation. All rights reserved + +#pragma once + +#using +#using +#using +#using +#using + +using namespace System; +using namespace System::ComponentModel; +using namespace System::Windows; +using namespace System::Windows::Controls; + +namespace Microsoft { namespace Samples { namespace Speech { namespace VoiceAccess { + + /// + /// Voice Access User Control implementation in C++/CLI + /// Displays current mode (Translator/Recognizer) based on m_useTranslatorConfig flag + /// + public ref class VoiceAccessUserControl : UserControl, INotifyPropertyChanged + { + private: + /// + /// Flag to determine if translator mode is active + /// true = Translator Mode, false = Recognizer Mode + /// + bool m_useTranslatorConfig; + + /// + /// Property for the mode text displayed in the UI + /// + String^ m_modeText; + + /// + /// UI Elements + /// + TextBlock^ ModeTextBlock; + TextBlock^ StatusTextBlock; + Button^ ToggleModeButton; + Button^ StartButton; + Button^ StopButton; + + public: + /// + /// Default constructor + /// + VoiceAccessUserControl() + { + m_useTranslatorConfig = false; + m_modeText = ""; + + InitializeComponent(); + DataContext = this; + + // Initialize with default mode + UpdateModeText(); + UpdateStatus("Voice Access Control initialized."); + } + + /// + /// Gets the current mode text + /// + property String^ ModeText + { + String^ get() { return m_modeText; } + private: void set(String^ value) + { + if (m_modeText != value) + { + m_modeText = value; + OnPropertyChanged("ModeText"); + } + } + } + + /// + /// Gets or sets the translator configuration flag + /// + property bool UseTranslatorConfig + { + bool get() { return m_useTranslatorConfig; } + void set(bool value) + { + if (m_useTranslatorConfig != value) + { + m_useTranslatorConfig = value; + UpdateModeText(); + OnPropertyChanged("UseTranslatorConfig"); + } + } + } + + /// + /// Property changed event for data binding + /// + virtual event PropertyChangedEventHandler^ PropertyChanged; + + private: + /// + /// Initialize the user control components + /// + void InitializeComponent() + { + // Load XAML content + String^ xamlUri = "pack://application:,,,/VoiceAccessUserControl.xaml"; + System::Uri^ uri = gcnew System::Uri(xamlUri, System::UriKind::Absolute); + System::Windows::Application::LoadComponent(this, uri); + + // Get references to named elements + ModeTextBlock = safe_cast(FindName("ModeTextBlock")); + StatusTextBlock = safe_cast(FindName("StatusTextBlock")); + ToggleModeButton = safe_cast(FindName("ToggleModeButton")); + StartButton = safe_cast(FindName("StartButton")); + StopButton = safe_cast(FindName("StopButton")); + + // Wire up event handlers + if (ToggleModeButton != nullptr) + ToggleModeButton->Click += gcnew RoutedEventHandler(this, &VoiceAccessUserControl::ToggleModeButton_Click); + if (StartButton != nullptr) + StartButton->Click += gcnew RoutedEventHandler(this, &VoiceAccessUserControl::StartButton_Click); + if (StopButton != nullptr) + StopButton->Click += gcnew RoutedEventHandler(this, &VoiceAccessUserControl::StopButton_Click); + } + + /// + /// Updates the mode text based on the current configuration + /// + void UpdateModeText() + { + ModeText = m_useTranslatorConfig ? "Translator Mode" : "Recognizer Mode"; + } + + /// + /// Updates the status text display + /// + /// Status message to display + void UpdateStatus(String^ message) + { + if (StatusTextBlock != nullptr) + { + DateTime now = DateTime::Now; + StatusTextBlock->Text = String::Format("[{0:HH:mm:ss}] {1}", now, message); + } + } + + /// + /// Raises the PropertyChanged event + /// + /// Name of the property that changed + void OnPropertyChanged(String^ propertyName) + { + PropertyChangedEventArgs^ args = gcnew PropertyChangedEventArgs(propertyName); + PropertyChanged(this, args); + } + + /// + /// Toggle mode button click handler + /// + void ToggleModeButton_Click(Object^ sender, RoutedEventArgs^ e) + { + UseTranslatorConfig = !UseTranslatorConfig; + UpdateStatus(String::Format("Mode changed to: {0}", ModeText)); + } + + /// + /// Start button click handler + /// + void StartButton_Click(Object^ sender, RoutedEventArgs^ e) + { + UpdateStatus(String::Format("Starting {0}...", ModeText)); + + // Simulate starting the appropriate service + if (m_useTranslatorConfig) + { + UpdateStatus("Translator service started. Ready to translate speech."); + } + else + { + UpdateStatus("Speech recognizer started. Ready to recognize speech."); + } + } + + /// + /// Stop button click handler + /// + void StopButton_Click(Object^ sender, RoutedEventArgs^ e) + { + UpdateStatus(String::Format("Stopping {0}...", ModeText)); + + // Simulate stopping the service + if (m_useTranslatorConfig) + { + UpdateStatus("Translator service stopped."); + } + else + { + UpdateStatus("Speech recognizer stopped."); + } + } + }; + +}}}} // namespace Microsoft::Samples::Speech::VoiceAccess \ No newline at end of file diff --git a/Samples/Win7Samples/winui/speech/cpp/voiceaccess/VoiceAccessUserControl.xaml b/Samples/Win7Samples/winui/speech/cpp/voiceaccess/VoiceAccessUserControl.xaml new file mode 100644 index 000000000..05060f835 --- /dev/null +++ b/Samples/Win7Samples/winui/speech/cpp/voiceaccess/VoiceAccessUserControl.xaml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +