From 76480ff1cb27024f2beadd3725a9a12cec228e9c Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Wed, 17 Mar 2021 13:56:34 +0000 Subject: [PATCH 1/6] Begin defining WinFormsTestApp --- AspNetCore.sln | 18 +++++++++ src/Components/ComponentsNoDeps.slnf | 1 + .../WinFormsTestApp/Form1.Designer.cs | 40 +++++++++++++++++++ .../testassets/WinFormsTestApp/Form1.cs | 20 ++++++++++ .../testassets/WinFormsTestApp/Program.cs | 28 +++++++++++++ .../WinFormsTestApp/WinFormsTestApp.csproj | 20 ++++++++++ .../WinFormsTestApp/wwwroot/css/app.css | 18 +++++++++ .../WinFormsTestApp/wwwroot/index.html | 24 +++++++++++ 8 files changed, 169 insertions(+) create mode 100644 src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.Designer.cs create mode 100644 src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.cs create mode 100644 src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Program.cs create mode 100644 src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/WinFormsTestApp.csproj create mode 100644 src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/wwwroot/css/app.css create mode 100644 src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/wwwroot/index.html diff --git a/AspNetCore.sln b/AspNetCore.sln index e8dc0637471f..6b313fc6fe38 100644 --- a/AspNetCore.sln +++ b/AspNetCore.sln @@ -1618,6 +1618,10 @@ 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 Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -7653,6 +7657,18 @@ 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 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -8452,6 +8468,8 @@ 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} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3E8720B3-DBDD-498C-B383-2CC32A054E8F} diff --git a/src/Components/ComponentsNoDeps.slnf b/src/Components/ComponentsNoDeps.slnf index ebdb7e6aaaf1..4ba3b3fc069e 100644 --- a/src/Components/ComponentsNoDeps.slnf +++ b/src/Components/ComponentsNoDeps.slnf @@ -39,6 +39,7 @@ "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\\Samples\\BlazorWinFormsApp\\BlazorWinFormsApp.csproj", "src\\Components\\WebView\\Samples\\BlazorWpfApp\\BlazorWpfApp.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..0c0b426f88b4 --- /dev/null +++ b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.Designer.cs @@ -0,0 +1,40 @@ + +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.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Text = "Form1"; + } + + #endregion + } +} 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..83462581aebe --- /dev/null +++ b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace WinFormsTestApp +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + } +} 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..df7157907937 --- /dev/null +++ b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/WinFormsTestApp.csproj @@ -0,0 +1,20 @@ + + + + $(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..4f895ce71e4d --- /dev/null +++ b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/wwwroot/css/app.css @@ -0,0 +1,18 @@ +#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; +} diff --git a/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/wwwroot/index.html b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/wwwroot/index.html new file mode 100644 index 000000000000..139ae0b8ffb8 --- /dev/null +++ b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/wwwroot/index.html @@ -0,0 +1,24 @@ + + + + + + + WinFormsTestApp + + + + + +
+ +
+ An unhandled error has occurred. + Reload + 🗙 +
+ + + + + From 8a5c77f926feb9eb08806d1994762b64caddf6b6 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Wed, 17 Mar 2021 14:16:11 +0000 Subject: [PATCH 2/6] Render a Blazor component --- .../WinFormsTestApp/Form1.Designer.cs | 21 ++++++++++++++++++- .../testassets/WinFormsTestApp/Form1.cs | 16 +++++++------- .../testassets/WinFormsTestApp/Main.razor | 1 + 3 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Main.razor diff --git a/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.Designer.cs b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.Designer.cs index 0c0b426f88b4..05f757f1b2bb 100644 --- a/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.Designer.cs +++ b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.Designer.cs @@ -29,12 +29,31 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); + 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(800, 450); + this.blazorWebView1.TabIndex = 0; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(15F, 37F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); + 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 index 83462581aebe..e94193a5bc7d 100644 --- a/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.cs +++ b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.cs @@ -1,12 +1,6 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.AspNetCore.Components.WebView.WindowsForms; namespace WinFormsTestApp { @@ -14,7 +8,13 @@ public partial class Form1 : Form { public Form1() { + var serviceCollection = new ServiceCollection(); + serviceCollection.AddBlazorWebView(); InitializeComponent(); + + blazorWebView1.HostPage = @"wwwroot\index.html"; + blazorWebView1.Services = serviceCollection.BuildServiceProvider(); + blazorWebView1.RootComponents.Add
("#app"); } } } diff --git a/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Main.razor b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Main.razor new file mode 100644 index 000000000000..82f4fb53acd6 --- /dev/null +++ b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Main.razor @@ -0,0 +1 @@ +

