Initial Test of GitHub Pages WASM site
|
@ -1,2 +1,6 @@
|
|||
# ToolkitLabs.Dev
|
||||
Repository for https://toolkitlabs.dev/ site
|
||||
|
||||
# ToolkitLabs.dev
|
||||
|
||||
Repository for [Toolkit Labs](https://toolkitlabs.dev/) site.
|
||||
|
||||
This site hosts the GitHub page generated from the [main repository here](https://github.com/CommunityToolkit/Labs-Windows) by [Uno Platform](https://platform.uno) tooling for WebAssembly.
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||
|
||||
<script type="text/javascript" src="./package_e3557dfeb248e5b56fd478348ed80872f1eb78b3/require.js"></script>
|
||||
<script type="text/javascript" src="./package_e3557dfeb248e5b56fd478348ed80872f1eb78b3/mono-config.js"></script>
|
||||
<script type="text/javascript" src="./package_e3557dfeb248e5b56fd478348ed80872f1eb78b3/uno-config.js"></script>
|
||||
<script type="text/javascript" src="./package_e3557dfeb248e5b56fd478348ed80872f1eb78b3/uno-bootstrap.js"></script>
|
||||
<script async type="text/javascript" src="./package_e3557dfeb248e5b56fd478348ed80872f1eb78b3/dotnet.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="./package_e3557dfeb248e5b56fd478348ed80872f1eb78b3/normalize.css" />
|
||||
<link rel="stylesheet" type="text/css" href="./package_e3557dfeb248e5b56fd478348ed80872f1eb78b3/uno-bootstrap.css" />
|
||||
<link rel="stylesheet" type="text/css" href="./package_e3557dfeb248e5b56fd478348ed80872f1eb78b3/Uno.UI.css" />
|
||||
<link rel="stylesheet" type="text/css" href="./package_e3557dfeb248e5b56fd478348ed80872f1eb78b3/Fonts.css" />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="uno-body" class="container-fluid uno-body">
|
||||
<div class="uno-loader"
|
||||
loading-position="bottom"
|
||||
loading-alert="none">
|
||||
|
||||
<!-- Logo: change src to customize the logo -->
|
||||
<img class="logo"
|
||||
src=""
|
||||
title="Uno is loading your application" />
|
||||
|
||||
<progress></progress>
|
||||
<span class="alert"></span>
|
||||
</div>
|
||||
</div>
|
||||
<noscript>
|
||||
<p>This application requires Javascript and WebAssembly to be enabled.</p>
|
||||
</noscript>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,5 @@
|
|||
var UnoAppManifest = {
|
||||
splashScreenImage: "Assets/SplashScreen.scale-200.png",
|
||||
splashScreenColor: "#fff",
|
||||
displayName: "CommunityToolkit Labs Sample App"
|
||||
}
|
Двоичные данные
package_e3557dfeb248e5b56fd478348ed80872f1eb78b3/Assets/Images/AutoSuggestBox.png
Normal file
После Ширина: | Высота: | Размер: 4.8 KiB |
Двоичные данные
package_e3557dfeb248e5b56fd478348ed80872f1eb78b3/Assets/Images/ConnectedAnimation.png
Normal file
После Ширина: | Высота: | Размер: 4.8 KiB |
Двоичные данные
package_e3557dfeb248e5b56fd478348ed80872f1eb78b3/Assets/Images/Header.dark.png
Normal file
После Ширина: | Высота: | Размер: 348 KiB |
Двоичные данные
package_e3557dfeb248e5b56fd478348ed80872f1eb78b3/Assets/Images/Header.light.png
Normal file
После Ширина: | Высота: | Размер: 361 KiB |
Двоичные данные
package_e3557dfeb248e5b56fd478348ed80872f1eb78b3/Assets/Images/LabsIcon.png
Normal file
После Ширина: | Высота: | Размер: 2.6 KiB |
Двоичные данные
package_e3557dfeb248e5b56fd478348ed80872f1eb78b3/Assets/Images/Wallpaper1.png
Normal file
После Ширина: | Высота: | Размер: 2.8 MiB |
Двоичные данные
package_e3557dfeb248e5b56fd478348ed80872f1eb78b3/Assets/LockScreenLogo.scale-200.png
Normal file
После Ширина: | Высота: | Размер: 1.4 KiB |
Двоичные данные
package_e3557dfeb248e5b56fd478348ed80872f1eb78b3/Assets/SplashScreen.scale-200.png
Normal file
После Ширина: | Высота: | Размер: 123 KiB |
Двоичные данные
package_e3557dfeb248e5b56fd478348ed80872f1eb78b3/Assets/Square150x150Logo.scale-200.png
Normal file
После Ширина: | Высота: | Размер: 2.9 KiB |
Двоичные данные
package_e3557dfeb248e5b56fd478348ed80872f1eb78b3/Assets/Square44x44Logo.scale-200.png
Normal file
После Ширина: | Высота: | Размер: 1.6 KiB |
Двоичные данные
package_e3557dfeb248e5b56fd478348ed80872f1eb78b3/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
Normal file
После Ширина: | Высота: | Размер: 1.2 KiB |
После Ширина: | Высота: | Размер: 1.4 KiB |
Двоичные данные
package_e3557dfeb248e5b56fd478348ed80872f1eb78b3/Assets/Wide310x150Logo.scale-200.png
Normal file
После Ширина: | Высота: | Размер: 3.1 KiB |
|
@ -0,0 +1,10 @@
|
|||
<linker>
|
||||
<assembly fullname="CommunityToolkit.Labs.Wasm" />
|
||||
<assembly fullname="Uno.UI" />
|
||||
<assembly fullname="Microsoft.Extensions.Options" />
|
||||
|
||||
<assembly fullname="System.Core">
|
||||
<!-- This is required by JSon.NET and any expression.Compile caller -->
|
||||
<type fullname="System.Linq.Expressions*" />
|
||||
</assembly>
|
||||
</linker>
|
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
title: Canvas Layout
|
||||
author: mhawker
|
||||
description: A canvas-like VirtualizingLayout for use in an ItemsRepeater
|
||||
keywords: CanvasLayout, ItemsRepeater, VirtualizingLayout, Canvas, Layout, Panel, Arrange
|
||||
dev_langs:
|
||||
- csharp
|
||||
category: Controls
|
||||
subcategory: Layout
|
||||
---
|
||||
|
||||
<!-- To know about all the available Markdown syntax, Check out https://docs.microsoft.com/contribute/markdown-reference -->
|
||||
<!-- Ensure you remove all comments before submission, to ensure that there are no formatting issues when displaying this page. -->
|
||||
<!-- It is recommended to check how the Documentation will look in the sample app, before Merging a PR -->
|
||||
<!-- **Note:** All links to other docs.microsoft.com pages should be relative without locale, i.e. for the one above would be /contribute/markdown-reference -->
|
||||
<!-- Included images should be optimized for size and not include any Intellectual Property references. -->
|
||||
|
||||
# CanvasLayout
|
||||
|
||||
For more information about this experiment see:
|
||||
- Discussion: TODO: PASTE LINK HERE
|
||||
- Issue: TODO: PASTE LINK HERE
|
||||
|
||||
The `CanvasLayout` is a custom Layout for ItemsRepeater...
|
||||
|
||||
## Example
|
||||
|
||||
> [!SAMPLE CanvasLayoutSample]
|
|
@ -0,0 +1,42 @@
|
|||
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
|
||||
<Page x:Class="CanvasLayoutExperiment.Samples.CanvasLayoutSample"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:labs="using:CommunityToolkit.Labs.WinUI"
|
||||
xmlns:local="using:CanvasLayoutExperiment.Samples"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Auto"
|
||||
HorizontalScrollMode="Auto"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
VerticalScrollMode="Auto">
|
||||
<muxc:ItemsRepeater ItemsSource="{x:Bind Items}">
|
||||
<muxc:ItemsRepeater.Layout>
|
||||
<labs:CanvasLayout />
|
||||
</muxc:ItemsRepeater.Layout>
|
||||
<muxc:ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate x:DataType="local:CanvasItem">
|
||||
<Border Width="{x:Bind Width}"
|
||||
Height="{x:Bind Height}"
|
||||
Background="Red"
|
||||
BorderBrush="White"
|
||||
BorderThickness="2"
|
||||
CornerRadius="9999">
|
||||
<TextBlock HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
win:TextLineBounds="Tight"
|
||||
FontSize="24"
|
||||
FontWeight="Bold"
|
||||
Foreground="White"
|
||||
Text="{x:Bind Text}" />
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</muxc:ItemsRepeater.ItemTemplate>
|
||||
</muxc:ItemsRepeater>
|
||||
</ScrollViewer>
|
||||
</Page>
|
|
@ -0,0 +1,32 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace CanvasLayoutExperiment.Samples;
|
||||
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
[ToolkitSample(id: nameof(CanvasLayoutSample), "Canvas Layout", description: "A canvas-like VirtualizingLayout for use in an ItemsRepeater")]
|
||||
public sealed partial class CanvasLayoutSample : Page
|
||||
{
|
||||
public ObservableCollection<CanvasItem> Items = new()
|
||||
{
|
||||
new() { Left = 100, Top = 50, Width = 100, Height = 100, Text = "Item 1" },
|
||||
new() { Left = 400, Top = 250, Width = 200, Height = 200, Text = "Item 2" },
|
||||
new() { Left = 200, Top = 500, Width = 100, Height = 100, Text = "Item 3" },
|
||||
new() { Left = 1200, Top = 2500, Width = 100, Height = 100, Text = "Item 4" },
|
||||
new() { Left = 2200, Top = 1500, Width = 100, Height = 100, Text = "Item 5" },
|
||||
new() { Left = 1200, Top = 3500, Width = 100, Height = 100, Text = "Item 6" },
|
||||
};
|
||||
|
||||
public CanvasLayoutSample()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
||||
|
||||
public class CanvasItem : CanvasLayoutItem
|
||||
{
|
||||
public string Text { get; set; } = string.Empty;
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
---
|
||||
title: ContentSizer
|
||||
author: mhawker
|
||||
description: The ContentSizer is a control which can be used to resize any element, usually its parent.
|
||||
keywords: ContentSizer, SizerBase, Control, Layout, Expander
|
||||
dev_langs:
|
||||
- csharp
|
||||
category: Controls
|
||||
subcategory: Layout
|
||||
---
|
||||
|
||||
<!-- To know about all the available Markdown syntax, Check out https://docs.microsoft.com/en-us/contribute/markdown-reference -->
|
||||
<!-- Ensure you remove all comments before submission, to ensure that there are no formatting issues when displaying this page. -->
|
||||
<!-- It is recommended to check how the Documentation will look in the sample app, before Merging a PR -->
|
||||
<!-- **Note:** All links to other docs.microsoft.com pages should be relative without locale, i.e. for the one above would be /contribute/markdown-reference -->
|
||||
<!-- Included images should be optimized for size and not include any Intellectual Property references. -->
|
||||
|
||||
# ContentSizer
|
||||
|
||||
<!-- TODO: Link docs -->
|
||||
The ContentSizer is a control which can be used to resize any element, usually its parent. If you are using a `Grid`, use [GridSplitter](GridSplitter.md) instead.
|
||||
|
||||
# Examples
|
||||
|
||||
The main use-case for a ContentSizer is to create an expandable shelf for your application. This allows the `Expander` itself to remember its opening/closing sizes.
|
||||
|
||||
A GridSplitter would be insufficient as it would force the grid to remember the row size and maintain its position when the `Expander` collapses.
|
||||
|
||||
> [!SAMPLE ContentSizerTopShelfPage]
|
||||
|
||||
The following example shows how to use the ContentSizer to create a left-side shelf; however, this scenario can also be accomplished with a GridSplitter.
|
||||
|
||||
> [!SAMPLE ContentSizerLeftShelfPage]
|
|
@ -0,0 +1,31 @@
|
|||
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
|
||||
<Page x:Class="SizerBaseExperiment.Samples.ContentSizerLeftShelfPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="using:CommunityToolkit.Labs.WinUI"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid MinWidth="400"
|
||||
MinHeight="300">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Left-side 'Shelf', In this case you could also use a GridSplitter -->
|
||||
<Border x:Name="SideContent"
|
||||
MinWidth="200"
|
||||
MaxWidth="600"
|
||||
Background="DarkGreen">
|
||||
<TextBlock HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center">
|
||||
Side Content
|
||||
</TextBlock>
|
||||
</Border>
|
||||
<controls:ContentSizer Grid.Column="1"
|
||||
TargetControl="{x:Bind SideContent}" />
|
||||
</Grid>
|
||||
</Page>
|
|
@ -0,0 +1,14 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace SizerBaseExperiment.Samples;
|
||||
|
||||
[ToolkitSample(id: nameof(ContentSizerLeftShelfPage), "Left-side Shelf", description: "Shows how to create an expandable shelf on the left-side of your app.")]
|
||||
public sealed partial class ContentSizerLeftShelfPage : Page
|
||||
{
|
||||
public ContentSizerLeftShelfPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
|
||||
<Page x:Class="SizerBaseExperiment.Samples.ContentSizerTopShelfPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="using:CommunityToolkit.Labs.WinUI"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid MinHeight="300">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Bottom 'Shelf', In this case you cannot use GridSplitter as row would maintain its size when Expander gets collapsed -->
|
||||
<muxc:Expander x:Name="TopExpander"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
ExpandDirection="Up"
|
||||
Header="This is some Shelf"
|
||||
IsExpanded="True">
|
||||
<Grid x:Name="ExpandContent"
|
||||
Height="128"
|
||||
MinHeight="32"
|
||||
MaxHeight="256">
|
||||
<TextBlock HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Text="This is the expanded content"
|
||||
TextWrapping="Wrap" />
|
||||
</Grid>
|
||||
</muxc:Expander>
|
||||
<!-- We expand the inner content size here so that Expander maintains it's size properly. -->
|
||||
<controls:ContentSizer Grid.Row="1"
|
||||
Height="16"
|
||||
VerticalAlignment="Top"
|
||||
Orientation="Horizontal"
|
||||
TargetControl="{x:Bind ExpandContent}"
|
||||
Visibility="{x:Bind TopExpander.IsExpanded, Mode=OneWay}" />
|
||||
</Grid>
|
||||
</Page>
|
|
@ -0,0 +1,14 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace SizerBaseExperiment.Samples;
|
||||
|
||||
[ToolkitSample(id: nameof(ContentSizerTopShelfPage), "Top Shelf", description: "Shows how to create an expandable shelf on the top of your app.")]
|
||||
public sealed partial class ContentSizerTopShelfPage : Page
|
||||
{
|
||||
public ContentSizerTopShelfPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
---
|
||||
title: PropertySizer
|
||||
author: mhawker
|
||||
description: The PropertySizer is a control which can be used to manipulate the value of another double based property.
|
||||
keywords: PropertySizer, SizerBase, Control, Layout, NavigationView
|
||||
dev_langs:
|
||||
- csharp
|
||||
category: Controls
|
||||
subcategory: Layout
|
||||
---
|
||||
|
||||
<!-- To know about all the available Markdown syntax, Check out https://docs.microsoft.com/en-us/contribute/markdown-reference -->
|
||||
<!-- Ensure you remove all comments before submission, to ensure that there are no formatting issues when displaying this page. -->
|
||||
<!-- It is recommended to check how the Documentation will look in the sample app, before Merging a PR -->
|
||||
<!-- **Note:** All links to other docs.microsoft.com pages should be relative without locale, i.e. for the one above would be /contribute/markdown-reference -->
|
||||
<!-- Included images should be optimized for size and not include any Intellectual Property references. -->
|
||||
|
||||
# PropertySizer
|
||||
|
||||
<!-- TODO: Link docs -->
|
||||
The PropertySizer is a control which can be used to manipulate the value of another <c>double</c> based property. For instance manipulating the <c>OpenPaneLength</c> of a <c>NavigationView</c> control. If you are using a <see cref="Grid"/>, use <see cref="GridSplitter"/> instead.
|
||||
|
||||
# Examples
|
||||
|
||||
The main use-case is for PropertySizer to allow you to manipulate the `OpenPaneLength` property of a `NavigationView` control to create a user customizable size shelf. This is handy when using NavigationView with a tree of items that represents some project or folder structure for your application.
|
||||
|
||||
Both GridSplitter and ContentSizer are insufficient as they would force the NavigationView to a specific size and not allow it to remember its size when it expands or collapses.
|
||||
|
||||
> [!SAMPLE PropertySizerNavigationViewPage]
|
|
@ -0,0 +1,71 @@
|
|||
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
|
||||
<Page x:Class="SizerBaseExperiment.Samples.PropertySizerNavigationViewPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="using:CommunityToolkit.Labs.WinUI"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<muxc:NavigationView x:Name="ViewPanel"
|
||||
Width="500"
|
||||
MinHeight="300"
|
||||
IsPaneOpen="True"
|
||||
OpenPaneLength="300"
|
||||
PaneDisplayMode="Left">
|
||||
<muxc:NavigationView.AutoSuggestBox>
|
||||
<AutoSuggestBox AutomationProperties.Name="Search"
|
||||
QueryIcon="Find" />
|
||||
</muxc:NavigationView.AutoSuggestBox>
|
||||
<muxc:NavigationView.MenuItems>
|
||||
<muxc:NavigationViewItem Content="Menu Item1"
|
||||
Tag="SamplePage1">
|
||||
<muxc:NavigationViewItem.Icon>
|
||||
<SymbolIcon Symbol="Play" />
|
||||
</muxc:NavigationViewItem.Icon>
|
||||
</muxc:NavigationViewItem>
|
||||
<muxc:NavigationViewItem Content="Menu Item2"
|
||||
Tag="SamplePage2">
|
||||
<muxc:NavigationViewItem.Icon>
|
||||
<SymbolIcon Symbol="Save" />
|
||||
</muxc:NavigationViewItem.Icon>
|
||||
</muxc:NavigationViewItem>
|
||||
<muxc:NavigationViewItem Content="Menu Item3 with Really Long Name and Such..."
|
||||
Tag="SamplePage3">
|
||||
<muxc:NavigationViewItem.Icon>
|
||||
<SymbolIcon Symbol="Refresh" />
|
||||
</muxc:NavigationViewItem.Icon>
|
||||
</muxc:NavigationViewItem>
|
||||
<muxc:NavigationViewItem Content="Menu Item4"
|
||||
Tag="SamplePage4">
|
||||
<muxc:NavigationViewItem.Icon>
|
||||
<SymbolIcon Symbol="Download" />
|
||||
</muxc:NavigationViewItem.Icon>
|
||||
</muxc:NavigationViewItem>
|
||||
</muxc:NavigationView.MenuItems>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<!-- Note the use of a TwoWay binding here, this is required for this control to work. -->
|
||||
<controls:PropertySizer HorizontalAlignment="Left"
|
||||
Binding="{x:Bind ViewPanel.OpenPaneLength, Mode=TwoWay}"
|
||||
Maximum="440"
|
||||
Minimum="52"
|
||||
Visibility="{x:Bind ViewPanel.IsPaneOpen, Mode=OneWay}" />
|
||||
<!--In An Application, put your host frame here: <Frame Grid.Column="1"/>-->
|
||||
<!-- Here we show the content as a border for a visual aid -->
|
||||
<Border Grid.Column="1"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
BorderBrush="Red"
|
||||
BorderThickness="4">
|
||||
<TextBlock HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Text="{x:Bind ViewPanel.OpenPaneLength, Mode=OneWay}" />
|
||||
</Border>
|
||||
</Grid>
|
||||
</muxc:NavigationView>
|
||||
</Page>
|
|
@ -0,0 +1,14 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace SizerBaseExperiment.Samples;
|
||||
|
||||
[ToolkitSample(id: nameof(PropertySizerNavigationViewPage), "NavigationView Shelf", description: "Shows how to create an expandable shelf using a NavigationView and PropertySizer.")]
|
||||
public sealed partial class PropertySizerNavigationViewPage : Page
|
||||
{
|
||||
public PropertySizerNavigationViewPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
title: Sizer Controls
|
||||
author: mhawker
|
||||
description: The Sizer controls allow users to resize various parts of your UI easily in a consistent fashion.
|
||||
keywords: GridSplitter, ContentSizer, PropertySizer, SizerBase, Control, Layout, Expander, Grid
|
||||
dev_langs:
|
||||
- csharp
|
||||
category: Controls
|
||||
subcategory: Layout
|
||||
---
|
||||
|
||||
<!-- To know about all the available Markdown syntax, Check out https://docs.microsoft.com/en-us/contribute/markdown-reference -->
|
||||
<!-- Ensure you remove all comments before submission, to ensure that there are no formatting issues when displaying this page. -->
|
||||
<!-- It is recommended to check how the Documentation will look in the sample app, before Merging a PR -->
|
||||
<!-- **Note:** All links to other docs.microsoft.com pages should be relative without locale, i.e. for the one above would be /contribute/markdown-reference -->
|
||||
<!-- Included images should be optimized for size and not include any Intellectual Property references. -->
|
||||
|
||||
# Sizer Controls
|
||||
|
||||
<!-- TODO: Link docs -->
|
||||
The Sizer controls consist of the following:
|
||||
|
||||
- GridSplitter
|
||||
- ContentSizer
|
||||
- PropertySizer
|
||||
|
||||
They each provide an ability for your users to manipulate different parts of your UI experiences.
|
||||
|
||||
This document provides information about common settings you can set on any of these controls.
|
||||
|
||||
## Custom Mouse Cursor
|
||||
|
||||
You may want to change the cursor that is shown when hovering over your element like this:
|
||||
|
||||
> [!SAMPLE SizerCursorPage]
|
|
@ -0,0 +1,25 @@
|
|||
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
|
||||
<Page x:Class="SizerBaseExperiment.Samples.SizerCursorPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="using:CommunityToolkit.Labs.WinUI"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid MinWidth="400"
|
||||
MinHeight="300">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border x:Name="SomeContent"
|
||||
MinWidth="200"
|
||||
MaxWidth="600" />
|
||||
<controls:ContentSizer Grid.Column="1"
|
||||
Cursor="Hand"
|
||||
TargetControl="{x:Bind SomeContent}" />
|
||||
</Grid>
|
||||
</Page>
|
|
@ -0,0 +1,14 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace SizerBaseExperiment.Samples;
|
||||
|
||||
[ToolkitSample(id: nameof(SizerCursorPage), "Custom Mouse Cursor", description: "Shows how to change the cursor of a Sizer control.")]
|
||||
public sealed partial class SizerCursorPage : Page
|
||||
{
|
||||
public SizerCursorPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,251 @@
|
|||
html,
|
||||
body {
|
||||
/**
|
||||
Disable root scrolling (bouncing effect on touch devices)
|
||||
*/
|
||||
position: fixed;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
-webkit-tap-highlight-color: rgba(0,0,0,0);
|
||||
/*
|
||||
Disable **browsers** touch (and pen) manipulations support.
|
||||
Remarks: This has no relation with the UIElement.ManipulationMode which are handled in managed code.
|
||||
It only ensures that uno will always get ALL pointer events instead of being stolen by the browser for its internal gesture detection.
|
||||
This will also disable left and right swipe gesture to navigate through browser's history.
|
||||
Remarks 2: If applied only on the root of the app, this won't break the scrolling (unlike if applied on all UIElement).
|
||||
*/
|
||||
touch-action: none;
|
||||
}
|
||||
|
||||
.uno-root-element {
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.uno-uielement {
|
||||
position: absolute;
|
||||
display: inline;
|
||||
outline: none;
|
||||
/*
|
||||
Disable pointer events by default to match HitTestVisibilityProperty default value.
|
||||
*/
|
||||
pointer-events: none;
|
||||
/*
|
||||
Padding & margin are required for measure/arrange to behave well:
|
||||
margin & padding are calculated through Xaml elements.
|
||||
*/
|
||||
margin: 0 !important;
|
||||
padding: 0;
|
||||
line-height: normal;
|
||||
-webkit-box-sizing: border-box !important;
|
||||
-moz-box-sizing: border-box !important;
|
||||
box-sizing: border-box !important;
|
||||
/*
|
||||
Force all element to have a transform, to allow correct measure of text and images.
|
||||
See WindowManager.ts on measureViewInternal() for more details.
|
||||
*/
|
||||
transform: translate(0, 0);
|
||||
|
||||
/*
|
||||
By default, the background of UWP controls is not drawn under the border of the control.
|
||||
*/
|
||||
background-clip: padding-box;
|
||||
}
|
||||
|
||||
.uno-uielement .noclip {
|
||||
/* Used when we need to force the element to be unclipped.
|
||||
--> Used by the toolkit for elevation
|
||||
*/
|
||||
clip: auto !important;
|
||||
}
|
||||
|
||||
svg.uno-uielement {
|
||||
/*
|
||||
The SVG elements are not intended to be a touch target (they are only a holder collection of child shapes),
|
||||
instead it's their child SvgElement that should be the target of the pointer.
|
||||
This also ensure that we are HitTestVisible only for shapes that has a fill.
|
||||
*/
|
||||
pointer-events: none;
|
||||
|
||||
stroke-width: 1px; /* default value of Shape.StrokeThickness */
|
||||
}
|
||||
|
||||
.uno-frameworkelement.uno-unarranged {
|
||||
-ms-opacity: 0;
|
||||
opacity: 0;
|
||||
position: fixed;
|
||||
}
|
||||
|
||||
.uno-uielement.uno-visibility-collapsed {
|
||||
/*
|
||||
Note: On wasm when we have an 'hidden' (or 'collapsed') element, its height is used to compute the native 'scrollHeight',
|
||||
driving the SV to flicker when we scroll while at the bottom of the viewport (if those hidden element would have increase the viewport if visible).
|
||||
To avoid that, we move the element way out of the visible bounds of the view.
|
||||
*/
|
||||
visibility: hidden !important;
|
||||
top: -100000px !important;
|
||||
left: -100000px !important;
|
||||
}
|
||||
|
||||
svg.uno-frameworkelement.uno-unarranged,
|
||||
iframe.uno-frameworkelement.uno-unarranged,
|
||||
img.uno-frameworkelement.uno-unarranged,
|
||||
video.uno-frameworkelement.uno-unarranged,
|
||||
embed.uno-frameworkelement.uno-unarranged {
|
||||
/*
|
||||
"Replaced element" (like iFrame, img, video, ... cf. https://developer.mozilla.org/en-US/docs/Web/CSS/Replaced_element)
|
||||
have a default size of 300x150px (as described here https://www.w3.org/TR/css-sizing-3/#intrinsic-sizes)
|
||||
> For boxes without an intrinsic aspect ratio:
|
||||
> [../..]
|
||||
> Otherwise, use 300px for the width and/or 150px for the height as needed.
|
||||
|
||||
SVG element that does not have a measurable viewport are also requested to follow the same logic
|
||||
https://www.w3.org/TR/SVGMobile12/coords.html#InitialViewport
|
||||
> If the parent document is styled with CSS, then the negotiation process must follow the CSS rules for replaced elements.
|
||||
|
||||
Here we make sure that any unarranged "replaced element" have a fixed with / height to 0,
|
||||
so they won't be taken in consideration by scroll viewers (overflow) which are computing their extent in native.
|
||||
|
||||
A common visual effect of this, is that a non virtualized GridView with items smaller than 150px height
|
||||
is vertically scrollable when it should not! (There is a Rectangle in their template, which rendered using an SVG element).
|
||||
|
||||
Note: this is required has have set a "transform: translate(0, 0);" on all ".uno-uielement",
|
||||
which has a side effect to establish a "containing block" (cf. WindowManager.ts on measureViewInternal()).
|
||||
*/
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.uno-textblock:not(.selectionEnabled) {
|
||||
-webkit-touch-callout: none; /* Safari */
|
||||
-webkit-user-select: none; /* iOSSafari */
|
||||
-khtml-user-select: none; /* Konqueror HTML */
|
||||
-moz-user-select: none; /* Firefox */
|
||||
-ms-user-select: none; /* Internet Explorer/Edge */
|
||||
user-select: none; /* Non-prefixed version, currently supported by Chrome and Opera */
|
||||
}
|
||||
|
||||
.uno-textblock {
|
||||
text-rendering: optimizeLegibility; /* iOS Safari */
|
||||
|
||||
/* Following are required for gradient brush as Foreground on text. Should not affect normal rendering. */
|
||||
-ms-background-clip: text !important;
|
||||
-webkit-background-clip: text !important;
|
||||
background-clip: text !important;
|
||||
|
||||
/* overflow:hidden is required for text-overflow: ellipsis to work correctly */
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
[data-use-hand-cursor-interaction="true"] .uno-buttonbase,
|
||||
[data-use-hand-cursor-interaction="true"] .uno-toggleswitch {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.uno-hyperlinkbutton {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.uno-textboxview {
|
||||
outline: none;
|
||||
border: none;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.uno-textelement {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.uno-htmlimage {
|
||||
user-select: none;
|
||||
-moz-user-select: none;
|
||||
-webkit-user-drag: none;
|
||||
-webkit-user-select: none;
|
||||
-ms-user-select: none;
|
||||
}
|
||||
|
||||
.uno-scrollcontentpresenter {
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.uno-scrollcontentpresenter.scroll-x-auto {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.uno-scrollcontentpresenter.scroll-y-auto {
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.uno-scrollcontentpresenter.scroll-x-disabled {
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.uno-scrollcontentpresenter.scroll-x-hidden {
|
||||
overflow-x: auto; /* We must not use "hidden" to allow native scrolling interaction like mouse wheel */
|
||||
scrollbar-width: none; /* scrollbar-height has no effect on FF, using scrollbar-width works on all browsers (non standard property) */
|
||||
}
|
||||
|
||||
.uno-scrollcontentpresenter.scroll-x-hidden::-webkit-scrollbar {
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.uno-scrollcontentpresenter.scroll-y-disabled {
|
||||
overflow-y: hidden;
|
||||
}
|
||||
|
||||
.uno-scrollcontentpresenter.scroll-y-hidden {
|
||||
overflow-y: auto; /* We must not use "hidden" to allow native scrolling interaction like mouse wheel */
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
.uno-scrollcontentpresenter.scroll-y-hidden::-webkit-scrollbar {
|
||||
width: 0;
|
||||
}
|
||||
|
||||
.uno-scrollcontentpresenter.scroll-x-visible {
|
||||
overflow-x: scroll;
|
||||
}
|
||||
|
||||
.uno-scrollcontentpresenter.scroll-y-visible {
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
.uno-splash {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
max-width: 620px;
|
||||
width: calc(100vw - 10px);
|
||||
height: auto;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-size: 620px 300px;
|
||||
}
|
||||
|
||||
/* Bootstrapper logo override */
|
||||
.uno-loader .logo {
|
||||
position: fixed !important;
|
||||
top: 50% !important;
|
||||
left: 50% !important;
|
||||
transform: translate(-50%, -50%) !important;
|
||||
max-width: 620px !important;
|
||||
width: calc(100vw - 10px) !important;
|
||||
height: auto !important;
|
||||
background-repeat: no-repeat !important;
|
||||
background-position: center !important;
|
||||
background-size: 620px 300px !important;
|
||||
}
|
||||
|
||||
textarea {
|
||||
resize: none;
|
||||
overflow: hidden; /* Scrolling is handled by the parent ScrollViewer */
|
||||
}
|
||||
|
||||
input::-ms-reveal,
|
||||
input::-ms-clear {
|
||||
display: none;
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
define([""], () => {
|
||||
});
|
||||
|
||||
class ActiveSocket {
|
||||
constructor(handle, socket) {
|
||||
this.handle = handle;
|
||||
this.socket = socket;
|
||||
}
|
||||
}
|
||||
|
||||
var WebSocketInterop = {
|
||||
|
||||
activeSockets: {},
|
||||
debug: false,
|
||||
|
||||
connect: function (handle, url) {
|
||||
this.ensureInitialized();
|
||||
|
||||
if (this.debug) console.log("WebSocketInterop: connect " + url);
|
||||
|
||||
var webSocket = new WebSocket(url);
|
||||
webSocket.binaryType = "arraybuffer";
|
||||
|
||||
webSocket.onopen = function () {
|
||||
if (this.debug) console.log(`Socket is opened [${webSocket.protocol}] ${WebSocketInterop.dispatchConnectedMethod}`);
|
||||
|
||||
WebSocketInterop.dispatchConnectedMethod(String(handle), webSocket.protocol);
|
||||
};
|
||||
|
||||
webSocket.onerror = function (evt) {
|
||||
WebSocketInterop.dispatchErrorMethod(String(handle), String(evt.error));
|
||||
};
|
||||
|
||||
webSocket.onclose = function (evt) {
|
||||
WebSocketInterop.dispatchClosedMethod(String(handle), webSocket.readyState, String(evt.reason));
|
||||
};
|
||||
|
||||
webSocket.onmessage = function (evt) {
|
||||
var msg = evt.data;
|
||||
|
||||
if (msg instanceof ArrayBuffer) {
|
||||
if (this.debug) console.log(`Received ArrayBuffer`);
|
||||
|
||||
if (msg !== null) {
|
||||
var arraySize = msg.byteLength;
|
||||
|
||||
if (this.debug) console.log(`Result: ${msg} / ${arraySize}`);
|
||||
|
||||
var ptr = Module._malloc(arraySize);
|
||||
try {
|
||||
writeArrayToMemory(new Int8Array(msg), ptr);
|
||||
|
||||
WebSocketInterop.dispatchReceivedBinaryMethod(String(handle), ptr, arraySize);
|
||||
}
|
||||
finally {
|
||||
Module._free(ptr);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this.debug) console.error(`empty arraybuffer ? ${msg}`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this.debug) console.log(`Received message ${msg}`);
|
||||
}
|
||||
};
|
||||
|
||||
this.activeSockets[handle] = new ActiveSocket(handle, webSocket);
|
||||
},
|
||||
|
||||
close: function (handle, code, statusDescription) {
|
||||
this.getActiveSocket(handle).close(code, statusDescription);
|
||||
|
||||
delete this.activeSockets[handle];
|
||||
},
|
||||
|
||||
send: function (handle, pData, count, offset) {
|
||||
var data = new ArrayBuffer(count);
|
||||
var bytes = new Int8Array(data);
|
||||
|
||||
for (var i = 0; i < count; i++) {
|
||||
bytes[i] = Module.HEAPU8[pData + i + offset];
|
||||
}
|
||||
|
||||
this.activeSockets[handle].socket.send(data);
|
||||
},
|
||||
|
||||
getActiveSocket: function (handle) {
|
||||
|
||||
var activeSocket = this.activeSockets[handle];
|
||||
|
||||
if (activeSocket === null) {
|
||||
throw `Unknown WasmWebSocket instance ${handle}`;
|
||||
}
|
||||
|
||||
return activeSocket.socket;
|
||||
},
|
||||
|
||||
ensureInitialized: function () {
|
||||
|
||||
WebSocketInterop.dispatchConnectedMethod = Module.mono_bind_static_method("[Uno.Wasm.WebSockets] Uno.Wasm.WebSockets.WasmWebSocket:DispatchConnected");
|
||||
WebSocketInterop.dispatchErrorMethod = Module.mono_bind_static_method("[Uno.Wasm.WebSockets] Uno.Wasm.WebSockets.WasmWebSocket:DispatchError");
|
||||
WebSocketInterop.dispatchReceivedBinaryMethod = Module.mono_bind_static_method("[Uno.Wasm.WebSockets] Uno.Wasm.WebSockets.WasmWebSocket:DispatchReceivedBinary");
|
||||
WebSocketInterop.dispatchClosedMethod = Module.mono_bind_static_method("[Uno.Wasm.WebSockets] Uno.Wasm.WebSockets.WasmWebSocket:DispatchClosed");
|
||||
}
|
||||
};
|
|
@ -0,0 +1,174 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
#include <emscripten.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <mono/jit/jit.h>
|
||||
|
||||
//JS funcs
|
||||
extern MonoObject* mono_wasm_invoke_js_with_args (int js_handle, MonoString *method, MonoArray *args, int *is_exception);
|
||||
extern MonoObject* mono_wasm_get_object_property (int js_handle, MonoString *propertyName, int *is_exception);
|
||||
extern MonoObject* mono_wasm_get_by_index (int js_handle, int property_index, int *is_exception);
|
||||
extern MonoObject* mono_wasm_set_object_property (int js_handle, MonoString *propertyName, MonoObject *value, int createIfNotExist, int hasOwnProperty, int *is_exception);
|
||||
extern MonoObject* mono_wasm_set_by_index (int js_handle, int property_index, MonoObject *value, int *is_exception);
|
||||
extern MonoObject* mono_wasm_get_global_object (MonoString *global_name, int *is_exception);
|
||||
extern void* mono_wasm_release_cs_owned_object (int js_handle);
|
||||
extern MonoObject* mono_wasm_create_cs_owned_object (MonoString *core_name, MonoArray *args, int *is_exception);
|
||||
extern MonoObject* mono_wasm_typed_array_to_array (int js_handle, int *is_exception);
|
||||
extern MonoObject* mono_wasm_typed_array_copy_to (int js_handle, int ptr, int begin, int end, int bytes_per_element, int *is_exception);
|
||||
extern MonoObject* mono_wasm_typed_array_from (int ptr, int begin, int end, int bytes_per_element, int type, int *is_exception);
|
||||
extern MonoObject* mono_wasm_typed_array_copy_from (int js_handle, int ptr, int begin, int end, int bytes_per_element, int *is_exception);
|
||||
extern MonoString* mono_wasm_add_event_listener (int jsObjHandle, MonoString *name, int weakDelegateHandle, int optionsObjHandle);
|
||||
extern MonoString* mono_wasm_remove_event_listener (int jsObjHandle, MonoString *name, int weakDelegateHandle, int capture);
|
||||
|
||||
// Compiles a JavaScript function from the function data passed.
|
||||
// Note: code snippet is not a function definition. Instead it must create and return a function instance.
|
||||
EM_JS(MonoObject*, compile_function, (int snippet_ptr, int len, int *is_exception), {
|
||||
try {
|
||||
var data = MONO.string_decoder.decode (snippet_ptr, snippet_ptr + len);
|
||||
var wrapper = '(function () { ' + data + ' })';
|
||||
var funcFactory = eval(wrapper);
|
||||
var func = funcFactory();
|
||||
if (typeof func !== 'function') {
|
||||
throw new Error('Code must return an instance of a JavaScript function. '
|
||||
+ 'Please use `return` statement to return a function.');
|
||||
}
|
||||
setValue (is_exception, 0, "i32");
|
||||
return BINDING.js_to_mono_obj (func, true);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
res = e.toString ();
|
||||
setValue (is_exception, 1, "i32");
|
||||
if (res === null || res === undefined)
|
||||
res = "unknown exception";
|
||||
return BINDING.js_to_mono_obj (res, true);
|
||||
}
|
||||
});
|
||||
|
||||
static MonoObject*
|
||||
mono_wasm_compile_function (MonoString *str, int *is_exception)
|
||||
{
|
||||
if (str == NULL)
|
||||
return NULL;
|
||||
//char *native_val = mono_string_to_utf8 (str);
|
||||
mono_unichar2 *native_val = mono_string_chars (str);
|
||||
int native_len = mono_string_length (str) * 2;
|
||||
|
||||
MonoObject* native_res = compile_function((int)native_val, native_len, is_exception);
|
||||
mono_free (native_val);
|
||||
if (native_res == NULL)
|
||||
return NULL;
|
||||
return native_res;
|
||||
}
|
||||
|
||||
void core_initialize_internals ()
|
||||
{
|
||||
mono_add_internal_call ("Interop/Runtime::InvokeJSWithArgs", mono_wasm_invoke_js_with_args);
|
||||
mono_add_internal_call ("Interop/Runtime::GetObjectProperty", mono_wasm_get_object_property);
|
||||
mono_add_internal_call ("Interop/Runtime::GetByIndex", mono_wasm_get_by_index);
|
||||
mono_add_internal_call ("Interop/Runtime::SetObjectProperty", mono_wasm_set_object_property);
|
||||
mono_add_internal_call ("Interop/Runtime::SetByIndex", mono_wasm_set_by_index);
|
||||
mono_add_internal_call ("Interop/Runtime::GetGlobalObject", mono_wasm_get_global_object);
|
||||
mono_add_internal_call ("Interop/Runtime::CreateCSOwnedObject", mono_wasm_create_cs_owned_object);
|
||||
mono_add_internal_call ("Interop/Runtime::ReleaseCSOwnedObject", mono_wasm_release_cs_owned_object);
|
||||
mono_add_internal_call ("Interop/Runtime::TypedArrayToArray", mono_wasm_typed_array_to_array);
|
||||
mono_add_internal_call ("Interop/Runtime::TypedArrayCopyTo", mono_wasm_typed_array_copy_to);
|
||||
mono_add_internal_call ("Interop/Runtime::TypedArrayFrom", mono_wasm_typed_array_from);
|
||||
mono_add_internal_call ("Interop/Runtime::TypedArrayCopyFrom", mono_wasm_typed_array_copy_from);
|
||||
mono_add_internal_call ("Interop/Runtime::CompileFunction", mono_wasm_compile_function);
|
||||
mono_add_internal_call ("Interop/Runtime::AddEventListener", mono_wasm_add_event_listener);
|
||||
mono_add_internal_call ("Interop/Runtime::RemoveEventListener", mono_wasm_remove_event_listener);
|
||||
}
|
||||
|
||||
// Int8Array | int8_t | byte or SByte (signed byte)
|
||||
// Uint8Array | uint8_t | byte or Byte (unsigned byte)
|
||||
// Uint8ClampedArray| uint8_t | byte or Byte (unsigned byte)
|
||||
// Int16Array | int16_t | short (signed short)
|
||||
// Uint16Array | uint16_t | ushort (unsigned short)
|
||||
// Int32Array | int32_t | int (signed integer)
|
||||
// Uint32Array | uint32_t | uint (unsigned integer)
|
||||
// Float32Array | float | float
|
||||
// Float64Array | double | double
|
||||
// typed array marshalling
|
||||
#define MARSHAL_ARRAY_BYTE 10
|
||||
#define MARSHAL_ARRAY_UBYTE 11
|
||||
#define MARSHAL_ARRAY_UBYTE_C 12 // alias of MARSHAL_ARRAY_UBYTE
|
||||
#define MARSHAL_ARRAY_SHORT 13
|
||||
#define MARSHAL_ARRAY_USHORT 14
|
||||
#define MARSHAL_ARRAY_INT 15
|
||||
#define MARSHAL_ARRAY_UINT 16
|
||||
#define MARSHAL_ARRAY_FLOAT 17
|
||||
#define MARSHAL_ARRAY_DOUBLE 18
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE MonoArray*
|
||||
mono_wasm_typed_array_new (char *arr, int length, int size, int type)
|
||||
{
|
||||
MonoClass *typeClass = mono_get_byte_class(); // default is Byte
|
||||
switch (type) {
|
||||
case MARSHAL_ARRAY_BYTE:
|
||||
typeClass = mono_get_sbyte_class();
|
||||
break;
|
||||
case MARSHAL_ARRAY_SHORT:
|
||||
typeClass = mono_get_int16_class();
|
||||
break;
|
||||
case MARSHAL_ARRAY_USHORT:
|
||||
typeClass = mono_get_uint16_class();
|
||||
break;
|
||||
case MARSHAL_ARRAY_INT:
|
||||
typeClass = mono_get_int32_class();
|
||||
break;
|
||||
case MARSHAL_ARRAY_UINT:
|
||||
typeClass = mono_get_uint32_class();
|
||||
break;
|
||||
case MARSHAL_ARRAY_FLOAT:
|
||||
typeClass = mono_get_single_class();
|
||||
break;
|
||||
case MARSHAL_ARRAY_DOUBLE:
|
||||
typeClass = mono_get_double_class();
|
||||
break;
|
||||
}
|
||||
|
||||
MonoArray *buffer;
|
||||
|
||||
buffer = mono_array_new (mono_get_root_domain(), typeClass, length);
|
||||
memcpy(mono_array_addr_with_size(buffer, sizeof(char), 0), arr, length * size);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE int
|
||||
mono_wasm_unbox_enum (MonoObject *obj)
|
||||
{
|
||||
if (!obj)
|
||||
return 0;
|
||||
|
||||
MonoType *type = mono_class_get_type (mono_object_get_class(obj));
|
||||
|
||||
void *ptr = mono_object_unbox (obj);
|
||||
switch (mono_type_get_type(mono_type_get_underlying_type (type))) {
|
||||
case MONO_TYPE_I1:
|
||||
case MONO_TYPE_U1:
|
||||
return *(unsigned char*)ptr;
|
||||
case MONO_TYPE_I2:
|
||||
return *(short*)ptr;
|
||||
case MONO_TYPE_U2:
|
||||
return *(unsigned short*)ptr;
|
||||
case MONO_TYPE_I4:
|
||||
return *(int*)ptr;
|
||||
case MONO_TYPE_U4:
|
||||
return *(unsigned int*)ptr;
|
||||
// WASM doesn't support returning longs to JS
|
||||
// case MONO_TYPE_I8:
|
||||
// case MONO_TYPE_U8:
|
||||
default:
|
||||
printf ("Invalid type %d to mono_unbox_enum\n", mono_type_get_type(mono_type_get_underlying_type (type)));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
var DotNetSupportLib = {
|
||||
$DOTNET: {
|
||||
conv_string: function (mono_obj) {
|
||||
return MONO.string_decoder.copy (mono_obj);
|
||||
}
|
||||
},
|
||||
mono_wasm_invoke_js_blazor: function(exceptionMessage, callInfo, arg0, arg1, arg2) {
|
||||
var mono_string = globalThis._mono_string_cached
|
||||
|| (globalThis._mono_string_cached = Module.cwrap('mono_wasm_string_from_js', 'number', ['string']));
|
||||
|
||||
try {
|
||||
var blazorExports = globalThis.Blazor;
|
||||
if (!blazorExports) {
|
||||
throw new Error('The blazor.webassembly.js library is not loaded.');
|
||||
}
|
||||
|
||||
return blazorExports._internal.invokeJSFromDotNet(callInfo, arg0, arg1, arg2);
|
||||
} catch (ex) {
|
||||
var exceptionJsString = ex.message + '\n' + ex.stack;
|
||||
var exceptionSystemString = mono_string(exceptionJsString);
|
||||
setValue (exceptionMessage, exceptionSystemString, 'i32'); // *exceptionMessage = exceptionSystemString;
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
|
||||
// This is for back-compat only and will eventually be removed
|
||||
mono_wasm_invoke_js_marshalled: function(exceptionMessage, asyncHandleLongPtr, functionName, argsJson, treatResultAsVoid) {
|
||||
|
||||
var mono_string = globalThis._mono_string_cached
|
||||
|| (globalThis._mono_string_cached = Module.cwrap('mono_wasm_string_from_js', 'number', ['string']));
|
||||
|
||||
try {
|
||||
// Passing a .NET long into JS via Emscripten is tricky. The method here is to pass
|
||||
// as pointer to the long, then combine two reads from the HEAPU32 array.
|
||||
// Even though JS numbers can't represent the full range of a .NET long, it's OK
|
||||
// because we'll never exceed Number.MAX_SAFE_INTEGER (2^53 - 1) in this case.
|
||||
//var u32Index = $1 >> 2;
|
||||
var u32Index = asyncHandleLongPtr >> 2;
|
||||
var asyncHandleJsNumber = Module.HEAPU32[u32Index + 1]*4294967296 + Module.HEAPU32[u32Index];
|
||||
|
||||
// var funcNameJsString = UTF8ToString (functionName);
|
||||
// var argsJsonJsString = argsJson && UTF8ToString (argsJson);
|
||||
var funcNameJsString = DOTNET.conv_string(functionName);
|
||||
var argsJsonJsString = argsJson && DOTNET.conv_string (argsJson);
|
||||
|
||||
var dotNetExports = globaThis.DotNet;
|
||||
if (!dotNetExports) {
|
||||
throw new Error('The Microsoft.JSInterop.js library is not loaded.');
|
||||
}
|
||||
|
||||
if (asyncHandleJsNumber) {
|
||||
dotNetExports.jsCallDispatcher.beginInvokeJSFromDotNet(asyncHandleJsNumber, funcNameJsString, argsJsonJsString, treatResultAsVoid);
|
||||
return 0;
|
||||
} else {
|
||||
var resultJson = dotNetExports.jsCallDispatcher.invokeJSFromDotNet(funcNameJsString, argsJsonJsString, treatResultAsVoid);
|
||||
return resultJson === null ? 0 : mono_string(resultJson);
|
||||
}
|
||||
} catch (ex) {
|
||||
var exceptionJsString = ex.message + '\n' + ex.stack;
|
||||
var exceptionSystemString = mono_string(exceptionJsString);
|
||||
setValue (exceptionMessage, exceptionSystemString, 'i32'); // *exceptionMessage = exceptionSystemString;
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
|
||||
// This is for back-compat only and will eventually be removed
|
||||
mono_wasm_invoke_js_unmarshalled: function(exceptionMessage, funcName, arg0, arg1, arg2) {
|
||||
try {
|
||||
// Get the function you're trying to invoke
|
||||
var funcNameJsString = DOTNET.conv_string(funcName);
|
||||
var dotNetExports = globalThis.DotNet;
|
||||
if (!dotNetExports) {
|
||||
throw new Error('The Microsoft.JSInterop.js library is not loaded.');
|
||||
}
|
||||
var funcInstance = dotNetExports.jsCallDispatcher.findJSFunction(funcNameJsString);
|
||||
|
||||
return funcInstance.call(null, arg0, arg1, arg2);
|
||||
} catch (ex) {
|
||||
var exceptionJsString = ex.message + '\n' + ex.stack;
|
||||
var mono_string = Module.cwrap('mono_wasm_string_from_js', 'number', ['string']); // TODO: Cache
|
||||
var exceptionSystemString = mono_string(exceptionJsString);
|
||||
setValue (exceptionMessage, exceptionSystemString, 'i32'); // *exceptionMessage = exceptionSystemString;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
autoAddDeps(DotNetSupportLib, '$DOTNET')
|
||||
mergeInto(LibraryManager.library, DotNetSupportLib)
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
-s ALLOW_MEMORY_GROWTH=1
|
||||
-s NO_EXIT_RUNTIME=1
|
||||
-s FORCE_FILESYSTEM=1
|
||||
-lidbfs.js
|
||||
-s "EXPORTED_RUNTIME_METHODS=['ccall', 'FS_createPath', 'FS_createDataFile', 'cwrap', 'setValue', 'getValue', 'UTF8ToString', 'UTF8ArrayToString', 'addFunction']"
|
||||
-s "EXPORTED_FUNCTIONS=['_putchar']"
|
||||
--source-map-base http://example.com
|
||||
-s USE_ZLIB=1
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"items": {
|
||||
"EmccProperties": [
|
||||
{ "identity": "RuntimeEmccVersion", "value": "2.0.23" },
|
||||
{ "identity": "RuntimeEmccVersionRaw", "value": "emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 2.0.23 (b15ca40ca02f469de3bf9a4de67a2655aede8974)" },
|
||||
{ "identity": "RuntimeEmccVersionHash", "value": "b15ca40ca02f469de3bf9a4de67a2655aede8974" }
|
||||
]
|
||||
}
|
||||
}
|