65.9K
CodeProject 正在变化。 阅读更多。
Home

妈妈的小帮手

starIconstarIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIcon

2.67/5 (2投票s)

2015年3月27日

CPOL

4分钟阅读

viewsIcon

12184

一个用于管理应用程序的应用程序,这些应用程序按功能分类,并优先处理管理家庭所需的任务。该应用程序由Microsoft的Azure云平台进行后端管理、控制和操作。

引言

Mother's Little Helper(MLH)是一个用于管理应用程序的应用程序,这些应用程序按功能分类,并优先处理管理家庭所需的任务。该应用程序通过Microsoft的Azure云平台进行后端管理、控制和操作。

背景

该应用程序的最终目标是简化现有应用程序的交互和使用,以及/或开发新应用程序,这些应用程序通常用于管理家庭,以提高效率和安全性。该应用程序的价值和用户界面的重点是通过Microsoft Cortana的语音识别/交互来管理应用程序。否则,通过触摸完成此管理将非常麻烦。MLH的总体主题是与连接相关的应用程序。此外,MLH利用连接的范例来提高家庭管理的效率。

MLH将利用Microsoft Azure平台记录的操作。通过遥测分析,这些操作将改进应用程序中的计算和建议。MLH还将集成和利用Microsoft应用程序套件提供的技术,包括但不限于Bing.com地图和Outlook的日程安排助手。

MLH的功能将包括;

  • 一个标准的优先级模板,允许MLH与其他应用程序交互,例如;银行、杂货店、药房等。
  • 通过Microsoft Cortana进行语音应用程序交互的能力。
  • 能够安排与事件相关的操作,优先处理事件,并根据地理位置计算行程时间。
  • 更新关于相邻时间段内计划的活动的建议,以提高行程效率。
  • 一项高级服务,可以与Chipolo™等基于连接的商业应用程序进行交互。
  • 能够使用Microsoft Bing地图系统和Outlook日程安排助手日历。
  • 一套适用于Windows和Windows Phone的通用应用程序。
  • 聚合和存储与应用程序界面相关联的操作信息,以提供有用的信息和统计数据仪表板,包括遥测数据,以改进用户的工作流程。具体来说,MLH可以
    • 维护家庭购买商品的库存,以便在商品低于特定水平时提供警报。
    • 当家庭车辆需要维修时发出警报。
      • MLH将监控上述高级应用程序的操作和警报,以提供复杂的遥测数据,确保所有家庭成员的最佳安全。 
  • Chipolo™ - 监控家庭成员的贵重物品,例如玩具、钥匙、衣物。
  • MeterReading™ - 监控家庭的公用事业使用情况并提供警报。
  • FOBO Tire™ - 持续监测家庭车辆的轮胎压力
  • Birdi™ - 持续监测空气质量、一氧化碳和火灾危险。

使用代码

注意:当应用程序加载到全黑屏幕时,按住搜索。Cortana会启动,然后询问“我能说什么?”Cortana会回复一个应用程序列表,我的应用程序就在其中。不幸的是,在开发的这个阶段,该应用程序什么也做不了。至于做任何有趣的事情,与Cortana合作真是太棒了。唯一的问题是,我无法确定我可能做错了什么,因为我将一个真实的Windows手机连接到电脑上,有时代码会起作用,有时则不会。关键在于能够创建与语音识别交互的代码,这真是太棒了。

MainPage.xaml

<Page
  x:Class="_15_03_16_hello_world_blankapp.MainPage"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="using:_15_03_16_hello_world_blankapp"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  mc:Ignorable="d"
  Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

  <Grid>
     
   <!--INITIATE MLH
    SET A REMINDER
    SHOP ONLINE- GROCERY STORE OR PHARMACY 
    ONLINE BANKING  
     FAMILY MEMBER MANAGEMENT 
     INITIATE INTERFACE WITH CONNECTIVY APPS--> 
    <!--<Button x:Name="clickMeButton" Content="Click Me" HorizontalAlignment="Left" Margin="143,147,0,0" VerticalAlignment="Top" Click="clickMeButton_Click"/> -->
    <TextBlock x:Name="resultTextBlock" HorizontalAlignment="Left" 
          Margin="189,324,0,0" 
          TextWrapping="Wrap" 
          VerticalAlignment="Top" 
          FontSize="48" RenderTransformOrigin="0.37,0.497"/>

  </Grid>
</Page>

//
//

MainPage.xaml.cs

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=391641

namespace _15_03_16_hello_world_blankapp
{
  /// <summary>
  /// An empty page that can be used on its own or navigated to within a Frame.
  /// </summary>
  public sealed partial class MainPage : Page
  {
    public MainPage()
    {
      this.InitializeComponent();

      this.NavigationCacheMode = NavigationCacheMode.Required;
    }

