Browse Source

windows phone 8.1 fix

Wei Mingzhi 6 years ago
parent
commit
aab28cc280

+ 6 - 5
winrt/SDLPal.Common/MainPage.xaml.cpp

@@ -28,10 +28,14 @@ static Platform::String^ msg_file_exts[] = { ".msg" };
 static Platform::String^ font_file_exts[] = { ".bdf" };
 static Platform::String^ log_file_exts[] = { ".log" };
 
+MainPage^ MainPage::Current = nullptr;
+
 MainPage::MainPage()
 {
 	InitializeComponent();
 
+	Current = this;
+
 	m_controls = ref new Platform::Collections::Map<Platform::String^, ButtonAttribute^>();
 	m_controls->Insert(btnBrowseMsgFile->Name, ref new ButtonAttribute(tbMsgFile, ref new Platform::Array<Platform::String^>(msg_file_exts, sizeof(msg_file_exts) / sizeof(msg_file_exts[0]))));
 	m_controls->Insert(btnBrowseFontFile->Name, ref new ButtonAttribute(tbFontFile, ref new Platform::Array<Platform::String^>(font_file_exts, sizeof(font_file_exts) / sizeof(font_file_exts[0]))));
@@ -240,7 +244,6 @@ void SDLPal::MainPage::btnBrowseFolder_Click(Platform::Object^ sender, Windows::
 	auto picker = ref new Windows::Storage::Pickers::FolderPicker();
 	picker->FileTypeFilter->Append("*");
 #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
-	picker->ContinuationData->Insert("Page", this);
 	picker->PickFolderAndContinue();
 #else
 	concurrency::create_task(picker->PickSingleFolderAsync()).then([this](Windows::Storage::StorageFolder^ folder) { SetPath(folder); });
@@ -254,8 +257,7 @@ void SDLPal::MainPage::btnBrowseFileOpen_Click(Platform::Object^ sender, Windows
 	auto picker = ref new Windows::Storage::Pickers::FileOpenPicker();
 	picker->FileTypeFilter->ReplaceAll(target->Filter);
 #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
-	picker->ContinuationData->Insert("Page", this);
-	picker->ContinuationData->Insert("Target", target->Object);
+	picker->ContinuationData->Insert("Target", button->Name);
 	picker->PickSingleFileAndContinue();
 #else
 	concurrency::create_task(picker->PickSingleFileAsync()).then(
@@ -273,8 +275,7 @@ void SDLPal::MainPage::btnBrowseFileSave_Click(Platform::Object^ sender, Windows
 	auto picker = ref new Windows::Storage::Pickers::FileSavePicker();
 	picker->FileTypeChoices->Insert(m_resLdr->GetString("LogFileType"), ref new Platform::Collections::Vector<Platform::String^>(target->Filter));
 #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
-	picker->ContinuationData->Insert("Page", this);
-	picker->ContinuationData->Insert("Target", target->Object);
+	picker->ContinuationData->Insert("Target", button->Name);
 	picker->PickSaveFileAndContinue();
 #else
 	concurrency::create_task(picker->PickSaveFileAsync()).then(

+ 3 - 0
winrt/SDLPal.Common/MainPage.xaml.h

@@ -72,5 +72,8 @@ namespace SDLPal
 		void btnClearFile_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
 		void Page_Loaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
 		void cbUseFile_CheckChanged(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+
+	internal:
+		static MainPage^ Current;
 	};
 }

+ 2 - 0
winrt/SDLPal.Common/WinRTUtil.cpp

@@ -142,7 +142,9 @@ INT UTIL_Platform_Init(int argc, char* argv[])
 {
 	// Defaults log to debug output
 	UTIL_LogAddOutputCallback([](LOGLEVEL, const char* str, const char*)->void {
+#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
 		OutputDebugStringA(str);
+#endif
 	}, PAL_DEFAULT_LOGLEVEL);
 
 	CreateRunningFile();

+ 3 - 2
winrt/SDLPal.WindowsPhone/App.xaml.cpp

@@ -131,8 +131,9 @@ void SDLPal::App::OnActivated(Windows::ApplicationModel::Activation::IActivatedE
 	if (dynamic_cast<IContinuationActivatedEventArgs^>(args) != nullptr)
 	{
 		auto contdata = dynamic_cast<IContinuationActivatedEventArgs^>(args)->ContinuationData;
-		auto page = dynamic_cast<SDLPal::MainPage^>(contdata->Lookup("Page"));
-		auto target = contdata->HasKey("Target") ? dynamic_cast<Windows::UI::Xaml::Controls::TextBox^>(contdata->Lookup("Target")) : nullptr;
+		auto page = MainPage::Current;
+		auto target = contdata->HasKey("Target") ?
+			dynamic_cast<Windows::UI::Xaml::Controls::TextBox ^>(page->FindName(dynamic_cast<Platform::String ^>(contdata->Lookup("Target")))) : nullptr;
 		switch (args->Kind)
 		{
 		case ActivationKind::PickFolderContinuation: