OSDN Git Service

行を生成するメソッドをLineToIndexTableに移動した
[fooeditengine/FooEditEngine.git] / Metro / Test / App.xaml.cs
1 /*\r
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
5 \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
8 \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
10  */\r
11 using System;\r
12 using System.Collections.Generic;\r
13 using System.IO;\r
14 using System.Linq;\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
28 \r
29 // 空のアプリケーション テンプレートについては、http://go.microsoft.com/fwlink/?LinkId=234227 を参照してください\r
30 \r
31 namespace Test\r
32 {\r
33     /// <summary>\r
34     /// 既定の Application クラスを補完するアプリケーション固有の動作を提供します。\r
35     /// </summary>\r
36     sealed partial class App : Application\r
37     {\r
38         bool SettingRegistored;\r
39         Popup Popup;\r
40 \r
41         /// <summary>\r
42         /// 単一アプリケーション オブジェクトを初期化します。これは、実行される作成したコードの\r
43         /// 最初の行であり、main() または WinMain() と論理的に等価です。\r
44         /// </summary>\r
45         public App()\r
46         {\r
47             this.InitializeComponent();\r
48             this.Suspending += OnSuspending;\r
49         }\r
50 \r
51         /// <summary>\r
52         /// アプリケーションがエンド ユーザーによって正常に起動されたときに呼び出されます。他のエントリ ポイントは、\r
53         /// アプリケーションが特定のファイルを開くために呼び出されたときに\r
54         /// 検索結果やその他の情報を表示するために使用されます。\r
55         /// </summary>\r
56         /// <param name="args">起動要求とプロセスの詳細を表示します。</param>\r
57         protected override void OnLaunched(LaunchActivatedEventArgs args)\r
58         {\r
59             Frame rootFrame = Window.Current.Content as Frame;\r
60 \r
61             // ウィンドウに既にコンテンツが表示されている場合は、アプリケーションの初期化を繰り返さずに、\r
62             // ウィンドウがアクティブであることだけを確認してください\r
63             if (rootFrame == null)\r
64             {\r
65                 // ナビゲーション コンテキストとして動作するフレームを作成し、最初のページに移動します\r
66                 rootFrame = new Frame();\r
67 \r
68                 if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)\r
69                 {\r
70                     //TODO: 以前中断したアプリケーションから状態を読み込みます。\r
71                 }\r
72 \r
73                 // フレームを現在のウィンドウに配置します\r
74                 Window.Current.Content = rootFrame;\r
75             }\r
76 \r
77             if (rootFrame.Content == null)\r
78             {\r
79                 // ナビゲーション スタックが復元されていない場合、最初のページに移動します。\r
80                 // このとき、必要な情報をナビゲーション パラメーターとして渡して、新しいページを\r
81                 // 構成します\r
82                 if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))\r
83                 {\r
84                     throw new Exception("Failed to create initial page");\r
85                 }\r
86             }\r
87             if (!this.SettingRegistored)\r
88             {\r
89                 SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested;\r
90                 this.SettingRegistored = true;\r
91             }\r
92             // 現在のウィンドウがアクティブであることを確認します\r
93             Window.Current.Activate();\r
94         }\r
95 \r
96         void OnCommandsRequested(SettingsPane settingsPane, SettingsPaneCommandsRequestedEventArgs eventArgs)\r
97         {\r
98             var handler = new UICommandInvokedHandler(OnSettingsCommand);\r
99 \r
100             var policyCommand = new SettingsCommand("setting", "設定", handler);\r
101             eventArgs.Request.ApplicationCommands.Add(policyCommand);\r
102         }\r
103 \r
104         private void OnSettingsCommand(IUICommand command)\r
105         {\r
106             var settingsCommand = (SettingsCommand)command;\r
107             switch (settingsCommand.Id.ToString())\r
108             {\r
109                 case "setting":\r
110                     ShowSettingsFlyout();\r
111                     break;\r
112             }\r
113         }\r
114 \r
115         void ShowSettingsFlyout()\r
116         {\r
117             var flyout = new Test.SettingsFlyout1();\r
118             flyout.Show();\r
119         }\r
120 \r
121         /// <summary>\r
122         /// アプリケーションの実行が中断されたときに呼び出されます。アプリケーションの状態は、\r
123         /// アプリケーションが終了されるのか、メモリの内容がそのままで再開されるのか\r
124         /// わからない状態で保存されます。\r
125         /// </summary>\r
126         /// <param name="sender">中断要求の送信元。</param>\r
127         /// <param name="e">中断要求の詳細。</param>\r
128         private void OnSuspending(object sender, SuspendingEventArgs e)\r
129         {\r
130             var deferral = e.SuspendingOperation.GetDeferral();\r
131             //TODO: アプリケーションの状態を保存してバックグラウンドの動作があれば停止します\r
132             deferral.Complete();\r
133         }\r
134     }\r
135 }\r