Ejemplo n.º 1
0
        private void SetCPUInfo()
        {
            string cpuinfoTem = "CPU:{0}%  内存:{1}%";
            string cpuinfo    = string.Format(cpuinfoTem, string.Format("{0:F}", performanceUtils.CPUPercent), string.Format("{0:F}", performanceUtils.MemoryPercent));

            CortanaHelper.SetCortanaText(cpuinfo);
        }
Ejemplo n.º 2
0
        protected async override void OnActivated(IActivatedEventArgs args)
        {
            base.OnActivated(args);
            if (Window.Current.Content == null)
            {
                await LaunchTheApp();
            }

            switch (args.Kind)
            {
            case ActivationKind.Protocol:
                await HandleProtocolActivation(args);

                break;

            case ActivationKind.VoiceCommand:
                await CortanaHelper.HandleProtocolActivation(args);

                break;

            case ActivationKind.ToastNotification:
                ToastHelper.HandleProtocolActivation(args);
                break;
            }
        }
Ejemplo n.º 3
0
        async Task PerformMediaLibraryIndexing()
        {
            await DispatchHelper.InvokeAsync(CoreDispatcherPriority.Low, () => MediaLibraryIndexingState = LoadingState.Loading);

            StorageFolder folder = await FileUtils.GetLocalStorageMediaFolder();

            await MediaLibraryHelper.ForeachSupportedFile(folder, async (IReadOnlyList <StorageFile> files) => await DiscoverMediaItems(files));

            await MediaLibraryHelper.ForeachSupportedFile(KnownFolders.VideosLibrary, async (IReadOnlyList <StorageFile> files) => await DiscoverMediaItems(files));

            await MediaLibraryHelper.ForeachSupportedFile(KnownFolders.MusicLibrary, async (IReadOnlyList <StorageFile> files) => await DiscoverMediaItems(files));

            await MediaLibraryHelper.ForeachSupportedFile(KnownFolders.CameraRoll, async (IReadOnlyList <StorageFile> files) => await DiscoverMediaItems(files, true));

            // Cortana gets all those artists, albums, songs names
            var artists = LoadArtists(null);

            if (artists != null)
            {
                await CortanaHelper.SetPhraseList("artistName", artists.Where(x => !string.IsNullOrEmpty(x.Name)).Select(x => x.Name).ToList());
            }

            var albums = LoadAlbums(null);

            if (albums != null)
            {
                await CortanaHelper.SetPhraseList("albumName", albums.Where(x => !string.IsNullOrEmpty(x.Name)).Select(x => x.Name).ToList());
            }

            await DispatchHelper.InvokeAsync(CoreDispatcherPriority.Low, () => MediaLibraryIndexingState = LoadingState.Loaded);
        }
Ejemplo n.º 4
0
        private string SetMusicInfo()
        {
            string musicinfo = musicUtils.GetMusicName();

            CortanaHelper.SetCortanaText(musicinfo);
            return(musicinfo);
        }
Ejemplo n.º 5
0
        private void SetNetworkInfo()
        {
            string netinfoTem = "上传:{0}  下载:{1}";
            string netinfo    = string.Format(netinfoTem, networkUtils.GetUploadSpeed(), networkUtils.GetDownloadSpeed());

            CortanaHelper.SetCortanaText(netinfo);
        }
Ejemplo n.º 6
0
 private async void SplashComplete(IEnumerable <string> cs)
 {
     if (timer != null)
     {
         timer.Cancel();
     }
     var task = ThreadPool.RunAsync(async(w) =>
     {
         await CortanaHelper.EditPhraseListAsync("AuroraWeatherCommandSet_zh-cn", "where", cs.ToArray());
     });
     await Dispatcher.RunAsync(CoreDispatcherPriority.High, new DispatchedHandler(() =>
     {
         DismissExtendedSplash();
     }));
 }
