Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HtmlControls: Added HtmlHxText elements, Added HtmlSelect/HtmlOption elements #79

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
76 changes: 37 additions & 39 deletions UI/HtmlControls/HtmlControls.Shared/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System;
using Microsoft.Extensions.Logging;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Navigation;

namespace HtmlControls
{
Expand All @@ -23,13 +13,8 @@ namespace HtmlControls
/// </summary>
public sealed partial class App : Application
{
#if NET5_0 && WINDOWS
private Window _window;

#else
private Windows.UI.Xaml.Window _window;
#endif

/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
Expand All @@ -49,8 +34,8 @@ public App()
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
Expand All @@ -59,11 +44,11 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
}
#endif

#if NET6_0_OR_GREATER && WINDOWS
#if NET6_0_OR_GREATER && WINDOWS && !HAS_UNO
_window = new Window();
_window.Activate();
#else
_window = Windows.UI.Xaml.Window.Current;
_window = Microsoft.UI.Xaml.Window.Current;
#endif

var rootFrame = _window.Content as Frame;
Expand All @@ -77,25 +62,25 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)

rootFrame.NavigationFailed += OnNavigationFailed;

if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
if (args.UWPLaunchActivatedEventArgs.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
// TODO: Load state from previously suspended application
}

// Place the frame in the current Window
_window.Content = rootFrame;
}

#if !(NET6_0_OR_GREATER && WINDOWS)
if (e.PrelaunchActivated == false)
if (args.UWPLaunchActivatedEventArgs.PrelaunchActivated == false)
#endif
{
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootFrame.Navigate(typeof(MainPage), e.Arguments);
rootFrame.Navigate(typeof(MainPage), args.Arguments);
}
// Ensure the current window is active
_window.Activate();
Expand All @@ -109,7 +94,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
/// <param name="e">Details about the navigation failure</param>
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
throw new Exception($"Failed to load {e.SourcePageType.FullName}: {e.Exception}");
throw new InvalidOperationException($"Failed to load {e.SourcePageType.FullName}: {e.Exception}");
}

/// <summary>
Expand All @@ -131,6 +116,14 @@ private void OnSuspending(object sender, SuspendingEventArgs e)
/// </summary>
private static void InitializeLogging()
{
#if DEBUG
// Logging is disabled by default for release builds, as it incurs a significant
// initialization cost from Microsoft.Extensions.Logging setup. If startup performance
// is a concern for your application, keep this disabled. If you're running on web or
// desktop targets, you can use url or command line parameters to enable it.
//
// For more performance documentation: https://platform.uno/docs/articles/Uno-UI-Performance.html

var factory = LoggerFactory.Create(builder =>
{
#if __WASM__
Expand All @@ -152,22 +145,22 @@ private static void InitializeLogging()
builder.AddFilter("Microsoft", LogLevel.Warning);

// Generic Xaml events
// builder.AddFilter("Windows.UI.Xaml", LogLevel.Debug );
// builder.AddFilter("Windows.UI.Xaml.VisualStateGroup", LogLevel.Debug );
// builder.AddFilter("Windows.UI.Xaml.StateTriggerBase", LogLevel.Debug );
// builder.AddFilter("Windows.UI.Xaml.UIElement", LogLevel.Debug );
// builder.AddFilter("Windows.UI.Xaml.FrameworkElement", LogLevel.Trace );
// builder.AddFilter("Microsoft.UI.Xaml", LogLevel.Debug );
// builder.AddFilter("Microsoft.UI.Xaml.VisualStateGroup", LogLevel.Debug );
// builder.AddFilter("Microsoft.UI.Xaml.StateTriggerBase", LogLevel.Debug );
// builder.AddFilter("Microsoft.UI.Xaml.UIElement", LogLevel.Debug );
// builder.AddFilter("Microsoft.UI.Xaml.FrameworkElement", LogLevel.Trace );

// Layouter specific messages
// builder.AddFilter("Windows.UI.Xaml.Controls", LogLevel.Debug );
// builder.AddFilter("Windows.UI.Xaml.Controls.Layouter", LogLevel.Debug );
// builder.AddFilter("Windows.UI.Xaml.Controls.Panel", LogLevel.Debug );
// builder.AddFilter("Microsoft.UI.Xaml.Controls", LogLevel.Debug );
// builder.AddFilter("Microsoft.UI.Xaml.Controls.Layouter", LogLevel.Debug );
// builder.AddFilter("Microsoft.UI.Xaml.Controls.Panel", LogLevel.Debug );

// builder.AddFilter("Windows.Storage", LogLevel.Debug );

// Binding related messages
// builder.AddFilter("Windows.UI.Xaml.Data", LogLevel.Debug );
// builder.AddFilter("Windows.UI.Xaml.Data", LogLevel.Debug );
// builder.AddFilter("Microsoft.UI.Xaml.Data", LogLevel.Debug );
// builder.AddFilter("Microsoft.UI.Xaml.Data", LogLevel.Debug );

// Binder memory references tracking
// builder.AddFilter("Uno.UI.DataBinding.BinderReferenceHolder", LogLevel.Debug );
Expand All @@ -180,6 +173,11 @@ private static void InitializeLogging()
});

global::Uno.Extensions.LogExtensionPoint.AmbientLoggerFactory = factory;

#if HAS_UNO
global::Uno.UI.Adapter.Microsoft.Extensions.Logging.LoggingAdapter.Initialize();
#endif
#endif
}
}
}
59 changes: 42 additions & 17 deletions UI/HtmlControls/HtmlControls.Shared/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,50 @@
xmlns:html="using:HtmlControls"
mc:Ignorable="d">

<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="20" Spacing="6">
<TextBlock FontSize="20">HtmlTimePicker <Span FontWeight="Bold">&lt;input type='time' /&gt;</Span></TextBlock>
<html:HtmlTimePicker HorizontalAlignment="Left" x:Name="time1" />
<html:HtmlTimePicker HorizontalAlignment="Left" x:Name="time2" Time="{Binding Time, ElementName=time1, Mode=TwoWay}" />
<ScrollViewer>
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="20" Spacing="6">
<TextBlock FontSize="20">HtmlTimePicker <Span FontWeight="Bold">&lt;input type='time' /&gt;</Span></TextBlock>
<html:HtmlTimePicker HorizontalAlignment="Left" x:Name="time1" />
<html:HtmlTimePicker HorizontalAlignment="Left" x:Name="time2" Time="{Binding Time, ElementName=time1, Mode=TwoWay}" />

<TextBlock FontSize="20">HtmlDatePicker <Span FontWeight="Bold">&lt;input type='date' /&gt;</Span></TextBlock>
<html:HtmlDatePicker HorizontalAlignment="Left" x:Name="date1" />
<html:HtmlDatePicker HorizontalAlignment="Left" x:Name="date2" Date="{Binding Date, ElementName=date1, Mode=TwoWay}" />
<TextBlock FontSize="20">HtmlDatePicker <Span FontWeight="Bold">&lt;input type='date' /&gt;</Span></TextBlock>
<html:HtmlDatePicker HorizontalAlignment="Left" x:Name="date1" />
<html:HtmlDatePicker HorizontalAlignment="Left" x:Name="date2" Date="{Binding Date, ElementName=date1, Mode=TwoWay}" />

<TextBlock FontSize="20">HtmlNumberInput <Span FontWeight="Bold">&lt;input type='number' /&gt;</Span></TextBlock>
<html:HtmlNumberInput HorizontalAlignment="Left" x:Name="number1" />
<html:HtmlNumberInput HorizontalAlignment="Left" x:Name="number2" Value="{Binding Value, ElementName=number1, Mode=TwoWay}" />
<TextBlock FontSize="20">HtmlNumberInput <Span FontWeight="Bold">&lt;input type='number' /&gt;</Span></TextBlock>
<html:HtmlNumberInput HorizontalAlignment="Left" x:Name="number1" />
<html:HtmlNumberInput HorizontalAlignment="Left" x:Name="number2" Value="{Binding Value, ElementName=number1, Mode=TwoWay}" />