    /// <summary>
    /// Invoked when this page is about to be displayed in a Frame.
    /// </summary>
    /// <param name="e">Event data that describes how this page was reached.
    /// This parameter is typically used to configure the page.</param>
    protected override async void OnNavigatedTo(NavigationEventArgs e)
    {
      // TODO: Prepare page for display here.

      // TODO: If your application contains multiple pages, ensure that you are
      // handling the hardware Back button by registering for the
      // Windows.Phone.UI.Input.HardwareButtons.BackPressed event.
      // If you are using the NavigationHelper provided by some templates,
      // this event is handled for you.

      if (e.NavigationMode == NavigationMode.New)
      {
        var storageFile = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync
          (new Uri("ms-appx:///VoiceCom.xml"));

        await Windows.Media.SpeechRecognition.VoiceCommandManager.InstallCommandSetsFromStorageFileAsync(storageFile);
      }

    }
    ////
    //private void clickMeButton_Click(object sender, RoutedEventArgs e)
    //{
    //   resultTextBlock.Text = "V for Villanova...V for Victory!";
    //}
    //

  }
}


//
//

<Application
  x:Class="_15_03_16_hello_world_blankapp.App"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="using:_15_03_16_hello_world_blankapp">

</Application>


//
//


App.xaml.cs

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Animation;
using Windows.UI.Xaml.Navigation;

// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=391641

namespace _15_03_16_hello_world_blankapp
{
  /// <summary>
  /// Provides application-specific behavior to supplement the default Application class.
  /// </summary>
  public sealed partial class App : Application
  {
    private TransitionCollection transitions;

    /// <summary>
    /// Initializes the singleton application object.  This is the first line of authored code
    /// executed, and as such is the logical equivalent of main() or WinMain().
    /// </summary>
    public App()
    {
      this.InitializeComponent();
      this.Suspending += this.OnSuspending;
    }

    /// <summary>
    /// Invoked when the application is launched normally by the end user.  Other entry points
    /// will be used when the application is launched to open a specific file, to display
    /// search results, and so forth.
    /// </summary>
    /// <param name="e">Details about the launch request and process.</param>
     
    protected override void OnActivated(IActivatedEventArgs args)
    {
      if (args.Kind == Windows.ApplicationModel.Activation.ActivationKind.VoiceCommand)
      {
        var commandArgs = args as Windows.ApplicationModel.Activation.VoiceCommandActivatedEventArgs;
        Windows.Media.SpeechRecognition.SpeechRecognitionResult speechRecognitionResult = commandArgs.Result;

        string voiceCommandName = speechRecognitionResult.RulePath[0];
        string textSpoken = speechRecognitionResult.Text;
        string navigationTarget = speechRecognitionResult.SemanticInterpretation.Properties["NavigationTarget"][0];

        switch (voiceCommandName)
        {
          case "EventReminder":
            //EventReminder(textSpoken, navigationTarget);
            break;
          //default:
            // There is no match for the voice command name
        }
      }
    }     
    protected override void OnLaunched(LaunchActivatedEventArgs e)
    {
#if DEBUG
      if (System.Diagnostics.Debugger.IsAttached)
      {
        this.DebugSettings.EnableFrameRateCounter = true;
      }
#endif

      Frame rootFrame = Window.Current.Content as Frame;

      // Do not repeat app initialization when the Window already has content,
      // just ensure that the window is active
      if (rootFrame == null)
      {
        // Create a Frame to act as the navigation context and navigate to the first page
        rootFrame = new Frame();

        // TODO: change this value to a cache size that is appropriate for your application
        rootFrame.CacheSize = 1;

        if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
        {
          // TODO: Load state from previously suspended application
        }

        // Place the frame in the current Window
        Window.Current.Content = rootFrame;
      }

      if (rootFrame.Content == null)
      {
        // Removes the turnstile navigation for startup.
        if (rootFrame.ContentTransitions != null)
        {
          this.transitions = new TransitionCollection();
          foreach (var c in rootFrame.ContentTransitions)
          {
            this.transitions.Add(c);
          }
        }

        rootFrame.ContentTransitions = null;
        rootFrame.Navigated += this.RootFrame_FirstNavigated;

        // When the navigation stack isn't restored navigate to the first page,
        // configuring the new page by passing required information as a navigation
        // parameter
        if (!rootFrame.Navigate(typeof(MainPage), e.Arguments))
        {
          throw new Exception("Failed to create initial page");
        }
      }

      // Ensure the current window is active
      Window.Current.Activate();
    }

    /// <summary>
    /// Restores the content transitions after the app has launched.
    /// </summary>
    /// <param name="sender">The object where the handler is attached.</param>
    /// <param name="e">Details about the navigation event.</param>
    private void RootFrame_FirstNavigated(object sender, NavigationEventArgs e)
    {
      var rootFrame = sender as Frame;
      rootFrame.ContentTransitions = this.transitions ?? new TransitionCollection() { new NavigationThemeTransition() };
      rootFrame.Navigated -= this.RootFrame_FirstNavigated;
    }

