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 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +