From 62adbcb8d7be53bf2da39ad497bb036fa2a567e1 Mon Sep 17 00:00:00 2001 From: Xing Zhou Date: Thu, 24 Nov 2016 16:01:30 +0800 Subject: [PATCH] Add support to Mooncake I add Radio buttons to let users to choose if they are working with Global Azure or Mooncake. By default the Global Azure option is checked. And the Add AzureEnvironment varible to differentiate it. This variable will be used when creating service client since the service endpoints are different from Global Azure and Mooncake. --- .../SampleUserControl.xaml.cs | 6 ++++ .../SubscriptionKeyPage.xaml | 5 ++++ .../SubscriptionKeyPage.xaml.cs | 29 +++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/SampleUserControlLibrary/SampleUserControl.xaml.cs b/SampleUserControlLibrary/SampleUserControl.xaml.cs index 15a8e4c..f580b73 100644 --- a/SampleUserControlLibrary/SampleUserControl.xaml.cs +++ b/SampleUserControlLibrary/SampleUserControl.xaml.cs @@ -98,6 +98,12 @@ public string SubscriptionKey set; } + public string AzureEnvironment + { + get; + set; + } + public SampleScenarios() { InitializeComponent(); diff --git a/SampleUserControlLibrary/SubscriptionKeyPage.xaml b/SampleUserControlLibrary/SubscriptionKeyPage.xaml index ff16284..d7f815a 100644 --- a/SampleUserControlLibrary/SubscriptionKeyPage.xaml +++ b/SampleUserControlLibrary/SubscriptionKeyPage.xaml @@ -39,6 +39,11 @@ + + + Global Azure + Mooncake - China Azure + diff --git a/SampleUserControlLibrary/SubscriptionKeyPage.xaml.cs b/SampleUserControlLibrary/SubscriptionKeyPage.xaml.cs index 5ed6eb5..cabd12e 100644 --- a/SampleUserControlLibrary/SubscriptionKeyPage.xaml.cs +++ b/SampleUserControlLibrary/SubscriptionKeyPage.xaml.cs @@ -49,6 +49,7 @@ public partial class SubscriptionKeyPage : Page, INotifyPropertyChanged private readonly string _defaultSubscriptionKeyPromptMessage = "Paste your subscription key here to start"; private static string s_subscriptionKey; + private static string s_environment; private SampleScenarios _sampleScenarios; public SubscriptionKeyPage(SampleScenarios sampleScenarios) @@ -78,6 +79,23 @@ public string SubscriptionKey } } + /// + /// Get or sets Azure Environment + /// + public string AzureEnvironment + { + get + { + return s_environment; + } + + set + { + s_environment = value; + _sampleScenarios.AzureEnvironment = s_environment; + } + } + /// /// Implement INotifyPropertyChanged interface /// @@ -186,5 +204,16 @@ private void GetKeyButton_Click(object sender, RoutedEventArgs e) { System.Diagnostics.Process.Start("https://www.microsoft.com/cognitive-services/en-us/sign-up"); } + + private void RadioButton_Checked(object sender, RoutedEventArgs e) + { + var button = sender as RadioButton; + + if (button.Content != null) + { + // s_environment = button.Content.ToString().ToLower(); + AzureEnvironment = button.Content.ToString().ToLower(); + } + } } }