Skip to content

Commit 07b3393

Browse files
committed
Add demo steps
1 parent d7fe0db commit 07b3393

File tree

6 files changed

+34
-25
lines changed

6 files changed

+34
-25
lines changed

Samples/Islands/WpfCalculator/CalculatorDemo/App.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace CalculatorDemo
1111
/// </summary>
1212
public partial class App : Application
1313
{
14+
#if false // Demo3_Step1_AddWasdk
1415
// Many WinAppSDK APIs require a DispatcherQueue to be running on the thread. We'll start one when the app starts up
1516
// and shut it down when the app is finished.
1617
protected override void OnStartup(StartupEventArgs e)
@@ -27,5 +28,7 @@ protected override void OnExit(ExitEventArgs e)
2728
}
2829

2930
DispatcherQueueController? _dispatcherQueueController;
31+
#endif
3032
}
33+
3134
}

Samples/Islands/WpfCalculator/CalculatorDemo/CalculatorDemo.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@
113113
<DependentUpon>Settings.settings</DependentUpon>
114114
<DesignTimeSharedInput>True</DesignTimeSharedInput>
115115
</Compile>
116+
<!-- Demo4_Step2_AddIsland
116117
<Compile Include="WpfIslandHost.cs" />
118+
-->
117119
<EmbeddedResource Include="Properties\Resources.resx">
118120
<Generator>ResXFileCodeGenerator</Generator>
119121
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@@ -131,9 +133,11 @@
131133
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.7" />
132134
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240428000" />
133135
</ItemGroup>
136+
<!-- Demo4_Step2_AddIsland
134137
<ItemGroup>
135138
<ProjectReference Include="..\DrawingIslandCsProjection\DrawingIslandCsProjection.csproj" />
136139
</ItemGroup>
140+
-->
137141
<ItemGroup>
138142
<Resource Include="appicon.ico" />
139143
</ItemGroup>

Samples/Islands/WpfCalculator/CalculatorDemo/MainWindow.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,19 @@ public sealed partial class MainWindow : Window
2323
private string _lastVal;
2424
private string _memVal;
2525
private AppWindow _appWindow;
26-
private Microsoft.UI.Composition.Compositor _compositor;
26+
27+
// Demo4_Step2_AddIsland
28+
// private Microsoft.UI.Composition.Compositor _compositor;
2729

2830
public MainWindow()
2931
{
3032
InitializeComponent();
3133
_paper = new PaperTrail(this);
3234
ProcessKey('0');
3335
EraseDisplay = true;
34-
_compositor = new Microsoft.UI.Composition.Compositor();
36+
37+
// Demo4_Step2_AddIsland
38+
// _compositor = new Microsoft.UI.Composition.Compositor();
3539
}
3640

3741
/// <summary>
@@ -452,6 +456,7 @@ public void Clear()
452456
}
453457
}
454458

459+
#if false // Demo3_Step2_AddCompact
455460
private void CompactView_Click(object sender, RoutedEventArgs e)
456461
{
457462
SetCompactView(true);
@@ -490,7 +495,9 @@ void SetCompactView(bool useCompactView)
490495
_appWindow.SetPresenter(AppWindowPresenterKind.Default);
491496
}
492497
}
498+
#endif
493499

500+
#if false // Demo4_Step2_AddIsland
494501
private void CreateDrawingIslandMenuItem_Click(object sender, RoutedEventArgs e)
495502
{
496503
var wpfIslandHost = new WpfIslandHost(_compositor);
@@ -501,5 +508,6 @@ private void CreateDrawingIslandMenuItem_Click(object sender, RoutedEventArgs e)
501508

502509
wpfIslandHost.DesktopChildSiteBridge.Connect(drawingIsland.Island);
503510
}
511+
#endif
504512
}
505513
}

Samples/Islands/WpfCalculator/CalculatorDemo/MainWindow.xaml

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,32 @@
1111
Icon="appicon.ico">
1212

1313
<Window.Resources>
14-
<!--
15-
calc_update_tweaks: This below style will apply to all Buttons by default.
16-
We set HorizontalAlignment and VeriticalAlignment to "Stretch" so that each button will fill its Grid cell.
17-
The Margin is here so that there's a bit of space between each button.
18-
-->
1914
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
2015
<Setter Property="HorizontalAlignment" Value="Stretch"/>
2116
<Setter Property="VerticalAlignment" Value="Stretch"/>
2217
<Setter Property="Margin" Value="2"/>
2318
</Style>
2419

25-
<!--
26-
calc_update_tweaks: We also make a new Style called "GrayButton". The buttons that have the gray appearance will use
27-
this style.
28-
-->
2920
<Style x:Key="GrayButton" TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
3021
<Setter Property="Background" Value="#33aaaabb"/>
3122
</Style>
3223
</Window.Resources>
3324

