3 // Implementation of the MainPage class.
8 #include "MainPage.xaml.h"
9 #include "SoundEditorPage.xaml.h"
11 using namespace Platform;
12 using namespace Windows::Foundation;
13 using namespace Windows::Foundation::Collections;
14 using namespace Windows::UI::Xaml;
15 using namespace Windows::UI::Xaml::Controls;
16 using namespace Windows::UI::Xaml::Controls::Primitives;
17 using namespace Windows::UI::Xaml::Data;
18 using namespace Windows::UI::Xaml::Input;
19 using namespace Windows::UI::Xaml::Media;
20 using namespace Windows::UI::Xaml::Interop;
21 using namespace Windows::UI::Xaml::Navigation;
23 // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
24 namespace ShootingGame
28 MainPage::MainPage(GameMain^ g) : gameMain_(g)
30 InitializeComponent();
31 //std::function<void (Windows::UI::Xaml::Controls::Page^ )> f(std::bind(&MainPage::Subframe,this,std::placeholders::_1));
32 gameMain_->SetSubFrameFunc(ref new GameMain::SubFrameFuncDelegate(this,&MainPage::Subframe));
33 gameMain_->SetIsBackButtonEnabledDelgate( ref new GameMain::IsBackButtonEnabledDelgate
37 backButton->IsEnabled = v;
43 void MainPage::Subframe(Windows::UI::Xaml::Controls::Page^ p)
48 UIElement^ content = p->Content;
50 SubContent->Content = content;
52 SubContent->Content = nullptr;
56 //UIElement^ MainPage::NavigateSubframe(Windows::UI::Xaml::Interop::TypeName typeName)
58 // if(!hiddenFrame_->Navigate(typeName,this))
60 // throw ref new FailureException(ref new String(L"切り替えできませんでした。"));
63 // Page^ hiddenPage = safe_cast<Page^>(hiddenFrame_->Content);
64 // UIElement^ content = hiddenPage->Content;
65 // hiddenPage->Content = nullptr;
66 // SubContent->Content = content;
73 /// Invoked when this page is about to be displayed in a Frame.
75 /// <param name="e">Event data that describes how this page was reached. The Parameter
76 /// property is typically used to configure the page.</param>
77 void MainPage::OnNavigatedTo(NavigationEventArgs^ e)
79 (void) e; // Unused parameter
82 void MainPage::UpdateProcessTime(float delta)
84 processTime->Text = ref new String((boost::wformat(L"%1.4f") % delta).str().c_str());
87 void MainPage::UpdateFrameTime(float delta,float max,float min,float avg)
89 frameTime->Text = ref new String((boost::wformat(L"%1.4f") % delta).str().c_str());
90 frameTimeMax->Text = ref new String((boost::wformat(L"%1.4f") % max).str().c_str());
91 frameTimeMin->Text = ref new String((boost::wformat(L"%1.4f") % min).str().c_str());
92 frameTimeAvg->Text = ref new String((boost::wformat(L"%1.4f") % avg).str().c_str());
96 //void ShootingGame::MainPage::Button_Click_1(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
98 // //TypeName t = {ref new String(L"ShootingGame.SoundEditorPage"),TypeKind::Custom};
99 // // if(!hiddenFrame_->Navigate(t,this))
101 // // throw ref new FailureException(ref new String(L"サウンドエディタに切り替えできませんでした。"));
104 // // Page^ hiddenPage = safe_cast<Page^>(hiddenFrame_->Content);
105 // // UIElement^ content = hiddenPage->Content;
106 // // hiddenPage->Content = nullptr;
107 // // SubContent->Content = content;
109 // //Grid^ grid = safe_cast<Grid^>(hiddenPage->FindName(L"LayoutRoot"));
110 // //if(grid != nullptr){
111 // //// Get each element.
112 // //UIElement^ c = safe_cast<UIElement^>(grid->FindName(L"Editor"));
113 // //UIElementCollection^ collection = grid->Children;
114 // //unsigned int index;
115 // //collection->IndexOf(c, &index);
116 // //collection->RemoveAt(index);
117 // //SubContent->Content = c;
122 //void MainPage::GameMain(ShootingGame::GameMain^ p){gameMain_ = p;}
124 //ShootingGame::GameMain^ MainPage::GameMain(){return gameMain_; }
126 void ShootingGame::MainPage::backButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
128 gameMain_->GameStateMachine().ProcessEvent(Event::Back());