示例#1
0
        protected override async void OnActivated(IActivatedEventArgs args)
        {
            // Was the app activated by a voice command?
            if (args.Kind == ActivationKind.VoiceCommand)
            {
                // Need to put this here to make sure the main page is displayed.
                Frame rootFrame = Window.Current.Content as Frame;
                if (rootFrame == null)
                {
                    rootFrame              = new Frame();
                    rootFrame.CacheSize    = 1;
                    Window.Current.Content = rootFrame;
                    rootFrame.Navigate(typeof(MainPage));
                }
                Window.Current.Activate();

                var commandArgs = args as VoiceCommandActivatedEventArgs;
                if (commandArgs != null)
                {
                    Windows.Media.SpeechRecognition.SpeechRecognitionResult speechRecognitionResult = commandArgs.Result;

                    // What command was issued?
                    string voiceCommandName = speechRecognitionResult.RulePath[0];

                    if (voiceCommandName == "ShowMeAll")
                    {
                        // TODO - find a better way to access the list name from the phrase list.
                        // Get the name of the list the user wants.
                        string textSpoken = speechRecognitionResult.Text;
                        string listName   = textSpoken.Substring(textSpoken.LastIndexOf(" ", StringComparison.Ordinal)).Trim();

                        // Pull back the list items and display them on the UI
                        // TODO - need a better way to update the Main Page than this.
                        var announcements = await SharePoint.GetListItems(listName);

                        await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => MainPage.Instance.UpdateListView(announcements));
                    }
                }
            }
        }
示例#2
0
        private async void GetListItems_OnClick(object sender, RoutedEventArgs e)
        {
            var announcements = await SharePoint.GetListItems("Announcements");

            UpdateListView(announcements);
        }