diff --git a/AspNetCore.sln b/AspNetCore.sln index e8dc0637471f..28f62ede717c 100644 --- a/AspNetCore.sln +++ b/AspNetCore.sln @@ -1618,6 +1618,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorWinFormsApp", "src\Co EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Http.Abstractions.Microbenchmarks", "src\Http\Http.Abstractions\perf\Microbenchmarks\Microsoft.AspNetCore.Http.Abstractions.Microbenchmarks.csproj", "{3F752B48-2936-4FCA-B0DC-4AB0F788F897}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "testassets", "testassets", "{F0849E7E-61DB-4849-9368-9E7BC125DCB0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsTestApp", "src\Components\WebView\Platforms\WindowsForms\testassets\WinFormsTestApp\WinFormsTestApp.csproj", "{99EE7769-3C81-477B-B947-0A5CBCD5B27D}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "testassets", "testassets", "{94D0D6F3-8632-41DE-908B-47A787D570FF}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WpfTestApp", "src\Components\WebView\Platforms\Wpf\testassets\WpfTestApp\WpfTestApp.csproj", "{036C6BDA-7B69-4E8C-A921-822DA5972A56}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -7653,6 +7661,30 @@ Global {3F752B48-2936-4FCA-B0DC-4AB0F788F897}.Release|x64.Build.0 = Release|Any CPU {3F752B48-2936-4FCA-B0DC-4AB0F788F897}.Release|x86.ActiveCfg = Release|Any CPU {3F752B48-2936-4FCA-B0DC-4AB0F788F897}.Release|x86.Build.0 = Release|Any CPU + {99EE7769-3C81-477B-B947-0A5CBCD5B27D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {99EE7769-3C81-477B-B947-0A5CBCD5B27D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {99EE7769-3C81-477B-B947-0A5CBCD5B27D}.Debug|x64.ActiveCfg = Debug|Any CPU + {99EE7769-3C81-477B-B947-0A5CBCD5B27D}.Debug|x64.Build.0 = Debug|Any CPU + {99EE7769-3C81-477B-B947-0A5CBCD5B27D}.Debug|x86.ActiveCfg = Debug|Any CPU + {99EE7769-3C81-477B-B947-0A5CBCD5B27D}.Debug|x86.Build.0 = Debug|Any CPU + {99EE7769-3C81-477B-B947-0A5CBCD5B27D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {99EE7769-3C81-477B-B947-0A5CBCD5B27D}.Release|Any CPU.Build.0 = Release|Any CPU + {99EE7769-3C81-477B-B947-0A5CBCD5B27D}.Release|x64.ActiveCfg = Release|Any CPU + {99EE7769-3C81-477B-B947-0A5CBCD5B27D}.Release|x64.Build.0 = Release|Any CPU + {99EE7769-3C81-477B-B947-0A5CBCD5B27D}.Release|x86.ActiveCfg = Release|Any CPU + {99EE7769-3C81-477B-B947-0A5CBCD5B27D}.Release|x86.Build.0 = Release|Any CPU + {036C6BDA-7B69-4E8C-A921-822DA5972A56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {036C6BDA-7B69-4E8C-A921-822DA5972A56}.Debug|Any CPU.Build.0 = Debug|Any CPU + {036C6BDA-7B69-4E8C-A921-822DA5972A56}.Debug|x64.ActiveCfg = Debug|Any CPU + {036C6BDA-7B69-4E8C-A921-822DA5972A56}.Debug|x64.Build.0 = Debug|Any CPU + {036C6BDA-7B69-4E8C-A921-822DA5972A56}.Debug|x86.ActiveCfg = Debug|Any CPU + {036C6BDA-7B69-4E8C-A921-822DA5972A56}.Debug|x86.Build.0 = Debug|Any CPU + {036C6BDA-7B69-4E8C-A921-822DA5972A56}.Release|Any CPU.ActiveCfg = Release|Any CPU + {036C6BDA-7B69-4E8C-A921-822DA5972A56}.Release|Any CPU.Build.0 = Release|Any CPU + {036C6BDA-7B69-4E8C-A921-822DA5972A56}.Release|x64.ActiveCfg = Release|Any CPU + {036C6BDA-7B69-4E8C-A921-822DA5972A56}.Release|x64.Build.0 = Release|Any CPU + {036C6BDA-7B69-4E8C-A921-822DA5972A56}.Release|x86.ActiveCfg = Release|Any CPU + {036C6BDA-7B69-4E8C-A921-822DA5972A56}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -8452,6 +8484,10 @@ Global {3BA297F8-1CA1-492D-AE64-A60B825D8501} = {D4E9A2C5-0838-42DF-BC80-C829C4C9137E} {CC740832-D268-47A3-9058-B9054F8397E2} = {D3B76F4E-A980-45BF-AEA1-EA3175B0B5A1} {3F752B48-2936-4FCA-B0DC-4AB0F788F897} = {DCBBDB52-4A49-4141-8F4D-81C0FFFB7BD5} + {F0849E7E-61DB-4849-9368-9E7BC125DCB0} = {D4E9A2C5-0838-42DF-BC80-C829C4C9137E} + {99EE7769-3C81-477B-B947-0A5CBCD5B27D} = {F0849E7E-61DB-4849-9368-9E7BC125DCB0} + {94D0D6F3-8632-41DE-908B-47A787D570FF} = {5241CF68-66A0-4724-9BAA-36DB959A5B11} + {036C6BDA-7B69-4E8C-A921-822DA5972A56} = {94D0D6F3-8632-41DE-908B-47A787D570FF} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3E8720B3-DBDD-498C-B383-2CC32A054E8F} diff --git a/src/Components/ComponentsNoDeps.slnf b/src/Components/ComponentsNoDeps.slnf index ebdb7e6aaaf1..81037f138f3b 100644 --- a/src/Components/ComponentsNoDeps.slnf +++ b/src/Components/ComponentsNoDeps.slnf @@ -39,7 +39,9 @@ "src\\Components\\WebAssembly\\testassets\\WasmLinkerTest\\WasmLinkerTest.csproj", "src\\Components\\WebView\\Platforms\\WebView2\\src\\Microsoft.AspNetCore.Components.WebView.WebView2.csproj", "src\\Components\\WebView\\Platforms\\WindowsForms\\src\\Microsoft.AspNetCore.Components.WebView.WindowsForms.csproj", + "src\\Components\\WebView\\Platforms\\WindowsForms\\testassets\\WinFormsTestApp\\WinFormsTestApp.csproj", "src\\Components\\WebView\\Platforms\\Wpf\\src\\Microsoft.AspNetCore.Components.WebView.Wpf.csproj", + "src\\Components\\WebView\\Platforms\\Wpf\\testassets\\WpfTestApp\\WpfTestApp.csproj", "src\\Components\\WebView\\Samples\\BlazorWinFormsApp\\BlazorWinFormsApp.csproj", "src\\Components\\WebView\\Samples\\BlazorWpfApp\\BlazorWpfApp.csproj", "src\\Components\\WebView\\WebView\\src\\Microsoft.AspNetCore.Components.WebView.csproj", diff --git a/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.Designer.cs b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.Designer.cs new file mode 100644 index 000000000000..8760eff652f1 --- /dev/null +++ b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.Designer.cs @@ -0,0 +1,59 @@ + +namespace WinFormsTestApp +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.blazorWebView1 = new Microsoft.AspNetCore.Components.WebView.WindowsForms.BlazorWebView(); + this.SuspendLayout(); + // + // panel1 + // + this.blazorWebView1.Dock = System.Windows.Forms.DockStyle.Fill; + this.blazorWebView1.Location = new System.Drawing.Point(0, 0); + this.blazorWebView1.Name = "blazorWebView1"; + this.blazorWebView1.Size = new System.Drawing.Size(1024, 768); + this.blazorWebView1.TabIndex = 0; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 18F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1024, 768); + this.Controls.Add(this.blazorWebView1); + this.Name = "Form1"; + this.Text = "Form1"; + this.ResumeLayout(false); + + } + + #endregion + + private Microsoft.AspNetCore.Components.WebView.WindowsForms.BlazorWebView blazorWebView1; + } +} diff --git a/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.cs b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.cs new file mode 100644 index 000000000000..bef599065da5 --- /dev/null +++ b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.cs @@ -0,0 +1,25 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Windows.Forms; +using System.Net.Http; +using Microsoft.AspNetCore.Components.WebView.WindowsForms; +using Microsoft.Extensions.DependencyInjection; + +namespace WinFormsTestApp +{ + public partial class Form1 : Form + { + public Form1() + { + var serviceCollection = new ServiceCollection(); + serviceCollection.AddBlazorWebView(); + serviceCollection.AddSingleton(); + InitializeComponent(); + + blazorWebView1.HostPage = @"wwwroot\webviewhost.html"; + blazorWebView1.Services = serviceCollection.BuildServiceProvider(); + blazorWebView1.RootComponents.Add("root"); + } + } +} diff --git a/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Program.cs b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Program.cs new file mode 100644 index 000000000000..470004c189ae --- /dev/null +++ b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Program.cs @@ -0,0 +1,28 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Windows.Forms; + +namespace WinFormsTestApp +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + AppDomain.CurrentDomain.UnhandledException += (sender, error) => + { + MessageBox.Show(text: error.ExceptionObject.ToString(), caption: "Error"); + }; + + Application.SetHighDpiMode(HighDpiMode.SystemAware); + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/WinFormsTestApp.csproj b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/WinFormsTestApp.csproj new file mode 100644 index 000000000000..bc3fb94fc15e --- /dev/null +++ b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/WinFormsTestApp.csproj @@ -0,0 +1,24 @@ + + + + $(DefaultNetCoreTargetFramework)-windows + WinExe + true + false + + + + + + + + + + + + + PreserveNewest + + + + diff --git a/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/wwwroot/css/app.css b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/wwwroot/css/app.css new file mode 100644 index 000000000000..5053cb6b080c --- /dev/null +++ b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/wwwroot/css/app.css @@ -0,0 +1,26 @@ +#blazor-error-ui { + background: lightyellow; + bottom: 0; + box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); + display: none; + left: 0; + padding: 0.6rem 1.25rem 0.7rem 1.25rem; + position: fixed; + width: 100%; + z-index: 1000; +} + +#blazor-error-ui .dismiss { + cursor: pointer; + position: absolute; + right: 0.75rem; + top: 0.5rem; +} + +.valid.modified:not([type=checkbox]) { + outline: 1px solid #26b050; +} + +.invalid { + outline: 1px solid red; +} diff --git a/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/wwwroot/webviewhost.html b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/wwwroot/webviewhost.html new file mode 100644 index 000000000000..5f746197c901 --- /dev/null +++ b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/wwwroot/webviewhost.html @@ -0,0 +1,51 @@ + + + + + + + WinFormsTestApp + + + + + + + + Loading... + + + + + + + + + + + + + + + + + + diff --git a/src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/App.xaml b/src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/App.xaml new file mode 100644 index 000000000000..cad35b7bac57 --- /dev/null +++ b/src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/App.xaml @@ -0,0 +1,10 @@ + + + + + diff --git a/src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/App.xaml.cs b/src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/App.xaml.cs new file mode 100644 index 000000000000..eac6a97a4c60 --- /dev/null +++ b/src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/App.xaml.cs @@ -0,0 +1,22 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Windows; + +namespace WpfTestApp +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + private void Application_Startup(object sender, StartupEventArgs e) + { + AppDomain.CurrentDomain.UnhandledException += (sender, error) => + { + MessageBox.Show(error.ExceptionObject.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); + }; + } + } +} diff --git a/src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/MainWindow.xaml b/src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/MainWindow.xaml new file mode 100644 index 000000000000..1b75505a67eb --- /dev/null +++ b/src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/MainWindow.xaml @@ -0,0 +1,15 @@ + + + + + + + diff --git a/src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/MainWindow.xaml.cs b/src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/MainWindow.xaml.cs new file mode 100644 index 000000000000..09b5b884d6b5 --- /dev/null +++ b/src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/MainWindow.xaml.cs @@ -0,0 +1,25 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Net.Http; +using System.Windows; +using Microsoft.Extensions.DependencyInjection; + +namespace WpfTestApp +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + var serviceCollection = new ServiceCollection(); + serviceCollection.AddBlazorWebView(); + serviceCollection.AddSingleton(); + Resources.Add("services", serviceCollection.BuildServiceProvider()); + + InitializeComponent(); + } + } +} diff --git a/src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/WpfTestApp.csproj b/src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/WpfTestApp.csproj new file mode 100644 index 000000000000..267680d6043d --- /dev/null +++ b/src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/WpfTestApp.csproj @@ -0,0 +1,24 @@ + + + + $(DefaultNetCoreTargetFramework)-windows + WinExe + true + false + + + + + + + + + + + + + PreserveNewest + + + + diff --git a/src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/wwwroot/css/app.css b/src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/wwwroot/css/app.css new file mode 100644 index 000000000000..5053cb6b080c --- /dev/null +++ b/src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/wwwroot/css/app.css @@ -0,0 +1,26 @@ +#blazor-error-ui { + background: lightyellow; + bottom: 0; + box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); + display: none; + left: 0; + padding: 0.6rem 1.25rem 0.7rem 1.25rem; + position: fixed; + width: 100%; + z-index: 1000; +} + +#blazor-error-ui .dismiss { + cursor: pointer; + position: absolute; + right: 0.75rem; + top: 0.5rem; +} + +.valid.modified:not([type=checkbox]) { + outline: 1px solid #26b050; +} + +.invalid { + outline: 1px solid red; +} diff --git a/src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/wwwroot/webviewhost.html b/src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/wwwroot/webviewhost.html new file mode 100644 index 000000000000..5f746197c901 --- /dev/null +++ b/src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/wwwroot/webviewhost.html @@ -0,0 +1,51 @@ + + + + + + + WinFormsTestApp + + + + + + + + Loading... + + + + + + + + + + + + + + + + + + diff --git a/src/Components/WebView/Samples/BlazorWinFormsApp/Form1.cs b/src/Components/WebView/Samples/BlazorWinFormsApp/Form1.cs index cdff0506fee5..5bcfe71ab7a6 100644 --- a/src/Components/WebView/Samples/BlazorWinFormsApp/Form1.cs +++ b/src/Components/WebView/Samples/BlazorWinFormsApp/Form1.cs @@ -1,10 +1,10 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.AspNetCore.Components.WebView.WindowsForms; -using Microsoft.Extensions.DependencyInjection; using System; using System.Windows.Forms; +using Microsoft.AspNetCore.Components.WebView.WindowsForms; +using Microsoft.Extensions.DependencyInjection; namespace BlazorWinFormsApp {