    /// <summary>
    /// Invoked when application execution is being suspended.  Application state is saved
    /// without knowing whether the application will be terminated or resumed with the contents
    /// of memory still intact.
    /// </summary>
    /// <param name="sender">The source of the suspend request.</param>
    /// <param name="e">Details about the suspend request.</param>
    private void OnSuspending(object sender, SuspendingEventArgs e)
    {
      var deferral = e.SuspendingOperation.GetDeferral();

      // TODO: Save application state and stop any background activity
      deferral.Complete();
    }
  }
}


//


//

VoiceComm.xml

<?xml version="1.0" encoding="utf-8"?>

<!--VOICE COMMAND CLASS TO START APP-->

<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1">

 <CommandSet xml:lang="en-us" Name="englishCommands">

  <CommandPrefix> Start MLH</CommandPrefix>

  <Example> Start MLH</Example>

  <Command Name="EventReminder">
   <Example>What Event Would You Like Reminder</Example>

   <ListenFor>doctors appointment </ListenFor>
   <ListenFor>meeting </ListenFor>
   <ListenFor>party</ListenFor>

   <Feedback>Sure I will schedule that for you</Feedback>

   <Navigate Target="App.xaml"/>

  </Command>
 </CommandSet>

<!--VOICE COMMAND CLASS TO SET REMINDER -->
 <!--ASK WHAT REMINDER IS-->
 <!--ASK WHAT TIME FOR REMINDER -->
 <!--ASK PLACE - TAKE NAME OF PLACE TO INTEGRATE WITH BING.COM MAPS -->

<!--VOICE COMMAND CLASS TO SHOP AT GROCERY STORE OR PHARMACY-->
 <!--TAKES USER TO EITHER WEBSITE-->
 <!--ASKS USER WHEN THEY WANT TO PICK IT UP-->
 <!--KNOWS PLACE - TAKES NAME OF PLACE TO INTEGRATE WITH BING.COM MAPS-->

<!--VOICE COMMAND CLASS TO TAKE USER TO BANKING APP-->

<!--VOICE COMMAND CLASS TO ASK USER IF THEY WANT TO KEEP TRACK OF MEMBER OF HOUSEHOLD-->
 <!--ASKS USER WHO THEY WANT TO REMEMBER OR IF THEY WANT TO ADD A MEMBER - DEPENDING ON WHETHER PARENT OR CHILD DIFF STEPS-->
 <!--IF CHILD - OPTIONS ARE CHORES, Rx DOSE,HOMEWORK-->
 <!--IF PARENT - OPTIONS ARE CHORES, Rx DOSE-->

<!--VOICE COMMAND CLASS TO ASK USER WHICH CONNECTIVITY APP-->

</VoiceCommands>

关注点

首先,通过开发这个应用程序,我了解了使用云平台创建应用程序的无限可能性。与其它云平台相比,Microsoft Azure云平台的优势在于其丰富的功能。特别是Windows 8和Bing.com地图提供了许多功能,并为我的应用程序提供了出色的交付途径。虽然由于严重的健康挑战我无法编写功能代码,但我对剩余的程序开发有清晰的愿景。

其次,遵循规定的Windows 8指南为我提供了一种高效且连贯的应用程序开发方法。此外,Windows 8指南使得应用程序的未来扩展以及为开发新应用程序提供坚实灵活的基础变得更加容易。

第三,Azure云平台真是太棒了。尽管我接触此类资源的经验仅限于少数几个,但Azure的能力是惊人的。仅通过研究Azure关于如何收集和存储信息以及提供与数据相关的反馈的无限方式的基本要素,Azure平台就为我构思了将来可能不会想到的项目。

第四,也是最后的,我学到的很多东西对我来说都是新颖而陌生的,开始接触所有工具和资源是令人不知所措的。Microsoft提供了清晰的文档以及实时聊天帮助,我觉得这真是太棒了。知道帮助只需轻轻一点即可获得,这使得这个过程尽可能地轻松,毫无疑问,我的信心从未动摇。

这个过程让我成为了Microsoft令人惊叹的资源集合的忠实拥护者。
这些资源和支持是完美的,并简化了我的努力。

历史

- 2015年3月6日 - 插入了项目摘要的第一个正式草稿。

- 2015年3月17日 - 过去两周一直在吸收与理论、实际实现和特定实现相关的海量信息,并尝试开发应用程序的工作版本。

- 2015年3月20日 – 审查了Cortana和Azure的编码功能。还更新和编辑了提交的内容。

© . All rights reserved.