mirror of
				https://github.com/MindWorkAI/AI-Studio.git
				synced 2025-11-04 04:40:20 +00:00 
			
		
		
		
	Added MudBlazor extensions
This commit is contained in:
		
							parent
							
								
									ddfb5b9845
								
							
						
					
					
						commit
						dc77caad12
					
				@ -13,6 +13,7 @@
 | 
			
		||||
        <link rel="icon" type="image/png" href="favicon.png"/>
 | 
			
		||||
        <link href="system/MudBlazor/MudBlazor.min.css" rel="stylesheet" />
 | 
			
		||||
        <link href="system/MudBlazor.Markdown/MudBlazor.Markdown.min.css" rel="stylesheet" />
 | 
			
		||||
        <link href="system/CodeBeam.MudBlazor.Extensions/MudExtensions.min.css" rel="stylesheet" />
 | 
			
		||||
        <link href="app.css" rel="stylesheet" />
 | 
			
		||||
        <HeadOutlet/>
 | 
			
		||||
        <script src="diff.js"></script>
 | 
			
		||||
@ -24,6 +25,7 @@
 | 
			
		||||
        <script src="boot.js"></script>
 | 
			
		||||
        <script src="system/MudBlazor/MudBlazor.min.js"></script>
 | 
			
		||||
        <script src="system/MudBlazor.Markdown/MudBlazor.Markdown.min.js"></script>
 | 
			
		||||
        <script src="system/CodeBeam.MudBlazor.Extensions/MudExtensions.min.js"></script>
 | 
			
		||||
        <script src="app.js"></script>
 | 
			
		||||
    </body>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,3 +1,4 @@
 | 
			
		||||
@using AIStudio
 | 
			
		||||
@using AIStudio.Tools
 | 
			
		||||
@using MudBlazor
 | 
			
		||||
@using MudExtensions
 | 
			
		||||
@ -5,3 +5,4 @@ global using AIStudio.Tools;
 | 
			
		||||
global using Microsoft.JSInterop;
 | 
			
		||||
 | 
			
		||||
global using MudBlazor;
 | 
			
		||||
global using MudExtensions;
 | 
			
		||||
@ -45,6 +45,7 @@
 | 
			
		||||
    </ItemGroup>
 | 
			
		||||
 | 
			
		||||
    <ItemGroup>
 | 
			
		||||
      <PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="7.1.0" />
 | 
			
		||||
      <PackageReference Include="HtmlAgilityPack" Version="1.11.71" />
 | 
			
		||||
      <PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="9.0.0" />
 | 
			
		||||
      <PackageReference Include="MudBlazor" Version="7.15.0" />
 | 
			
		||||
 | 
			
		||||
