ソース掲示板




すべてから検索

キーワード   条件 表示 現行ログ 過去ログ トピックス 名前 本文

  メンテナンス 前画面に戻る

対象スレッド 件名: App.xaml.cs
名前: lightbox
処理選択
パスワード

件名 App.xaml.cs
名前 lightbox
コメント
@DIV
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
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.Navigation;

//名前空間
namespace S130510_LBOX_StoreBlank
{
	//クラス
	sealed partial class App : Application
	{

		//コンストラクタ
		public App()
		{
			this.InitializeComponent();
			this.Suspending += OnSuspending;
		}

		// プログラム全体で共有する構造体の定義( Navigate の引数用 )
		@C:red(public struct MyParam
		{
			public string title;
			public int type;
		})

		// ルートフレームの作成
		public Frame rootFrame = Window.Current.Content as Frame;

		// *************************************************
		// アプリケーションがエンド ユーザーによって正常に起動されたときに呼び出されます
		// *************************************************
		protected override void OnLaunched(LaunchActivatedEventArgs args)
		{
			// Navigate の引数作成
			@c:red(MyParam NavigateArgs) = new MyParam() @c:red({ title = "アプリケーション開始", type = 0 });

			// ウィンドウに既にコンテンツが表示されている場合は、アプリケーションの初期化を繰り返さずに、
			// ウィンドウがアクティブであることだけを確認してください
			if (rootFrame == null)
			{

				Debug.WriteLine("ルートフレームを新しく作成しました");
				rootFrame = new Frame();

				if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
				{
					//TODO: 以前中断したアプリケーションから状態を読み込みます。
				}

				// フレームを現在のウィンドウに配置します
				Window.Current.Content = rootFrame;
			}

			if (rootFrame.Content == null)
			{

				// *************************************************
				// ナビゲーション スタックが復元されていない場合、最初のページに移動します。
				// このとき、必要な情報をナビゲーション パラメーターとして渡して、新しいページを
				// 構成します
				// *************************************************
				if (!rootFrame.Navigate(typeof(MainPage), @c:red(NavigateArgs)))
				{
					throw new Exception("Failed to create initial page");
				}

				Debug.WriteLine("ルートフレームにページをロードしました");

			}

			// 現在のウィンドウがアクティブにします
			Window.Current.Activate();
		}

		// *************************************************
		// アプリケーションの実行が中断されたときに呼び出されます。
		// *************************************************
		private void OnSuspending(object sender, SuspendingEventArgs e)
		{
			Debug.WriteLine("アプリケーションの実行が中断されました");

			var deferral = e.SuspendingOperation.GetDeferral();
			//TODO: アプリケーションの状態を保存してバックグラウンドの動作があれば停止します
			deferral.Complete();
		}
	}
}
@END