private async void NextButton_Clicked(object sender, RoutedEventArgs e)
        {
            var wifiAvailable = networkPresenter.WifiIsAvailable();

            SetPreferences();
            Type nextScreen;

            try
            {
                nextScreen = (await wifiAvailable) ? typeof(OOBENetwork) : typeof(MainPage);
            }
            catch (Exception)
            {
                nextScreen = typeof(MainPage);
            }

            await Window.Current.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                // If the next screen is the main-page, navigate there, but also launch Cortana to its Consent Page independently
                if (nextScreen == typeof(MainPage))
                {
                    await CortanaHelper.LaunchCortanaToConsentPageAsyncIfNeeded();
                }
                NavigationUtils.NavigateToScreen(nextScreen);
            });
        }
Example #2
0
        private async void ConnectToWifi(WiFiAvailableNetwork network, PasswordCredential credential, CoreDispatcher dispatcher)
        {
            var didConnect = credential == null?
                             networkPresenter.ConnectToNetwork(network, Automatic) :
                                 networkPresenter.ConnectToNetworkWithPassword(network, Automatic, credential);

            await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                SwitchToItemState(network, WifiConnectingState, false);
            });

            if (await didConnect)
            {
                await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    CortanaHelper.LaunchCortanaToConsentPageAsyncIfNeeded();
                    NavigationUtils.NavigateToScreen(typeof(MainPage));
                });
            }
            else
            {
                await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    var item        = SwitchToItemState(network, WifiInitialState, false);
                    item.IsSelected = false;
                });
            }
        }
Example #3
0
 private async void NetworkGrid_NetworkConnected(object sender, EventArgs e)
 {
     await OOBENetworkPageDispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
     {
         await CortanaHelper.LaunchCortanaToConsentPageAsyncIfNeeded();
         NavigationUtils.NavigateToScreen(typeof(MainPage));
     });
 }
Example #4
0
        /// <summary>
        /// Check to return appropriate language depending on selection
        /// Item1: Image Exists, Item2:Speech, Item3:App Localization(manifest), Lang Tag
        /// </summary>
        /// <param name="language"></param>
        /// <returns></returns>
        public Tuple <bool, bool, bool, string> CheckUpdateLanguage(string language)
        {
            string currentLang = ApplicationLanguages.PrimaryLanguageOverride;
            string languageTag = GetLanguageTagFromDisplayName(language);
            Tuple <bool, bool, bool, string> langVerify = new Tuple <bool, bool, bool, string>(false, false, false, languageTag);

            List <string> imageLanguagesList = GetImageSupportedLanguages();

            langVerify = Tuple.Create <bool, bool, bool, string>(
                imageLanguagesList.Contains(languageTag),
                CortanaHelper.IsCortanaSupportedLanguage(languageTag),
                displayNameToLanguageMap.Values.Contains(languageTag),
                languageTag);

            if (currentLang != languageTag && Language.IsWellFormed(languageTag))
            {
                //image does not contain or selected lang does not support Speech
                if (!imageLanguagesList.Contains(languageTag) || !(CortanaHelper.IsCortanaSupportedLanguage(languageTag)))
                {
                    //Look for near Lang removing all sugtags
                    var filteredList = imageLanguagesList.Where(x => x.Contains(languageTag.Substring(0, languageTag.IndexOf('-'))));
                    foreach (var item in filteredList)
                    {
                        if (null != item && item.Trim().Length > 0)
                        {
                            //Found matching Language, take preference, continue checking
                            //Change the primary only if primary language not part of imagelist
                            if (!imageLanguagesList.Contains(languageTag))
                            {
                                languageTag = item;
                            }
                            //Set appropriate languageTag if Language as speech
                            if (CortanaHelper.IsCortanaSupportedLanguage(item))
                            {
                                languageTag = item;
                                langVerify  = Tuple.Create <bool, bool, bool, string>(
                                    imageLanguagesList.Contains(languageTag),
                                    CortanaHelper.IsCortanaSupportedLanguage(languageTag),
                                    displayNameToLanguageMap.Values.Contains(languageTag),
                                    languageTag);
                                break;
                            }
                        }
                    }
                }

                langVerify = Tuple.Create <bool, bool, bool, string>(
                    imageLanguagesList.Contains(languageTag),
                    CortanaHelper.IsCortanaSupportedLanguage(languageTag),
                    displayNameToLanguageMap.Values.Contains(languageTag),
                    languageTag);
            }

            return(langVerify);
        }
Example #5
0
        /// <summary>
        /// Returns the Tuple with
        ///     Item1: Image has language resources
        ///     Item2: Speech supported
        ///     Item3: Supports Localization through Manifest
        /// </summary>
        /// <param name="languageTag"></param>
        /// <returns></returns>
        public Tuple <bool, bool, bool> GetLanguageTuple(string languageTag)
        {
            List <string>            imageList  = GetImageSupportedLanguages();
            Tuple <bool, bool, bool> langVerify = new Tuple <bool, bool, bool>(false, false, false);

            langVerify = Tuple.Create <bool, bool, bool>(
                imageList.Contains(languageTag),
                CortanaHelper.IsCortanaSupportedLanguage(languageTag),
                displayNameToLanguageMap.Values.Contains(languageTag));

            return(langVerify);
        }
Example #6
0
        private void CortanaVoiceActivationSwitch_Toggled(object sender, RoutedEventArgs e)
        {
#if BUILDWITHCORTANA
            var cortanaSettings = CortanaSettings.GetDefault();
            var cortanaVoiceActivationSwitch = (ToggleSwitch)sender;

            bool enableVoiceActivation = cortanaVoiceActivationSwitch.IsOn;

            // If user is requesting to turn on voice activation, but consent has not been provided yet, then launch Cortana to ask for consent first
            if (!cortanaSettings.HasUserConsentToVoiceActivation)
            {
                // Guard against the case where the switch is toggled off when Consent hasn't been given yet
                // This occurs when we are re-entering this method when the switch is turned off in the code that follows
                if (!enableVoiceActivation)
                {
                    return;
                }

                // Launch Cortana to get the User Consent.  This is required before a change to enable voice activation is permitted
                CortanaVoiceActivationSwitch.IsEnabled = false;
                needsCortanaConsent = true;
                CortanaVoiceActivationSwitch.IsOn = false;
                cortanaConsentRequestedFromSwitch = true;
                CortanaHelper.LaunchCortanaToConsentPageAsync();
            }
            // Otherwise, we already have consent, so just enable or disable the voice activation setting.
            // Do this asynchronously because the API waits for the SpeechRuntime EXE to launch
            else
            {
                CortanaVoiceActivationSwitch.IsEnabled = false;
                Window.Current.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    cortanaSettings.IsVoiceActivationEnabled = enableVoiceActivation;
                    CortanaVoiceActivationSwitch.IsEnabled   = true;
                });
            }
#endif
        }
Example #7
0
 private void SkipButton_Clicked(object sender, RoutedEventArgs e)
 {
     CortanaHelper.LaunchCortanaToConsentPageAsyncIfNeeded();
     NavigationUtils.NavigateToScreen(typeof(MainPage));
 }