<TextBlock FontSize="20">HtmlColorPicker <Span FontWeight="Bold">&lt;input type='color' /&gt;</Span></TextBlock>
<html:HtmlColorPicker HorizontalAlignment="Left" x:Name="color1" />
<html:HtmlColorPicker HorizontalAlignment="Left" x:Name="color2" Color="{Binding Color, ElementName=color1, Mode=TwoWay}" />
<TextBlock FontSize="20">HtmlColorPicker <Span FontWeight="Bold">&lt;input type='color' /&gt;</Span></TextBlock>
<html:HtmlColorPicker HorizontalAlignment="Left" x:Name="color1" />
<html:HtmlColorPicker HorizontalAlignment="Left" x:Name="color2" Color="{Binding Color, ElementName=color1, Mode=TwoWay}" />

<TextBlock FontSize="20">HtmlRangeInput <Span FontWeight="Bold">&lt;input type='range' /&gt;</Span></TextBlock>
<html:HtmlRangeInput HorizontalAlignment="Left" x:Name="range1" />
<html:HtmlRangeInput HorizontalAlignment="Left" x:Name="range2" Value="{Binding Value, ElementName=range1, Mode=TwoWay}" />
</StackPanel>
<TextBlock FontSize="20">HtmlRangeInput <Span FontWeight="Bold">&lt;input type='range' /&gt;</Span></TextBlock>
<html:HtmlRangeInput HorizontalAlignment="Left" x:Name="range1" Value="25" />
<html:HtmlRangeInput HorizontalAlignment="Left" x:Name="range2" Value="{Binding Value, ElementName=range1, Mode=TwoWay}" />

<TextBlock FontSize="20">HtmlProgress <Span FontWeight="Bold">&lt;progress/&gt;</Span></TextBlock>
<html:HtmlProgress HorizontalAlignment="Left" x:Name="progress1" Max="100" Value="{Binding Value, ElementName=range1}" />

<TextBlock FontSize="20">HtmlMeter <Span FontWeight="Bold">&lt;meter/&gt;</Span></TextBlock>
<html:HtmlMeter HorizontalAlignment="Left" x:Name="meter1" Max="100" Value="{Binding Value, ElementName=range1}" />

<TextBlock FontSize="20">HtmlHxText <Span FontWeight="Bold">&lt;h1 /&gt;, &lt;h2 /&gt;, &lt;h3 /&gt;, &lt;h4 /&gt;</Span></TextBlock>
<TextBox x:Name="text" Text="Sample text you can change..." />
<html:HtmlH1Text HorizontalAlignment="Left" x:Name="h1" Text="{Binding Text, ElementName=text}" />
<html:HtmlH2Text HorizontalAlignment="Left" x:Name="h2" Text="{Binding Text, ElementName=text}" />
<html:HtmlH3Text HorizontalAlignment="Left" x:Name="h3" Text="{Binding Text, ElementName=text}" />
<html:HtmlH4Text HorizontalAlignment="Left" x:Name="h4" Text="{Binding Text, ElementName=text}" />

<TextBlock FontSize="20">HtmlSelect / HtmlOption <Span FontWeight="Bold">&lt;select /&gt;, &lt;option /&gt;</Span></TextBlock>
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
<html:HtmlSelect x:Name="select1">
<html:HtmlOption Value="o1">Option 1</html:HtmlOption>
<html:HtmlOption Value="o2">Option 2</html:HtmlOption>
<html:HtmlOption Value="o3">Option 3</html:HtmlOption>
</html:HtmlSelect>
<TextBlock Text="{Binding SelectedIndex, ElementName=select1}"/>
</StackPanel>
</StackPanel>
</ScrollViewer>
</Page>
17 changes: 1 addition & 16 deletions UI/HtmlControls/HtmlControls.Shared/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
using Microsoft.UI.Xaml.Controls;