3425
<Grid x:Name="MainGrid">
3526
<DockPanel Name="MyPanel">
36-
<!--
37-
calc_update_tweaks: Remove the hardcoded hight to make the Menu taller so that the menu items can be fully visible.
38-
-->
3927
<Menu Name="MainMenu" DockPanel.Dock="Top">
4028
<MenuItem Header="File">
29+
<!-- Demo4_Step2_AddIsland
4130
<MenuItem Name="CreateDrawingIslandMenuItem" Click="CreateDrawingIslandMenuItem_Click" Header="Create DrawingIsland" />
31+
-->
4232
<MenuItem Click="OnMenuExit" Header="Exit" />
4333
</MenuItem>
4434
<MenuItem Header="View">
4535
<MenuItem Name="StandardMenu" Click="OnMenuStandard" IsCheckable="true" IsChecked="True"
4636
Header="Standard" />
37+
<!-- Demo3_Step2_AddCompact
4738
<MenuItem Name="CompactView" Click="CompactView_Click" Header="Enter Compact View" />
39+
-->
4840
</MenuItem>
4941
<MenuItem Header="Help">
5042
<MenuItem Click="OnMenuAbout" Header="About" />
@@ -81,10 +73,6 @@
8173
<Button Name="B3" Click="DigitBtn_Click" Grid.Column="6" Grid.Row="4">3</Button>
8274
<Button Name="B0" Click="DigitBtn_Click" Grid.Column="4" Grid.Row="5">0</Button>
8375
<Button Name="BPeriod" Click="DigitBtn_Click" Grid.Column="5" Grid.Row="5">.</Button>
84-
<!--
85-
calc_update_tweaks: We add Style="{StaticResource GrayButton}" here to the Buttons we want to be gray to
86-
use the new Style we defined above.
87-
-->
8876
<Button Name="BPM" Click="OperBtn_Click" Style="{StaticResource GrayButton}" Grid.Column="6" Grid.Row="5">+/-</Button>
8977
<Button Name="BDevide" Click="OperBtn_Click" Style="{StaticResource GrayButton}" Grid.Column="7" Grid.Row="2">/</Button>
9078
<Button Name="BMultiply" Click="OperBtn_Click" Style="{StaticResource GrayButton}" Grid.Column="7" Grid.Row="3">*</Button>
@@ -102,9 +90,6 @@
10290
ToolTip="Usage: 'A 1/X'">
10391
1/X
10492
</Button>
105-
<!--
106-
calc_update_tweaks: Let's make the "=" Button an Accent button, so it's easy to find.
107-
-->
10893
<Button Name="BEqual" Click="OperBtn_Click" Grid.Column="8" Grid.Row="5"
10994
Foreground="{DynamicResource AccentButtonForeground}" Background="{DynamicResource AccentButtonBackground}">=</Button>
11095
<Button Name="BC" Click="OperBtn_Click" Style="{StaticResource GrayButton}" Grid.Column="8" Grid.Row="1"
@@ -133,10 +118,6 @@
133118
</Button>
134119
<TextBlock Name="BMemBox" Grid.Column="3" Grid.Row="1" Margin="10,17,10,17" Grid.ColumnSpan="2">Memory: [empty]</TextBlock>
135120

136-
<!--
137-
calc_update_tweaks: Make the calculator text a little larger to be more visible.
138-
Also, make the TextBox borders a little less harsh.
139-
-->
140121
<local:MyTextBox Grid.ColumnSpan="9" x:Name="DisplayBox" Height="30" Margin="5" FontSize="20" BorderBrush="LightGray"/>
141122
<Border x:Name="DisplayAreaBorder" Grid.Row="1" Grid.ColumnSpan="3" Grid.RowSpan="5" Margin="5">
142123
<local:MyTextBox x:Name="PaperBox" BorderBrush="LightGray"/>
@@ -146,6 +127,7 @@
146127
</DockPanel>
147128

148129
<!-- This is what's shown when we enter the compat view mode-->
130+
<!-- Demo3_Step2_AddCompact
149131
<DockPanel Name="CompactPanel" Visibility="Collapsed">
150132
<DockPanel DockPanel.Dock="Top">
151133
<Button Name="ExitCompactViewButton" Click="ExitCompactViewButton_Click" DockPanel.Dock="Right">Restore</Button>
@@ -155,5 +137,6 @@
155137
<Border x:Name="CompactAreaBorder">
156138
</Border>
157139
</DockPanel>
140+
-->
158141
</Grid>
159142
</Window>

Samples/Islands/WpfCalculator/CalculatorDemoPackage/CalculatorDemoPackage.wapproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@
6363
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" />
6464
<ItemGroup>
6565
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.3233" PrivateAssets="all" />
66+
<!-- Demo3_Step1_AddWasdk
6667
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240428000" />
68+
-->
6769
</ItemGroup>
6870
<ItemGroup>
6971
<ProjectReference Include="..\CalculatorDemo\CalculatorDemo.csproj" />

Samples/Islands/WpfCalculator/WpfCalculator.sln

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CalculatorDemo", "Calculato
1111
EndProject
1212
Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "CalculatorDemoPackage", "CalculatorDemoPackage\CalculatorDemoPackage.wapproj", "{0A343519-113B-4EF9-959C-30F559524BC4}"
1313
EndProject
14+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Demo2_Step3", "Demo2_Step3", "{D326EA21-1EE1-4D67-A0CE-898D9EC84300}"
15+
EndProject
16+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Demo4_Step2", "Demo4_Step2", "{1C23C858-0772-4881-A947-32E8870C35AE}"
17+
EndProject
1418
Global
1519
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1620
Debug|ARM64 = Debug|ARM64
@@ -79,6 +83,11 @@ Global
7983
GlobalSection(SolutionProperties) = preSolution
8084
HideSolutionNode = FALSE
8185
EndGlobalSection
86+
GlobalSection(NestedProjects) = preSolution
87+
{709C54E1-0F2F-4A59-80B2-4CFD08B720E5} = {1C23C858-0772-4881-A947-32E8870C35AE}
88+
{48847923-880A-4A61-99CF-64B8EABD412B} = {D326EA21-1EE1-4D67-A0CE-898D9EC84300}
89+
{0A343519-113B-4EF9-959C-30F559524BC4} = {D326EA21-1EE1-4D67-A0CE-898D9EC84300}
90+
EndGlobalSection
8291
GlobalSection(ExtensibilityGlobals) = postSolution
8392
SolutionGuid = {85542A88-746B-4646-9027-3AA360D075C2}
8493
EndGlobalSection

0 commit comments

Comments
 (0)