Hello!

From 0bb757f24b6295300535576202e9c9c7606951d7 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Wed, 17 Mar 2021 14:20:37 +0000 Subject: [PATCH 3/6] Render a BasicTestApp.Index --- .../WindowsForms/testassets/WinFormsTestApp/Form1.cs | 4 ++-- .../WindowsForms/testassets/WinFormsTestApp/Main.razor | 1 - .../testassets/WinFormsTestApp/WinFormsTestApp.csproj | 6 +++++- .../wwwroot/{index.html => webviewhost.html} | 0 4 files changed, 7 insertions(+), 4 deletions(-) delete mode 100644 src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Main.razor rename src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/wwwroot/{index.html => webviewhost.html} (100%) diff --git a/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.cs b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.cs index e94193a5bc7d..5cd93b977aea 100644 --- a/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.cs +++ b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.cs @@ -12,9 +12,9 @@ public Form1() serviceCollection.AddBlazorWebView(); InitializeComponent(); - blazorWebView1.HostPage = @"wwwroot\index.html"; + blazorWebView1.HostPage = @"wwwroot\webviewhost.html"; blazorWebView1.Services = serviceCollection.BuildServiceProvider(); - blazorWebView1.RootComponents.Add
("#app"); + blazorWebView1.RootComponents.Add("#app"); } } } diff --git a/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Main.razor b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Main.razor deleted file mode 100644 index 82f4fb53acd6..000000000000 --- a/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Main.razor +++ /dev/null @@ -1 +0,0 @@ -

Hello!

