DevToys logo DevToys
  • Home
  • Blog
  • Documentation
  • Download
Search Results for

    Show / Hide Table of Contents

    Web View

    You can create a web view using the WebView() static method, which produces a IUIWebView.

    Important

    DevToys UI is made using web technology. Most of the UI is in fact a web page, using HTML and CSS. The WebView UI component is therefore, in fact, an iframe. On Windows, the UI is rendered with the built-in Microsoft Edge WebView2, based on Chromium. On macOS and Linux, the UI is rendered with the built-in WebKit.

    Sample

    using DevToys.Api;
    using System.ComponentModel.Composition;
    using static DevToys.Api.GUI;
    
    namespace MyProject;
    
    [Export(typeof(IGuiTool))]
    [Name("My Tool")]
    [ToolDisplayInformation(
        IconFontName = "FluentSystemIcons",
        IconGlyph = '\uE670',
        ResourceManagerAssemblyIdentifier = nameof(MyResourceAssemblyIdentifier),
        ResourceManagerBaseName = "MyProject.Strings",
        ShortDisplayTitleResourceName = nameof(Strings.ShortDisplayTitle),
        DescriptionResourceName = nameof(Strings.Description),
        GroupName = "My Group")]
    internal sealed class MyGuiTool : IGuiTool
    {
        public UIToolView View
            => new UIToolView(
                WebView()
                    .NavigateToUri(new Uri("https://devtoys.app/")));
    
        public void OnDataReceived(string dataTypeName, object? parsedData)
        {
            // Handle Smart Detection.
        }
    }
    

    The code above produces the following UI:

    DevToys - My Tool - Web View

    In this article
    DevToys logo © 2024 DevToys