namespace HtmlControls
{
Expand Down
102 changes: 54 additions & 48 deletions UI/HtmlControls/HtmlControls.Wasm/HtmlControls.Wasm.csproj
Original file line number Diff line number Diff line change
@@ -1,51 +1,57 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<NoWarn>NU1701</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<MonoRuntimeDebuggerEnabled>true</MonoRuntimeDebuggerEnabled>
<DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Content Include="Assets\SplashScreen.png" />
</ItemGroup>
<ItemGroup>
<UpToDateCheckInput Include="..\HtmlControls.Shared\**\*.xaml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="WasmCSS\Fonts.css" />
<EmbeddedResource Include="WasmScripts\AppManifest.js" />
</ItemGroup>
<ItemGroup>
<LinkerDescriptor Include="LinkerConfig.xml" />
</ItemGroup>
<ItemGroup>
<!--
This item group is required by the project template because of the
new SDK-Style project, otherwise some files are not added automatically.
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<NoWarn>NU1701</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<MonoRuntimeDebuggerEnabled>true</MonoRuntimeDebuggerEnabled>
<DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<!--
IL Linking is disabled in Debug configuration.
When building in Release, see https://platform.uno/docs/articles/features/using-il-linker-webassembly.html
-->
<WasmShellILLinkerEnabled>false</WasmShellILLinkerEnabled>
</PropertyGroup>
<ItemGroup>
<Content Include="Assets\SplashScreen.png" />
</ItemGroup>
<ItemGroup>
<UpToDateCheckInput Include="..\HtmlControls.Shared\**\*.xaml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="WasmCSS\Fonts.css" />
<EmbeddedResource Include="WasmScripts\AppManifest.js" />
</ItemGroup>
<ItemGroup>
<LinkerDescriptor Include="LinkerConfig.xml" />
</ItemGroup>
<ItemGroup>
<!--
This item group is required by the project template because of the
new SDK-Style project, otherwise some files are not added automatically.

You can safely remove this ItemGroup completely.
-->
<None Include="Program.cs" />
<None Include="LinkerConfig.xml" />
<None Include="wwwroot\web.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.Compatibility" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.4.0" />
<PackageReference Include="Uno.UI.WebAssembly" Version="4.5.12" />
<PackageReference Include="Uno.UI.RemoteControl" Version="4.5.12" Condition="'$(Configuration)'=='Debug'" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.5.12" />
<PackageReference Include="Uno.Wasm.Bootstrap" Version="3.3.1" />
<PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="3.3.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HtmlControls\HtmlControls.csproj" />
</ItemGroup>
<Import Project="..\HtmlControls.Shared\HtmlControls.Shared.projitems" Label="Shared" Condition="Exists('..\HtmlControls.Shared\HtmlControls.Shared.projitems')" />
You can safely remove this ItemGroup completely.
-->
<None Include="Program.cs" />
<None Include="LinkerConfig.xml" />
<None Include="wwwroot\web.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0" />
<PackageReference Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.4.0" />
<PackageReference Include="Uno.WinUI.WebAssembly" Version="4.6.19" />
<PackageReference Include="Uno.WinUI.RemoteControl" Version="4.6.19" Condition="'$(Configuration)'=='Debug'" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.6.19" />
<PackageReference Include="Uno.Wasm.Bootstrap" Version="7.0.3" />
<PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="7.0.3" />
<PackageReference Include="Uno.WinUI.Lottie" Version="4.6.19" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HtmlControls\HtmlControls.csproj" />
</ItemGroup>
<Import Project="..\HtmlControls.Shared\HtmlControls.Shared.projitems" Label="Shared" Condition="Exists('..\HtmlControls.Shared\HtmlControls.Shared.projitems')" />
</Project>
2 changes: 1 addition & 1 deletion UI/HtmlControls/HtmlControls.Wasm/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class Program

static int Main(string[] args)
{
Windows.UI.Xaml.Application.Start(_ => _app = new App());
Microsoft.UI.Xaml.Application.Start(_ => _app = new App());

return 0;
}
Expand Down