diff --git a/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/WinFormsTestApp.csproj b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/WinFormsTestApp.csproj index df7157907937..bc3fb94fc15e 100644 --- a/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/WinFormsTestApp.csproj +++ b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/WinFormsTestApp.csproj @@ -1,4 +1,4 @@ - + $(DefaultNetCoreTargetFramework)-windows @@ -7,6 +7,10 @@ false + + + + diff --git a/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/wwwroot/index.html b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/wwwroot/webviewhost.html similarity index 100% rename from src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/wwwroot/index.html rename to src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/wwwroot/webviewhost.html From 9da9414721e51605435ec1b2011de5b12d5dbe74 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Wed, 17 Mar 2021 14:27:27 +0000 Subject: [PATCH 4/6] Embiggen the window --- .../testassets/WinFormsTestApp/Form1.Designer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.Designer.cs b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.Designer.cs index 05f757f1b2bb..8760eff652f1 100644 --- a/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.Designer.cs +++ b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.Designer.cs @@ -37,14 +37,14 @@ private void InitializeComponent() 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(800, 450); + this.blazorWebView1.Size = new System.Drawing.Size(1024, 768); this.blazorWebView1.TabIndex = 0; // // Form1 // - this.AutoScaleDimensions = new System.Drawing.SizeF(15F, 37F); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 18F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); + this.ClientSize = new System.Drawing.Size(1024, 768); this.Controls.Add(this.blazorWebView1); this.Name = "Form1"; this.Text = "Form1"; From 0282f36d126bf1fd51d1d109c9fb54d00b22921b Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Thu, 18 Mar 2021 12:04:52 +0000 Subject: [PATCH 5/6] Minor tweaks to make more of the E2E test cases run properly --- .../testassets/WinFormsTestApp/Form1.cs | 9 +++-- .../WinFormsTestApp/wwwroot/css/app.css | 10 +++++- .../WinFormsTestApp/wwwroot/webviewhost.html | 35 ++++++++++++++++--- .../Samples/BlazorWinFormsApp/Form1.cs | 4 +-- 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.cs b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.cs index 5cd93b977aea..bef599065da5 100644 --- a/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.cs +++ b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/Form1.cs @@ -1,6 +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 System.Windows.Forms; -using Microsoft.Extensions.DependencyInjection; +using System.Net.Http; using Microsoft.AspNetCore.Components.WebView.WindowsForms; +using Microsoft.Extensions.DependencyInjection; namespace WinFormsTestApp { @@ -10,11 +14,12 @@ public Form1() { var serviceCollection = new ServiceCollection(); serviceCollection.AddBlazorWebView(); + serviceCollection.AddSingleton(); InitializeComponent(); blazorWebView1.HostPage = @"wwwroot\webviewhost.html"; blazorWebView1.Services = serviceCollection.BuildServiceProvider(); - blazorWebView1.RootComponents.Add("#app"); + blazorWebView1.RootComponents.Add("root"); } } } 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 index 4f895ce71e4d..5053cb6b080c 100644 --- a/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/wwwroot/css/app.css +++ b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/wwwroot/css/app.css @@ -1,4 +1,4 @@ -#blazor-error-ui { +#blazor-error-ui { background: lightyellow; bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); @@ -16,3 +16,11 @@ 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 index 139ae0b8ffb8..5f746197c901 100644 --- a/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/wwwroot/webviewhost.html +++ b/src/Components/WebView/Platforms/WindowsForms/testassets/WinFormsTestApp/wwwroot/webviewhost.html @@ -10,15 +10,42 @@ -
+ -
+ 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 { From 9eff7c8bab788f4aa80ae52ddbf83e26435f6ac0 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Thu, 18 Mar 2021 12:15:02 +0000 Subject: [PATCH 6/6] WPF version of test app --- AspNetCore.sln | 18 +++++++ src/Components/ComponentsNoDeps.slnf | 1 + .../Wpf/testassets/WpfTestApp/App.xaml | 10 ++++ .../Wpf/testassets/WpfTestApp/App.xaml.cs | 22 ++++++++ .../Wpf/testassets/WpfTestApp/MainWindow.xaml | 15 ++++++ .../testassets/WpfTestApp/MainWindow.xaml.cs | 25 +++++++++ .../testassets/WpfTestApp/WpfTestApp.csproj | 24 +++++++++ .../testassets/WpfTestApp/wwwroot/css/app.css | 26 ++++++++++ .../WpfTestApp/wwwroot/webviewhost.html | 51 +++++++++++++++++++ 9 files changed, 192 insertions(+) create mode 100644 src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/App.xaml create mode 100644 src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/App.xaml.cs create mode 100644 src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/MainWindow.xaml create mode 100644 src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/MainWindow.xaml.cs create mode 100644 src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/WpfTestApp.csproj create mode 100644 src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/wwwroot/css/app.css create mode 100644 src/Components/WebView/Platforms/Wpf/testassets/WpfTestApp/wwwroot/webviewhost.html diff --git a/AspNetCore.sln b/AspNetCore.sln index 6b313fc6fe38..28f62ede717c 100644 --- a/AspNetCore.sln +++ b/AspNetCore.sln @@ -1622,6 +1622,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "testassets", "testassets", 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 @@ -7669,6 +7673,18 @@ Global {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 @@ -8470,6 +8486,8 @@ Global {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 4ba3b3fc069e..81037f138f3b 100644 --- a/src/Components/ComponentsNoDeps.slnf +++ b/src/Components/ComponentsNoDeps.slnf @@ -41,6 +41,7 @@ "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/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... + + + + + + + + + + + + + + + + + +