Skip to content

Commit ae4dd24

Browse files
committed
Minor cleanup to align C++ and C# demos
1 parent 6b15e7b commit ae4dd24

File tree

3 files changed

+30
-27
lines changed

3 files changed

+30
-27
lines changed

Samples/Islands/DrawingIsland/DrawingCppTestApp/WinMain.cpp

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,14 @@
33

44
#include "pch.h"
55

6-
namespace winrt
7-
{
8-
using namespace Microsoft::UI::Composition;
9-
using namespace Microsoft::UI::Content;
10-
using namespace Microsoft::UI::Dispatching;
11-
using namespace Microsoft::UI::Input;
12-
using namespace Microsoft::UI::Windowing;
13-
14-
using namespace DrawingIslandComponents;
15-
}
16-
176
int __stdcall wWinMain(HINSTANCE, HINSTANCE, PWSTR, int)
187
{
198
winrt::init_apartment(winrt::apartment_type::single_threaded);
209

2110
auto controller{ winrt::DispatcherQueueController::CreateOnCurrentThread() };
2211
auto queue = controller.DispatcherQueue();
2312

24-
// Associating the AppWindow with the DispatcherQueue on which the ContentIsland is created
25-
// will ensure that the ContentIsland is Closed when the AppWindow closes.
13+
// Associate the AppWindow's lifetime with the DispatcherQueue to automatically close on exit.
2614
auto window = winrt::AppWindow::Create();
2715
window.AssociateWithDispatcherQueue(queue);
2816
window.Closing(
@@ -35,20 +23,21 @@ int __stdcall wWinMain(HINSTANCE, HINSTANCE, PWSTR, int)
3523
window.Title(L"Drawing C++ TestApp");
3624
window.Show();
3725

38-
// Create the Island content in the window.
26+
#pragma region ...
27+
// Create a ContentSiteBridge and connect Island content into it.
3928
auto compositor = winrt::Compositor();
40-
auto island = winrt::DrawingIsland(compositor).Island();
41-
42-
// Create a ContentSiteBridge and connect the ContentIsland to it.
4329
auto siteBridge = winrt::DesktopChildSiteBridge::Create(compositor, window.Id());
4430
siteBridge.ResizePolicy(winrt::ContentSizePolicy::ResizeContentToParentWindow);
4531
siteBridge.Show();
32+
33+
auto island = winrt::DrawingIsland(compositor).Island();
4634
siteBridge.Connect(island);
4735

4836
// Move initial focus to the ContentIsland.
4937
auto focusNavigationHost = winrt::InputFocusNavigationHost::GetForSiteBridge(siteBridge);
5038
focusNavigationHost.NavigateFocus(winrt::FocusNavigationRequest::Create(
5139
winrt::FocusNavigationReason::Programmatic));
40+
#pragma endregion
5241

5342
queue.RunEventLoop();
5443

Samples/Islands/DrawingIsland/DrawingCppTestApp/pch.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,14 @@
1919
#include <winrt/Microsoft.UI.Windowing.h>
2020

2121
#include "winrt/DrawingIslandComponents.h"
22+
23+
namespace winrt
24+
{
25+
using namespace Microsoft::UI::Composition;
26+
using namespace Microsoft::UI::Content;
27+
using namespace Microsoft::UI::Dispatching;
28+
using namespace Microsoft::UI::Input;
29+
using namespace Microsoft::UI::Windowing;
30+
31+
using namespace DrawingIslandComponents;
32+
}

Samples/Islands/DrawingIsland/DrawingCsTestApp/Program.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,24 @@
1414
var controller = DispatcherQueueController.CreateOnCurrentThread();
1515
var queue = controller.DispatcherQueue;
1616

17+
// Associate the AppWindow's lifetime with the DispatcherQueue to automatically close on exit.
1718
var window = AppWindow.Create();
1819
window.AssociateWithDispatcherQueue(queue);
1920
window.Closing +=(sender, args) =>
2021
{
22+
// Ensure the DispatcherQueue exits the event loop on close.
2123
queue.EnqueueEventLoopExit();
2224
};
2325

2426
window.Title = "Drawing C# .NET TestApp";
2527
window.Show();
2628

2729
#region ...
28-
//var compositor = new Compositor();
29-
30-
//var siteBridge = DesktopChildSiteBridge.Create(compositor, window.Id);
31-
//siteBridge.ResizePolicy = ContentSizePolicy.ResizeContentToParentWindow;
32-
//siteBridge.Show();
30+
// Create a ContentSiteBridge and connect Island content into it.
31+
var compositor = new Compositor();
32+
var siteBridge = DesktopChildSiteBridge.Create(compositor, window.Id);
33+
siteBridge.ResizePolicy = ContentSizePolicy.ResizeContentToParentWindow;
34+
siteBridge.Show();
3335

3436
//var drawing = new DrawingIsland(compositor);
3537
//siteBridge.Connect(drawing.Island);
@@ -43,16 +45,17 @@
4345
//siteBridge.Connect(island);
4446

4547
#region ...
46-
//var island = HelmetScenario.CreateIsland(compositor);
47-
//siteBridge.Connect(island);
48+
var island = HelmetScenario.CreateIsland(compositor);
49+
siteBridge.Connect(island);
4850
#endregion
4951

5052
#endregion
5153
#endregion
5254

53-
//var focusNavigationHost = InputFocusNavigationHost.GetForSiteBridge(siteBridge);
54-
//focusNavigationHost.NavigateFocus(FocusNavigationRequest.Create(
55-
// FocusNavigationReason.Programmatic));
55+
// Move initial focus to the ContentIsland.
56+
var focusNavigationHost = InputFocusNavigationHost.GetForSiteBridge(siteBridge);
57+
focusNavigationHost.NavigateFocus(FocusNavigationRequest.Create(
58+
FocusNavigationReason.Programmatic));
5659
#endregion
5760

5861
queue.RunEventLoop();

0 commit comments

Comments
 (0)