@ -39,6 +39,7 @@
 | 
			
		||||
                <ThirdPartyComponent Name=".NET" Developer="Microsoft & Open Source Community" LicenseName="MIT" LicenseUrl="https://github.com/dotnet/runtime/blob/main/LICENSE.TXT" RepositoryUrl="https://github.com/dotnet" UseCase="The C# language is used for the implementation of the user interface and the backend. To implement the user interface with C#, the Blazor technology from ASP.NET Core is used. All these technologies are integrated into the .NET SDK."/>
 | 
			
		||||
                <ThirdPartyComponent Name="MudBlazor" Developer="Jonny Larsson, Meinrad Recheis & Open Source Community" LicenseName="MIT" LicenseUrl="https://github.com/MudBlazor/MudBlazor/blob/dev/LICENSE" RepositoryUrl="https://github.com/MudBlazor/MudBlazor/" UseCase="Building on .NET, ASP.NET Core, and Blazor, MudBlazor is used as a library for designing and developing the user interface. It is a great project that significantly accelerates the development of advanced user interfaces with Blazor."/>
 | 
			
		||||
                <ThirdPartyComponent Name="MudBlazor.Markdown" Developer="My Nihongo & Open Source Community" LicenseName="MIT" LicenseUrl="https://github.com/MyNihongo/MudBlazor.Markdown/blob/main/LICENSE" RepositoryUrl="https://github.com/MyNihongo/MudBlazor.Markdown" UseCase="This component is used to render Markdown text. This is important because the LLM often responds with Markdown-formatted text, allowing us to present it in a way that is easier to read."/>
 | 
			
		||||
                <ThirdPartyComponent Name="CodeBeam.MudBlazor.Extensions" Developer="Mehmet Can Karagöz & Open Source Community" LicenseName="MIT" LicenseUrl="https://github.com/CodeBeamOrg/CodeBeam.MudBlazor.Extensions/blob/dev/LICENSE" RepositoryUrl="https://github.com/CodeBeamOrg/CodeBeam.MudBlazor.Extensions" UseCase="This library is used to extend the MudBlazor library. It provides additional components that are not part of the MudBlazor library."/>
 | 
			
		||||
                <ThirdPartyComponent Name="Rust" Developer="Graydon Hoare, Rust Foundation, Rust developers & Open Source Community" LicenseName="MIT" LicenseUrl="https://github.com/rust-lang/rust/blob/master/LICENSE-MIT" RepositoryUrl="https://github.com/rust-lang/rust" UseCase="The .NET backend cannot be started as a desktop app. Therefore, I use a second backend in Rust, which I call runtime. With Rust as the runtime, Tauri can be used to realize a typical desktop app. Thanks to Rust, this app can be offered for Windows, macOS, and Linux desktops. Rust is a great language for developing safe and high-performance software."/>
 | 
			
		||||
                <ThirdPartyComponent Name="Tauri" Developer="Daniel Thompson-Yvetot, Lucas Nogueira, Tensor, Boscop, Serge Zaitsev, George Burton & Open Source Community" LicenseName="MIT" LicenseUrl="https://github.com/tauri-apps/tauri/blob/dev/LICENSE_MIT" RepositoryUrl="https://github.com/tauri-apps/tauri" UseCase="Tauri is used to host the Blazor user interface. It is a great project that allows the creation of desktop applications using web technologies. I love Tauri!"/>
 | 
			
		||||
                <ThirdPartyComponent Name="Rocket" Developer="Sergio Benitez & Open Source Community" LicenseName="MIT" LicenseUrl="https://github.com/rwf2/Rocket/blob/master/LICENSE-MIT" RepositoryUrl="https://github.com/rwf2/Rocket" UseCase="We use Rocket to implement the runtime API. This is necessary because the runtime must be able to communicate with the user interface (IPC). Rocket is a great framework for implementing web APIs in Rust."/>
 | 
			
		||||
 | 
			
		||||
@ -3,3 +3,4 @@
 | 
			
		||||
@using AIStudio.Tools
 | 
			
		||||
@using Microsoft.AspNetCore.Components.Routing
 | 
			
		||||
@using MudBlazor
 | 
			
		||||
@using MudExtensions
 | 
			
		||||
@ -7,6 +7,8 @@ using Microsoft.Extensions.Logging.Console;
 | 
			
		||||
 | 
			
		||||
using MudBlazor.Services;
 | 
			
		||||
 | 
			
		||||
using MudExtensions.Services;
 | 
			
		||||
 | 
			
		||||
#if !DEBUG
 | 
			
		||||
using System.Reflection;
 | 
			
		||||
using Microsoft.Extensions.FileProviders;
 | 
			
		||||
