Microsoft.Toolkit.Win32/Microsoft.Toolkit.Forms.UI..../WebView.Init.cs

222 строки
9.1 KiB
C#
Исходник Обычный вид История

2019-02-23 02:50:03 +03:00
// 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.
2018-05-31 21:05:03 +03:00
using System;
using System.ComponentModel;
Add Xaml Islands Xaml Wrappers Preview (#2432) * Folded the latest work into the CTK. This includes wrappers for MediaPlayerElement, InkCanvas, and InkToolbar. There's also a new Samples app called TestSample (for the time being). In order to accomplish this, the projects in the Win32 sln needed to be updated to .NET 4.7.2 and SDK 17686. * Added WPF MapControl wrapper. * Initial WPF wraps for SwapChainPanel & WebView. * refactors setter implementation for consistency. Fixes some missing event handlers in WebView (Lite). * Minimally working demos of InkToolbar with InkToolBarCustomToolButton as a wrapped child control. Not quite happy with this implementation, but wanted to bounce it off the team. * Sets the appropriate type on the Wrapper attached property * 95% code-generated wrappers (minor post-process touchups only) * Fixes the binding issue on MediaPlayer property for one-way binding. * Refactored events to use a dynamic wrapper for event args. * Updates events to pattern that works, requiring event args wrappers. (thus adding 25 event args wrappers) and an additional control wrapper. * WIP: Refactoring WebView for fallback behavior. * Committing this so I can test another branch. * Restoring samples for Ink, Mediaplayer, et al. * Checkpointing * InkPresenter's pretty well fleshed out. * Fixes compile issue. * Pulled back on winmd ref changes. * Map control is in the sample project now, and doesn't die, but doesn't show a map yet, either. * looking into binding issues with the map control, but not convinced that's the issue. * Added SwapChainPanel to sample * Fixes references so that Debug & Release both build * Attempts to apply dpi fixes to test sample project. Also fixes implementation selection condition for WebViewCompatible. * Updates required after merge. * Removed SwapChainPanel, MapControl, and hopefully extraneous InkPresenter code. * Revert "Removed SwapChainPanel, MapControl, and hopefully extraneous InkPresenter code." This reverts commit 5f977c3fddad1d5bb2d72b367157892982e9c033. * Ran UpdateHeaders.bat * Experimentation with full control set. * Restored to .NET 4.6.2 * Removed SecurityCriticalAttribute from class, not needed. * Fixed a naming issue that surfaced in review. * Got rid of the ".Compatible" namespace for the WebViewCompatible control. * renamed Microsoft.Windows.Interop to Microsoft.Toolkit.Win32.UI.Interop. Convertet project to enable pack * Regenerated wrappers including basic redirect pointers for documentation. Included a few more wrappers and enums to simplify and reduce need for WinMD. * split up Microsoft.Toolkit.Win32.UI.Controls in WPF and WinForms binaries sharing common code * Fix references - Add missing project references - Use Windows.winmd set by Directory.Build - Convert GAC references to NuGet packages * updated headers * Worked in the latest WindowsXamlHost / WindowsXamlHostBase (with a local extension to enable needed functionality). * More properly integrates Interop.WPF code, extending WindowsXamlHostBase to sort out differences. * Fixing some sample project breakages in an earlier brancrh to prove out the branch. * Splitting WindowsXamlHost off to WPF & WinForms. This is the WPF path. * Pulls in Interop.WinForms. * Moves wpf shared code in by link. * Set IsFullscreenButtonVisibile = false in MediaPlayerElement since it's not supported. * Moved the sample app to a more appropriate namespace / assembly name in prep for importing WinForms sample. Also hammered out WebViewCompatible. * Getting the WinForms Sample app in. * Ran UpdateHeaders.bat * Updated to use latest SDK (17713) via Directory.Build.props file. * Making sure the samples uses Directory.Build.props target platform version. * Got the WebViewCompatible partially operable. * Almost there, checkpointing for a pull from rimuri/xaml-islands_more-fixes. * StyleCop fixes for Microsoft.Toolkit.Win32.UI.Interop.WinForms Some fixes still required for documentation and usage in some cases. * StyleCop fixes for Microsoft.Toolkit.Win32.UI.Interop.WPF * Optimize references * Fixing a comment in directory.build.props. * Fix commas in WindowsXamlHostBase.cs * Fix StyleCop issues with DependencyObjectCollection.cs * designer tweak * fixes binding on the source property. * Updated initialization of WebView in WebViewCompatibilityAdapter. * Working out stylecop errors. * Refactored to get rid of Windows dependency creeping out of WindowsXamlHostBase. * fixed up release build configuration * reverted tpm for all projects * Set docking state before EndInit Asynchronous initialization occurs after calling EndInit. To prevent multiple paints when the control is resized during initialization, move the dock style prior to EndInit to ensure the target HWND RECT. * Correct order of members * Implement IDisposable WebView is disposable. Making WebViewCompatibilityAdapter disposable and dispose of WebView * DRY out WinRT type detection WebViewCompatible duplicated WinMD metadata detection * Correct order of members * Correct issues with merge * Add missing file headers * Remove redundant `partial` keyword * Remove default type of int for enum `int` is already governing type for an enum * Remove `global::` prefix for WinRT types The ability to access a member in the global namespace is useful when a member might be hidden by another entity of the same name. Example ``` class Foo { public class System { } const int Console = 0; static void Main() { Console.WriteLine("Bar"); } } ``` The `Console.WriteLine` throws an error because it accesses Foo.Console, which is a constant. Using `System.Console` does no better, since it accesses `Foo.System` class, which does not have a static `WriteLine` method. The only way to get it to compile is to use `global::System.Console.WriteLine("Bar")`; however, it is not required in these instances. * ThreadStaticAttribute does not do anything for instance members * Move WinRT interop files to proper namespace Follows convention used by WebView * Clean up InkCanvas - Remove `this` - Use `inheritdoc` for documentation generation - Remove unused using statement * Clean up InkToolbar.cs - Remove unused using - Remove `this` * Clean up InkToolbarCustomPenButton.cs - Remove `this` * Clean up InkToolbarCustomToolButton.cs - Remove unused usings - Remove `this` - Remove `global::` alias * Clean up InkToolbarIsStencilButtonCheckChangedEventArgs.cs - Remove unused usings - Simplify names - Fix property `StencilKind` to use interop type instead of WinRT * Clean up InkToolbarMenuButton.cs - Remove unused using - Remove `this` - Remove cast to int on `MenuKind`. Enum is already int, so no need to cast then cast to enum. * Clean up InkToolbarPenButton.cs - Remove unused using - Remove `this` * Clean up InkToolbarStencilButton.cs - Remove unused usings - Remove `this` - Remove `global::` in most places - Convert `Ruler` to expression bodied member * Clean up InkToolbarToggleButton.cs - Remove unused usings - Remove `this` - Convert `ToggleKind` to expression body, remove unnecessary cast to int - Remove `global::` in most places * Clean up InkToolbarToolButton.cs - Remove unused usings - Remove `this` - Remove most instances of `global::` - Convert `ToolKind` to expression body, remove unnecessary cast to int * Clean up BindingBase.cs - Remove `this` * Clean up BindingExpression.cs - Remove `this` * Clean up BringIntoViewOptions.cs - Remove `this` * Clean up Brush.cs - Remove `this` - Left review comments for uncaught NRE * Clean up BrushTransition.cs - Remove `this` * Clean up MediaPlayerElement.cs - Remove unused usings - Remove `this` * Leave review comment in MediaSourceConverter.cs * Remove `Support` folder Contents moved to WinRT/Interop folder * Clean up WindowsXamlHostBaseExt.cs - Add inheritdoc for documentation - Remove `this` * Clean up IWebViewCompatible.cs - Remove unused using - Group members (all properties, methods, events, etc. together) * Clean up WebBaseCompatabilityAdapter.cs - Group members * Provide Web adapters correct implementation for IDispose pattern * Clean up WebBrowserCompatabilityAdapter.cs - Implement proper IDisposable - Add null checks prior to operations to avoid ObjectDisposeException or NullRefrenceException * Clean up WebViewCompatabilityAdapter.cs - Add null checks for operations to avoid unhandled NRE * Work in progress * Fixing a merge error. * updated folder names and updated toolbox xml file * Add app.config/app.manifest to WinForms sample app Required to support high DPI * added visualstudiotoolsmanidest.xml to nuget package * WIP while updating from master * Designer now allows association between ink toolbar & its canvas. * Ink canvas / toolbar updates, dug in on mediaplayerelement. * MediaPlayerElement oprational to the same level of functionality as WPF edition. * Project rename fix * Fixing a reference that broke in merge. * Ran UpdateHeaders.bat. * Fixed release build config. * Adding stub MDs for control documents. * Add link to ExternDll.cs * Adding md documentation for wrappers. * Remove duplicate tag from build props Move WebBrowserUriTypeConverter to shared * Adding missing task extensions for both WPF & WinForms. * Addressing a PR comment about comments. * Adding no-op Pack targets for the build. * removed samples apps from building in release mode * Tweaked docs. * Fixing TargetPlatformVersion / TargetPlatformMinVersion * WIP * Removing code from accidental commit from winforms branch. * Temp solution to InkToolbar issue. * set min target version * Resolves review issues. * Addressing PR 2299 change requests. * Cosmetic change to trigger another build to see if it overcomes the OOM error in the previous build. * updated win32 project to 17733 * updated comments * removed Shadow.cs because Windows.UI.Xaml.Media.Shadow is removed from latest insider build. Replaced WebViewControl.AddpreLoadedScript with AddInitializeScript * Clears up event handler on dispose of WidowsXamlHost. * Renaming packages in #2299 (#2420) * renamed win32 namespaces * updated vs toolbox namespaces * Update NativeDefines - Move to correct namespace - Update to use existing definitions for WM * Update Win32 code Move Win32 code into appropriate namespace. Fix issues with `NativeMethods` style classes and add documentation about when to use which and for what. * Update namespace - Remove unused namespaces - Move `using` outside of `namespace` declaration * Merge branch 'rjmurillo/XamlIslands' into rjmurillo/XamlIslands-ControlTest * Fix AssemblyInfos for XamlHosts * API feedback part 1 * API updates #2 * Code docs updates - Separate remarks into `<remarks />` tag - Link types with `<see />` tag - Fix some typos * fixed up solution and csproj * Add Windows Forms Focus workaround for RS5 * Revert "Revert "Introduction of XamlHost"" This reverts commit 52001880f0877cc283c230f3840ed69e944ebbb1. * Jimwilcox/xaml islands control test (#2431) * Folded the latest work into the CTK. This includes wrappers for MediaPlayerElement, InkCanvas, and InkToolbar. There's also a new Samples app called TestSample (for the time being). In order to accomplish this, the projects in the Win32 sln needed to be updated to .NET 4.7.2 and SDK 17686. * Added WPF MapControl wrapper. * Initial WPF wraps for SwapChainPanel & WebView. * refactors setter implementation for consistency. Fixes some missing event handlers in WebView (Lite). * Minimally working demos of InkToolbar with InkToolBarCustomToolButton as a wrapped child control. Not quite happy with this implementation, but wanted to bounce it off the team. * Sets the appropriate type on the Wrapper attached property * 95% code-generated wrappers (minor post-process touchups only) * Fixes the binding issue on MediaPlayer property for one-way binding. * Refactored events to use a dynamic wrapper for event args. * Updates events to pattern that works, requiring event args wrappers. (thus adding 25 event args wrappers) and an additional control wrapper. * WIP: Refactoring WebView for fallback behavior. * Committing this so I can test another branch. * Restoring samples for Ink, Mediaplayer, et al. * Checkpointing * InkPresenter's pretty well fleshed out. * Fixes compile issue. * Pulled back on winmd ref changes. * Map control is in the sample project now, and doesn't die, but doesn't show a map yet, either. * looking into binding issues with the map control, but not convinced that's the issue. * Added SwapChainPanel to sample * Fixes references so that Debug & Release both build * Attempts to apply dpi fixes to test sample project. Also fixes implementation selection condition for WebViewCompatible. * Updates required after merge. * Removed SwapChainPanel, MapControl, and hopefully extraneous InkPresenter code. * Revert "Removed SwapChainPanel, MapControl, and hopefully extraneous InkPresenter code." This reverts commit 5f977c3fddad1d5bb2d72b367157892982e9c033. * Ran UpdateHeaders.bat * Experimentation with full control set. * Restored to .NET 4.6.2 * Removed SecurityCriticalAttribute from class, not needed. * Fixed a naming issue that surfaced in review. * Got rid of the ".Compatible" namespace for the WebViewCompatible control. * renamed Microsoft.Windows.Interop to Microsoft.Toolkit.Win32.UI.Interop. Convertet project to enable pack * Regenerated wrappers including basic redirect pointers for documentation. Included a few more wrappers and enums to simplify and reduce need for WinMD. * split up Microsoft.Toolkit.Win32.UI.Controls in WPF and WinForms binaries sharing common code * Fix references - Add missing project references - Use Windows.winmd set by Directory.Build - Convert GAC references to NuGet packages * updated headers * Worked in the latest WindowsXamlHost / WindowsXamlHostBase (with a local extension to enable needed functionality). * More properly integrates Interop.WPF code, extending WindowsXamlHostBase to sort out differences. * Fixing some sample project breakages in an earlier brancrh to prove out the branch. * Splitting WindowsXamlHost off to WPF & WinForms. This is the WPF path. * Pulls in Interop.WinForms. * Moves wpf shared code in by link. * Set IsFullscreenButtonVisibile = false in MediaPlayerElement since it's not supported. * Moved the sample app to a more appropriate namespace / assembly name in prep for importing WinForms sample. Also hammered out WebViewCompatible. * Getting the WinForms Sample app in. * Ran UpdateHeaders.bat * Updated to use latest SDK (17713) via Directory.Build.props file. * Making sure the samples uses Directory.Build.props target platform version. * Got the WebViewCompatible partially operable. * Almost there, checkpointing for a pull from rimuri/xaml-islands_more-fixes. * StyleCop fixes for Microsoft.Toolkit.Win32.UI.Interop.WinForms Some fixes still required for documentation and usage in some cases. * StyleCop fixes for Microsoft.Toolkit.Win32.UI.Interop.WPF * Optimize references * Fixing a comment in directory.build.props. * Fix commas in WindowsXamlHostBase.cs * Fix StyleCop issues with DependencyObjectCollection.cs * designer tweak * fixes binding on the source property. * Updated initialization of WebView in WebViewCompatibilityAdapter. * Working out stylecop errors. * Refactored to get rid of Windows dependency creeping out of WindowsXamlHostBase. * fixed up release build configuration * reverted tpm for all projects * Set docking state before EndInit Asynchronous initialization occurs after calling EndInit. To prevent multiple paints when the control is resized during initialization, move the dock style prior to EndInit to ensure the target HWND RECT. * Correct order of members * Implement IDisposable WebView is disposable. Making WebViewCompatibilityAdapter disposable and dispose of WebView * DRY out WinRT type detection WebViewCompatible duplicated WinMD metadata detection * Correct order of members * Correct issues with merge * Add missing file headers * Remove redundant `partial` keyword * Remove default type of int for enum `int` is already governing type for an enum * Remove `global::` prefix for WinRT types The ability to access a member in the global namespace is useful when a member might be hidden by another entity of the same name. Example ``` class Foo { public class System { } const int Console = 0; static void Main() { Console.WriteLine("Bar"); } } ``` The `Console.WriteLine` throws an error because it accesses Foo.Console, which is a constant. Using `System.Console` does no better, since it accesses `Foo.System` class, which does not have a static `WriteLine` method. The only way to get it to compile is to use `global::System.Console.WriteLine("Bar")`; however, it is not required in these instances. * ThreadStaticAttribute does not do anything for instance members * Move WinRT interop files to proper namespace Follows convention used by WebView * Clean up InkCanvas - Remove `this` - Use `inheritdoc` for documentation generation - Remove unused using statement * Clean up InkToolbar.cs - Remove unused using - Remove `this` * Clean up InkToolbarCustomPenButton.cs - Remove `this` * Clean up InkToolbarCustomToolButton.cs - Remove unused usings - Remove `this` - Remove `global::` alias * Clean up InkToolbarIsStencilButtonCheckChangedEventArgs.cs - Remove unused usings - Simplify names - Fix property `StencilKind` to use interop type instead of WinRT * Clean up InkToolbarMenuButton.cs - Remove unused using - Remove `this` - Remove cast to int on `MenuKind`. Enum is already int, so no need to cast then cast to enum. * Clean up InkToolbarPenButton.cs - Remove unused using - Remove `this` * Clean up InkToolbarStencilButton.cs - Remove unused usings - Remove `this` - Remove `global::` in most places - Convert `Ruler` to expression bodied member * Clean up InkToolbarToggleButton.cs - Remove unused usings - Remove `this` - Convert `ToggleKind` to expression body, remove unnecessary cast to int - Remove `global::` in most places * Clean up InkToolbarToolButton.cs - Remove unused usings - Remove `this` - Remove most instances of `global::` - Convert `ToolKind` to expression body, remove unnecessary cast to int * Clean up BindingBase.cs - Remove `this` * Clean up BindingExpression.cs - Remove `this` * Clean up BringIntoViewOptions.cs - Remove `this` * Clean up Brush.cs - Remove `this` - Left review comments for uncaught NRE * Clean up BrushTransition.cs - Remove `this` * Clean up MediaPlayerElement.cs - Remove unused usings - Remove `this` * Leave review comment in MediaSourceConverter.cs * Remove `Support` folder Contents moved to WinRT/Interop folder * Clean up WindowsXamlHostBaseExt.cs - Add inheritdoc for documentation - Remove `this` * Clean up IWebViewCompatible.cs - Remove unused using - Group members (all properties, methods, events, etc. together) * Clean up WebBaseCompatabilityAdapter.cs - Group members * Provide Web adapters correct implementation for IDispose pattern * Clean up WebBrowserCompatabilityAdapter.cs - Implement proper IDisposable - Add null checks prior to operations to avoid ObjectDisposeException or NullRefrenceException * Clean up WebViewCompatabilityAdapter.cs - Add null checks for operations to avoid unhandled NRE * Work in progress * Fixing a merge error. * updated folder names and updated toolbox xml file * Add app.config/app.manifest to WinForms sample app Required to support high DPI * added visualstudiotoolsmanidest.xml to nuget package * WIP while updating from master * Designer now allows association between ink toolbar & its canvas. * Ink canvas / toolbar updates, dug in on mediaplayerelement. * MediaPlayerElement oprational to the same level of functionality as WPF edition. * Project rename fix * Fixing a reference that broke in merge. * Ran UpdateHeaders.bat. * Fixed release build config. * Adding stub MDs for control documents. * Add link to ExternDll.cs * Adding md documentation for wrappers. * Remove duplicate tag from build props Move WebBrowserUriTypeConverter to shared * Adding missing task extensions for both WPF & WinForms. * Addressing a PR comment about comments. * Adding no-op Pack targets for the build. * removed samples apps from building in release mode * Tweaked docs. * Fixing TargetPlatformVersion / TargetPlatformMinVersion * WIP * Removing code from accidental commit from winforms branch. * Temp solution to InkToolbar issue. * set min target version * Resolves review issues. * Addressing PR 2299 change requests. * Cosmetic change to trigger another build to see if it overcomes the OOM error in the previous build. * updated win32 project to 17733 * updated comments * removed Shadow.cs because Windows.UI.Xaml.Media.Shadow is removed from latest insider build. Replaced WebViewControl.AddpreLoadedScript with AddInitializeScript * Clears up event handler on dispose of WidowsXamlHost. * Renaming packages in #2299 (#2420) * renamed win32 namespaces * updated vs toolbox namespaces * Fix for local build for PR #2490 merged into #2299. * Added missing projects to Release Build config. * Revert "Fix for local build for PR #2490 merged into #2299." This reverts commit d9202e06206de69092ef0ca7a007e6d92577bac6. * Update NativeDefines - Move to correct namespace - Update to use existing definitions for WM * Update Win32 code Move Win32 code into appropriate namespace. Fix issues with `NativeMethods` style classes and add documentation about when to use which and for what. * Update namespace - Remove unused namespaces - Move `using` outside of `namespace` declaration * Merge branch 'rjmurillo/XamlIslands' into rjmurillo/XamlIslands-ControlTest * Fix AssemblyInfos for XamlHosts * API feedback part 1 * API updates #2 * Code docs updates - Separate remarks into `<remarks />` tag - Link types with `<see />` tag - Fix some typos * Changed the way SetContent works in WindowsXamlHostBase so that it doesn't expose Windows.winmd to the client. * Code docs updates - Separate remarks into `<remarks />` tag - Link types with `<see />` tag - Fix some typos * Remove Ryland's test projects from SLN * Make NativeDefines.cs consistent New entries added that should use enum `WM` * Use `var` in WindowsXamlHostBase.KeyboardFocus.cs * Remove redundant `this` qualifier in WindowsXamlHostBase.KeyboardFocus.cs * Remove unused `using` in WindowsXamlHostBase.KeyboardFocus.cs * Fix for SA1505 * Resources designer namespace update * Prevent _xamlSource from leaking This field is only needed to surface the content through the `WindowsXamlHost.Child` property and does not otherwise need to be exposed to inherited classes when the property will suffice. To maintain the same API surface as the WPF control, a new API `SetContent` was added to take the `FrameworkElement`. The implementation of `SetContent(FrameworkElement)` is identical to `SetContent(UIElement)` other than the parameter type. CC @ryalanms * Work around CoreInputSink bug, Windows Forms Focus issue * Update SetContent method Change a6b20f57bbbe3d34b35bda5a7d2a5071b2c7a2d0 introduced a signature change * Relax WebView fail fast when setting properties in XAML Remove assert conditions for state and add comments as to what is happening and what expected behavior should be. * Fixes after pulling in code from Rebased and ControlTest branches. * Addresses items in PR #2432
2018-09-06 20:36:28 +03:00
using Microsoft.Toolkit.Win32.UI.Controls;
2018-05-31 21:05:03 +03:00
using Microsoft.Toolkit.Win32.UI.Controls.Interop;
using Microsoft.Toolkit.Win32.UI.Controls.Interop.WinRT;
using WebViewControlProcessCapabilityState = Windows.Web.UI.Interop.WebViewControlProcessCapabilityState;
Add Xaml Islands Xaml Wrappers Preview (#2432) * Folded the latest work into the CTK. This includes wrappers for MediaPlayerElement, InkCanvas, and InkToolbar. There's also a new Samples app called TestSample (for the time being). In order to accomplish this, the projects in the Win32 sln needed to be updated to .NET 4.7.2 and SDK 17686. * Added WPF MapControl wrapper. * Initial WPF wraps for SwapChainPanel & WebView. * refactors setter implementation for consistency. Fixes some missing event handlers in WebView (Lite). * Minimally working demos of InkToolbar with InkToolBarCustomToolButton as a wrapped child control. Not quite happy with this implementation, but wanted to bounce it off the team. * Sets the appropriate type on the Wrapper attached property * 95% code-generated wrappers (minor post-process touchups only) * Fixes the binding issue on MediaPlayer property for one-way binding. * Refactored events to use a dynamic wrapper for event args. * Updates events to pattern that works, requiring event args wrappers. (thus adding 25 event args wrappers) and an additional control wrapper. * WIP: Refactoring WebView for fallback behavior. * Committing this so I can test another branch. * Restoring samples for Ink, Mediaplayer, et al. * Checkpointing * InkPresenter's pretty well fleshed out. * Fixes compile issue. * Pulled back on winmd ref changes. * Map control is in the sample project now, and doesn't die, but doesn't show a map yet, either. * looking into binding issues with the map control, but not convinced that's the issue. * Added SwapChainPanel to sample * Fixes references so that Debug & Release both build * Attempts to apply dpi fixes to test sample project. Also fixes implementation selection condition for WebViewCompatible. * Updates required after merge. * Removed SwapChainPanel, MapControl, and hopefully extraneous InkPresenter code. * Revert "Removed SwapChainPanel, MapControl, and hopefully extraneous InkPresenter code." This reverts commit 5f977c3fddad1d5bb2d72b367157892982e9c033. * Ran UpdateHeaders.bat * Experimentation with full control set. * Restored to .NET 4.6.2 * Removed SecurityCriticalAttribute from class, not needed. * Fixed a naming issue that surfaced in review. * Got rid of the ".Compatible" namespace for the WebViewCompatible control. * renamed Microsoft.Windows.Interop to Microsoft.Toolkit.Win32.UI.Interop. Convertet project to enable pack * Regenerated wrappers including basic redirect pointers for documentation. Included a few more wrappers and enums to simplify and reduce need for WinMD. * split up Microsoft.Toolkit.Win32.UI.Controls in WPF and WinForms binaries sharing common code * Fix references - Add missing project references - Use Windows.winmd set by Directory.Build - Convert GAC references to NuGet packages * updated headers * Worked in the latest WindowsXamlHost / WindowsXamlHostBase (with a local extension to enable needed functionality). * More properly integrates Interop.WPF code, extending WindowsXamlHostBase to sort out differences. * Fixing some sample project breakages in an earlier brancrh to prove out the branch. * Splitting WindowsXamlHost off to WPF & WinForms. This is the WPF path. * Pulls in Interop.WinForms. * Moves wpf shared code in by link. * Set IsFullscreenButtonVisibile = false in MediaPlayerElement since it's not supported. * Moved the sample app to a more appropriate namespace / assembly name in prep for importing WinForms sample. Also hammered out WebViewCompatible. * Getting the WinForms Sample app in. * Ran UpdateHeaders.bat * Updated to use latest SDK (17713) via Directory.Build.props file. * Making sure the samples uses Directory.Build.props target platform version. * Got the WebViewCompatible partially operable. * Almost there, checkpointing for a pull from rimuri/xaml-islands_more-fixes. * StyleCop fixes for Microsoft.Toolkit.Win32.UI.Interop.WinForms Some fixes still required for documentation and usage in some cases. * StyleCop fixes for Microsoft.Toolkit.Win32.UI.Interop.WPF * Optimize references * Fixing a comment in directory.build.props. * Fix commas in WindowsXamlHostBase.cs * Fix StyleCop issues with DependencyObjectCollection.cs * designer tweak * fixes binding on the source property. * Updated initialization of WebView in WebViewCompatibilityAdapter. * Working out stylecop errors. * Refactored to get rid of Windows dependency creeping out of WindowsXamlHostBase. * fixed up release build configuration * reverted tpm for all projects * Set docking state before EndInit Asynchronous initialization occurs after calling EndInit. To prevent multiple paints when the control is resized during initialization, move the dock style prior to EndInit to ensure the target HWND RECT. * Correct order of members * Implement IDisposable WebView is disposable. Making WebViewCompatibilityAdapter disposable and dispose of WebView * DRY out WinRT type detection WebViewCompatible duplicated WinMD metadata detection * Correct order of members * Correct issues with merge * Add missing file headers * Remove redundant `partial` keyword * Remove default type of int for enum `int` is already governing type for an enum * Remove `global::` prefix for WinRT types The ability to access a member in the global namespace is useful when a member might be hidden by another entity of the same name. Example ``` class Foo { public class System { } const int Console = 0; static void Main() { Console.WriteLine("Bar"); } } ``` The `Console.WriteLine` throws an error because it accesses Foo.Console, which is a constant. Using `System.Console` does no better, since it accesses `Foo.System` class, which does not have a static `WriteLine` method. The only way to get it to compile is to use `global::System.Console.WriteLine("Bar")`; however, it is not required in these instances. * ThreadStaticAttribute does not do anything for instance members * Move WinRT interop files to proper namespace Follows convention used by WebView * Clean up InkCanvas - Remove `this` - Use `inheritdoc` for documentation generation - Remove unused using statement * Clean up InkToolbar.cs - Remove unused using - Remove `this` * Clean up InkToolbarCustomPenButton.cs - Remove `this` * Clean up InkToolbarCustomToolButton.cs - Remove unused usings - Remove `this` - Remove `global::` alias * Clean up InkToolbarIsStencilButtonCheckChangedEventArgs.cs - Remove unused usings - Simplify names - Fix property `StencilKind` to use interop type instead of WinRT * Clean up InkToolbarMenuButton.cs - Remove unused using - Remove `this` - Remove cast to int on `MenuKind`. Enum is already int, so no need to cast then cast to enum. * Clean up InkToolbarPenButton.cs - Remove unused using - Remove `this` * Clean up InkToolbarStencilButton.cs - Remove unused usings - Remove `this` - Remove `global::` in most places - Convert `Ruler` to expression bodied member * Clean up InkToolbarToggleButton.cs - Remove unused usings - Remove `this` - Convert `ToggleKind` to expression body, remove unnecessary cast to int - Remove `global::` in most places * Clean up InkToolbarToolButton.cs - Remove unused usings - Remove `this` - Remove most instances of `global::` - Convert `ToolKind` to expression body, remove unnecessary cast to int * Clean up BindingBase.cs - Remove `this` * Clean up BindingExpression.cs - Remove `this` * Clean up BringIntoViewOptions.cs - Remove `this` * Clean up Brush.cs - Remove `this` - Left review comments for uncaught NRE * Clean up BrushTransition.cs - Remove `this` * Clean up MediaPlayerElement.cs - Remove unused usings - Remove `this` * Leave review comment in MediaSourceConverter.cs * Remove `Support` folder Contents moved to WinRT/Interop folder * Clean up WindowsXamlHostBaseExt.cs - Add inheritdoc for documentation - Remove `this` * Clean up IWebViewCompatible.cs - Remove unused using - Group members (all properties, methods, events, etc. together) * Clean up WebBaseCompatabilityAdapter.cs - Group members * Provide Web adapters correct implementation for IDispose pattern * Clean up WebBrowserCompatabilityAdapter.cs - Implement proper IDisposable - Add null checks prior to operations to avoid ObjectDisposeException or NullRefrenceException * Clean up WebViewCompatabilityAdapter.cs - Add null checks for operations to avoid unhandled NRE * Work in progress * Fixing a merge error. * updated folder names and updated toolbox xml file * Add app.config/app.manifest to WinForms sample app Required to support high DPI * added visualstudiotoolsmanidest.xml to nuget package * WIP while updating from master * Designer now allows association between ink toolbar & its canvas. * Ink canvas / toolbar updates, dug in on mediaplayerelement. * MediaPlayerElement oprational to the same level of functionality as WPF edition. * Project rename fix * Fixing a reference that broke in merge. * Ran UpdateHeaders.bat. * Fixed release build config. * Adding stub MDs for control documents. * Add link to ExternDll.cs * Adding md documentation for wrappers. * Remove duplicate tag from build props Move WebBrowserUriTypeConverter to shared * Adding missing task extensions for both WPF & WinForms. * Addressing a PR comment about comments. * Adding no-op Pack targets for the build. * removed samples apps from building in release mode * Tweaked docs. * Fixing TargetPlatformVersion / TargetPlatformMinVersion * WIP * Removing code from accidental commit from winforms branch. * Temp solution to InkToolbar issue. * set min target version * Resolves review issues. * Addressing PR 2299 change requests. * Cosmetic change to trigger another build to see if it overcomes the OOM error in the previous build. * updated win32 project to 17733 * updated comments * removed Shadow.cs because Windows.UI.Xaml.Media.Shadow is removed from latest insider build. Replaced WebViewControl.AddpreLoadedScript with AddInitializeScript * Clears up event handler on dispose of WidowsXamlHost. * Renaming packages in #2299 (#2420) * renamed win32 namespaces * updated vs toolbox namespaces * Update NativeDefines - Move to correct namespace - Update to use existing definitions for WM * Update Win32 code Move Win32 code into appropriate namespace. Fix issues with `NativeMethods` style classes and add documentation about when to use which and for what. * Update namespace - Remove unused namespaces - Move `using` outside of `namespace` declaration * Merge branch 'rjmurillo/XamlIslands' into rjmurillo/XamlIslands-ControlTest * Fix AssemblyInfos for XamlHosts * API feedback part 1 * API updates #2 * Code docs updates - Separate remarks into `<remarks />` tag - Link types with `<see />` tag - Fix some typos * fixed up solution and csproj * Add Windows Forms Focus workaround for RS5 * Revert "Revert "Introduction of XamlHost"" This reverts commit 52001880f0877cc283c230f3840ed69e944ebbb1. * Jimwilcox/xaml islands control test (#2431) * Folded the latest work into the CTK. This includes wrappers for MediaPlayerElement, InkCanvas, and InkToolbar. There's also a new Samples app called TestSample (for the time being). In order to accomplish this, the projects in the Win32 sln needed to be updated to .NET 4.7.2 and SDK 17686. * Added WPF MapControl wrapper. * Initial WPF wraps for SwapChainPanel & WebView. * refactors setter implementation for consistency. Fixes some missing event handlers in WebView (Lite). * Minimally working demos of InkToolbar with InkToolBarCustomToolButton as a wrapped child control. Not quite happy with this implementation, but wanted to bounce it off the team. * Sets the appropriate type on the Wrapper attached property * 95% code-generated wrappers (minor post-process touchups only) * Fixes the binding issue on MediaPlayer property for one-way binding. * Refactored events to use a dynamic wrapper for event args. * Updates events to pattern that works, requiring event args wrappers. (thus adding 25 event args wrappers) and an additional control wrapper. * WIP: Refactoring WebView for fallback behavior. * Committing this so I can test another branch. * Restoring samples for Ink, Mediaplayer, et al. * Checkpointing * InkPresenter's pretty well fleshed out. * Fixes compile issue. * Pulled back on winmd ref changes. * Map control is in the sample project now, and doesn't die, but doesn't show a map yet, either. * looking into binding issues with the map control, but not convinced that's the issue. * Added SwapChainPanel to sample * Fixes references so that Debug & Release both build * Attempts to apply dpi fixes to test sample project. Also fixes implementation selection condition for WebViewCompatible. * Updates required after merge. * Removed SwapChainPanel, MapControl, and hopefully extraneous InkPresenter code. * Revert "Removed SwapChainPanel, MapControl, and hopefully extraneous InkPresenter code." This reverts commit 5f977c3fddad1d5bb2d72b367157892982e9c033. * Ran UpdateHeaders.bat * Experimentation with full control set. * Restored to .NET 4.6.2 * Removed SecurityCriticalAttribute from class, not needed. * Fixed a naming issue that surfaced in review. * Got rid of the ".Compatible" namespace for the WebViewCompatible control. * renamed Microsoft.Windows.Interop to Microsoft.Toolkit.Win32.UI.Interop. Convertet project to enable pack * Regenerated wrappers including basic redirect pointers for documentation. Included a few more wrappers and enums to simplify and reduce need for WinMD. * split up Microsoft.Toolkit.Win32.UI.Controls in WPF and WinForms binaries sharing common code * Fix references - Add missing project references - Use Windows.winmd set by Directory.Build - Convert GAC references to NuGet packages * updated headers * Worked in the latest WindowsXamlHost / WindowsXamlHostBase (with a local extension to enable needed functionality). * More properly integrates Interop.WPF code, extending WindowsXamlHostBase to sort out differences. * Fixing some sample project breakages in an earlier brancrh to prove out the branch. * Splitting WindowsXamlHost off to WPF & WinForms. This is the WPF path. * Pulls in Interop.WinForms. * Moves wpf shared code in by link. * Set IsFullscreenButtonVisibile = false in MediaPlayerElement since it's not supported. * Moved the sample app to a more appropriate namespace / assembly name in prep for importing WinForms sample. Also hammered out WebViewCompatible. * Getting the WinForms Sample app in. * Ran UpdateHeaders.bat * Updated to use latest SDK (17713) via Directory.Build.props file. * Making sure the samples uses Directory.Build.props target platform version. * Got the WebViewCompatible partially operable. * Almost there, checkpointing for a pull from rimuri/xaml-islands_more-fixes. * StyleCop fixes for Microsoft.Toolkit.Win32.UI.Interop.WinForms Some fixes still required for documentation and usage in some cases. * StyleCop fixes for Microsoft.Toolkit.Win32.UI.Interop.WPF * Optimize references * Fixing a comment in directory.build.props. * Fix commas in WindowsXamlHostBase.cs * Fix StyleCop issues with DependencyObjectCollection.cs * designer tweak * fixes binding on the source property. * Updated initialization of WebView in WebViewCompatibilityAdapter. * Working out stylecop errors. * Refactored to get rid of Windows dependency creeping out of WindowsXamlHostBase. * fixed up release build configuration * reverted tpm for all projects * Set docking state before EndInit Asynchronous initialization occurs after calling EndInit. To prevent multiple paints when the control is resized during initialization, move the dock style prior to EndInit to ensure the target HWND RECT. * Correct order of members * Implement IDisposable WebView is disposable. Making WebViewCompatibilityAdapter disposable and dispose of WebView * DRY out WinRT type detection WebViewCompatible duplicated WinMD metadata detection * Correct order of members * Correct issues with merge * Add missing file headers * Remove redundant `partial` keyword * Remove default type of int for enum `int` is already governing type for an enum * Remove `global::` prefix for WinRT types The ability to access a member in the global namespace is useful when a member might be hidden by another entity of the same name. Example ``` class Foo { public class System { } const int Console = 0; static void Main() { Console.WriteLine("Bar"); } } ``` The `Console.WriteLine` throws an error because it accesses Foo.Console, which is a constant. Using `System.Console` does no better, since it accesses `Foo.System` class, which does not have a static `WriteLine` method. The only way to get it to compile is to use `global::System.Console.WriteLine("Bar")`; however, it is not required in these instances. * ThreadStaticAttribute does not do anything for instance members * Move WinRT interop files to proper namespace Follows convention used by WebView * Clean up InkCanvas - Remove `this` - Use `inheritdoc` for documentation generation - Remove unused using statement * Clean up InkToolbar.cs - Remove unused using - Remove `this` * Clean up InkToolbarCustomPenButton.cs - Remove `this` * Clean up InkToolbarCustomToolButton.cs - Remove unused usings - Remove `this` - Remove `global::` alias * Clean up InkToolbarIsStencilButtonCheckChangedEventArgs.cs - Remove unused usings - Simplify names - Fix property `StencilKind` to use interop type instead of WinRT * Clean up InkToolbarMenuButton.cs - Remove unused using - Remove `this` - Remove cast to int on `MenuKind`. Enum is already int, so no need to cast then cast to enum. * Clean up InkToolbarPenButton.cs - Remove unused using - Remove `this` * Clean up InkToolbarStencilButton.cs - Remove unused usings - Remove `this` - Remove `global::` in most places - Convert `Ruler` to expression bodied member * Clean up InkToolbarToggleButton.cs - Remove unused usings - Remove `this` - Convert `ToggleKind` to expression body, remove unnecessary cast to int - Remove `global::` in most places * Clean up InkToolbarToolButton.cs - Remove unused usings - Remove `this` - Remove most instances of `global::` - Convert `ToolKind` to expression body, remove unnecessary cast to int * Clean up BindingBase.cs - Remove `this` * Clean up BindingExpression.cs - Remove `this` * Clean up BringIntoViewOptions.cs - Remove `this` * Clean up Brush.cs - Remove `this` - Left review comments for uncaught NRE * Clean up BrushTransition.cs - Remove `this` * Clean up MediaPlayerElement.cs - Remove unused usings - Remove `this` * Leave review comment in MediaSourceConverter.cs * Remove `Support` folder Contents moved to WinRT/Interop folder * Clean up WindowsXamlHostBaseExt.cs - Add inheritdoc for documentation - Remove `this` * Clean up IWebViewCompatible.cs - Remove unused using - Group members (all properties, methods, events, etc. together) * Clean up WebBaseCompatabilityAdapter.cs - Group members * Provide Web adapters correct implementation for IDispose pattern * Clean up WebBrowserCompatabilityAdapter.cs - Implement proper IDisposable - Add null checks prior to operations to avoid ObjectDisposeException or NullRefrenceException * Clean up WebViewCompatabilityAdapter.cs - Add null checks for operations to avoid unhandled NRE * Work in progress * Fixing a merge error. * updated folder names and updated toolbox xml file * Add app.config/app.manifest to WinForms sample app Required to support high DPI * added visualstudiotoolsmanidest.xml to nuget package * WIP while updating from master * Designer now allows association between ink toolbar & its canvas. * Ink canvas / toolbar updates, dug in on mediaplayerelement. * MediaPlayerElement oprational to the same level of functionality as WPF edition. * Project rename fix * Fixing a reference that broke in merge. * Ran UpdateHeaders.bat. * Fixed release build config. * Adding stub MDs for control documents. * Add link to ExternDll.cs * Adding md documentation for wrappers. * Remove duplicate tag from build props Move WebBrowserUriTypeConverter to shared * Adding missing task extensions for both WPF & WinForms. * Addressing a PR comment about comments. * Adding no-op Pack targets for the build. * removed samples apps from building in release mode * Tweaked docs. * Fixing TargetPlatformVersion / TargetPlatformMinVersion * WIP * Removing code from accidental commit from winforms branch. * Temp solution to InkToolbar issue. * set min target version * Resolves review issues. * Addressing PR 2299 change requests. * Cosmetic change to trigger another build to see if it overcomes the OOM error in the previous build. * updated win32 project to 17733 * updated comments * removed Shadow.cs because Windows.UI.Xaml.Media.Shadow is removed from latest insider build. Replaced WebViewControl.AddpreLoadedScript with AddInitializeScript * Clears up event handler on dispose of WidowsXamlHost. * Renaming packages in #2299 (#2420) * renamed win32 namespaces * updated vs toolbox namespaces * Fix for local build for PR #2490 merged into #2299. * Added missing projects to Release Build config. * Revert "Fix for local build for PR #2490 merged into #2299." This reverts commit d9202e06206de69092ef0ca7a007e6d92577bac6. * Update NativeDefines - Move to correct namespace - Update to use existing definitions for WM * Update Win32 code Move Win32 code into appropriate namespace. Fix issues with `NativeMethods` style classes and add documentation about when to use which and for what. * Update namespace - Remove unused namespaces - Move `using` outside of `namespace` declaration * Merge branch 'rjmurillo/XamlIslands' into rjmurillo/XamlIslands-ControlTest * Fix AssemblyInfos for XamlHosts * API feedback part 1 * API updates #2 * Code docs updates - Separate remarks into `<remarks />` tag - Link types with `<see />` tag - Fix some typos * Changed the way SetContent works in WindowsXamlHostBase so that it doesn't expose Windows.winmd to the client. * Code docs updates - Separate remarks into `<remarks />` tag - Link types with `<see />` tag - Fix some typos * Remove Ryland's test projects from SLN * Make NativeDefines.cs consistent New entries added that should use enum `WM` * Use `var` in WindowsXamlHostBase.KeyboardFocus.cs * Remove redundant `this` qualifier in WindowsXamlHostBase.KeyboardFocus.cs * Remove unused `using` in WindowsXamlHostBase.KeyboardFocus.cs * Fix for SA1505 * Resources designer namespace update * Prevent _xamlSource from leaking This field is only needed to surface the content through the `WindowsXamlHost.Child` property and does not otherwise need to be exposed to inherited classes when the property will suffice. To maintain the same API surface as the WPF control, a new API `SetContent` was added to take the `FrameworkElement`. The implementation of `SetContent(FrameworkElement)` is identical to `SetContent(UIElement)` other than the parameter type. CC @ryalanms * Work around CoreInputSink bug, Windows Forms Focus issue * Update SetContent method Change a6b20f57bbbe3d34b35bda5a7d2a5071b2c7a2d0 introduced a signature change * Relax WebView fail fast when setting properties in XAML Remove assert conditions for state and add comments as to what is happening and what expected behavior should be. * Fixes after pulling in code from Rebased and ControlTest branches. * Addresses items in PR #2432
2018-09-06 20:36:28 +03:00
namespace Microsoft.Toolkit.Forms.UI.Controls
2018-05-31 21:05:03 +03:00
{
/// <inheritdoc cref="ISupportInitialize"/>
public partial class WebView : ISupportInitialize
{
// Initialization flag for ISupportInitialize
private InitializationState _initializationState;
internal WebView(WebViewControlHost webViewControl)
: this()
{
_webViewControl = webViewControl ?? throw new ArgumentNullException(nameof(webViewControl));
Process = _webViewControl.Process;
EnsureInitialized();
}
private bool Initialized => _initializationState == InitializationState.IsInitialized;
private bool Initializing => _initializationState == InitializationState.IsInitializing;
private bool WebViewControlInitialized => _webViewControl != null;
void ISupportInitialize.BeginInit()
{
if (Initialized)
{
// Cannot initialize WebView since it is already completely initialized
throw new InvalidOperationException(DesignerUI.E_WEBVIEW_ALREADY_INITIALIZED);
}
if (Initializing)
{
// Cannot initialize WebView since it is already being initialized
throw new InvalidOperationException(DesignerUI.E_WEBVIEW_ALREADY_INITIALIZING);
}
_initializationState = InitializationState.IsInitializing;
}
void ISupportInitialize.EndInit()
{
if (!Initializing)
{
// Cannot complete WebView initialization that is not being initialized
throw new InvalidOperationException(DesignerUI.E_WEBVIEW_NOT_INITIALIZING);
}
if (!DesignMode)
{
OSVersionHelper.ThrowIfBeforeWindows10April2018();
}
try
{
Initialize();
}
catch (TypeLoadException)
{
// Some types are exposed that the designer tries to reflect over, throwing TypeLoadException
// We're okay to ignore this if we're not in design mode
if (!DesignMode)
{
throw;
}
}
}
private void CheckInitialized()
{
if (!Initialized)
{
// Initialization incomplete
throw new InvalidOperationException(DesignerUI.E_WEBVIEW_NOT_INITIALIZED);
}
}
// Ensures this class is initialized. Initialization involves using ISupportInitialize methods
private void EnsureInitialized()
{
// If already disposed, do nothing
if (IsDisposed)
{
throw new ObjectDisposedException(GetType().Name);
}
// If not already initialized and not already initializing
if (!Initialized && !Initializing)
{
((ISupportInitialize)this).BeginInit();
((ISupportInitialize)this).EndInit();
}
}
private void Initialize()
{
Verify.AreEqual(_initializationState, InitializationState.IsInitializing);
// This is causing freezing
if (!DesignMode)
{
OSVersionHelper.ThrowIfBeforeWindows10April2018();
if (!WebViewControlInitialized)
{
if (Process == null)
{
// Was not injected via ctor, create using defaults
Add Xaml Islands Xaml Wrappers Preview (#2432) * Folded the latest work into the CTK. This includes wrappers for MediaPlayerElement, InkCanvas, and InkToolbar. There's also a new Samples app called TestSample (for the time being). In order to accomplish this, the projects in the Win32 sln needed to be updated to .NET 4.7.2 and SDK 17686. * Added WPF MapControl wrapper. * Initial WPF wraps for SwapChainPanel & WebView. * refactors setter implementation for consistency. Fixes some missing event handlers in WebView (Lite). * Minimally working demos of InkToolbar with InkToolBarCustomToolButton as a wrapped child control. Not quite happy with this implementation, but wanted to bounce it off the team. * Sets the appropriate type on the Wrapper attached property * 95% code-generated wrappers (minor post-process touchups only) * Fixes the binding issue on MediaPlayer property for one-way binding. * Refactored events to use a dynamic wrapper for event args. * Updates events to pattern that works, requiring event args wrappers. (thus adding 25 event args wrappers) and an additional control wrapper. * WIP: Refactoring WebView for fallback behavior. * Committing this so I can test another branch. * Restoring samples for Ink, Mediaplayer, et al. * Checkpointing * InkPresenter's pretty well fleshed out. * Fixes compile issue. * Pulled back on winmd ref changes. * Map control is in the sample project now, and doesn't die, but doesn't show a map yet, either. * looking into binding issues with the map control, but not convinced that's the issue. * Added SwapChainPanel to sample * Fixes references so that Debug & Release both build * Attempts to apply dpi fixes to test sample project. Also fixes implementation selection condition for WebViewCompatible. * Updates required after merge. * Removed SwapChainPanel, MapControl, and hopefully extraneous InkPresenter code. * Revert "Removed SwapChainPanel, MapControl, and hopefully extraneous InkPresenter code." This reverts commit 5f977c3fddad1d5bb2d72b367157892982e9c033. * Ran UpdateHeaders.bat * Experimentation with full control set. * Restored to .NET 4.6.2 * Removed SecurityCriticalAttribute from class, not needed. * Fixed a naming issue that surfaced in review. * Got rid of the ".Compatible" namespace for the WebViewCompatible control. * renamed Microsoft.Windows.Interop to Microsoft.Toolkit.Win32.UI.Interop. Convertet project to enable pack * Regenerated wrappers including basic redirect pointers for documentation. Included a few more wrappers and enums to simplify and reduce need for WinMD. * split up Microsoft.Toolkit.Win32.UI.Controls in WPF and WinForms binaries sharing common code * Fix references - Add missing project references - Use Windows.winmd set by Directory.Build - Convert GAC references to NuGet packages * updated headers * Worked in the latest WindowsXamlHost / WindowsXamlHostBase (with a local extension to enable needed functionality). * More properly integrates Interop.WPF code, extending WindowsXamlHostBase to sort out differences. * Fixing some sample project breakages in an earlier brancrh to prove out the branch. * Splitting WindowsXamlHost off to WPF & WinForms. This is the WPF path. * Pulls in Interop.WinForms. * Moves wpf shared code in by link. * Set IsFullscreenButtonVisibile = false in MediaPlayerElement since it's not supported. * Moved the sample app to a more appropriate namespace / assembly name in prep for importing WinForms sample. Also hammered out WebViewCompatible. * Getting the WinForms Sample app in. * Ran UpdateHeaders.bat * Updated to use latest SDK (17713) via Directory.Build.props file. * Making sure the samples uses Directory.Build.props target platform version. * Got the WebViewCompatible partially operable. * Almost there, checkpointing for a pull from rimuri/xaml-islands_more-fixes. * StyleCop fixes for Microsoft.Toolkit.Win32.UI.Interop.WinForms Some fixes still required for documentation and usage in some cases. * StyleCop fixes for Microsoft.Toolkit.Win32.UI.Interop.WPF * Optimize references * Fixing a comment in directory.build.props. * Fix commas in WindowsXamlHostBase.cs * Fix StyleCop issues with DependencyObjectCollection.cs * designer tweak * fixes binding on the source property. * Updated initialization of WebView in WebViewCompatibilityAdapter. * Working out stylecop errors. * Refactored to get rid of Windows dependency creeping out of WindowsXamlHostBase. * fixed up release build configuration * reverted tpm for all projects * Set docking state before EndInit Asynchronous initialization occurs after calling EndInit. To prevent multiple paints when the control is resized during initialization, move the dock style prior to EndInit to ensure the target HWND RECT. * Correct order of members * Implement IDisposable WebView is disposable. Making WebViewCompatibilityAdapter disposable and dispose of WebView * DRY out WinRT type detection WebViewCompatible duplicated WinMD metadata detection * Correct order of members * Correct issues with merge * Add missing file headers * Remove redundant `partial` keyword * Remove default type of int for enum `int` is already governing type for an enum * Remove `global::` prefix for WinRT types The ability to access a member in the global namespace is useful when a member might be hidden by another entity of the same name. Example ``` class Foo { public class System { } const int Console = 0; static void Main() { Console.WriteLine("Bar"); } } ``` The `Console.WriteLine` throws an error because it accesses Foo.Console, which is a constant. Using `System.Console` does no better, since it accesses `Foo.System` class, which does not have a static `WriteLine` method. The only way to get it to compile is to use `global::System.Console.WriteLine("Bar")`; however, it is not required in these instances. * ThreadStaticAttribute does not do anything for instance members * Move WinRT interop files to proper namespace Follows convention used by WebView * Clean up InkCanvas - Remove `this` - Use `inheritdoc` for documentation generation - Remove unused using statement * Clean up InkToolbar.cs - Remove unused using - Remove `this` * Clean up InkToolbarCustomPenButton.cs - Remove `this` * Clean up InkToolbarCustomToolButton.cs - Remove unused usings - Remove `this` - Remove `global::` alias * Clean up InkToolbarIsStencilButtonCheckChangedEventArgs.cs - Remove unused usings - Simplify names - Fix property `StencilKind` to use interop type instead of WinRT * Clean up InkToolbarMenuButton.cs - Remove unused using - Remove `this` - Remove cast to int on `MenuKind`. Enum is already int, so no need to cast then cast to enum. * Clean up InkToolbarPenButton.cs - Remove unused using - Remove `this` * Clean up InkToolbarStencilButton.cs - Remove unused usings - Remove `this` - Remove `global::` in most places - Convert `Ruler` to expression bodied member * Clean up InkToolbarToggleButton.cs - Remove unused usings - Remove `this` - Convert `ToggleKind` to expression body, remove unnecessary cast to int - Remove `global::` in most places * Clean up InkToolbarToolButton.cs - Remove unused usings - Remove `this` - Remove most instances of `global::` - Convert `ToolKind` to expression body, remove unnecessary cast to int * Clean up BindingBase.cs - Remove `this` * Clean up BindingExpression.cs - Remove `this` * Clean up BringIntoViewOptions.cs - Remove `this` * Clean up Brush.cs - Remove `this` - Left review comments for uncaught NRE * Clean up BrushTransition.cs - Remove `this` * Clean up MediaPlayerElement.cs - Remove unused usings - Remove `this` * Leave review comment in MediaSourceConverter.cs * Remove `Support` folder Contents moved to WinRT/Interop folder * Clean up WindowsXamlHostBaseExt.cs - Add inheritdoc for documentation - Remove `this` * Clean up IWebViewCompatible.cs - Remove unused using - Group members (all properties, methods, events, etc. together) * Clean up WebBaseCompatabilityAdapter.cs - Group members * Provide Web adapters correct implementation for IDispose pattern * Clean up WebBrowserCompatabilityAdapter.cs - Implement proper IDisposable - Add null checks prior to operations to avoid ObjectDisposeException or NullRefrenceException * Clean up WebViewCompatabilityAdapter.cs - Add null checks for operations to avoid unhandled NRE * Work in progress * Fixing a merge error. * updated folder names and updated toolbox xml file * Add app.config/app.manifest to WinForms sample app Required to support high DPI * added visualstudiotoolsmanidest.xml to nuget package * WIP while updating from master * Designer now allows association between ink toolbar & its canvas. * Ink canvas / toolbar updates, dug in on mediaplayerelement. * MediaPlayerElement oprational to the same level of functionality as WPF edition. * Project rename fix * Fixing a reference that broke in merge. * Ran UpdateHeaders.bat. * Fixed release build config. * Adding stub MDs for control documents. * Add link to ExternDll.cs * Adding md documentation for wrappers. * Remove duplicate tag from build props Move WebBrowserUriTypeConverter to shared * Adding missing task extensions for both WPF & WinForms. * Addressing a PR comment about comments. * Adding no-op Pack targets for the build. * removed samples apps from building in release mode * Tweaked docs. * Fixing TargetPlatformVersion / TargetPlatformMinVersion * WIP * Removing code from accidental commit from winforms branch. * Temp solution to InkToolbar issue. * set min target version * Resolves review issues. * Addressing PR 2299 change requests. * Cosmetic change to trigger another build to see if it overcomes the OOM error in the previous build. * updated win32 project to 17733 * updated comments * removed Shadow.cs because Windows.UI.Xaml.Media.Shadow is removed from latest insider build. Replaced WebViewControl.AddpreLoadedScript with AddInitializeScript * Clears up event handler on dispose of WidowsXamlHost. * Renaming packages in #2299 (#2420) * renamed win32 namespaces * updated vs toolbox namespaces * Update NativeDefines - Move to correct namespace - Update to use existing definitions for WM * Update Win32 code Move Win32 code into appropriate namespace. Fix issues with `NativeMethods` style classes and add documentation about when to use which and for what. * Update namespace - Remove unused namespaces - Move `using` outside of `namespace` declaration * Merge branch 'rjmurillo/XamlIslands' into rjmurillo/XamlIslands-ControlTest * Fix AssemblyInfos for XamlHosts * API feedback part 1 * API updates #2 * Code docs updates - Separate remarks into `<remarks />` tag - Link types with `<see />` tag - Fix some typos * fixed up solution and csproj * Add Windows Forms Focus workaround for RS5 * Revert "Revert "Introduction of XamlHost"" This reverts commit 52001880f0877cc283c230f3840ed69e944ebbb1. * Jimwilcox/xaml islands control test (#2431) * Folded the latest work into the CTK. This includes wrappers for MediaPlayerElement, InkCanvas, and InkToolbar. There's also a new Samples app called TestSample (for the time being). In order to accomplish this, the projects in the Win32 sln needed to be updated to .NET 4.7.2 and SDK 17686. * Added WPF MapControl wrapper. * Initial WPF wraps for SwapChainPanel & WebView. * refactors setter implementation for consistency. Fixes some missing event handlers in WebView (Lite). * Minimally working demos of InkToolbar with InkToolBarCustomToolButton as a wrapped child control. Not quite happy with this implementation, but wanted to bounce it off the team. * Sets the appropriate type on the Wrapper attached property * 95% code-generated wrappers (minor post-process touchups only) * Fixes the binding issue on MediaPlayer property for one-way binding. * Refactored events to use a dynamic wrapper for event args. * Updates events to pattern that works, requiring event args wrappers. (thus adding 25 event args wrappers) and an additional control wrapper. * WIP: Refactoring WebView for fallback behavior. * Committing this so I can test another branch. * Restoring samples for Ink, Mediaplayer, et al. * Checkpointing * InkPresenter's pretty well fleshed out. * Fixes compile issue. * Pulled back on winmd ref changes. * Map control is in the sample project now, and doesn't die, but doesn't show a map yet, either. * looking into binding issues with the map control, but not convinced that's the issue. * Added SwapChainPanel to sample * Fixes references so that Debug & Release both build * Attempts to apply dpi fixes to test sample project. Also fixes implementation selection condition for WebViewCompatible. * Updates required after merge. * Removed SwapChainPanel, MapControl, and hopefully extraneous InkPresenter code. * Revert "Removed SwapChainPanel, MapControl, and hopefully extraneous InkPresenter code." This reverts commit 5f977c3fddad1d5bb2d72b367157892982e9c033. * Ran UpdateHeaders.bat * Experimentation with full control set. * Restored to .NET 4.6.2 * Removed SecurityCriticalAttribute from class, not needed. * Fixed a naming issue that surfaced in review. * Got rid of the ".Compatible" namespace for the WebViewCompatible control. * renamed Microsoft.Windows.Interop to Microsoft.Toolkit.Win32.UI.Interop. Convertet project to enable pack * Regenerated wrappers including basic redirect pointers for documentation. Included a few more wrappers and enums to simplify and reduce need for WinMD. * split up Microsoft.Toolkit.Win32.UI.Controls in WPF and WinForms binaries sharing common code * Fix references - Add missing project references - Use Windows.winmd set by Directory.Build - Convert GAC references to NuGet packages * updated headers * Worked in the latest WindowsXamlHost / WindowsXamlHostBase (with a local extension to enable needed functionality). * More properly integrates Interop.WPF code, extending WindowsXamlHostBase to sort out differences. * Fixing some sample project breakages in an earlier brancrh to prove out the branch. * Splitting WindowsXamlHost off to WPF & WinForms. This is the WPF path. * Pulls in Interop.WinForms. * Moves wpf shared code in by link. * Set IsFullscreenButtonVisibile = false in MediaPlayerElement since it's not supported. * Moved the sample app to a more appropriate namespace / assembly name in prep for importing WinForms sample. Also hammered out WebViewCompatible. * Getting the WinForms Sample app in. * Ran UpdateHeaders.bat * Updated to use latest SDK (17713) via Directory.Build.props file. * Making sure the samples uses Directory.Build.props target platform version. * Got the WebViewCompatible partially operable. * Almost there, checkpointing for a pull from rimuri/xaml-islands_more-fixes. * StyleCop fixes for Microsoft.Toolkit.Win32.UI.Interop.WinForms Some fixes still required for documentation and usage in some cases. * StyleCop fixes for Microsoft.Toolkit.Win32.UI.Interop.WPF * Optimize references * Fixing a comment in directory.build.props. * Fix commas in WindowsXamlHostBase.cs * Fix StyleCop issues with DependencyObjectCollection.cs * designer tweak * fixes binding on the source property. * Updated initialization of WebView in WebViewCompatibilityAdapter. * Working out stylecop errors. * Refactored to get rid of Windows dependency creeping out of WindowsXamlHostBase. * fixed up release build configuration * reverted tpm for all projects * Set docking state before EndInit Asynchronous initialization occurs after calling EndInit. To prevent multiple paints when the control is resized during initialization, move the dock style prior to EndInit to ensure the target HWND RECT. * Correct order of members * Implement IDisposable WebView is disposable. Making WebViewCompatibilityAdapter disposable and dispose of WebView * DRY out WinRT type detection WebViewCompatible duplicated WinMD metadata detection * Correct order of members * Correct issues with merge * Add missing file headers * Remove redundant `partial` keyword * Remove default type of int for enum `int` is already governing type for an enum * Remove `global::` prefix for WinRT types The ability to access a member in the global namespace is useful when a member might be hidden by another entity of the same name. Example ``` class Foo { public class System { } const int Console = 0; static void Main() { Console.WriteLine("Bar"); } } ``` The `Console.WriteLine` throws an error because it accesses Foo.Console, which is a constant. Using `System.Console` does no better, since it accesses `Foo.System` class, which does not have a static `WriteLine` method. The only way to get it to compile is to use `global::System.Console.WriteLine("Bar")`; however, it is not required in these instances. * ThreadStaticAttribute does not do anything for instance members * Move WinRT interop files to proper namespace Follows convention used by WebView * Clean up InkCanvas - Remove `this` - Use `inheritdoc` for documentation generation - Remove unused using statement * Clean up InkToolbar.cs - Remove unused using - Remove `this` * Clean up InkToolbarCustomPenButton.cs - Remove `this` * Clean up InkToolbarCustomToolButton.cs - Remove unused usings - Remove `this` - Remove `global::` alias * Clean up InkToolbarIsStencilButtonCheckChangedEventArgs.cs - Remove unused usings - Simplify names - Fix property `StencilKind` to use interop type instead of WinRT * Clean up InkToolbarMenuButton.cs - Remove unused using - Remove `this` - Remove cast to int on `MenuKind`. Enum is already int, so no need to cast then cast to enum. * Clean up InkToolbarPenButton.cs - Remove unused using - Remove `this` * Clean up InkToolbarStencilButton.cs - Remove unused usings - Remove `this` - Remove `global::` in most places - Convert `Ruler` to expression bodied member * Clean up InkToolbarToggleButton.cs - Remove unused usings - Remove `this` - Convert `ToggleKind` to expression body, remove unnecessary cast to int - Remove `global::` in most places * Clean up InkToolbarToolButton.cs - Remove unused usings - Remove `this` - Remove most instances of `global::` - Convert `ToolKind` to expression body, remove unnecessary cast to int * Clean up BindingBase.cs - Remove `this` * Clean up BindingExpression.cs - Remove `this` * Clean up BringIntoViewOptions.cs - Remove `this` * Clean up Brush.cs - Remove `this` - Left review comments for uncaught NRE * Clean up BrushTransition.cs - Remove `this` * Clean up MediaPlayerElement.cs - Remove unused usings - Remove `this` * Leave review comment in MediaSourceConverter.cs * Remove `Support` folder Contents moved to WinRT/Interop folder * Clean up WindowsXamlHostBaseExt.cs - Add inheritdoc for documentation - Remove `this` * Clean up IWebViewCompatible.cs - Remove unused using - Group members (all properties, methods, events, etc. together) * Clean up WebBaseCompatabilityAdapter.cs - Group members * Provide Web adapters correct implementation for IDispose pattern * Clean up WebBrowserCompatabilityAdapter.cs - Implement proper IDisposable - Add null checks prior to operations to avoid ObjectDisposeException or NullRefrenceException * Clean up WebViewCompatabilityAdapter.cs - Add null checks for operations to avoid unhandled NRE * Work in progress * Fixing a merge error. * updated folder names and updated toolbox xml file * Add app.config/app.manifest to WinForms sample app Required to support high DPI * added visualstudiotoolsmanidest.xml to nuget package * WIP while updating from master * Designer now allows association between ink toolbar & its canvas. * Ink canvas / toolbar updates, dug in on mediaplayerelement. * MediaPlayerElement oprational to the same level of functionality as WPF edition. * Project rename fix * Fixing a reference that broke in merge. * Ran UpdateHeaders.bat. * Fixed release build config. * Adding stub MDs for control documents. * Add link to ExternDll.cs * Adding md documentation for wrappers. * Remove duplicate tag from build props Move WebBrowserUriTypeConverter to shared * Adding missing task extensions for both WPF & WinForms. * Addressing a PR comment about comments. * Adding no-op Pack targets for the build. * removed samples apps from building in release mode * Tweaked docs. * Fixing TargetPlatformVersion / TargetPlatformMinVersion * WIP * Removing code from accidental commit from winforms branch. * Temp solution to InkToolbar issue. * set min target version * Resolves review issues. * Addressing PR 2299 change requests. * Cosmetic change to trigger another build to see if it overcomes the OOM error in the previous build. * updated win32 project to 17733 * updated comments * removed Shadow.cs because Windows.UI.Xaml.Media.Shadow is removed from latest insider build. Replaced WebViewControl.AddpreLoadedScript with AddInitializeScript * Clears up event handler on dispose of WidowsXamlHost. * Renaming packages in #2299 (#2420) * renamed win32 namespaces * updated vs toolbox namespaces * Fix for local build for PR #2490 merged into #2299. * Added missing projects to Release Build config. * Revert "Fix for local build for PR #2490 merged into #2299." This reverts commit d9202e06206de69092ef0ca7a007e6d92577bac6. * Update NativeDefines - Move to correct namespace - Update to use existing definitions for WM * Update Win32 code Move Win32 code into appropriate namespace. Fix issues with `NativeMethods` style classes and add documentation about when to use which and for what. * Update namespace - Remove unused namespaces - Move `using` outside of `namespace` declaration * Merge branch 'rjmurillo/XamlIslands' into rjmurillo/XamlIslands-ControlTest * Fix AssemblyInfos for XamlHosts * API feedback part 1 * API updates #2 * Code docs updates - Separate remarks into `<remarks />` tag - Link types with `<see />` tag - Fix some typos * Changed the way SetContent works in WindowsXamlHostBase so that it doesn't expose Windows.winmd to the client. * Code docs updates - Separate remarks into `<remarks />` tag - Link types with `<see />` tag - Fix some typos * Remove Ryland's test projects from SLN * Make NativeDefines.cs consistent New entries added that should use enum `WM` * Use `var` in WindowsXamlHostBase.KeyboardFocus.cs * Remove redundant `this` qualifier in WindowsXamlHostBase.KeyboardFocus.cs * Remove unused `using` in WindowsXamlHostBase.KeyboardFocus.cs * Fix for SA1505 * Resources designer namespace update * Prevent _xamlSource from leaking This field is only needed to surface the content through the `WindowsXamlHost.Child` property and does not otherwise need to be exposed to inherited classes when the property will suffice. To maintain the same API surface as the WPF control, a new API `SetContent` was added to take the `FrameworkElement`. The implementation of `SetContent(FrameworkElement)` is identical to `SetContent(UIElement)` other than the parameter type. CC @ryalanms * Work around CoreInputSink bug, Windows Forms Focus issue * Update SetContent method Change a6b20f57bbbe3d34b35bda5a7d2a5071b2c7a2d0 introduced a signature change * Relax WebView fail fast when setting properties in XAML Remove assert conditions for state and add comments as to what is happening and what expected behavior should be. * Fixes after pulling in code from Rebased and ControlTest branches. * Addresses items in PR #2432
2018-09-06 20:36:28 +03:00
var options = new Win32.UI.Controls.Interop.WinRT.WebViewControlProcessOptions()
{
PrivateNetworkClientServerCapability =
Add Xaml Islands Xaml Wrappers Preview (#2432) * Folded the latest work into the CTK. This includes wrappers for MediaPlayerElement, InkCanvas, and InkToolbar. There's also a new Samples app called TestSample (for the time being). In order to accomplish this, the projects in the Win32 sln needed to be updated to .NET 4.7.2 and SDK 17686. * Added WPF MapControl wrapper. * Initial WPF wraps for SwapChainPanel & WebView. * refactors setter implementation for consistency. Fixes some missing event handlers in WebView (Lite). * Minimally working demos of InkToolbar with InkToolBarCustomToolButton as a wrapped child control. Not quite happy with this implementation, but wanted to bounce it off the team. * Sets the appropriate type on the Wrapper attached property * 95% code-generated wrappers (minor post-process touchups only) * Fixes the binding issue on MediaPlayer property for one-way binding. * Refactored events to use a dynamic wrapper for event args. * Updates events to pattern that works, requiring event args wrappers. (thus adding 25 event args wrappers) and an additional control wrapper. * WIP: Refactoring WebView for fallback behavior. * Committing this so I can test another branch. * Restoring samples for Ink, Mediaplayer, et al. * Checkpointing * InkPresenter's pretty well fleshed out. * Fixes compile issue. * Pulled back on winmd ref changes. * Map control is in the sample project now, and doesn't die, but doesn't show a map yet, either. * looking into binding issues with the map control, but not convinced that's the issue. * Added SwapChainPanel to sample * Fixes references so that Debug & Release both build * Attempts to apply dpi fixes to test sample project. Also fixes implementation selection condition for WebViewCompatible. * Updates required after merge. * Removed SwapChainPanel, MapControl, and hopefully extraneous InkPresenter code. * Revert "Removed SwapChainPanel, MapControl, and hopefully extraneous InkPresenter code." This reverts commit 5f977c3fddad1d5bb2d72b367157892982e9c033. * Ran UpdateHeaders.bat * Experimentation with full control set. * Restored to .NET 4.6.2 * Removed SecurityCriticalAttribute from class, not needed. * Fixed a naming issue that surfaced in review. * Got rid of the ".Compatible" namespace for the WebViewCompatible control. * renamed Microsoft.Windows.Interop to Microsoft.Toolkit.Win32.UI.Interop. Convertet project to enable pack * Regenerated wrappers including basic redirect pointers for documentation. Included a few more wrappers and enums to simplify and reduce need for WinMD. * split up Microsoft.Toolkit.Win32.UI.Controls in WPF and WinForms binaries sharing common code * Fix references - Add missing project references - Use Windows.winmd set by Directory.Build - Convert GAC references to NuGet packages * updated headers * Worked in the latest WindowsXamlHost / WindowsXamlHostBase (with a local extension to enable needed functionality). * More properly integrates Interop.WPF code, extending WindowsXamlHostBase to sort out differences. * Fixing some sample project breakages in an earlier brancrh to prove out the branch. * Splitting WindowsXamlHost off to WPF & WinForms. This is the WPF path. * Pulls in Interop.WinForms. * Moves wpf shared code in by link. * Set IsFullscreenButtonVisibile = false in MediaPlayerElement since it's not supported. * Moved the sample app to a more appropriate namespace / assembly name in prep for importing WinForms sample. Also hammered out WebViewCompatible. * Getting the WinForms Sample app in. * Ran UpdateHeaders.bat * Updated to use latest SDK (17713) via Directory.Build.props file. * Making sure the samples uses Directory.Build.props target platform version. * Got the WebViewCompatible partially operable. * Almost there, checkpointing for a pull from rimuri/xaml-islands_more-fixes. * StyleCop fixes for Microsoft.Toolkit.Win32.UI.Interop.WinForms Some fixes still required for documentation and usage in some cases. * StyleCop fixes for Microsoft.Toolkit.Win32.UI.Interop.WPF * Optimize references * Fixing a comment in directory.build.props. * Fix commas in WindowsXamlHostBase.cs * Fix StyleCop issues with DependencyObjectCollection.cs * designer tweak * fixes binding on the source property. * Updated initialization of WebView in WebViewCompatibilityAdapter. * Working out stylecop errors. * Refactored to get rid of Windows dependency creeping out of WindowsXamlHostBase. * fixed up release build configuration * reverted tpm for all projects * Set docking state before EndInit Asynchronous initialization occurs after calling EndInit. To prevent multiple paints when the control is resized during initialization, move the dock style prior to EndInit to ensure the target HWND RECT. * Correct order of members * Implement IDisposable WebView is disposable. Making WebViewCompatibilityAdapter disposable and dispose of WebView * DRY out WinRT type detection WebViewCompatible duplicated WinMD metadata detection * Correct order of members * Correct issues with merge * Add missing file headers * Remove redundant `partial` keyword * Remove default type of int for enum `int` is already governing type for an enum * Remove `global::` prefix for WinRT types The ability to access a member in the global namespace is useful when a member might be hidden by another entity of the same name. Example ``` class Foo { public class System { } const int Console = 0; static void Main() { Console.WriteLine("Bar"); } } ``` The `Console.WriteLine` throws an error because it accesses Foo.Console, which is a constant. Using `System.Console` does no better, since it accesses `Foo.System` class, which does not have a static `WriteLine` method. The only way to get it to compile is to use `global::System.Console.WriteLine("Bar")`; however, it is not required in these instances. * ThreadStaticAttribute does not do anything for instance members * Move WinRT interop files to proper namespace Follows convention used by WebView * Clean up InkCanvas - Remove `this` - Use `inheritdoc` for documentation generation - Remove unused using statement * Clean up InkToolbar.cs - Remove unused using - Remove `this` * Clean up InkToolbarCustomPenButton.cs - Remove `this` * Clean up InkToolbarCustomToolButton.cs - Remove unused usings - Remove `this` - Remove `global::` alias * Clean up InkToolbarIsStencilButtonCheckChangedEventArgs.cs - Remove unused usings - Simplify names - Fix property `StencilKind` to use interop type instead of WinRT * Clean up InkToolbarMenuButton.cs - Remove unused using - Remove `this` - Remove cast to int on `MenuKind`. Enum is already int, so no need to cast then cast to enum. * Clean up InkToolbarPenButton.cs - Remove unused using - Remove `this` * Clean up InkToolbarStencilButton.cs - Remove unused usings - Remove `this` - Remove `global::` in most places - Convert `Ruler` to expression bodied member * Clean up InkToolbarToggleButton.cs - Remove unused usings - Remove `this` - Convert `ToggleKind` to expression body, remove unnecessary cast to int - Remove `global::` in most places * Clean up InkToolbarToolButton.cs - Remove unused usings - Remove `this` - Remove most instances of `global::` - Convert `ToolKind` to expression body, remove unnecessary cast to int * Clean up BindingBase.cs - Remove `this` * Clean up BindingExpression.cs - Remove `this` * Clean up BringIntoViewOptions.cs - Remove `this` * Clean up Brush.cs - Remove `this` - Left review comments for uncaught NRE * Clean up BrushTransition.cs - Remove `this` * Clean up MediaPlayerElement.cs - Remove unused usings - Remove `this` * Leave review comment in MediaSourceConverter.cs * Remove `Support` folder Contents moved to WinRT/Interop folder * Clean up WindowsXamlHostBaseExt.cs - Add inheritdoc for documentation - Remove `this` * Clean up IWebViewCompatible.cs - Remove unused using - Group members (all properties, methods, events, etc. together) * Clean up WebBaseCompatabilityAdapter.cs - Group members * Provide Web adapters correct implementation for IDispose pattern * Clean up WebBrowserCompatabilityAdapter.cs - Implement proper IDisposable - Add null checks prior to operations to avoid ObjectDisposeException or NullRefrenceException * Clean up WebViewCompatabilityAdapter.cs - Add null checks for operations to avoid unhandled NRE * Work in progress * Fixing a merge error. * updated folder names and updated toolbox xml file * Add app.config/app.manifest to WinForms sample app Required to support high DPI * added visualstudiotoolsmanidest.xml to nuget package * WIP while updating from master * Designer now allows association between ink toolbar & its canvas. * Ink canvas / toolbar updates, dug in on mediaplayerelement. * MediaPlayerElement oprational to the same level of functionality as WPF edition. * Project rename fix * Fixing a reference that broke in merge. * Ran UpdateHeaders.bat. * Fixed release build config. * Adding stub MDs for control documents. * Add link to ExternDll.cs * Adding md documentation for wrappers. * Remove duplicate tag from build props Move WebBrowserUriTypeConverter to shared * Adding missing task extensions for both WPF & WinForms. * Addressing a PR comment about comments. * Adding no-op Pack targets for the build. * removed samples apps from building in release mode * Tweaked docs. * Fixing TargetPlatformVersion / TargetPlatformMinVersion * WIP * Removing code from accidental commit from winforms branch. * Temp solution to InkToolbar issue. * set min target version * Resolves review issues. * Addressing PR 2299 change requests. * Cosmetic change to trigger another build to see if it overcomes the OOM error in the previous build. * updated win32 project to 17733 * updated comments * removed Shadow.cs because Windows.UI.Xaml.Media.Shadow is removed from latest insider build. Replaced WebViewControl.AddpreLoadedScript with AddInitializeScript * Clears up event handler on dispose of WidowsXamlHost. * Renaming packages in #2299 (#2420) * renamed win32 namespaces * updated vs toolbox namespaces * Update NativeDefines - Move to correct namespace - Update to use existing definitions for WM * Update Win32 code Move Win32 code into appropriate namespace. Fix issues with `NativeMethods` style classes and add documentation about when to use which and for what. * Update namespace - Remove unused namespaces - Move `using` outside of `namespace` declaration * Merge branch 'rjmurillo/XamlIslands' into rjmurillo/XamlIslands-ControlTest * Fix AssemblyInfos for XamlHosts * API feedback part 1 * API updates #2 * Code docs updates - Separate remarks into `<remarks />` tag - Link types with `<see />` tag - Fix some typos * fixed up solution and csproj * Add Windows Forms Focus workaround for RS5 * Revert "Revert "Introduction of XamlHost"" This reverts commit 52001880f0877cc283c230f3840ed69e944ebbb1. * Jimwilcox/xaml islands control test (#2431) * Folded the latest work into the CTK. This includes wrappers for MediaPlayerElement, InkCanvas, and InkToolbar. There's also a new Samples app called TestSample (for the time being). In order to accomplish this, the projects in the Win32 sln needed to be updated to .NET 4.7.2 and SDK 17686. * Added WPF MapControl wrapper. * Initial WPF wraps for SwapChainPanel & WebView. * refactors setter implementation for consistency. Fixes some missing event handlers in WebView (Lite). * Minimally working demos of InkToolbar with InkToolBarCustomToolButton as a wrapped child control. Not quite happy with this implementation, but wanted to bounce it off the team. * Sets the appropriate type on the Wrapper attached property * 95% code-generated wrappers (minor post-process touchups only) * Fixes the binding issue on MediaPlayer property for one-way binding. * Refactored events to use a dynamic wrapper for event args. * Updates events to pattern that works, requiring event args wrappers. (thus adding 25 event args wrappers) and an additional control wrapper. * WIP: Refactoring WebView for fallback behavior. * Committing this so I can test another branch. * Restoring samples for Ink, Mediaplayer, et al. * Checkpointing * InkPresenter's pretty well fleshed out. * Fixes compile issue. * Pulled back on winmd ref changes. * Map control is in the sample project now, and doesn't die, but doesn't show a map yet, either. * looking into binding issues with the map control, but not convinced that's the issue. * Added SwapChainPanel to sample * Fixes references so that Debug & Release both build * Attempts to apply dpi fixes to test sample project. Also fixes implementation selection condition for WebViewCompatible. * Updates required after merge. * Removed SwapChainPanel, MapControl, and hopefully extraneous InkPresenter code. * Revert "Removed SwapChainPanel, MapControl, and hopefully extraneous InkPresenter code." This reverts commit 5f977c3fddad1d5bb2d72b367157892982e9c033. * Ran UpdateHeaders.bat * Experimentation with full control set. * Restored to .NET 4.6.2 * Removed SecurityCriticalAttribute from class, not needed. * Fixed a naming issue that surfaced in review. * Got rid of the ".Compatible" namespace for the WebViewCompatible control. * renamed Microsoft.Windows.Interop to Microsoft.Toolkit.Win32.UI.Interop. Convertet project to enable pack * Regenerated wrappers including basic redirect pointers for documentation. Included a few more wrappers and enums to simplify and reduce need for WinMD. * split up Microsoft.Toolkit.Win32.UI.Controls in WPF and WinForms binaries sharing common code * Fix references - Add missing project references - Use Windows.winmd set by Directory.Build - Convert GAC references to NuGet packages * updated headers * Worked in the latest WindowsXamlHost / WindowsXamlHostBase (with a local extension to enable needed functionality). * More properly integrates Interop.WPF code, extending WindowsXamlHostBase to sort out differences. * Fixing some sample project breakages in an earlier brancrh to prove out the branch. * Splitting WindowsXamlHost off to WPF & WinForms. This is the WPF path. * Pulls in Interop.WinForms. * Moves wpf shared code in by link. * Set IsFullscreenButtonVisibile = false in MediaPlayerElement since it's not supported. * Moved the sample app to a more appropriate namespace / assembly name in prep for importing WinForms sample. Also hammered out WebViewCompatible. * Getting the WinForms Sample app in. * Ran UpdateHeaders.bat * Updated to use latest SDK (17713) via Directory.Build.props file. * Making sure the samples uses Directory.Build.props target platform version. * Got the WebViewCompatible partially operable. * Almost there, checkpointing for a pull from rimuri/xaml-islands_more-fixes. * StyleCop fixes for Microsoft.Toolkit.Win32.UI.Interop.WinForms Some fixes still required for documentation and usage in some cases. * StyleCop fixes for Microsoft.Toolkit.Win32.UI.Interop.WPF * Optimize references * Fixing a comment in directory.build.props. * Fix commas in WindowsXamlHostBase.cs * Fix StyleCop issues with DependencyObjectCollection.cs * designer tweak * fixes binding on the source property. * Updated initialization of WebView in WebViewCompatibilityAdapter. * Working out stylecop errors. * Refactored to get rid of Windows dependency creeping out of WindowsXamlHostBase. * fixed up release build configuration * reverted tpm for all projects * Set docking state before EndInit Asynchronous initialization occurs after calling EndInit. To prevent multiple paints when the control is resized during initialization, move the dock style prior to EndInit to ensure the target HWND RECT. * Correct order of members * Implement IDisposable WebView is disposable. Making WebViewCompatibilityAdapter disposable and dispose of WebView * DRY out WinRT type detection WebViewCompatible duplicated WinMD metadata detection * Correct order of members * Correct issues with merge * Add missing file headers * Remove redundant `partial` keyword * Remove default type of int for enum `int` is already governing type for an enum * Remove `global::` prefix for WinRT types The ability to access a member in the global namespace is useful when a member might be hidden by another entity of the same name. Example ``` class Foo { public class System { } const int Console = 0; static void Main() { Console.WriteLine("Bar"); } } ``` The `Console.WriteLine` throws an error because it accesses Foo.Console, which is a constant. Using `System.Console` does no better, since it accesses `Foo.System` class, which does not have a static `WriteLine` method. The only way to get it to compile is to use `global::System.Console.WriteLine("Bar")`; however, it is not required in these instances. * ThreadStaticAttribute does not do anything for instance members * Move WinRT interop files to proper namespace Follows convention used by WebView * Clean up InkCanvas - Remove `this` - Use `inheritdoc` for documentation generation - Remove unused using statement * Clean up InkToolbar.cs - Remove unused using - Remove `this` * Clean up InkToolbarCustomPenButton.cs - Remove `this` * Clean up InkToolbarCustomToolButton.cs - Remove unused usings - Remove `this` - Remove `global::` alias * Clean up InkToolbarIsStencilButtonCheckChangedEventArgs.cs - Remove unused usings - Simplify names - Fix property `StencilKind` to use interop type instead of WinRT * Clean up InkToolbarMenuButton.cs - Remove unused using - Remove `this` - Remove cast to int on `MenuKind`. Enum is already int, so no need to cast then cast to enum. * Clean up InkToolbarPenButton.cs - Remove unused using - Remove `this` * Clean up InkToolbarStencilButton.cs - Remove unused usings - Remove `this` - Remove `global::` in most places - Convert `Ruler` to expression bodied member * Clean up InkToolbarToggleButton.cs - Remove unused usings - Remove `this` - Convert `ToggleKind` to expression body, remove unnecessary cast to int - Remove `global::` in most places * Clean up InkToolbarToolButton.cs - Remove unused usings - Remove `this` - Remove most instances of `global::` - Convert `ToolKind` to expression body, remove unnecessary cast to int * Clean up BindingBase.cs - Remove `this` * Clean up BindingExpression.cs - Remove `this` * Clean up BringIntoViewOptions.cs - Remove `this` * Clean up Brush.cs - Remove `this` - Left review comments for uncaught NRE * Clean up BrushTransition.cs - Remove `this` * Clean up MediaPlayerElement.cs - Remove unused usings - Remove `this` * Leave review comment in MediaSourceConverter.cs * Remove `Support` folder Contents moved to WinRT/Interop folder * Clean up WindowsXamlHostBaseExt.cs - Add inheritdoc for documentation - Remove `this` * Clean up IWebViewCompatible.cs - Remove unused using - Group members (all properties, methods, events, etc. together) * Clean up WebBaseCompatabilityAdapter.cs - Group members * Provide Web adapters correct implementation for IDispose pattern * Clean up WebBrowserCompatabilityAdapter.cs - Implement proper IDisposable - Add null checks prior to operations to avoid ObjectDisposeException or NullRefrenceException * Clean up WebViewCompatabilityAdapter.cs - Add null checks for operations to avoid unhandled NRE * Work in progress * Fixing a merge error. * updated folder names and updated toolbox xml file * Add app.config/app.manifest to WinForms sample app Required to support high DPI * added visualstudiotoolsmanidest.xml to nuget package * WIP while updating from master * Designer now allows association between ink toolbar & its canvas. * Ink canvas / toolbar updates, dug in on mediaplayerelement. * MediaPlayerElement oprational to the same level of functionality as WPF edition. * Project rename fix * Fixing a reference that broke in merge. * Ran UpdateHeaders.bat. * Fixed release build config. * Adding stub MDs for control documents. * Add link to ExternDll.cs * Adding md documentation for wrappers. * Remove duplicate tag from build props Move WebBrowserUriTypeConverter to shared * Adding missing task extensions for both WPF & WinForms. * Addressing a PR comment about comments. * Adding no-op Pack targets for the build. * removed samples apps from building in release mode * Tweaked docs. * Fixing TargetPlatformVersion / TargetPlatformMinVersion * WIP * Removing code from accidental commit from winforms branch. * Temp solution to InkToolbar issue. * set min target version * Resolves review issues. * Addressing PR 2299 change requests. * Cosmetic change to trigger another build to see if it overcomes the OOM error in the previous build. * updated win32 project to 17733 * updated comments * removed Shadow.cs because Windows.UI.Xaml.Media.Shadow is removed from latest insider build. Replaced WebViewControl.AddpreLoadedScript with AddInitializeScript * Clears up event handler on dispose of WidowsXamlHost. * Renaming packages in #2299 (#2420) * renamed win32 namespaces * updated vs toolbox namespaces * Fix for local build for PR #2490 merged into #2299. * Added missing projects to Release Build config. * Revert "Fix for local build for PR #2490 merged into #2299." This reverts commit d9202e06206de69092ef0ca7a007e6d92577bac6. * Update NativeDefines - Move to correct namespace - Update to use existing definitions for WM * Update Win32 code Move Win32 code into appropriate namespace. Fix issues with `NativeMethods` style classes and add documentation about when to use which and for what. * Update namespace - Remove unused namespaces - Move `using` outside of `namespace` declaration * Merge branch 'rjmurillo/XamlIslands' into rjmurillo/XamlIslands-ControlTest * Fix AssemblyInfos for XamlHosts * API feedback part 1 * API updates #2 * Code docs updates - Separate remarks into `<remarks />` tag - Link types with `<see />` tag - Fix some typos * Changed the way SetContent works in WindowsXamlHostBase so that it doesn't expose Windows.winmd to the client. * Code docs updates - Separate remarks into `<remarks />` tag - Link types with `<see />` tag - Fix some typos * Remove Ryland's test projects from SLN * Make NativeDefines.cs consistent New entries added that should use enum `WM` * Use `var` in WindowsXamlHostBase.KeyboardFocus.cs * Remove redundant `this` qualifier in WindowsXamlHostBase.KeyboardFocus.cs * Remove unused `using` in WindowsXamlHostBase.KeyboardFocus.cs * Fix for SA1505 * Resources designer namespace update * Prevent _xamlSource from leaking This field is only needed to surface the content through the `WindowsXamlHost.Child` property and does not otherwise need to be exposed to inherited classes when the property will suffice. To maintain the same API surface as the WPF control, a new API `SetContent` was added to take the `FrameworkElement`. The implementation of `SetContent(FrameworkElement)` is identical to `SetContent(UIElement)` other than the parameter type. CC @ryalanms * Work around CoreInputSink bug, Windows Forms Focus issue * Update SetContent method Change a6b20f57bbbe3d34b35bda5a7d2a5071b2c7a2d0 introduced a signature change * Relax WebView fail fast when setting properties in XAML Remove assert conditions for state and add comments as to what is happening and what expected behavior should be. * Fixes after pulling in code from Rebased and ControlTest branches. * Addresses items in PR #2432
2018-09-06 20:36:28 +03:00
(Win32.UI.Controls.Interop.WinRT.WebViewControlProcessCapabilityState)(_delayedPrivateNetworkEnabled
? WebViewControlProcessCapabilityState.Enabled
: WebViewControlProcessCapabilityState.Disabled),
EnterpriseId = _delayedEnterpriseId
};
Process = new WebViewControlProcess(options);
}
else
2018-05-31 21:05:03 +03:00
{
Verify.IsNotNull(Process);
_delayedPrivateNetworkEnabled = Process.IsPrivateNetworkClientServerCapabilityEnabled;
_delayedEnterpriseId = Process.EnterpriseId;
}
Verify.IsNotNull(Process);
2018-05-31 21:05:03 +03:00
_webViewControl = Process.CreateWebViewControlHost(Handle, ClientRectangle);
SubscribeEvents();
// Set values. They could have been changed in the designer
IsScriptNotifyAllowed = _delayedIsScriptNotifyAllowed;
IsIndexedDBEnabled = _delayedIsIndexDbEnabled;
IsJavaScriptEnabled = _delayedIsJavaScriptEnabled;
// This will cause a navigation
Source = _delayedSource;
}
else
{
// Already provided control
SubscribeEvents();
}
_webViewControl.IsVisible = true;
}
_initializationState = InitializationState.IsInitialized;
}
private void SubscribeEvents()
{
if (_webViewControl == null)
{
return;
}
_webViewControl.AcceleratorKeyPressed += OnAcceleratorKeyPressed;
_webViewControl.ContainsFullScreenElementChanged += OnContainsFullScreenElementChanged;
_webViewControl.ContentLoading += OnContentLoading;
_webViewControl.DOMContentLoaded += OnDOMContentLoaded;
_webViewControl.FrameContentLoading += OnFrameContentLoading;
_webViewControl.FrameDOMContentLoaded += OnFrameDOMContentLoaded;
_webViewControl.FrameNavigationCompleted += OnFrameNavigationCompleted;
_webViewControl.FrameNavigationStarting += OnFrameNavigationStarting;
_webViewControl.GotFocus += OnGotFocus;
2018-05-31 21:05:03 +03:00
_webViewControl.LongRunningScriptDetected += OnLongRunningScriptDetected;
_webViewControl.LostFocus += OnLostFocus;
2018-05-31 21:05:03 +03:00
_webViewControl.MoveFocusRequested += OnMoveFocusRequested;
_webViewControl.NavigationCompleted += OnNavigationCompleted;
_webViewControl.NavigationStarting += OnNavigationStarting;
_webViewControl.NewWindowRequested += OnNewWindowRequested;
_webViewControl.PermissionRequested += OnPermissionRequested;
_webViewControl.ScriptNotify += OnScriptNotify;
_webViewControl.UnsafeContentWarningDisplaying += OnUnsafeContentWarningDisplaying;
_webViewControl.UnsupportedUriSchemeIdentified += OnUnsupportedUriSchemeIdentified;
_webViewControl.UnviewableContentIdentified += OnUnviewableContentIdentified;
}
private void UnsubscribeEvents()
{
if (_webViewControl == null)
{
return;
}
_webViewControl.AcceleratorKeyPressed -= OnAcceleratorKeyPressed;
_webViewControl.ContainsFullScreenElementChanged -= OnContainsFullScreenElementChanged;
_webViewControl.ContentLoading -= OnContentLoading;
_webViewControl.DOMContentLoaded -= OnDOMContentLoaded;
_webViewControl.FrameContentLoading -= OnFrameContentLoading;
_webViewControl.FrameDOMContentLoaded -= OnFrameDOMContentLoaded;
_webViewControl.FrameNavigationCompleted -= OnFrameNavigationCompleted;
_webViewControl.FrameNavigationStarting -= OnFrameNavigationStarting;
_webViewControl.GotFocus -= OnGotFocus;
2018-05-31 21:05:03 +03:00
_webViewControl.LongRunningScriptDetected -= OnLongRunningScriptDetected;
_webViewControl.LostFocus -= OnLostFocus;
2018-05-31 21:05:03 +03:00
_webViewControl.MoveFocusRequested -= OnMoveFocusRequested;
_webViewControl.NavigationCompleted -= OnNavigationCompleted;
_webViewControl.NavigationStarting -= OnNavigationStarting;
_webViewControl.NewWindowRequested -= OnNewWindowRequested;
_webViewControl.PermissionRequested -= OnPermissionRequested;
_webViewControl.ScriptNotify -= OnScriptNotify;
_webViewControl.UnsafeContentWarningDisplaying -= OnUnsafeContentWarningDisplaying;
_webViewControl.UnsupportedUriSchemeIdentified -= OnUnsupportedUriSchemeIdentified;
_webViewControl.UnviewableContentIdentified -= OnUnviewableContentIdentified;
}
}
}