Ejemplo n.º 7
0
        protected override async void OnActivated(IActivatedEventArgs args)
        {
            base.OnActivated(args);

            await DataService.Instance.LoadAsync();

            string user = CortanaHelper.GetRequestedContact(args as VoiceCommandActivatedEventArgs);

            if (DataService.Instance.Contacts != null)
            {
                var contact = DataService.Instance.Contacts.Where(c => c.Name == user).FirstOrDefault();
                if (contact != null)
                {
                    Frame frame = new Frame();
                    frame.Content          = new ContactDetailPage(contact);
                    Window.Current.Content = frame;
                    Window.Current.Activate();
                }
            }
        }
Ejemplo n.º 8
0
        void CheckCortana()
        {
            var isCortanaSupported = CortanaHelper.IsCortanaSupported();

            var cortanaVoiceActivationSwitch = SwitchCotana;

            cortanaVoiceActivationSwitch.IsEnabled = isCortanaSupported;

            // If Cortana is supported on this device and the user has never granted voice consent,
            // then set a flag so that each time this page is activated we will poll for
            // Cortana's Global Consent Value and update the UI if needed.
            if (isCortanaSupported)
            {
                var  cortanaSettings     = CortanaSettings.GetDefault();
                bool needsCortanaConsent = !cortanaSettings.HasUserConsentToVoiceActivation;

                // If consent isn't needed, then update the voice activation switch to reflect its current system state.
                if (!needsCortanaConsent)
                {
                    cortanaVoiceActivationSwitch.IsChecked = cortanaSettings.IsVoiceActivationEnabled;
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
            await DataService.Instance.LoadAsync();

            // generate live tiles
            TileHelper.GenerateSceduledTileNotifications(DataService.Instance.Contacts, 3);

            // update cortana voice command file
            CortanaHelper.WriteAndUpdateVoiceCommandDefinition(DataService.Instance.Contacts);

            // Load app via secondary tile
            if (e.TileId != "App")
            {
                foreach (var item in DataService.Instance.Contacts)
                {
                    if (e.TileId == item.Id)
                    {
                        Window.Current.Content = new ContactDetailPage(item);
                        Window.Current.Activate();
                        return;
                    }
                }
            }

            var rootHost = new RootHost();

            Window.Current.Content = rootHost;

            if (await TileHelper.UpdateUnpinnedSecondaryTilesInContacts(DataService.Instance.Contacts))
            {
                // update model consistency
                await DataService.Instance.SaveAsync();
            }

            Window.Current.Activate();
        }
Ejemplo n.º 10
0
        protected override async Task <DialogTurnResult> OnContinueDialogAsync(DialogContext innerDc, CancellationToken cancellationToken = default(CancellationToken))
        {
            var activity = innerDc.Context.Activity;

            if (CortanaHelper.IsLaunchActivity(activity) && string.IsNullOrEmpty(activity.Text))
            {
                await OnStartAsync(innerDc);

                return(EndOfTurn);
            }

            switch (activity.Type)
            {
            case ActivityTypes.Message:
            {
                var result = await innerDc.ContinueDialogAsync();

                switch (result.Status)
                {
                case DialogTurnStatus.Empty:
                {
                    await RouteAsync(innerDc);

                    break;
                }

                case DialogTurnStatus.Complete:
                {
                    await CompleteAsync(innerDc);

                    // End active dialog
                    await innerDc.EndDialogAsync();

                    break;
                }

                default:
                {
                    break;
                }
                }

                break;
            }

            case ActivityTypes.Event:
            {
                await OnEventAsync(innerDc);

                break;
            }

            case ActivityTypes.ConversationUpdate:
            {
                if (activity.From.Id != "default-user")
                {
                    await OnStartAsync(innerDc);
                }
                break;
            }

            default:
            {
                await OnSystemMessageAsync(innerDc);

                break;
            }
            }

            return(EndOfTurn);
        }
Ejemplo n.º 11
0
 protected override void OnClosed(EventArgs e)
 {
     CortanaHelper.RestoreCortanaText();
     base.OnClosed(e);
 }