@ -93,6 +95,7 @@ internal sealed class Program
 | 
			
		||||
            options.FormatterName = TerminalLogger.FORMATTER_NAME;
 | 
			
		||||
        }).AddConsoleFormatter<TerminalLogger, ConsoleFormatterOptions>();
 | 
			
		||||
 | 
			
		||||
        builder.Services.AddMudExtensions();
 | 
			
		||||
        builder.Services.AddMudServices(config =>
 | 
			
		||||
        {
 | 
			
		||||
            config.SnackbarConfiguration.PositionClass = Defaults.Classes.Position.BottomLeft;
 | 
			
		||||
 | 
			
		||||
@ -2,6 +2,20 @@
 | 
			
		||||
  "version": 1,
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "net8.0": {
 | 
			
		||||
      "CodeBeam.MudBlazor.Extensions": {
 | 
			
		||||
        "type": "Direct",
 | 
			
		||||
        "requested": "[7.1.0, )",
 | 
			
		||||
        "resolved": "7.1.0",
 | 
			
		||||
        "contentHash": "qbyCT4XMc/lbi2XdkUh9aSPu97RUPDisU7fpTCU0Q4nGywqJsAxrwcpaxJqoycq+uj3smwX5zOn6yzfsHUObeQ==",
 | 
			
		||||
        "dependencies": {
 | 
			
		||||
          "BuildBundlerMinifier": "3.2.449",
 | 
			
		||||
          "CsvHelper": "31.0.3",
 | 
			
		||||
          "Microsoft.AspNetCore.Components": "8.0.11",
 | 
			
		||||
          "Microsoft.AspNetCore.Components.Web": "8.0.11",
 | 
			
		||||
          "MudBlazor": "7.15.0",
 | 
			
		||||
          "ZXing.Net": "0.16.9"
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      "HtmlAgilityPack": {
 | 
			
		||||
        "type": "Direct",
 | 
			
		||||
        "requested": "[1.11.71, )",
 | 
			
		||||
@ -53,6 +67,16 @@
 | 
			
		||||
          "HtmlAgilityPack": "1.11.61"
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      "BuildBundlerMinifier": {
 | 
			
		||||
        "type": "Transitive",
 | 
			
		||||
        "resolved": "3.2.449",
 | 
			
		||||
        "contentHash": "uA9sYDy4VepL3xwzBTLcP2LyuVYMt0ZIT3gaSiXvGoX15Ob+rOP+hGydhevlSVd+rFo+Y+VQFEHDuWU8HBW+XA=="
 | 
			
		||||
      },
 | 
			
		||||
      "CsvHelper": {
 | 
			
		||||
        "type": "Transitive",
 | 
			
		||||
        "resolved": "31.0.3",
 | 
			
		||||
        "contentHash": "ygck8DR4mG/VDA/LgIVVGpEtXXPDVaaNZNJGrOAJ4pckVw4MbAQ3n/u6YFDv3bwlQhlxTmPhCyk5E4hxe96Crg=="
 | 
			
		||||
      },
 | 
			
		||||
      "Markdig": {
 | 
			
		||||
        "type": "Transitive",
 | 
			
		||||
        "resolved": "0.37.0",
 | 
			
		||||
@ -60,66 +84,66 @@
 | 
			
		||||
      },
 | 
			
		||||
      "Microsoft.AspNetCore.Authorization": {
 | 
			
		||||
        "type": "Transitive",
 | 
			
		||||
        "resolved": "8.0.8",
 | 
			
		||||
        "contentHash": "e+ehkJTx0bqUb9zzM9ohV830LhoK3fy5lfVGPWAozbq6I2rJpyq7L0OUgEGNEQLMTzawkDjpNlJ4WU1ck/TDjw==",
 | 
			
		||||
        "resolved": "8.0.11",
 | 
			
		||||
        "contentHash": "ACaLyjBSz9WUzbaJe0Sv09/FihRNHYlRUIj3uQ8CZFFByf6Qwv3+PXnbltidFKz2iOyqdvppQias3emdQUY2nA==",
 | 
			
		||||
        "dependencies": {
 | 
			
		||||
          "Microsoft.AspNetCore.Metadata": "8.0.8",
 | 
			
		||||
          "Microsoft.Extensions.Logging.Abstractions": "8.0.1",
 | 
			
		||||
          "Microsoft.AspNetCore.Metadata": "8.0.11",
 | 
			
		||||
          "Microsoft.Extensions.Logging.Abstractions": "8.0.2",
 | 
			
		||||
          "Microsoft.Extensions.Options": "8.0.2"
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      "Microsoft.AspNetCore.Components": {
 | 
			
		||||
        "type": "Transitive",
 | 
			
		||||
        "resolved": "8.0.8",
 | 
			
		||||
        "contentHash": "VszyvGli+bgbt6gANOPSx8dzHWIH8qrDmWaNzb0GcU8MDKi2eULNW4ga+xyj7ApOYDLZA2V1FL4710Edw0Om4g==",
 | 
			
		||||
        "resolved": "8.0.11",
 | 
			
		||||
        "contentHash": "kyhSQcVEQvMnv2BNRn7JRgYCr+PIO5Uh1mhIFdCNycxE/k8NsI72sV693s1KVmVebMA8g3hTBmfBEheWb3hhww==",
 | 
			
		||||
        "dependencies": {
 | 
			
		||||
          "Microsoft.AspNetCore.Authorization": "8.0.8",
 | 
			
		||||
          "Microsoft.AspNetCore.Components.Analyzers": "8.0.8"
 | 
			
		||||
          "Microsoft.AspNetCore.Authorization": "8.0.11",
 | 
			
		||||
          "Microsoft.AspNetCore.Components.Analyzers": "8.0.11"
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      "Microsoft.AspNetCore.Components.Analyzers": {
 | 
			
		||||
        "type": "Transitive",
 | 
			
		||||
        "resolved": "8.0.8",
 | 
			
		||||
        "contentHash": "PKujmeqEO8fY/U5bWoww63yMF4XqjSnrq0cP4fXUyz4JVYTkh+MZEFktfLaoVaGU4JbtUNjJFvEYA96H8lbb8Q=="
 | 
			
		||||
        "resolved": "8.0.11",
 | 
			
		||||
        "contentHash": "4JtFt5IR0ixuFpwY6D2Xi5R+vZQ6iykd2EuG3puHETCOZOgYG8M538LCY1lbgQTkHOL04YKDjQTQu8PU/BaXRQ=="
 | 
			
		||||
      },
 | 
			
		||||
      "Microsoft.AspNetCore.Components.Forms": {
 | 
			
		||||
        "type": "Transitive",
 | 
			
		||||
        "resolved": "8.0.8",
 | 
			
		||||
        "contentHash": "81P0TqjN+Q52QZbMje1Cirb7DOPKBW8CiemLo9x0KITWEGofdNJJECK1FPoMfUkgyaOknuCRQy0L+6G3K6+rPg==",
 | 
			
		||||
        "resolved": "8.0.11",
 | 
			
		||||
        "contentHash": "60g+idqaiVhPVNOqauy/vH5lREpjcuKl3/w6zJhdU1PFWg4jtdoyIPQH+qxBKsUohkELhH3cRfzGRKElVuZuwg==",
 | 
			
		||||
        "dependencies": {
 | 
			
		||||
          "Microsoft.AspNetCore.Components": "8.0.8"
 | 
			
		||||
          "Microsoft.AspNetCore.Components": "8.0.11"
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      "Microsoft.AspNetCore.Components.Web": {
 | 
			
		||||
        "type": "Transitive",
 | 
			
		||||
        "resolved": "8.0.8",
 | 
			
		||||
        "contentHash": "PX6JYvx2A5R1cQNLiTMMcm+7zvloVCGxvuRf24Ezaj1aUvZDYnSfyNkD2gyVun7AizGAn+x3QYr4mBfbZ9L5TA==",
 | 
			
		||||
        "resolved": "8.0.11",
 | 
			
		||||
        "contentHash": "IDmjQ/K7hv6zUEz2LsCkQBngZx6PMnty8OdSPf0hYGMpC+4Yi37pgCc/25fFu3CSBe8nDirqTrqKtfToHWCpbw==",
 | 
			
		||||
        "dependencies": {
 | 
			
		||||
          "Microsoft.AspNetCore.Components": "8.0.8",
 | 
			
		||||
          "Microsoft.AspNetCore.Components.Forms": "8.0.8",
 | 
			
		||||
          "Microsoft.Extensions.DependencyInjection": "8.0.0",
 | 
			
		||||
          "Microsoft.AspNetCore.Components": "8.0.11",
 | 
			
		||||
          "Microsoft.AspNetCore.Components.Forms": "8.0.11",
 | 
			
		||||
          "Microsoft.Extensions.DependencyInjection": "8.0.1",
 | 
			
		||||
          "Microsoft.Extensions.Primitives": "8.0.0",
 | 
			
		||||
          "Microsoft.JSInterop": "8.0.8",
 | 
			
		||||
          "Microsoft.JSInterop": "8.0.11",
 | 
			
		||||
          "System.IO.Pipelines": "8.0.0"
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      "Microsoft.AspNetCore.Metadata": {
 | 
			
		||||
        "type": "Transitive",
 | 
			
		||||
        "resolved": "8.0.8",
 | 
			
		||||
        "contentHash": "4WSCv7ddawjabLZ7hj0Ai7hTzFYLw5PsvHVKrJkuBgrv+blELbIDMVj7b5q7PZs7Xvz0W0ViKY/rcVkqD0D5yQ=="
 | 
			
		||||
        "resolved": "8.0.11",
 | 
			
		||||
        "contentHash": "cy04xnMSTXTkRPjEwseRz57R5zjR/CWsdEOHH6NhWbNl97k+U1w6dSjqIOC7kv08tyzmM30FzIilSDtE5HdL/A=="
 | 
			
		||||
      },
 | 
			
		||||
      "Microsoft.Extensions.DependencyInjection": {
 | 
			
		||||
        "type": "Transitive",
 | 
			
		||||
        "resolved": "8.0.0",
 | 
			
		||||
        "contentHash": "V8S3bsm50ig6JSyrbcJJ8bW2b9QLGouz+G1miK3UTaOWmMtFwNNNzUf4AleyDWUmTrWMLNnFSLEQtxmxgNQnNQ==",
 | 
			
		||||
        "resolved": "8.0.1",
 | 
			
		||||
        "contentHash": "BmANAnR5Xd4Oqw7yQ75xOAYODybZQRzdeNucg7kS5wWKd2PNnMdYtJ2Vciy0QLylRmv42DGl5+AFL9izA6F1Rw==",
 | 
			
		||||
        "dependencies": {
 | 
			
		||||
          "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0"
 | 
			
		||||
          "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2"
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      "Microsoft.Extensions.DependencyInjection.Abstractions": {
 | 
			
		||||
        "type": "Transitive",
 | 
			
		||||
        "resolved": "8.0.1",
 | 
			
		||||
        "contentHash": "fGLiCRLMYd00JYpClraLjJTNKLmMJPnqxMaiRzEBIIvevlzxz33mXy39Lkd48hu1G+N21S7QpaO5ZzKsI6FRuA=="
 | 
			
		||||
        "resolved": "8.0.2",
 | 
			
		||||
        "contentHash": "3iE7UF7MQkCv1cxzCahz+Y/guQbTqieyxyaWKhrRO91itI9cOKO76OHeQDahqG4MmW5umr3CcCvGmK92lWNlbg=="
 | 
			
		||||
      },
 | 
			
		||||
      "Microsoft.Extensions.FileProviders.Abstractions": {
 | 
			
		||||
        "type": "Transitive",
 | 
			
		||||
@ -147,10 +171,10 @@
 | 
			
		||||
      },
 | 
			
		||||
      "Microsoft.Extensions.Logging.Abstractions": {
 | 
			
		||||
        "type": "Transitive",
 | 
			
		||||
        "resolved": "8.0.1",
 | 
			
		||||
        "contentHash": "RIFgaqoaINxkM2KTOw72dmilDmTrYA0ns2KW4lDz4gZ2+o6IQ894CzmdL3StM2oh7QQq44nCWiqKqc4qUI9Jmg==",
 | 
			
		||||
        "resolved": "8.0.2",
 | 
			
		||||
        "contentHash": "nroMDjS7hNBPtkZqVBbSiQaQjWRDxITI8Y7XnDs97rqG3EbzVTNLZQf7bIeUJcaHOV8bca47s1Uxq94+2oGdxA==",
 | 
			
		||||
        "dependencies": {
 | 
			
		||||
          "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1"
 | 
			
		||||
          "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2"
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      "Microsoft.Extensions.Options": {
 | 
			
		||||
@ -169,15 +193,20 @@
 | 
			
		||||
      },
 | 
			
		||||
      "Microsoft.JSInterop": {
 | 
			
		||||
        "type": "Transitive",
 | 
			
		||||
        "resolved": "8.0.8",
 | 
			
		||||
        "contentHash": "vJhGdkYKvytLIMi5J2vpsyfjPKzSm7dnCfdGwjt4skvJcomlJyKDTA3wAwxIMuMbiWcOi1HuiQ6R+85C+qFJrw=="
 | 
			
		||||
        "resolved": "8.0.11",
 | 
			
		||||
        "contentHash": "UYSbAkNGTWVUne3I04/9IRQel3Bt1Ww6Y5cjvZEZ89rWhBD1yWu7YDotvQS62V6mgSfFaXXPGrCUm1VG824QXw=="
 | 
			
		||||
      },
 | 
			
		||||
      "System.IO.Pipelines": {
 | 
			
		||||
        "type": "Transitive",
 | 
			
		||||
        "resolved": "8.0.0",
 | 
			
		||||
        "contentHash": "FHNOatmUq0sqJOkTx+UF/9YK1f180cnW5FVqnQMvYUN0elp6wFzbtPSiqbo1/ru8ICp43JM1i7kKkk6GsNGHlA=="
 | 
			
		||||
      },
 | 
			
		||||
      "ZXing.Net": {
 | 
			
		||||
        "type": "Transitive",
 | 
			
		||||
        "resolved": "0.16.9",
 | 
			
		||||
        "contentHash": "7WaVMHklpT3Ye2ragqRIwlFRsb6kOk63BOGADV0fan3ulVfGLUYkDi5yNUsZS/7FVNkWbtHAlDLmu4WnHGfqvQ=="
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "net8.0/osx-arm64": {}
 | 
			
		||||
    "net8.0/osx-x64": {}
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1
									
								
								app/MindWork AI Studio/wwwroot/system/CodeBeam.MudBlazor.Extensions/MudExtensions.min.css
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										1
									
								
								app/MindWork AI Studio/wwwroot/system/CodeBeam.MudBlazor.Extensions/MudExtensions.min.css
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										1
									
								
								app/MindWork AI Studio/wwwroot/system/CodeBeam.MudBlazor.Extensions/MudExtensions.min.js
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										1
									
								
								app/MindWork AI Studio/wwwroot/system/CodeBeam.MudBlazor.Extensions/MudExtensions.min.js
									
									
									
									
										vendored
									
									
										Executable file
									
								
							@ -0,0 +1 @@
 | 
			
		||||
function auto_size(n){n.style.height="5px";n.style.height=n.scrollHeight+4+"px"}function getcss(n,t){const i=document.querySelector(n);return i.style.getPropertyValue(t)}function setcss(n,t,i){const r=document.querySelectorAll(n);for(let n=0;n<r.length;n++)r[n].style.setProperty(t,i)}class MudScrollManagerExtended{scrollToMiddle(n,t){let i=document.getElementById(n),r=document.getElementById(t);i.scrollTop=r.offsetTop-i.offsetHeight+i.offsetHeight/2+r.offsetHeight/2}}window.mudScrollManagerExtended=new MudScrollManagerExtended;window.mudTeleport={teleport:(n,t)=>{const i=document.querySelector(t);return i?(i.appendChild(n),"ok"):"not found"},removeFromDOM:n=>{n&&n.__internalId!==null&&n.remove()}};class MudSignaturePadManager{constructor(){this.pads=[]}addPad(n,t,i){const r=new MudSignaturePad(n,t,i);r.init();this.pads.push(r)}togglePadEraser(n){const t=this.getPad(n);t&&t.toggleEraser()}disposePad(n){const t=this.getPad(n);t&&t.dispose()}clearPad(n){const t=this.getPad(n);t&&t.clear(!0)}downloadPadImage(n){const t=this.getPad(n);t&&t.download()}getBase64(n){const t=this.getPad(n);if(t)return t.getBase64()}updatePadOptions(n,t){const i=this.getPad(n);i&&i.setOptions(t)}updatePadImage(n,t){const i=this.getPad(n);if(i){if(t.startsWith("data:image/png;base64,")){i.updateImage(t);return}i.updateImage(`data:image/png;base64,${t}`)}}getPad(n){const t=this.pads.findIndex(t=>t.canvas.id===n.id);return t>=0?this.pads[t]:null}}class MudSignaturePad{constructor(n,t,i){this.canvas=t;this.options=i;this.isMouseDown=!1;this.isErasing=!1;this.memCanvas=document.createElement("canvas");this.points=[];this.dotnetRef=n}get ctx(){return this.canvas.getContext("2d")}get memCtx(){return this.memCanvas.getContext("2d")}getBase64(){return this.canvas.toDataURL()}init(){this.setCanvasSize();this.setOptions(this.options);this.canvas.addEventListener("mousedown",n=>this.startDrawing(n));this.canvas.addEventListener("mousemove",n=>this.drawLine(n));this.canvas.addEventListener("mouseup",()=>this.stopDrawing());this.canvas.addEventListener("mouseout",()=>this.stopDrawing());this.canvas.addEventListener("touchstart",n=>this.startDrawing(n));this.canvas.addEventListener("touchend",()=>this.stopDrawing());this.canvas.addEventListener("touchmove",n=>this.drawLine(n));this.setPencilCursor()}download(){const n=document.createElement("a");n.download="signature.png";n.href=this.canvas.toDataURL();n.click();n.remove()}updateImage(n){this.clear(!0);const t=new Image,i=this.ctx,r=this.memCtx;t.onload=function(){i.drawImage(t,0,0);r.drawImage(t,0,0);t.remove()};t.src=n}setCanvasSize(){const t=this.canvas.parentElement,n=t.getBoundingClientRect();this.canvas.width=n.width;this.canvas.height=n.height;this.memCanvas.height=n.height;this.memCanvas.width=n.width}dispose(){this.canvas.removeEventListener("mousedown");this.canvas.removeEventListener("mousemove");this.canvas.removeEventListener("mouseup");this.canvas.removeEventListener("mouseout");this.canvas.removeEventListener("touchstart");this.canvas.removeEventListener("touchend");this.canvas.removeEventListener("touchmove")}clear(n){n===!0&&this.memCtx.clearRect(0,0,this.canvas.width,this.canvas.height);this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height)}stopDrawing(){this.isMouseDown=!1;this.memCtx.clearRect(0,0,this.memCanvas.width,this.memCanvas.height);this.memCtx.drawImage(this.canvas,0,0);this.points=[]}startDrawing(n){this.isMouseDown=!0;this.points.push({x:n.offsetX,y:n.offsetY})}setOptions(n){this.ctx.lineWidth=n.lineWidth;this.ctx.lineJoin=n.lineJoin;this.ctx.lineCap=n.lineCap;this.ctx.strokeStyle=n.strokeStyle;this.options=n}toggleEraser(){if(this.isErasing=!this.isErasing,this.isErasing){this.setEraserCursor();return}this.setPencilCursor()}setPencilCursor(){this.canvas.setAttribute("style","cursor:url('_content/CodeBeam.MudBlazor.Extensions/pencil.cur'), auto;")}setEraserCursor(){this.canvas.setAttribute("style","cursor:url('_content/CodeBeam.MudBlazor.Extensions/eraser.cur'), auto;")}drawLine(n){this.isMouseDown&&(this.isErasing===!1?(this.clear(),this.ctx.drawImage(this.memCanvas,0,0),this.points.push({x:n.offsetX,y:n.offsetY}),this.drawPoints(this.ctx,this.points)):this.ctx.clearRect(n.offsetX,n.offsetY,23,23))}drawPoints(n,t){if(!(t.length<6)){if(t.length<6){const i=t[0];n.beginPath();n.arc(i.x,i.y,n.lineWidth/2,0,Math.PI*2,!0);n.closePath();n.fill();this.pushUpdateToBlazorComponent();return}n.beginPath();n.moveTo(t[0].x,t[0].y);let i;for(let r=1;r<t.length-2;r++){const u=(t[r].x+t[r+1].x)/2,f=(t[r].y+t[r+1].y)/2;n.quadraticCurveTo(t[r].x,t[r].y,u,f);i=r}n.quadraticCurveTo(t[i].x,t[i].y,t[i+1].x,t[i+1].y);n.stroke();this.pushUpdateToBlazorComponent()}}pushUpdateToBlazorComponent(){this.dotnetRef.invokeMethodAsync("SignatureDataChangedAsync")}}window.mudSignaturePad=new MudSignaturePadManager;
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 4.5 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								app/MindWork AI Studio/wwwroot/system/CodeBeam.MudBlazor.Extensions/eraser.cur
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								app/MindWork AI Studio/wwwroot/system/CodeBeam.MudBlazor.Extensions/eraser.cur
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 4.2 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								app/MindWork AI Studio/wwwroot/system/CodeBeam.MudBlazor.Extensions/pencil.cur
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								app/MindWork AI Studio/wwwroot/system/CodeBeam.MudBlazor.Extensions/pencil.cur
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 326 B  | 
		Loading…
	
		Reference in New Issue
	
	Block a user