2 * Copyright (C) 2013 FooProject
\r
3 * * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
\r
4 * the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
\r
6 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
7 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
\r
9 You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
12 using System.Collections.Generic;
\r
15 using Windows.ApplicationModel;
\r
16 using Windows.ApplicationModel.Activation;
\r
17 using Windows.Foundation;
\r
18 using Windows.Foundation.Collections;
\r
19 using Windows.UI.Xaml;
\r
20 using Windows.UI.Xaml.Controls;
\r
21 using Windows.UI.Xaml.Controls.Primitives;
\r
22 using Windows.UI.Xaml.Data;
\r
23 using Windows.UI.Xaml.Input;
\r
24 using Windows.UI.Xaml.Media;
\r
25 using Windows.UI.Xaml.Navigation;
\r
26 using Windows.UI.ApplicationSettings;
\r
27 using Windows.UI.Popups;
\r
29 // 空のアプリケーション テンプレートについては、http://go.microsoft.com/fwlink/?LinkId=234227 を参照してください
\r
34 /// 既定の Application クラスを補完するアプリケーション固有の動作を提供します。
\r
36 sealed partial class App : Application
\r
38 bool SettingRegistored;
\r
42 /// 単一アプリケーション オブジェクトを初期化します。これは、実行される作成したコードの
\r
43 /// 最初の行であり、main() または WinMain() と論理的に等価です。
\r
47 this.InitializeComponent();
\r
48 this.Suspending += OnSuspending;
\r
52 /// アプリケーションがエンド ユーザーによって正常に起動されたときに呼び出されます。他のエントリ ポイントは、
\r
53 /// アプリケーションが特定のファイルを開くために呼び出されたときに
\r
54 /// 検索結果やその他の情報を表示するために使用されます。
\r
56 /// <param name="args">起動要求とプロセスの詳細を表示します。</param>
\r
57 protected override void OnLaunched(LaunchActivatedEventArgs args)
\r
59 Frame rootFrame = Window.Current.Content as Frame;
\r
61 // ウィンドウに既にコンテンツが表示されている場合は、アプリケーションの初期化を繰り返さずに、
\r
62 // ウィンドウがアクティブであることだけを確認してください
\r
63 if (rootFrame == null)
\r
65 // ナビゲーション コンテキストとして動作するフレームを作成し、最初のページに移動します
\r
66 rootFrame = new Frame();
\r
68 if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
\r
70 //TODO: 以前中断したアプリケーションから状態を読み込みます。
\r
73 // フレームを現在のウィンドウに配置します
\r
74 Window.Current.Content = rootFrame;
\r
77 if (rootFrame.Content == null)
\r
79 // ナビゲーション スタックが復元されていない場合、最初のページに移動します。
\r
80 // このとき、必要な情報をナビゲーション パラメーターとして渡して、新しいページを
\r
82 if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))
\r
84 throw new Exception("Failed to create initial page");
\r
87 if (!this.SettingRegistored)
\r
89 SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested;
\r
90 this.SettingRegistored = true;
\r
92 // 現在のウィンドウがアクティブであることを確認します
\r
93 Window.Current.Activate();
\r
96 void OnCommandsRequested(SettingsPane settingsPane, SettingsPaneCommandsRequestedEventArgs eventArgs)
\r
98 var handler = new UICommandInvokedHandler(OnSettingsCommand);
\r
100 var policyCommand = new SettingsCommand("setting", "設定", handler);
\r
101 eventArgs.Request.ApplicationCommands.Add(policyCommand);
\r
104 private void OnSettingsCommand(IUICommand command)
\r
106 var settingsCommand = (SettingsCommand)command;
\r
107 switch (settingsCommand.Id.ToString())
\r
110 ShowSettingsFlyout();
\r
115 void ShowSettingsFlyout()
\r
117 var flyout = new Test.SettingsFlyout1();
\r
122 /// アプリケーションの実行が中断されたときに呼び出されます。アプリケーションの状態は、
\r
123 /// アプリケーションが終了されるのか、メモリの内容がそのままで再開されるのか
\r
124 /// わからない状態で保存されます。
\r
126 /// <param name="sender">中断要求の送信元。</param>
\r
127 /// <param name="e">中断要求の詳細。</param>
\r
128 private void OnSuspending(object sender, SuspendingEventArgs e)
\r
130 var deferral = e.SuspendingOperation.GetDeferral();
\r
131 //TODO: アプリケーションの状態を保存してバックグラウンドの動作があれば停止します
\r
132 deferral.Complete();
\r