michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "FrameworkView.h" michael@0: #include "MetroUtils.h" michael@0: #include "nsICommandLineRunner.h" michael@0: #include "nsNetUtil.h" michael@0: #include "nsIDOMChromeWindow.h" michael@0: #include "nsIURI.h" michael@0: #include "nsPrintfCString.h" michael@0: #include "mozilla/Services.h" michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: #include "MetroUIUtils.h" michael@0: #include "nsIStringBundle.h" michael@0: michael@0: using namespace mozilla; michael@0: using namespace ABI::Windows::Foundation; michael@0: using namespace ABI::Windows::Foundation::Collections; michael@0: using namespace Microsoft::WRL; michael@0: using namespace Microsoft::WRL::Wrappers; michael@0: michael@0: // Play to contract michael@0: using namespace ABI::Windows::Media::PlayTo; michael@0: michael@0: // Activation contracts michael@0: using namespace ABI::Windows::ApplicationModel::Activation; michael@0: using namespace ABI::Windows::ApplicationModel::DataTransfer; michael@0: using namespace ABI::Windows::ApplicationModel::Search; michael@0: michael@0: // Settings contract michael@0: using namespace ABI::Windows::UI::ApplicationSettings; michael@0: using namespace ABI::Windows::UI::Popups; michael@0: michael@0: // Print contract michael@0: using namespace ABI::Windows::Graphics::Printing; michael@0: michael@0: namespace mozilla { michael@0: namespace widget { michael@0: namespace winrt { michael@0: michael@0: extern nsTArray* sSettingsArray; michael@0: michael@0: void michael@0: FrameworkView::SearchActivated(ComPtr& aArgs, bool aStartup) michael@0: { michael@0: if (!aArgs) michael@0: return; michael@0: michael@0: HString data; michael@0: AssertHRESULT(aArgs->get_QueryText(data.GetAddressOf())); michael@0: if (WindowsIsStringEmpty(data.Get())) michael@0: return; michael@0: michael@0: unsigned int length; michael@0: WinUtils::LogW(L"SearchActivated text=%s", data.GetRawBuffer(&length)); michael@0: if (aStartup) { michael@0: WindowsDuplicateString(data.Get(), &sActivationURI); michael@0: } else { michael@0: PerformURILoadOrSearch(data); michael@0: } michael@0: } michael@0: michael@0: void michael@0: FrameworkView::FileActivated(ComPtr& aArgs, bool aStartup) michael@0: { michael@0: if (!aArgs) michael@0: return; michael@0: michael@0: ComPtr> list; michael@0: AssertHRESULT(aArgs->get_Files(list.GetAddressOf())); michael@0: ComPtr item; michael@0: AssertHRESULT(list->GetAt(0, item.GetAddressOf())); michael@0: HString filePath; michael@0: AssertHRESULT(item->get_Path(filePath.GetAddressOf())); michael@0: michael@0: if (aStartup) { michael@0: WindowsDuplicateString(filePath.Get(), &sActivationURI); michael@0: } else { michael@0: PerformURILoad(filePath); michael@0: } michael@0: } michael@0: michael@0: void michael@0: FrameworkView::LaunchActivated(ComPtr& aArgs, bool aStartup) michael@0: { michael@0: if (!aArgs) michael@0: return; michael@0: HString data; michael@0: AssertHRESULT(aArgs->get_Arguments(data.GetAddressOf())); michael@0: if (WindowsIsStringEmpty(data.Get())) michael@0: return; michael@0: michael@0: // If we're being launched from a secondary tile then we have a 2nd command line param of -url michael@0: // and a third of the secondary tile. We want it in sActivationURI so that browser.js will michael@0: // load it in without showing the start UI. michael@0: int argc; michael@0: unsigned int length; michael@0: LPWSTR* argv = CommandLineToArgvW(data.GetRawBuffer(&length), &argc); michael@0: if (aStartup && argc == 2 && !wcsicmp(argv[0], L"-url")) { michael@0: WindowsCreateString(argv[1], wcslen(argv[1]), &sActivationURI); michael@0: } else { michael@0: // Some other command line or this is not a startup. michael@0: // If it is startup we process it later when XPCOM is initialilzed. michael@0: mActivationCommandLine = data.GetRawBuffer(&length); michael@0: if (!aStartup) { michael@0: ProcessLaunchArguments(); michael@0: } michael@0: } michael@0: } michael@0: michael@0: void michael@0: FrameworkView::ProcessLaunchArguments() michael@0: { michael@0: if (!mActivationCommandLine.Length()) michael@0: return; michael@0: michael@0: int argc; michael@0: LPWSTR* argv = CommandLineToArgvW(mActivationCommandLine.BeginReading(), &argc); michael@0: nsCOMPtr cmdLine = michael@0: (do_CreateInstance("@mozilla.org/toolkit/command-line;1")); michael@0: if (!cmdLine) { michael@0: NS_WARNING("Unable to instantiate command line runner."); michael@0: return; michael@0: } michael@0: michael@0: LPSTR *argvUTF8 = new LPSTR[argc]; michael@0: for (int i = 0; i < argc; ++i) { michael@0: NS_ConvertUTF16toUTF8 arg(argv[i]); michael@0: argvUTF8[i] = new char[arg.Length() + 1]; michael@0: strcpy(argvUTF8[i], const_cast(arg.BeginReading())); michael@0: WinUtils::LogW(L"Launch arg[%d]: '%s'", i, argv[i]); michael@0: } michael@0: michael@0: nsresult rv = cmdLine->Init(argc, michael@0: argvUTF8, michael@0: nullptr, michael@0: nsICommandLine::STATE_REMOTE_EXPLICIT); michael@0: if (NS_SUCCEEDED(rv)) { michael@0: cmdLine->Run(); michael@0: } else { michael@0: NS_WARNING("cmdLine->Init failed."); michael@0: } michael@0: michael@0: for (int i = 0; i < argc; ++i) { michael@0: delete[] argvUTF8[i]; michael@0: } michael@0: delete[] argvUTF8; michael@0: } michael@0: michael@0: void michael@0: FrameworkView::ProcessActivationArgs(IActivatedEventArgs* aArgs, bool aStartup) michael@0: { michael@0: ActivationKind kind; michael@0: if (!aArgs || FAILED(aArgs->get_Kind(&kind))) michael@0: return; michael@0: ComPtr args(aArgs); michael@0: if (kind == ActivationKind::ActivationKind_Protocol) { michael@0: WinUtils::Log("Activation argument kind: Protocol"); michael@0: ComPtr protoArgs; michael@0: AssertHRESULT(args.As(&protoArgs)); michael@0: ComPtr uri; michael@0: AssertHRESULT(protoArgs->get_Uri(uri.GetAddressOf())); michael@0: if (!uri) michael@0: return; michael@0: michael@0: HString data; michael@0: AssertHRESULT(uri->get_AbsoluteUri(data.GetAddressOf())); michael@0: if (WindowsIsStringEmpty(data.Get())) michael@0: return; michael@0: michael@0: if (aStartup) { michael@0: WindowsDuplicateString(data.Get(), &sActivationURI); michael@0: } else { michael@0: PerformURILoad(data); michael@0: } michael@0: } else if (kind == ActivationKind::ActivationKind_Search) { michael@0: WinUtils::Log("Activation argument kind: Search"); michael@0: ComPtr searchArgs; michael@0: args.As(&searchArgs); michael@0: SearchActivated(searchArgs, aStartup); michael@0: } else if (kind == ActivationKind::ActivationKind_File) { michael@0: WinUtils::Log("Activation argument kind: File"); michael@0: ComPtr fileArgs; michael@0: args.As(&fileArgs); michael@0: FileActivated(fileArgs, aStartup); michael@0: } else if (kind == ActivationKind::ActivationKind_Launch) { michael@0: WinUtils::Log("Activation argument kind: Launch"); michael@0: ComPtr launchArgs; michael@0: args.As(&launchArgs); michael@0: LaunchActivated(launchArgs, aStartup); michael@0: } michael@0: } michael@0: michael@0: void michael@0: FrameworkView::SetupContracts() michael@0: { michael@0: LogFunction(); michael@0: HRESULT hr; michael@0: michael@0: // Add support for the share charm to indicate that we share data to other apps michael@0: ComPtr transStatics; michael@0: hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_ApplicationModel_DataTransfer_DataTransferManager).Get(), michael@0: transStatics.GetAddressOf()); michael@0: AssertHRESULT(hr); michael@0: ComPtr trans; michael@0: AssertHRESULT(transStatics->GetForCurrentView(trans.GetAddressOf())); michael@0: trans->add_DataRequested(Callback<__FITypedEventHandler_2_Windows__CApplicationModel__CDataTransfer__CDataTransferManager_Windows__CApplicationModel__CDataTransfer__CDataRequestedEventArgs_t>( michael@0: this, &FrameworkView::OnDataShareRequested).Get(), &mDataTransferRequested); michael@0: michael@0: // Add support for the search charm to indicate that you can search using our app. michael@0: ComPtr searchStatics; michael@0: hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_ApplicationModel_Search_SearchPane).Get(), michael@0: searchStatics.GetAddressOf()); michael@0: AssertHRESULT(hr); michael@0: ComPtr searchPane; michael@0: AssertHRESULT(searchStatics->GetForCurrentView(searchPane.GetAddressOf())); michael@0: searchPane->add_QuerySubmitted(Callback<__FITypedEventHandler_2_Windows__CApplicationModel__CSearch__CSearchPane_Windows__CApplicationModel__CSearch__CSearchPaneQuerySubmittedEventArgs_t>( michael@0: this, &FrameworkView::OnSearchQuerySubmitted).Get(), &mSearchQuerySubmitted); michael@0: michael@0: // Add support for the devices play to charm michael@0: ComPtr playToStatics; michael@0: hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Media_PlayTo_PlayToManager).Get(), michael@0: playToStatics.GetAddressOf()); michael@0: AssertHRESULT(hr); michael@0: ComPtr playTo; michael@0: AssertHRESULT(playToStatics->GetForCurrentView(playTo.GetAddressOf())); michael@0: playTo->add_SourceRequested(Callback<__FITypedEventHandler_2_Windows__CMedia__CPlayTo__CPlayToManager_Windows__CMedia__CPlayTo__CPlayToSourceRequestedEventArgs_t>( michael@0: this, &FrameworkView::OnPlayToSourceRequested).Get(), &mPlayToRequested); michael@0: michael@0: // Add support for the settings charm michael@0: ComPtr settingsPaneStatics; michael@0: hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_ApplicationSettings_SettingsPane).Get(), michael@0: settingsPaneStatics.GetAddressOf()); michael@0: AssertHRESULT(hr); michael@0: ComPtr settingsPane; michael@0: AssertHRESULT(settingsPaneStatics->GetForCurrentView(settingsPane.GetAddressOf())); michael@0: settingsPane->add_CommandsRequested(Callback<__FITypedEventHandler_2_Windows__CUI__CApplicationSettings__CSettingsPane_Windows__CUI__CApplicationSettings__CSettingsPaneCommandsRequestedEventArgs_t>( michael@0: this, &FrameworkView::OnSettingsCommandsRequested).Get(), &mSettingsPane); michael@0: michael@0: // Add support for the settings print charm michael@0: ComPtr printStatics; michael@0: hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Printing_PrintManager).Get(), michael@0: printStatics.GetAddressOf()); michael@0: AssertHRESULT(hr); michael@0: ComPtr printManager; michael@0: AssertHRESULT(printStatics->GetForCurrentView(printManager.GetAddressOf())); michael@0: printManager->add_PrintTaskRequested(Callback<__FITypedEventHandler_2_Windows__CGraphics__CPrinting__CPrintManager_Windows__CGraphics__CPrinting__CPrintTaskRequestedEventArgs_t>( michael@0: this, &FrameworkView::OnPrintTaskRequested).Get(), &mPrintManager); michael@0: } michael@0: michael@0: void michael@0: FrameworkView::PerformURILoad(HString& aURI) michael@0: { michael@0: LogFunction(); michael@0: michael@0: unsigned int length; michael@0: WinUtils::LogW(L"PerformURILoad uri=%s", aURI.GetRawBuffer(&length)); michael@0: michael@0: nsCOMPtr cmdLine = michael@0: (do_CreateInstance("@mozilla.org/toolkit/command-line;1")); michael@0: if (!cmdLine) { michael@0: NS_WARNING("Unable to instantiate command line runner."); michael@0: return; michael@0: } michael@0: michael@0: nsAutoCString utf8data(NS_ConvertUTF16toUTF8(aURI.GetRawBuffer(&length))); michael@0: michael@0: // NB: The first argument gets stripped by nsICommandLineRunner::Init, michael@0: // so it doesn't matter what we pass as the first argument, but we michael@0: // have to pass something. michael@0: const char *argv[] = { "", // This argument gets stripped michael@0: "-url", michael@0: utf8data.BeginReading() }; michael@0: nsresult rv = cmdLine->Init(ArrayLength(argv), michael@0: const_cast(argv), nullptr, michael@0: nsICommandLine::STATE_REMOTE_EXPLICIT); michael@0: if (NS_FAILED(rv)) { michael@0: NS_WARNING("cmdLine->Init failed."); michael@0: return; michael@0: } michael@0: cmdLine->Run(); michael@0: } michael@0: michael@0: void michael@0: FrameworkView::PerformSearch(HString& aQuery) michael@0: { michael@0: LogFunction(); michael@0: michael@0: nsCOMPtr cmdLine = michael@0: (do_CreateInstance("@mozilla.org/toolkit/command-line;1")); michael@0: if (!cmdLine) { michael@0: NS_WARNING("Unable to instantiate command line runner."); michael@0: return; michael@0: } michael@0: michael@0: nsAutoCString parameter; michael@0: parameter.AppendLiteral("\""); michael@0: unsigned int length; michael@0: parameter.Append(NS_ConvertUTF16toUTF8(aQuery.GetRawBuffer(&length))); michael@0: parameter.AppendLiteral("\""); michael@0: michael@0: // NB: The first argument gets stripped by nsICommandLineRunner::Init, michael@0: // so it doesn't matter what we pass as the first argument, but we michael@0: // have to pass something. michael@0: const char *argv[] = { "", // This argument gets stripped michael@0: "-search", michael@0: parameter.BeginReading() }; michael@0: nsresult rv = cmdLine->Init(ArrayLength(argv), michael@0: const_cast(argv), nullptr, michael@0: nsICommandLine::STATE_REMOTE_EXPLICIT); michael@0: if (NS_FAILED(rv)) { michael@0: NS_WARNING("cmdLine->Init failed."); michael@0: return; michael@0: } michael@0: cmdLine->Run(); michael@0: } michael@0: michael@0: void michael@0: FrameworkView::PerformURILoadOrSearch(HString& aString) michael@0: { michael@0: LogFunction(); michael@0: michael@0: if (WindowsIsStringEmpty(aString.Get())) { michael@0: WinUtils::Log("Emptry string passed to PerformURILoadOrSearch"); michael@0: return; michael@0: } michael@0: michael@0: // If we have a URI then devert to load the URI directly michael@0: ComPtr uri; michael@0: MetroUtils::CreateUri(aString.Get(), uri); michael@0: if (uri) { michael@0: PerformURILoad(aString); michael@0: } else { michael@0: PerformSearch(aString); michael@0: } michael@0: } michael@0: michael@0: HRESULT michael@0: FrameworkView::OnDataShareRequested(IDataTransferManager* aDTM, michael@0: IDataRequestedEventArgs* aArg) michael@0: { michael@0: // Only share pages that contain a title and a URI michael@0: nsCOMPtr metroUIUtils = do_CreateInstance("@mozilla.org/metro-ui-utils;1"); michael@0: if (!metroUIUtils) michael@0: return E_FAIL; michael@0: michael@0: nsString url, title; michael@0: nsresult rv = metroUIUtils->GetCurrentPageURI(url); michael@0: nsresult rv2 = metroUIUtils->GetCurrentPageTitle(title); michael@0: if (NS_FAILED(rv) || NS_FAILED(rv2)) { michael@0: return E_FAIL; michael@0: } michael@0: michael@0: // Get the package to share michael@0: HRESULT hr; michael@0: ComPtr request; michael@0: AssertRetHRESULT(hr = aArg->get_Request(request.GetAddressOf()), hr); michael@0: ComPtr dataPackage; michael@0: AssertRetHRESULT(hr = request->get_Data(dataPackage.GetAddressOf()), hr); michael@0: ComPtr props; michael@0: AssertRetHRESULT(hr = dataPackage->get_Properties(props.GetAddressOf()), hr); michael@0: michael@0: // Only add a URI to the package when there is no selected content. michael@0: // This is because most programs treat URIs as highest priority to generate michael@0: // their own preview, but we only want the selected content to show up. michael@0: bool hasSelectedContent = false; michael@0: metroUIUtils->GetHasSelectedContent(&hasSelectedContent); michael@0: if (!hasSelectedContent) { michael@0: ComPtr uri; michael@0: AssertRetHRESULT(hr = MetroUtils::CreateUri(HStringReference(url.BeginReading()).Get(), uri), hr); michael@0: michael@0: // If there is no selection, then we don't support sharing for sites that michael@0: // are not HTTP, HTTPS, FTP, and FILE. michael@0: HString schemeHString; michael@0: uri->get_SchemeName(schemeHString.GetAddressOf()); michael@0: unsigned int length; michael@0: LPCWSTR scheme = schemeHString.GetRawBuffer(&length); michael@0: if (!scheme || wcscmp(scheme, L"http") && wcscmp(scheme, L"https") && michael@0: wcscmp(scheme, L"ftp") && wcscmp(scheme, L"file")) { michael@0: return S_OK; michael@0: } michael@0: michael@0: AssertRetHRESULT(hr = dataPackage->SetUri(uri.Get()), hr); michael@0: } michael@0: michael@0: // Add whatever content metroUIUtils wants us to for the text sharing michael@0: nsString shareText; michael@0: if (NS_SUCCEEDED(metroUIUtils->GetShareText(shareText)) && shareText.Length()) { michael@0: AssertRetHRESULT(hr = dataPackage->SetText(HStringReference(shareText.BeginReading()).Get()) ,hr); michael@0: } michael@0: michael@0: // Add whatever content metroUIUtils wants us to for the HTML sharing michael@0: nsString shareHTML; michael@0: if (NS_SUCCEEDED(metroUIUtils->GetShareHTML(shareHTML)) && shareHTML.Length()) { michael@0: // The sharing format needs some special headers, so pass it through Windows michael@0: ComPtr htmlFormatHelper; michael@0: hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_ApplicationModel_DataTransfer_HtmlFormatHelper).Get(), michael@0: htmlFormatHelper.GetAddressOf()); michael@0: AssertRetHRESULT(hr, hr); michael@0: HSTRING fixedHTML; michael@0: htmlFormatHelper->CreateHtmlFormat(HStringReference(shareHTML.BeginReading()).Get(), &fixedHTML); michael@0: michael@0: // And now add the fixed HTML to the data package michael@0: AssertRetHRESULT(hr = dataPackage->SetHtmlFormat(fixedHTML), hr); michael@0: } michael@0: michael@0: // Obtain the brand name michael@0: nsCOMPtr bundleService = michael@0: do_GetService(NS_STRINGBUNDLE_CONTRACTID); michael@0: NS_ENSURE_TRUE(bundleService, E_FAIL); michael@0: nsCOMPtr brandBundle; michael@0: nsString brandName; michael@0: bundleService->CreateBundle("chrome://branding/locale/brand.properties", michael@0: getter_AddRefs(brandBundle)); michael@0: NS_ENSURE_TRUE(brandBundle, E_FAIL); michael@0: if(brandBundle) { michael@0: brandBundle->GetStringFromName(MOZ_UTF16("brandFullName"), michael@0: getter_Copies(brandName)); michael@0: } michael@0: michael@0: // Set these properties at the end. Otherwise users can get a michael@0: // "There was a problem with the data package" error when there michael@0: // is simply nothing to share. michael@0: props->put_ApplicationName(HStringReference(brandName.BeginReading()).Get()); michael@0: if (title.Length()) { michael@0: props->put_Title(HStringReference(title.BeginReading()).Get()); michael@0: } else { michael@0: props->put_Title(HStringReference(brandName.BeginReading()).Get()); michael@0: } michael@0: props->put_Description(HStringReference(url.BeginReading()).Get()); michael@0: michael@0: return S_OK; michael@0: } michael@0: michael@0: HRESULT michael@0: FrameworkView::OnSearchQuerySubmitted(ISearchPane* aPane, michael@0: ISearchPaneQuerySubmittedEventArgs* aArgs) michael@0: { michael@0: LogFunction(); michael@0: HString aQuery; michael@0: aArgs->get_QueryText(aQuery.GetAddressOf()); michael@0: PerformURILoadOrSearch(aQuery); michael@0: return S_OK; michael@0: } michael@0: michael@0: HRESULT michael@0: FrameworkView::OnSettingsCommandInvoked(IUICommand* aCommand) michael@0: { michael@0: LogFunction(); michael@0: HRESULT hr; michael@0: uint32_t id; michael@0: ComPtr prop; michael@0: AssertRetHRESULT(hr = aCommand->get_Id((IInspectable**)prop.GetAddressOf()), hr); michael@0: AssertRetHRESULT(hr = prop->GetUInt32(&id), hr); michael@0: michael@0: nsCOMPtr obs = mozilla::services::GetObserverService(); michael@0: if (obs) { michael@0: NS_ConvertASCIItoUTF16 idStr(nsPrintfCString("%lu", id)); michael@0: obs->NotifyObservers(nullptr, "metro-settings-entry-selected", idStr.BeginReading()); michael@0: } michael@0: michael@0: return S_OK; michael@0: } michael@0: michael@0: void michael@0: FrameworkView::AddSetting(ISettingsPaneCommandsRequestedEventArgs* aArgs, michael@0: uint32_t aId, HString& aSettingName) michael@0: { michael@0: HRESULT hr; michael@0: michael@0: ComPtr request; michael@0: AssertHRESULT(aArgs->get_Request(request.GetAddressOf())); michael@0: michael@0: // ApplicationCommands - vector that holds SettingsCommand to be invoked michael@0: ComPtr> list; michael@0: AssertHRESULT(request->get_ApplicationCommands(list.GetAddressOf())); michael@0: michael@0: ComPtr command; michael@0: ComPtr factory; michael@0: hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_ApplicationSettings_SettingsCommand).Get(), michael@0: factory.GetAddressOf()); michael@0: AssertHRESULT(hr); michael@0: michael@0: // Create the IInspectable string property that identifies this command michael@0: ComPtr prop; michael@0: ComPtr propStatics; michael@0: hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Foundation_PropertyValue).Get(), michael@0: propStatics.GetAddressOf()); michael@0: AssertHRESULT(hr); michael@0: hr = propStatics->CreateUInt32(aId, prop.GetAddressOf()); michael@0: AssertHRESULT(hr); michael@0: michael@0: // Create the command michael@0: hr = factory->CreateSettingsCommand(prop.Get(), aSettingName.Get(), michael@0: Callback( michael@0: this, &FrameworkView::OnSettingsCommandInvoked).Get(), command.GetAddressOf()); michael@0: AssertHRESULT(hr); michael@0: michael@0: // Add it to the list michael@0: hr = list->Append(command.Get()); michael@0: AssertHRESULT(hr); michael@0: } michael@0: michael@0: HRESULT michael@0: FrameworkView::OnSettingsCommandsRequested(ISettingsPane* aPane, michael@0: ISettingsPaneCommandsRequestedEventArgs* aArgs) michael@0: { michael@0: if (!sSettingsArray) michael@0: return E_FAIL; michael@0: if (!sSettingsArray->Length()) michael@0: return S_OK; michael@0: for (uint32_t i = 0; i < sSettingsArray->Length(); i++) { michael@0: HString label; michael@0: label.Set(sSettingsArray->ElementAt(i).BeginReading()); michael@0: AddSetting(aArgs, i, label); michael@0: } michael@0: return S_OK; michael@0: } michael@0: michael@0: HRESULT michael@0: FrameworkView::OnPlayToSourceRequested(IPlayToManager* aPlayToManager, michael@0: IPlayToSourceRequestedEventArgs* aArgs) michael@0: { michael@0: // TODO: Implement PlayTo, find the element on the page and then do something similar to this: michael@0: // PlayToReceiver::Dispatcher.Helper.BeginInvoke( michael@0: // mMediaElement = ref new Windows::UI::Xaml::Controls::MediaElement(); michael@0: // mMediaElement->Source = ref new Uri("http://www.youtube.com/watch?v=2U0NFgoNI7s"); michael@0: // aArgs->SourceRequest->SetSource(mMediaElement->PlayToSource); michael@0: return S_OK; michael@0: } michael@0: michael@0: HRESULT michael@0: FrameworkView::OnPrintTaskSourceRequested(IPrintTaskSourceRequestedArgs* aArgs) michael@0: { michael@0: return S_OK; michael@0: } michael@0: michael@0: HRESULT michael@0: FrameworkView::OnPrintTaskRequested(IPrintManager* aPrintManager, michael@0: IPrintTaskRequestedEventArgs* aArgs) michael@0: { michael@0: return S_OK; michael@0: } michael@0: michael@0: void michael@0: FrameworkView::CreatePrintControl(IPrintDocumentPackageTarget* docPackageTarget, michael@0: D2D1_PRINT_CONTROL_PROPERTIES* printControlProperties) michael@0: { michael@0: } michael@0: michael@0: HRESULT michael@0: FrameworkView::ClosePrintControl() michael@0: { michael@0: return S_OK; michael@0: } michael@0: michael@0: // Print out one page, with the given print ticket. michael@0: // This sample has only one page and we ignore pageNumber below. michael@0: void FrameworkView::PrintPage(uint32_t pageNumber, michael@0: D2D1_RECT_F imageableArea, michael@0: D2D1_SIZE_F pageSize, michael@0: IStream* pagePrintTicketStream) michael@0: { michael@0: } michael@0: michael@0: } } }