├── .gitattributes ├── .gitignore ├── BlazorCefApp.sln ├── BlazorCefApp ├── .config │ └── dotnet-tools.json ├── App.razor ├── BlazorCefApp.csproj ├── BlazorSessionExt.cs ├── CustomizeUI │ ├── UIDialogAlert.razor │ ├── UIDialogConfirm.razor │ └── UIDialogPrompt.razor ├── Demos │ ├── ClipView │ │ └── ClipView.razor │ ├── ComPort │ │ └── ComPort.razor │ ├── DemoDialogBase.cs │ ├── ExeInfo │ │ └── ExeInfo.razor │ ├── MoreCmds │ │ └── MoreCmds.razor │ ├── MsTscAx │ │ ├── MsTscAx.razor │ │ ├── RdpAxHost.cs │ │ └── RdpPanel.cs │ ├── Notepad │ │ └── Notepad.razor │ ├── NtfyIcon │ │ └── NtfyIcon.razor │ ├── PlayMp4 │ │ └── PlayMp4.razor │ ├── PopMenu │ │ └── PopMenu.razor │ ├── ProcList │ │ └── ProcList.razor │ ├── RazorLive │ │ ├── RazorDiagnosticJsonConverter.cs │ │ ├── RazorLive.razor │ │ ├── RazorLive.razor.cs │ │ └── TagHelperDescriptorJsonConverter.cs │ └── RegView │ │ └── RegView.razor ├── MyDownloadForm.cs ├── MyDownloadForm.resx ├── Pages │ ├── Error.razor │ ├── Index.razor │ └── _Host.cshtml ├── Program.cs ├── Properties │ └── launchSettings.json ├── Providers.cs ├── Shared │ └── MainLayout.razor ├── Startup.cs ├── _Imports.razor ├── appsettings.Development.json ├── appsettings.json └── wwwroot │ ├── css │ ├── bootstrap │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ ├── open-iconic │ │ ├── FONT-LICENSE │ │ ├── ICON-LICENSE │ │ ├── README.md │ │ └── font │ │ │ ├── css │ │ │ └── open-iconic-bootstrap.min.css │ │ │ └── fonts │ │ │ ├── open-iconic.eot │ │ │ ├── open-iconic.otf │ │ │ ├── open-iconic.svg │ │ │ ├── open-iconic.ttf │ │ │ └── open-iconic.woff │ └── site.css │ ├── demo.mp4 │ ├── favicon.ico │ └── splash.jpg ├── LICENSE ├── README.md ├── demoscreenshots └── demo-index.png └── dllrefs └── mstscax_interop.dll /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | [Aa][Rr][Mm]/ 24 | [Aa][Rr][Mm]64/ 25 | bld/ 26 | [Bb]in/ 27 | [Oo]bj/ 28 | [Ll]og/ 29 | 30 | # Visual Studio 2015/2017 cache/options directory 31 | .vs/ 32 | # Uncomment if you have tasks that create the project's static files in wwwroot 33 | #wwwroot/ 34 | 35 | # Visual Studio 2017 auto generated files 36 | Generated\ Files/ 37 | 38 | # MSTest test Results 39 | [Tt]est[Rr]esult*/ 40 | [Bb]uild[Ll]og.* 41 | 42 | # NUNIT 43 | *.VisualState.xml 44 | TestResult.xml 45 | 46 | # Build Results of an ATL Project 47 | [Dd]ebugPS/ 48 | [Rr]eleasePS/ 49 | dlldata.c 50 | 51 | # Benchmark Results 52 | BenchmarkDotNet.Artifacts/ 53 | 54 | # .NET Core 55 | project.lock.json 56 | project.fragment.lock.json 57 | artifacts/ 58 | 59 | # StyleCop 60 | StyleCopReport.xml 61 | 62 | # Files built by Visual Studio 63 | *_i.c 64 | *_p.c 65 | *_h.h 66 | *.ilk 67 | *.meta 68 | *.obj 69 | *.iobj 70 | *.pch 71 | *.pdb 72 | *.ipdb 73 | *.pgc 74 | *.pgd 75 | *.rsp 76 | *.sbr 77 | *.tlb 78 | *.tli 79 | *.tlh 80 | *.tmp 81 | *.tmp_proj 82 | *_wpftmp.csproj 83 | *.log 84 | *.vspscc 85 | *.vssscc 86 | .builds 87 | *.pidb 88 | *.svclog 89 | *.scc 90 | 91 | # Chutzpah Test files 92 | _Chutzpah* 93 | 94 | # Visual C++ cache files 95 | ipch/ 96 | *.aps 97 | *.ncb 98 | *.opendb 99 | *.opensdf 100 | *.sdf 101 | *.cachefile 102 | *.VC.db 103 | *.VC.VC.opendb 104 | 105 | # Visual Studio profiler 106 | *.psess 107 | *.vsp 108 | *.vspx 109 | *.sap 110 | 111 | # Visual Studio Trace Files 112 | *.e2e 113 | 114 | # TFS 2012 Local Workspace 115 | $tf/ 116 | 117 | # Guidance Automation Toolkit 118 | *.gpState 119 | 120 | # ReSharper is a .NET coding add-in 121 | _ReSharper*/ 122 | *.[Rr]e[Ss]harper 123 | *.DotSettings.user 124 | 125 | # JustCode is a .NET coding add-in 126 | .JustCode 127 | 128 | # TeamCity is a build add-in 129 | _TeamCity* 130 | 131 | # DotCover is a Code Coverage Tool 132 | *.dotCover 133 | 134 | # AxoCover is a Code Coverage Tool 135 | .axoCover/* 136 | !.axoCover/settings.json 137 | 138 | # Visual Studio code coverage results 139 | *.coverage 140 | *.coveragexml 141 | 142 | # NCrunch 143 | _NCrunch_* 144 | .*crunch*.local.xml 145 | nCrunchTemp_* 146 | 147 | # MightyMoose 148 | *.mm.* 149 | AutoTest.Net/ 150 | 151 | # Web workbench (sass) 152 | .sass-cache/ 153 | 154 | # Installshield output folder 155 | [Ee]xpress/ 156 | 157 | # DocProject is a documentation generator add-in 158 | DocProject/buildhelp/ 159 | DocProject/Help/*.HxT 160 | DocProject/Help/*.HxC 161 | DocProject/Help/*.hhc 162 | DocProject/Help/*.hhk 163 | DocProject/Help/*.hhp 164 | DocProject/Help/Html2 165 | DocProject/Help/html 166 | 167 | # Click-Once directory 168 | publish/ 169 | 170 | # Publish Web Output 171 | *.[Pp]ublish.xml 172 | *.azurePubxml 173 | # Note: Comment the next line if you want to checkin your web deploy settings, 174 | # but database connection strings (with potential passwords) will be unencrypted 175 | *.pubxml 176 | *.publishproj 177 | 178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 179 | # checkin your Azure Web App publish settings, but sensitive information contained 180 | # in these scripts will be unencrypted 181 | PublishScripts/ 182 | 183 | # NuGet Packages 184 | *.nupkg 185 | # The packages folder can be ignored because of Package Restore 186 | **/[Pp]ackages/* 187 | # except build/, which is used as an MSBuild target. 188 | !**/[Pp]ackages/build/ 189 | # Uncomment if necessary however generally it will be regenerated when needed 190 | #!**/[Pp]ackages/repositories.config 191 | # NuGet v3's project.json files produces more ignorable files 192 | *.nuget.props 193 | *.nuget.targets 194 | 195 | # Microsoft Azure Build Output 196 | csx/ 197 | *.build.csdef 198 | 199 | # Microsoft Azure Emulator 200 | ecf/ 201 | rcf/ 202 | 203 | # Windows Store app package directories and files 204 | AppPackages/ 205 | BundleArtifacts/ 206 | Package.StoreAssociation.xml 207 | _pkginfo.txt 208 | *.appx 209 | 210 | # Visual Studio cache files 211 | # files ending in .cache can be ignored 212 | *.[Cc]ache 213 | # but keep track of directories ending in .cache 214 | !?*.[Cc]ache/ 215 | 216 | # Others 217 | ClientBin/ 218 | ~$* 219 | *~ 220 | *.dbmdl 221 | *.dbproj.schemaview 222 | *.jfm 223 | *.pfx 224 | *.publishsettings 225 | orleans.codegen.cs 226 | 227 | # Including strong name files can present a security risk 228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 229 | #*.snk 230 | 231 | # Since there are multiple workflows, uncomment next line to ignore bower_components 232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 233 | #bower_components/ 234 | 235 | # RIA/Silverlight projects 236 | Generated_Code/ 237 | 238 | # Backup & report files from converting an old project file 239 | # to a newer Visual Studio version. Backup files are not needed, 240 | # because we have git ;-) 241 | _UpgradeReport_Files/ 242 | Backup*/ 243 | UpgradeLog*.XML 244 | UpgradeLog*.htm 245 | ServiceFabricBackup/ 246 | *.rptproj.bak 247 | 248 | # SQL Server files 249 | *.mdf 250 | *.ldf 251 | *.ndf 252 | 253 | # Business Intelligence projects 254 | *.rdl.data 255 | *.bim.layout 256 | *.bim_*.settings 257 | *.rptproj.rsuser 258 | *- Backup*.rdl 259 | 260 | # Microsoft Fakes 261 | FakesAssemblies/ 262 | 263 | # GhostDoc plugin setting file 264 | *.GhostDoc.xml 265 | 266 | # Node.js Tools for Visual Studio 267 | .ntvs_analysis.dat 268 | node_modules/ 269 | 270 | # Visual Studio 6 build log 271 | *.plg 272 | 273 | # Visual Studio 6 workspace options file 274 | *.opt 275 | 276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 277 | *.vbw 278 | 279 | # Visual Studio LightSwitch build output 280 | **/*.HTMLClient/GeneratedArtifacts 281 | **/*.DesktopClient/GeneratedArtifacts 282 | **/*.DesktopClient/ModelManifest.xml 283 | **/*.Server/GeneratedArtifacts 284 | **/*.Server/ModelManifest.xml 285 | _Pvt_Extensions 286 | 287 | # Paket dependency manager 288 | .paket/paket.exe 289 | paket-files/ 290 | 291 | # FAKE - F# Make 292 | .fake/ 293 | 294 | # JetBrains Rider 295 | .idea/ 296 | *.sln.iml 297 | 298 | # CodeRush personal settings 299 | .cr/personal 300 | 301 | # Python Tools for Visual Studio (PTVS) 302 | __pycache__/ 303 | *.pyc 304 | 305 | # Cake - Uncomment if you are using it 306 | # tools/** 307 | # !tools/packages.config 308 | 309 | # Tabs Studio 310 | *.tss 311 | 312 | # Telerik's JustMock configuration file 313 | *.jmconfig 314 | 315 | # BizTalk build output 316 | *.btp.cs 317 | *.btm.cs 318 | *.odx.cs 319 | *.xsd.cs 320 | 321 | # OpenCover UI analysis results 322 | OpenCover/ 323 | 324 | # Azure Stream Analytics local run output 325 | ASALocalRun/ 326 | 327 | # MSBuild Binary and Structured Log 328 | *.binlog 329 | 330 | # NVidia Nsight GPU debugger configuration file 331 | *.nvuser 332 | 333 | # MFractors (Xamarin productivity tool) working folder 334 | .mfractor/ 335 | 336 | # Local History for Visual Studio 337 | .localhistory/ 338 | 339 | # BeatPulse healthcheck temp database 340 | healthchecksdb -------------------------------------------------------------------------------- /BlazorCefApp.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29920.165 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E500659E-E2E5-41E5-8B8E-0439A37AB18C}" 7 | ProjectSection(SolutionItems) = preProject 8 | README.md = README.md 9 | EndProjectSection 10 | EndProject 11 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorCefApp", "BlazorCefApp\BlazorCefApp.csproj", "{CA04457A-7790-49D4-8566-DA1FAC7A4674}" 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|Any CPU = Debug|Any CPU 16 | Release|Any CPU = Release|Any CPU 17 | EndGlobalSection 18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 19 | {CA04457A-7790-49D4-8566-DA1FAC7A4674}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 20 | {CA04457A-7790-49D4-8566-DA1FAC7A4674}.Debug|Any CPU.Build.0 = Debug|Any CPU 21 | {CA04457A-7790-49D4-8566-DA1FAC7A4674}.Release|Any CPU.ActiveCfg = Release|Any CPU 22 | {CA04457A-7790-49D4-8566-DA1FAC7A4674}.Release|Any CPU.Build.0 = Release|Any CPU 23 | EndGlobalSection 24 | GlobalSection(SolutionProperties) = preSolution 25 | HideSolutionNode = FALSE 26 | EndGlobalSection 27 | GlobalSection(ExtensibilityGlobals) = postSolution 28 | SolutionGuid = {CB323DD1-E1DE-4791-A2FE-B581E311FBB6} 29 | EndGlobalSection 30 | EndGlobal 31 | -------------------------------------------------------------------------------- /BlazorCefApp/.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "dotnet-ef": { 6 | "version": "3.1.4", 7 | "commands": [ 8 | "dotnet-ef" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /BlazorCefApp/App.razor: -------------------------------------------------------------------------------- 1 |  2 | @inject BlazorSession bses 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |

Sorry, there's nothing at this address.

12 |
13 |
14 |
15 | -------------------------------------------------------------------------------- /BlazorCefApp/BlazorCefApp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.1 5 | WinExe 6 | true 7 | true 8 | 9 | 10 | 11 | x86 12 | false 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | ..\dllrefs\mstscax_interop.dll 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /BlazorCefApp/BlazorSessionExt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Components.Rendering; 6 | using Microsoft.AspNetCore.Components; 7 | using BlazorPlus; 8 | using CefLite; 9 | 10 | 11 | namespace BlazorCefApp 12 | { 13 | 14 | static public class BlazorSessionExt 15 | { 16 | static public ICefWinBrowser FindBrowser(this BlazorSession session) 17 | { 18 | WebCustomizeSession wcs = (WebCustomizeSession)session; 19 | long CefWinBrowserId; 20 | if (!long.TryParse(wcs.HttpContextAccessor.HttpContext.Request.Cookies["CefWinBrowserId"], out CefWinBrowserId)) 21 | { 22 | //BlazorSession.Current.Toast("Failed to get browserid"); 23 | return CefWin.MainBrowser; 24 | } 25 | ICefWinBrowser browser = CefWin.FindBrowser(CefWinBrowserId); 26 | if (browser == null) 27 | { 28 | //BlazorSession.Current.Toast("Failed to find browser : " + CefWinBrowserId); 29 | return CefWin.MainBrowser; 30 | } 31 | return browser; 32 | } 33 | 34 | static public void RunBrowser(this BlazorSession session, Action action) 35 | { 36 | var browser = FindBrowser(session); 37 | CefWin.PostToAppThread(delegate 38 | { 39 | action(browser); 40 | }); 41 | } 42 | 43 | static public void ShowDevTools(this BlazorSession session) 44 | { 45 | RunBrowser(session, browser => 46 | { 47 | browser.Agent.ShowDevTools(); 48 | }); 49 | } 50 | 51 | static public void CloseBrowser(this BlazorSession session) 52 | { 53 | RunBrowser(session, browser => 54 | { 55 | browser.Agent.Dispose(); 56 | }); 57 | } 58 | } 59 | 60 | 61 | 62 | 63 | } 64 | -------------------------------------------------------------------------------- /BlazorCefApp/CustomizeUI/UIDialogAlert.razor: -------------------------------------------------------------------------------- 1 | @inherits UIDialogAlertBase 2 | 3 |
4 |

@Option.RenderTitle()

5 |

6 | @Option.RenderMessage() 7 |

8 |
9 | 10 |
11 | 12 | @code 13 | { 14 | string OKButtonClass 15 | { 16 | get 17 | { 18 | switch (Option.OKType) 19 | { 20 | case UIDialogOptionActionType.Danger: 21 | return "btn btn-danger"; 22 | default: 23 | return "btn btn-primary"; 24 | } 25 | } 26 | } 27 | 28 | protected override void OnSetOption() 29 | { 30 | if (Option.OKText == null) 31 | Option.OKText = "OK"; 32 | } 33 | 34 | ElementReference btnok; 35 | 36 | protected override void OnAfterRender(bool firstRender) 37 | { 38 | BlazorSession.Current.Focus(btnok); 39 | } 40 | 41 | void OKClicked() 42 | { 43 | CloseDialog(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /BlazorCefApp/CustomizeUI/UIDialogConfirm.razor: -------------------------------------------------------------------------------- 1 | @inherits UIDialogConfirmBase 2 | 3 |
4 |

@Option.RenderTitle()

5 |

6 | @Option.RenderMessage() 7 |

8 |
9 | 10 |     11 | 12 |
13 | 14 | @code 15 | { 16 | string OKButtonClass 17 | { 18 | get 19 | { 20 | switch (Option.OKType) 21 | { 22 | case UIDialogOptionActionType.Danger: 23 | return "btn btn-danger"; 24 | default: 25 | return "btn btn-primary"; 26 | } 27 | } 28 | } 29 | 30 | protected override void OnSetOption() 31 | { 32 | if (Option.OKText == null) 33 | Option.OKText = "OK"; 34 | if (Option.CancelText == null) 35 | Option.CancelText = "Cancel"; 36 | } 37 | 38 | ElementReference btnok; 39 | ElementReference btncancel; 40 | 41 | protected override void OnAfterRender(bool firstRender) 42 | { 43 | BlazorSession.Current.Focus(btncancel); 44 | } 45 | 46 | void OKClicked() 47 | { 48 | CloseDialog(true); 49 | } 50 | 51 | void CancelClicked() 52 | { 53 | CloseDialog(false); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /BlazorCefApp/CustomizeUI/UIDialogPrompt.razor: -------------------------------------------------------------------------------- 1 | @inherits UIDialogPromptBase 2 | 3 |
4 |

@Option.RenderTitle()

5 |

6 | @Option.RenderMessage() 7 |

8 | 9 |
10 | 11 |     12 | 13 |
14 | 15 | 16 | 17 | @code 18 | { 19 | string OKButtonClass 20 | { 21 | get 22 | { 23 | switch (Option.OKType) 24 | { 25 | case UIDialogOptionActionType.Danger: 26 | return "btn btn-danger"; 27 | default: 28 | return "btn btn-primary"; 29 | } 30 | } 31 | } 32 | 33 | BlazorInteropObject bs; 34 | 35 | public string Value { get; set; } 36 | 37 | protected override void OnSetOption() 38 | { 39 | if (Option.OKText == null) 40 | Option.OKText = "OK"; 41 | if (Option.CancelText == null) 42 | Option.CancelText = "Cancel"; 43 | 44 | SetValue(Option.DefaultValue); 45 | } 46 | 47 | ElementReference btnok; 48 | ElementReference btncancel; 49 | 50 | ElementReference inp; 51 | 52 | bool ValueIsOK = false; 53 | 54 | Dictionary GetBtnAttr() 55 | { 56 | Dictionary dict = new Dictionary(); 57 | dict["style"] = "min-width:90px"; 58 | if (!ValueIsOK) 59 | { 60 | dict["disabled"] = true; 61 | dict["style"] = "min-width:90px;opacity:0.2"; 62 | } 63 | return dict; 64 | } 65 | 66 | void SetValue(object val) 67 | { 68 | Value = Convert.ToString(val); 69 | if (Option.ValueValidator != null) 70 | ValueIsOK = Option.ValueValidator(Value); 71 | else 72 | ValueIsOK = !string.IsNullOrWhiteSpace(Value); 73 | StateHasChanged(); 74 | } 75 | 76 | protected override void OnAfterRender(bool firstRender) 77 | { 78 | BlazorSession.Current.Focus(inp); 79 | 80 | if (!firstRender) 81 | return; 82 | 83 | 84 | bs.ClientEvent += (sender, evt) => 85 | { 86 | if (evt.Name == "SetValue") 87 | { 88 | SetValue(evt.Arguments[0]); 89 | } 90 | if (evt.Name == "EnterKey") 91 | { 92 | OKClicked(); 93 | } 94 | }; 95 | 96 | bs.Eval(@" 97 | var bs=this; 98 | var inp=arguments[0]; 99 | inp.value=arguments[1]; 100 | var oldval=inp.value; 101 | function checkchanging(){ 102 | if(inp.value==oldval)return; 103 | oldval=inp.value; 104 | bs.ClientEvent('SetValue',[inp.value]); 105 | } 106 | inp.onkeyup=checkchanging; 107 | inp.onchange=checkchanging; 108 | inp.onkeydown=function(e) 109 | { 110 | if(e.keyCode!=13)return; 111 | bs.ClientEvent('EnterKey',[]); 112 | } 113 | ", inp, Value); 114 | 115 | 116 | } 117 | 118 | void OKClicked() 119 | { 120 | if (ValueIsOK) 121 | CloseDialog(Value); 122 | } 123 | 124 | void CancelClicked() 125 | { 126 | CloseDialog(null); 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /BlazorCefApp/Demos/ClipView/ClipView.razor: -------------------------------------------------------------------------------- 1 | @using System.Windows.Forms 2 | 3 | @inject BlazorSession bses 4 | 5 | @code { 6 | 7 | int refreshcount = 0; 8 | 9 | ClipboardStatus status = new ClipboardStatus(); 10 | 11 | class ClipboardStatus 12 | { 13 | public bool ContainsAudio; 14 | public bool ContainsImage; 15 | public bool ContainsFileDropList; 16 | public bool ContainsText; 17 | public bool ContainsHtml; 18 | public bool ContainsRtf; 19 | public string[] Formats; 20 | } 21 | 22 | void RefreshStatus() 23 | { 24 | refreshcount++; 25 | 26 | CefLite.CefWin.InvokeInAppThreadAsync(delegate 27 | { 28 | status.ContainsAudio = Clipboard.ContainsAudio(); 29 | status.ContainsImage = Clipboard.ContainsImage(); 30 | status.ContainsFileDropList = Clipboard.ContainsFileDropList(); 31 | status.ContainsText = Clipboard.ContainsText(TextDataFormat.Text); 32 | status.ContainsHtml = Clipboard.ContainsText(TextDataFormat.Html); 33 | status.ContainsRtf = Clipboard.ContainsText(TextDataFormat.Rtf); 34 | status.Formats = Clipboard.GetDataObject()?.GetFormats(); 35 | bses.InvokeInRenderThread(delegate 36 | { 37 | bses.SetTimeout(500, RefreshStatus); 38 | StateHasChanged(); 39 | }); 40 | }); 41 | } 42 | 43 | RenderFragment CreateDialogForImg(string url) 44 | { 45 | RenderFragment rf = __builder => 46 | { 47 |
48 | 49 |
; 50 | }; 51 | return rf; 52 | } 53 | 54 | void ShowImage() 55 | { 56 | CefLite.CefWin.InvokeInAppThreadAsync(delegate 57 | { 58 | var img = Clipboard.GetImage(); 59 | bses.InvokeInRenderThread(delegate 60 | { 61 | if (img == null) 62 | { 63 | bses.Toast("No Image"); 64 | return; 65 | } 66 | 67 | System.IO.MemoryStream ms = new System.IO.MemoryStream(); 68 | img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); 69 | var str = "data:image/jpeg;base64," + Convert.ToBase64String(ms.ToArray()); 70 | 71 | 72 | bses.ShowDialog(CreateDialogForImg(str)); 73 | 74 | }); 75 | }); 76 | } 77 | } 78 | 79 | @{ 80 | if(refreshcount==0) 81 | { 82 | bses.SetTimeout(1, RefreshStatus); 83 | } 84 | } 85 | 86 | 92 |
93 |
94 | 95 |
96 | ClipView 97 |
98 |
99 |
100 |
101 | #@refreshcount 102 |
103 |
104 | @(status.ContainsAudio?"Yes":"") 105 |
106 |
107 | @(status.ContainsImage?"Yes":"") 108 | @if (status.ContainsImage) 109 | { 110 | 111 | } 112 |
113 |
114 | @(status.ContainsFileDropList?"Yes":"") 115 |
116 |
117 | @(status.ContainsText?"Yes":"") 118 |
119 |
120 | @(status.ContainsHtml?"Yes":"") 121 |
122 |
123 | @(status.ContainsRtf?"Yes":"") 124 |
125 | 126 |
127 | @{ 128 | if (status.Formats == null) 129 | { 130 |
No Formats
131 | } 132 | else 133 | { 134 | foreach (string format in status.Formats) 135 | { 136 |
137 | Format : @format 138 |
139 | } 140 | } 141 | } 142 |
143 | 144 |
145 |
-------------------------------------------------------------------------------- /BlazorCefApp/Demos/ComPort/ComPort.razor: -------------------------------------------------------------------------------- 1 | @inherits DemoDialogBase 2 | @implements IDisposable 3 | 4 | @inject BlazorSession bses 5 | 6 | @code { 7 | 8 | bool _pageDisposed; 9 | System.IO.Ports.SerialPort _sport = new System.IO.Ports.SerialPort(); 10 | 11 | protected override void OnInitialized() 12 | { 13 | base.OnInitialized(); 14 | //NOTE: install System.Text.Encoding.CodePages for more Encoding : Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); 15 | _sport.Encoding = System.Text.Encoding.UTF8; 16 | _sport.ReadTimeout = -1; 17 | _sport.BaudRate = 115200; 18 | _sport.PortName = System.IO.Ports.SerialPort.GetPortNames().OrderByDescending(v => v).First(); 19 | } 20 | 21 | void IDisposable.Dispose() 22 | { 23 | _pageDisposed = true; 24 | if (_sport.IsOpen) _sport.Close(); 25 | _sport = null; 26 | } 27 | 28 | byte[] buffer = new byte[65536]; 29 | int buflen = 0; 30 | 31 | async Task PlayPortAsync() 32 | { 33 | try 34 | { 35 | _sport.Open(); 36 | } 37 | catch (Exception x) 38 | { 39 | bses.Alert("Error", x.ToString()); 40 | return; 41 | } 42 | 43 | try 44 | { 45 | //wait UI Renderer show the msgpanel 46 | //NOTE:PlayPortAsync is called by the button , so the rest code is running in renderer thread 47 | await Task.Delay(100); 48 | 49 | while (true) 50 | { 51 | int rc = await _sport.BaseStream.ReadAsync(buffer, buflen, buffer.Length - buflen); 52 | if (rc == 0) 53 | { 54 | if (_pageDisposed) 55 | return; 56 | await Task.Delay(100); 57 | continue; 58 | } 59 | 60 | buflen += rc; 61 | 62 | ParseAgain: 63 | int pos = Array.IndexOf(buffer, (byte)13, 0, buflen); 64 | if (pos != -1) 65 | { 66 | string line = _sport.Encoding.GetString(buffer, 0, pos); 67 | CreateMsgItem().CssClass("msgitem-line").InnerText(line.Trim()); 68 | int newlen = buflen - pos - 1; 69 | if (newlen > 0) 70 | { 71 | Buffer.BlockCopy(buffer, pos + 1, buffer, 0, newlen); 72 | buflen = newlen; 73 | goto ParseAgain; 74 | } 75 | buflen = 0; 76 | } 77 | else if (buflen == buffer.Length) 78 | { 79 | CreateMsgItem().CssClass("msgitem-full").InnerText("buffer full , ignore " + buflen + " bytes"); 80 | buflen = 0; 81 | } 82 | else if (buflen == 1 && buffer[0] == 10) 83 | { 84 | buflen = 0;//ignore '\r' 85 | } 86 | 87 | StateHasChanged(); 88 | } 89 | } 90 | catch (Exception x) 91 | { 92 | if (_pageDisposed) 93 | return; 94 | bses.Alert("Error", x.ToString()); 95 | _sport.Close(); 96 | StateHasChanged(); 97 | } 98 | finally 99 | { 100 | //TODO: bug , if the unplug the device , it didn't release correctly 101 | try { _sport.Close(); } catch { } 102 | } 103 | } 104 | 105 | PlusControl msgpanel; 106 | void msgpanel_ready(BlazorDomTree bdt) 107 | { 108 | msgpanel = bdt.Root; 109 | } 110 | 111 | PlusControl CreateMsgItem() 112 | { 113 | PlusControl newdiv; 114 | lock (msgpanel) 115 | { 116 | while (msgpanel.GetChildCount() > 200) 117 | msgpanel.RemoveChild(msgpanel.GetChildAt(0)); 118 | newdiv = msgpanel.Create("div"); 119 | } 120 | msgpanel.Eval("var p=this;setTimeout(function(){p.scrollTop=p.scrollHeight},1)"); 121 | return newdiv; 122 | } 123 | 124 | PlusControl inp; 125 | void inp_ready(BlazorDomTree bdt) 126 | { 127 | inp = bdt.Root; 128 | inp.OnEnterKey(delegate 129 | { 130 | TrySend(); 131 | StateHasChanged(); 132 | }); 133 | } 134 | 135 | void TrySend() 136 | { 137 | string str = inp.Value; 138 | if (string.IsNullOrEmpty(str)) 139 | { 140 | bses.Toast("type something.."); 141 | return; 142 | } 143 | 144 | byte[] data = _sport.Encoding.GetBytes(str + "\n"); 145 | try 146 | { 147 | _sport.BaseStream.Write(data, 0, data.Length); 148 | } 149 | catch (Exception x) 150 | { 151 | bses.Alert("Error", x.ToString()); 152 | return; 153 | } 154 | 155 | CreateMsgItem().CssClass("msgitem-send").InnerText(str); 156 | 157 | inp.Value = ""; 158 | inp.SetFocus(); 159 | } 160 | 161 | } 162 | 163 | 174 | 175 |
176 |
177 | 178 |
179 | @if (!_sport.IsOpen) 180 | { 181 | ComPort 182 | } 183 | else 184 | { 185 | @_sport.PortName @_sport.BaudRate 186 | } 187 |
188 |
189 |
190 | @if (!_sport.IsOpen) 191 | { 192 | 193 | 194 | 195 | 196 | 197 |
PortName
BaudRate
198 |
199 | } 200 | else 201 | { 202 | @if (buflen > 1024) 203 | { 204 |
incoming bytes : @buflen @BitConverter.ToString(buffer, 0, buflen)
205 | } 206 | 207 | 208 |
209 | 210 | 211 |
212 | } 213 |
214 |
215 | -------------------------------------------------------------------------------- /BlazorCefApp/Demos/DemoDialogBase.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using BlazorPlus; 7 | using Microsoft.AspNetCore.Routing.Template; 8 | using Microsoft.AspNetCore.DataProtection; 9 | 10 | namespace BlazorCefApp.Demos 11 | { 12 | public abstract class DemoDialogBase : ComponentBase 13 | { 14 | BlazorDialog _dlg; 15 | [CascadingParameter] 16 | public BlazorDialog OwnerDialog 17 | { 18 | get 19 | { 20 | return _dlg; 21 | } 22 | set 23 | { 24 | _dlg = value; 25 | _dlg.CancelHandler = mode => 26 | { 27 | //mode : "ESC" or "BACK" 28 | OnDialogCancel(mode); 29 | }; 30 | _dlg.CloseCalled += _dlg_CloseCalled; 31 | } 32 | 33 | } 34 | 35 | private void _dlg_CloseCalled(object sender, EventArgs e) 36 | { 37 | OnDialogClosed(); 38 | } 39 | 40 | protected virtual void OnDialogClosed() 41 | { 42 | 43 | } 44 | 45 | public void Close() 46 | { 47 | _dlg.CloseAnimate("dialog-slide-out", 200); 48 | } 49 | public void CloseWithoutAnimate() 50 | { 51 | _dlg.Close(); 52 | } 53 | 54 | protected virtual void OnDialogCancel(string mode) 55 | { 56 | Close(); 57 | } 58 | 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /BlazorCefApp/Demos/ExeInfo/ExeInfo.razor: -------------------------------------------------------------------------------- 1 | @inherits DemoDialogBase 2 | 3 | @inject BlazorSession bses 4 | 5 | @inject Microsoft.AspNetCore.Http.IHttpContextAccessor hca 6 | 7 | @inject Microsoft.AspNetCore.Hosting.IWebHostEnvironment whe 8 | 9 | @inject Microsoft.Extensions.Configuration.IConfiguration config 10 | 11 | @inject NavigationManager navmgr 12 | 13 | 14 | @{ 15 | DateTime now = DateTime.Now; 16 | } 17 | 18 | 19 | 48 | 49 |
50 |
51 | 52 |
53 | ExeInfo 54 |
55 |
56 |
57 | 58 |
59 | 60 | BlazorPlus.BlazorSession: 61 | 62 | 63 |
64 | @BlazorSession.Current.SessionId 65 |
66 | 67 |
68 | @BlazorSession.Current.StartTime.ToLongTimeString() 69 |
70 |
71 | @((now - BlazorSession.Current.StartTime).ToString().Split('.')[0]) 72 |
73 | 74 |
75 | @BlazorSession.InstanceCount 76 |
77 |
78 | @BlazorSession.InstanceDisposedCount 79 |
80 |
81 | 82 | 83 |
84 | 85 | BlazorSession.Current.Browser: 86 | 87 | 88 |
89 | @BlazorSession.Current.Browser?.UniqueID 90 |
91 |
92 | @BlazorSession.Current.Browser?.JavaScriptTimezoneOffset 93 |
94 |
95 | @BlazorSession.Current.Browser?.ToBrowserTime(now) 96 |
97 | @*
98 | @(now- (now - now.ToUniversalTime()) - TimeSpan.FromMinutes(BlazorSession.Current.Browser?.JavaScriptTimezoneOffset??0)) 99 |
*@ 100 | 101 |
102 | 103 | 104 |
105 | 106 | Server Time : 107 | 108 |
109 | @(now) 110 |
111 | 112 |
113 | @now.ToUniversalTime() 114 |
115 |
116 | @TimeZoneInfo.Local.DisplayName 117 |
118 |
119 | @TimeZoneInfo.Local.IsDaylightSavingTime(DateTime.Now) 120 |
121 |
122 | @(-(now - now.ToUniversalTime()).TotalMinutes) (Adjusted if DaylightSaving) 123 |
124 |
125 | @(-TimeZoneInfo.Local.BaseUtcOffset.TotalMinutes) (BaseUtcOffset) 126 |
127 |
128 | 129 |
130 | 131 | appsettings.json / appsettings.Development.json 132 | 133 |
134 | @config.GetSection("Logging").GetSection("LogLevel").GetSection("Default").Value 135 |
136 |
137 | 138 | 139 |
140 | 141 | HttpContext: 142 | 143 |
144 | @hca.HttpContext.Connection.Id 145 |
146 |
147 | @hca.HttpContext.Connection.RemoteIpAddress      port: @hca.HttpContext.Connection.RemotePort 148 |
149 |
150 | @(hca.HttpContext.Request.Scheme)://@(hca.HttpContext.Request.Host)@(hca.HttpContext.Request.Path)@(hca.HttpContext.Request.QueryString) 151 |
152 | 153 |
154 | @navmgr.Uri 155 |
156 | 157 |
158 | @string.Join(",", hca.HttpContext.Request.Headers.Keys.ToArray()) 159 |
160 |
161 | @string.Join(",", hca.HttpContext.Request.Cookies.Keys.ToArray()) 162 |
163 |
164 |
165 | 166 | IWebHostEnvironment: 167 | 168 |
169 | @whe.ApplicationName 170 |
171 |
172 | @whe.EnvironmentName 173 |
174 |
175 | @whe.WebRootPath 176 |
177 |
178 | @whe.ContentRootPath 179 |
180 | @*
181 | @whe.WebRootFileProvider 182 |
183 |
184 | @whe.ContentRootFileProvider 185 |
*@ 186 |
187 | 188 | @{ 189 | System.Diagnostics.Process p = System.Diagnostics.Process.GetCurrentProcess(); 190 | } 191 | 192 |
193 | 194 | Environment: 195 | 196 |
197 | @AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName 198 |
199 |
200 | @Environment.Version 201 |
202 |
203 | @Environment.OSVersion ( @(Environment.Is64BitProcess?"64bit":"32bit") ) 204 |
205 |
206 | @Environment.CurrentDirectory 207 |
208 |
209 | @Environment.WorkingSet.ToString("###,###,##0") 210 |
211 |
212 | @p.PeakWorkingSet64.ToString("###,###,##0") 213 |
214 |
215 | @p.HandleCount 216 |
217 |
218 | @p.ProcessName 219 |
220 |
221 | @AppDomain.CurrentDomain.BaseDirectory 222 |
223 |
224 |
225 | 226 | GC Memory: 227 | 228 | 229 |
230 | @(GC.GetTotalMemory(false).ToString("###,###,##0")) 231 |
232 | @{ 233 | var minfo = GC.GetGCMemoryInfo(); 234 | } 235 | 236 |
237 | @minfo.HeapSizeBytes.ToString("###,###,##0") 238 |
239 |
240 | @minfo.FragmentedBytes.ToString("###,###,##0") 241 |
242 | 243 | 244 |
245 | 246 | 247 |
248 | 249 | Disk/Folder 250 | 251 |
252 | @(string.Join(",", Environment.GetLogicalDrives())) 253 |
254 | @foreach (var enumval in Enum.GetValues(typeof(Environment.SpecialFolder))) 255 | { 256 |
257 | @Environment.GetFolderPath((Environment.SpecialFolder)enumval) 258 |
259 | } 260 | 261 |
262 | 263 | 264 |
265 |
266 | -------------------------------------------------------------------------------- /BlazorCefApp/Demos/MoreCmds/MoreCmds.razor: -------------------------------------------------------------------------------- 1 | 
2 |
3 | 4 |
5 | ExeInfo 6 |
7 |
8 |
9 | 10 |

MoreCmds

11 |

Under construction..

12 | 13 |
14 |
15 | 16 | @code { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /BlazorCefApp/Demos/MsTscAx/MsTscAx.razor: -------------------------------------------------------------------------------- 1 | @inherits DemoDialogBase 2 | 3 | @using WF = System.Windows.Forms 4 | 5 | @implements IDisposable 6 | 7 | @inject BlazorSession bses 8 | 9 | @code 10 | { 11 | bool _disposed = false; 12 | void IDisposable.Dispose() 13 | { 14 | _disposed = true; 15 | if (panels.Count == 0) 16 | return; 17 | CefLite.CefWin.InvokeInAppThread(delegate 18 | { 19 | foreach (var p in panels.ToArray()) 20 | { 21 | ClosePanel(p); 22 | } 23 | }); 24 | } 25 | 26 | void ClosePanel(RdpPanel panel) 27 | { 28 | if (!panels.Contains(panel)) 29 | return; 30 | panels.Remove(panel); 31 | if (!_disposed) bses.InvokeInRenderThread(StateHasChanged); 32 | CefLite.CefWin.InvokeInAppThread(delegate 33 | { 34 | panel.Dispose(); 35 | }); 36 | } 37 | 38 | protected override void OnDialogCancel(string mode) 39 | { 40 | if (panels.Count == 0) 41 | { 42 | this.Close(); 43 | return; 44 | } 45 | 46 | if (panels.Any(v => v.Visible)) 47 | return; 48 | 49 | bses.ConfirmYes("Quit", "There're " + panels.Count + " sessions , do you want to quit?", () => 50 | { 51 | this.Close(); 52 | }); 53 | } 54 | 55 | void HidePanels() 56 | { 57 | CefLite.CefWin.InvokeInAppThread(delegate 58 | { 59 | panels.ForEach(v => v.Hide()); 60 | }); 61 | } 62 | void SwitchPanel(RdpPanel panel) 63 | { 64 | CefLite.CefWin.InvokeInAppThread(delegate 65 | { 66 | foreach (var p in panels) 67 | if (p != panel) 68 | p.Hide(); 69 | panel.Show(); 70 | }); 71 | } 72 | 73 | public string JsonFilePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "MsTscAx.json"); 74 | 75 | public class MsTscItem 76 | { 77 | public string Server { get; set; } 78 | public string Description { get; set; } 79 | } 80 | public class MsTscConfig 81 | { 82 | public List Items { get; set; } = new List(); 83 | } 84 | 85 | MsTscConfig _config; 86 | public MsTscConfig GetConfig() 87 | { 88 | if (_config != null) 89 | return _config; 90 | 91 | if (System.IO.File.Exists(JsonFilePath)) 92 | { 93 | try 94 | { 95 | _config = System.Text.Json.JsonSerializer.Deserialize(System.IO.File.ReadAllText(JsonFilePath)); 96 | } 97 | catch (Exception x) 98 | { 99 | bses.Alert("Error", x.ToString()); 100 | } 101 | } 102 | 103 | if (_config == null) 104 | _config = new MsTscConfig(); 105 | 106 | return _config; 107 | } 108 | 109 | List panels = new List(); 110 | 111 | 112 | void ShowItem(MsTscItem item) 113 | { 114 | bses.RunBrowser(browser => 115 | { 116 | RdpPanel panel = panels.FirstOrDefault(v => v.Tag == item); 117 | if (panel != null) 118 | { 119 | panel.Show(); 120 | bses.InvokeInRenderThread(StateHasChanged); 121 | return; 122 | } 123 | 124 | var form = browser.FindForm(); 125 | panel = new RdpPanel(); 126 | panel.Anchor = WF.AnchorStyles.Top | WF.AnchorStyles.Bottom | WF.AnchorStyles.Left | WF.AnchorStyles.Right; 127 | panel.Top = 30; 128 | panel.Left = 0; 129 | panel.Width = form.ClientSize.Width; 130 | panel.Height = form.ClientSize.Height - panel.Top; 131 | 132 | form.Controls.Add(panel); 133 | 134 | 135 | panel.Tag = item; 136 | panels.Add(panel); 137 | panel.Disconnected += delegate 138 | { 139 | bses.Toast("panel.Disconnected"); 140 | ClosePanel(panel); 141 | }; 142 | 143 | CefLite.CefWin.DoMessageLoopOnce(); 144 | panel.Connect(item.Server); 145 | bses.InvokeInRenderThread(StateHasChanged); 146 | }); 147 | } 148 | 149 | string FixHost(string host) 150 | { 151 | if (host.Contains("://")) 152 | host = host.Substring(host.IndexOf("://") + 3); 153 | if (host.Contains("/")) 154 | host = host.Substring(0, host.IndexOf("/")); 155 | return host; 156 | } 157 | 158 | async Task AddNewItemAsync() 159 | { 160 | UIDialogOption opt = new UIDialogOption(); 161 | opt.Title = "Add Server"; 162 | opt.Message = "servername or servername:port"; 163 | opt.ValueValidator = (obj) => 164 | { 165 | string str = Convert.ToString(obj)?.Trim(); 166 | if (string.IsNullOrEmpty(str)) 167 | return false; 168 | 169 | str = FixHost(str); 170 | 171 | int p = str.IndexOf(':'); 172 | int port = 3389; 173 | if (p != -1) 174 | { 175 | if (!int.TryParse(str.Substring(p + 1), out port)) 176 | { 177 | return false; 178 | } 179 | str = str.Substring(0, p); 180 | } 181 | 182 | if (string.IsNullOrEmpty(str)) 183 | return false; 184 | 185 | return true; 186 | }; 187 | 188 | string val = await bses.PromptAsync(opt); 189 | 190 | if (string.IsNullOrEmpty(val)) 191 | return; 192 | 193 | val = FixHost(val); 194 | 195 | string valhost = val.Split(':')[0]; 196 | if (!System.Net.IPAddress.TryParse(valhost, out _)) 197 | { 198 | try 199 | { 200 | await System.Net.Dns.GetHostEntryAsync(valhost); 201 | } 202 | catch (Exception x) 203 | { 204 | bses.Alert("Error", x.ToString()); 205 | return; 206 | } 207 | } 208 | 209 | 210 | MsTscItem item = new MsTscItem() { Server = val }; 211 | var cfg = GetConfig(); 212 | cfg.Items.Add(item); 213 | try 214 | { 215 | System.IO.File.WriteAllText(JsonFilePath, System.Text.Json.JsonSerializer.Serialize(cfg)); 216 | } 217 | catch (Exception x) 218 | { 219 | bses.Alert("Error", x.ToString()); 220 | } 221 | } 222 | 223 | } 224 | 225 | 256 | 257 |
258 | 259 | @if (panels.Any(v => v.Visible)) 260 | { 261 | var fp = panels.First(v => v.Visible); 262 | 263 | 264 |
265 | 266 |
267 | 268 | @foreach (var panel in panels) 269 | { 270 | var item = (MsTscItem)panel.Tag; 271 | if (panel == fp) 272 | { 273 | 274 | } 275 | else 276 | { 277 | 278 | } 279 | } 280 | 281 |
282 | 283 |
284 | } 285 | else 286 | { 287 |
288 | 289 |
290 | Remote Desktop 291 |
292 |
293 |
294 |
295 | 296 | @foreach (MsTscItem item in GetConfig().Items) 297 | { 298 | var panel = panels.FirstOrDefault(v => v.Tag == item); 299 | if (panel != null) 300 | { 301 |
302 |
@item.Server
303 |

...

304 |
305 | } 306 | else 307 | { 308 |
309 |
@item.Server
310 |

...

311 |
312 | } 313 | } 314 | 315 |
316 |
Add New Item
317 |

...

318 |
319 | 320 |
321 |
322 | } 323 |
324 | 325 | -------------------------------------------------------------------------------- /BlazorCefApp/Demos/MsTscAx/RdpAxHost.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | using System.Windows.Input; 7 | using mstscax_interop; 8 | 9 | namespace BlazorCefApp.Demos.MsTscAx 10 | { 11 | public class RdpAxHost : AxHost 12 | { 13 | //https://docs.microsoft.com/en-us/windows/win32/termserv/remote-desktop-activex-control 14 | 15 | static string _FindNewestClsid() 16 | { 17 | using var key = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey("CLSID"); 18 | 19 | //string[] guids = { "1DF7C823-B2D4-4B54-975A-F2AC5D7CF8B8" //MsTscAx.MsTscAx.12 20 | // ,"A0C63C30-F08D-4AB4-907C-34905D770C7D" //MsTscAx.MsTscAx.11 21 | // ,"8B918B82-7985-4C24-89DF-C33AD2BBFBCD" //MsTscAx.MsTscAx.10 22 | // ,"A3BC03A0-041D-42E3-AD22-882B7865C9C5" //MsTscAx.MsTscAx.9 23 | // ,"54D38BF7-B1EF-4479-9674-1BD6EA465258" //MsTscAx.MsTscAx.8 24 | //}; 25 | 26 | //foreach (string guid in guids) 27 | //{ 28 | // try 29 | // { 30 | // using var subkey = key.OpenSubKey("{" + guid + "}"); 31 | // return guid; 32 | // } 33 | // catch 34 | // { 35 | 36 | // } 37 | //} 38 | 39 | //8B918B82-7985-4C24-89DF-C33AD2BBFBCD 40 | return Type.GetTypeFromProgID("MsTscAx.MsTscAx").GUID.ToString(); 41 | 42 | //return "54D38BF7-B1EF-4479-9674-1BD6EA465258"; //MsTscAx.MsTscAx.8 //Windows 7, Windows Server 2008 43 | } 44 | 45 | public static readonly string CLSID = _FindNewestClsid(); 46 | 47 | IMsTscAxEvents _events; 48 | public RdpAxHost(IMsTscAxEvents eventHandler) : base(CLSID) 49 | { 50 | _events = eventHandler; 51 | } 52 | 53 | IMsRdpClient7 _ax; 54 | public IMsRdpClient7 RdpClient 55 | { 56 | get 57 | { 58 | if (_ax == null) 59 | _ax = (IMsRdpClient7)base.GetOcx(); 60 | return _ax; 61 | } 62 | } 63 | 64 | ConnectionPointCookie cookie; 65 | protected override void CreateSink() 66 | { 67 | cookie = new ConnectionPointCookie(RdpClient, _events, typeof(IMsTscAxEvents)); 68 | } 69 | 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /BlazorCefApp/Demos/MsTscAx/RdpPanel.cs: -------------------------------------------------------------------------------- 1 | using CefLite; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using System.Windows.Forms; 7 | using mstscax_interop; 8 | 9 | namespace BlazorCefApp.Demos.MsTscAx 10 | { 11 | public class RdpPanel : Panel, IMsTscAxEvents 12 | { 13 | 14 | void QuitPanel() 15 | { 16 | Disconnected?.Invoke(this, EventArgs.Empty); 17 | this.Dispose(); 18 | } 19 | 20 | public event EventHandler Disconnected; 21 | 22 | protected override void OnHandleDestroyed(EventArgs e) 23 | { 24 | base.OnHandleDestroyed(e); 25 | axhost?.Dispose(); 26 | } 27 | 28 | RdpAxHost axhost; 29 | 30 | public void Connect(string serverAndPort) 31 | { 32 | //MessageBox.Show(RdpAxHost.CLSID); 33 | 34 | if (axhost != null) axhost.Dispose(); 35 | axhost = new RdpAxHost(this); 36 | axhost.Dock = DockStyle.Fill; 37 | this.Controls.Add(axhost); 38 | 39 | string[] pair = serverAndPort.Split(':'); 40 | 41 | CefWin.SetTimeout(100, delegate 42 | { 43 | var rc = axhost.RdpClient; 44 | rc.Server = pair[0]; 45 | 46 | //rc.Domain = ""; 47 | 48 | rc.DesktopWidth = this.ClientSize.Width; 49 | rc.DesktopHeight = this.ClientSize.Height; 50 | rc.ConnectingText = "playing...."; 51 | var adv = rc.AdvancedSettings8; 52 | adv.Compress = 1; 53 | adv.BitmapPeristence = 1; 54 | 55 | if (pair.Length > 1 && int.TryParse(pair[1], out int port)) 56 | { 57 | adv.RDPPort = port; 58 | } 59 | 60 | //rc.UserName = "Administrator"; 61 | //adv.ClearTextPassword = "********"; 62 | adv.AuthenticationLevel = 2; 63 | adv.EnableCredSspSupport = true; 64 | 65 | rc.Connect(); 66 | }); 67 | } 68 | 69 | 70 | 71 | void IMsTscAxEvents.OnConnecting() 72 | { 73 | //CefLite.CefWin.InvokeInAppThread(delegate 74 | //{ 75 | // MessageBox.Show("Connecting"); 76 | //}); 77 | } 78 | 79 | void IMsTscAxEvents.OnConnected() 80 | { 81 | //CefLite.CefWin.InvokeInAppThread(delegate 82 | //{ 83 | // MessageBox.Show("OnConnected"); 84 | //}); 85 | } 86 | 87 | void IMsTscAxEvents.OnLoginComplete() 88 | { 89 | 90 | } 91 | 92 | void IMsTscAxEvents.OnDisconnected(int discReason) 93 | { 94 | //7943 no username/password ? 95 | 96 | //2825 The remote computer requires Network Level Authentication, which your computer does not support. 97 | // set EnableCredSspSupport = true; 98 | 99 | // 100 | 101 | CefLite.CefWin.InvokeInAppThread(delegate 102 | { 103 | //MessageBox.Show("OnDisconnected " + discReason); 104 | QuitPanel(); 105 | }); 106 | } 107 | 108 | void IMsTscAxEvents.OnEnterFullScreenMode() 109 | { 110 | 111 | } 112 | 113 | void IMsTscAxEvents.OnLeaveFullScreenMode() 114 | { 115 | 116 | } 117 | 118 | void IMsTscAxEvents.OnChannelReceivedData(string chanName, string data) 119 | { 120 | 121 | } 122 | 123 | void IMsTscAxEvents.OnRequestGoFullScreen() 124 | { 125 | 126 | } 127 | 128 | void IMsTscAxEvents.OnRequestLeaveFullScreen() 129 | { 130 | 131 | } 132 | 133 | void IMsTscAxEvents.OnFatalError(int errorCode) 134 | { 135 | 136 | } 137 | 138 | void IMsTscAxEvents.OnWarning(int warningCode) 139 | { 140 | 141 | } 142 | 143 | void IMsTscAxEvents.OnRemoteDesktopSizeChange(int width, int height) 144 | { 145 | 146 | } 147 | 148 | void IMsTscAxEvents.OnIdleTimeoutNotification() 149 | { 150 | 151 | } 152 | 153 | void IMsTscAxEvents.OnRequestContainerMinimize() 154 | { 155 | 156 | } 157 | 158 | void IMsTscAxEvents.OnConfirmClose(out bool pfAllowClose) 159 | { 160 | pfAllowClose = true; 161 | } 162 | 163 | void IMsTscAxEvents.OnReceivedTSPublicKey(string publicKey, out bool pfContinueLogon) 164 | { 165 | pfContinueLogon = true; 166 | } 167 | 168 | void IMsTscAxEvents.OnAutoReconnecting(int disconnectReason, int attemptCount, out AutoReconnectContinueState pArcContinueStatus) 169 | { 170 | pArcContinueStatus = AutoReconnectContinueState.autoReconnectContinueAutomatic; 171 | } 172 | 173 | void IMsTscAxEvents.OnAuthenticationWarningDisplayed() 174 | { 175 | 176 | } 177 | 178 | void IMsTscAxEvents.OnAuthenticationWarningDismissed() 179 | { 180 | 181 | } 182 | 183 | void IMsTscAxEvents.OnRemoteProgramResult(string bstrRemoteProgram, RemoteProgramResult lError, bool vbIsExecutable) 184 | { 185 | 186 | } 187 | 188 | void IMsTscAxEvents.OnRemoteProgramDisplayed(bool vbDisplayed, uint uDisplayInformation) 189 | { 190 | 191 | } 192 | 193 | void IMsTscAxEvents.OnRemoteWindowDisplayed(bool vbDisplayed, ref _RemotableHandle hwnd, RemoteWindowDisplayedAttribute windowAttribute) 194 | { 195 | 196 | } 197 | 198 | void IMsTscAxEvents.OnLogonError(int lError) 199 | { 200 | //CefLite.CefWin.InvokeInAppThread(delegate 201 | //{ 202 | // MessageBox.Show("OnLogonError " + lError); 203 | //}); 204 | } 205 | 206 | void IMsTscAxEvents.OnFocusReleased(int iDirection) 207 | { 208 | 209 | } 210 | 211 | void IMsTscAxEvents.OnUserNameAcquired(string bstrUserName) 212 | { 213 | //TODO: remember last user name ? 214 | 215 | //CefLite.CefWin.InvokeInAppThread(delegate 216 | //{ 217 | // MessageBox.Show("OnUserNameAcquired " + bstrUserName); 218 | //}); 219 | } 220 | 221 | void IMsTscAxEvents.OnMouseInputModeChanged(bool fMouseModeRelative) 222 | { 223 | 224 | } 225 | 226 | void IMsTscAxEvents.OnServiceMessageReceived(string serviceMessage) 227 | { 228 | 229 | } 230 | 231 | void IMsTscAxEvents.OnConnectionBarPullDown() 232 | { 233 | 234 | } 235 | 236 | void IMsTscAxEvents.OnNetworkStatusChanged(uint qualityLevel, int bandwidth, int rtt) 237 | { 238 | 239 | } 240 | 241 | void IMsTscAxEvents.OnDevicesButtonPressed() 242 | { 243 | 244 | } 245 | 246 | void IMsTscAxEvents.OnAutoReconnected() 247 | { 248 | 249 | } 250 | 251 | void IMsTscAxEvents.OnAutoReconnecting2(int disconnectReason, bool networkAvailable, int attemptCount, int maxAttemptCount) 252 | { 253 | 254 | } 255 | } 256 | } 257 | -------------------------------------------------------------------------------- /BlazorCefApp/Demos/Notepad/Notepad.razor: -------------------------------------------------------------------------------- 1 | @inherits DemoDialogBase 2 | 3 | @inject BlazorSession bses 4 | 5 | @code{ 6 | 7 | string currentFilePath; 8 | string originalTextCode = ""; 9 | string currentTextCode = ""; 10 | 11 | PlusControl textarea; 12 | void textarea_ready(BlazorDomTree bdt) 13 | { 14 | textarea = bdt.Root; 15 | textarea.OnChanging(delegate 16 | { 17 | currentTextCode = textarea.Value; 18 | StateHasChanged(); 19 | }); 20 | textarea.SetFocus(1); 21 | } 22 | 23 | void WriteToFile(string filepath) 24 | { 25 | try 26 | { 27 | System.IO.File.WriteAllText(filepath, currentTextCode); 28 | originalTextCode = currentTextCode; 29 | } 30 | catch (Exception x) 31 | { 32 | bses.ConsoleError(x.ToString()); 33 | bses.Alert("Error", x.Message); 34 | } 35 | } 36 | 37 | void ShowOpenFileDialog() 38 | { 39 | if (string.IsNullOrWhiteSpace(currentTextCode) || originalTextCode == currentTextCode) 40 | { 41 | ShowOpenFileDialogImpl(); 42 | return; 43 | } 44 | 45 | bses.Confirm("Open", "Open another file without saving text?", (result) => 46 | { 47 | if (result == true) 48 | ShowOpenFileDialogImpl(); 49 | else 50 | textarea.SetFocus(); 51 | }); 52 | } 53 | 54 | void ShowOpenFileDialogImpl() 55 | { 56 | 57 | bses.RunBrowser(browser => 58 | { 59 | var form = browser.FindForm(); 60 | using (System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog()) 61 | { 62 | if (currentFilePath != null) 63 | dialog.FileName = currentFilePath; 64 | dialog.Filter = "Text Files|*.txt"; 65 | var res = dialog.ShowDialog(form); 66 | if (res != System.Windows.Forms.DialogResult.OK) 67 | return; 68 | 69 | bses.InvokeInRenderThread(delegate 70 | { 71 | string txt; 72 | string openfilepath = dialog.FileName; 73 | try 74 | { 75 | txt = System.IO.File.ReadAllText(openfilepath); 76 | } 77 | catch (Exception x) 78 | { 79 | bses.ConsoleError(x.ToString()); 80 | bses.Alert("Error", x.Message); 81 | return; 82 | } 83 | 84 | currentFilePath = openfilepath; 85 | originalTextCode = currentTextCode = txt; 86 | textarea.Value = txt; 87 | textarea.SetFocus(1); 88 | StateHasChanged(); 89 | bses.Toast("Load " + System.IO.Path.GetFileName(currentFilePath)); 90 | }); 91 | } 92 | }); 93 | } 94 | void ShowSaveFileDialog() 95 | { 96 | bses.RunBrowser(browser => 97 | { 98 | var form = browser.FindForm(); 99 | using (System.Windows.Forms.SaveFileDialog dialog = new System.Windows.Forms.SaveFileDialog()) 100 | { 101 | if (currentFilePath != null) 102 | dialog.FileName = currentFilePath; 103 | dialog.Filter = "Text Files|*.txt"; 104 | var res = dialog.ShowDialog(form); 105 | if (res != System.Windows.Forms.DialogResult.OK) 106 | return; 107 | 108 | bses.InvokeInRenderThread(delegate 109 | { 110 | string savefilepath = dialog.FileName; 111 | try 112 | { 113 | WriteToFile(savefilepath); 114 | } 115 | catch (Exception x) 116 | { 117 | bses.ConsoleError(x.ToString()); 118 | bses.Alert("Error", x.Message); 119 | return; 120 | } 121 | 122 | currentFilePath = savefilepath; 123 | originalTextCode = currentTextCode; 124 | textarea.SetFocus(1); 125 | StateHasChanged(); 126 | bses.Toast("Save " + System.IO.Path.GetFileName(currentFilePath)); 127 | }); 128 | } 129 | }); 130 | } 131 | void SaveCurrentFile() 132 | { 133 | if (currentFilePath == null) 134 | ShowSaveFileDialog(); 135 | else 136 | WriteToFile(currentFilePath); 137 | } 138 | 139 | void ExploreCurrentFile() 140 | { 141 | System.Diagnostics.Process.Start("Explorer", "/select, \""+currentFilePath+"\""); 142 | } 143 | 144 | protected override void OnDialogCancel(string mode) 145 | { 146 | 147 | if (string.IsNullOrWhiteSpace(currentTextCode) || originalTextCode == currentTextCode) 148 | { 149 | Close(); 150 | return; 151 | } 152 | 153 | bses.Confirm("Quit", "Quit without saving text?", (result) => 154 | { 155 | if (result == true) 156 | Close(); 157 | else 158 | textarea.SetFocus(); 159 | }); 160 | 161 | } 162 | 163 | void Dialog_KeyPress(KeyboardEventArgs args) 164 | { 165 | bses.ConsoleLog(System.Text.Json.JsonSerializer.Serialize(args)); 166 | if (args.CtrlKey && args.Code == "KeyS") 167 | { 168 | SaveCurrentFile(); 169 | } 170 | } 171 | 172 | } 173 | 174 |
175 |
176 | 177 | 178 | 179 |
180 | @(currentFilePath==null?"Untitled":System.IO.Path.GetFileName(currentFilePath)) 181 | @(originalTextCode != currentTextCode?"*":"") 182 |
183 | @if (currentFilePath != null) 184 | { 185 | 186 | } 187 | 188 |
189 | 190 |
191 | 192 | -------------------------------------------------------------------------------- /BlazorCefApp/Demos/NtfyIcon/NtfyIcon.razor: -------------------------------------------------------------------------------- 1 | @inherits DemoDialogBase 2 | 3 | @using WF = System.Windows.Forms 4 | 5 | @implements IDisposable 6 | 7 | @inject BlazorSession bses 8 | 9 | @code 10 | { 11 | System.Windows.Forms.NotifyIcon ni; 12 | 13 | bool _disposed = false; 14 | void IDisposable.Dispose() 15 | { 16 | _disposed = true; 17 | if (ni != null) 18 | { 19 | ni.Dispose(); 20 | } 21 | } 22 | } 23 | 24 | 25 | @code { 26 | 27 | void Show() 28 | { 29 | CefLite.CefWin.InvokeInAppThread(delegate 30 | { 31 | System.Drawing.Bitmap img = new System.Drawing.Bitmap(32, 32); 32 | using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(img)) 33 | { 34 | g.FillEllipse(System.Drawing.Brushes.Red, 0, 0, 32, 32); 35 | g.FillRectangle(System.Drawing.Brushes.Blue, 8, 8, 16, 16); 36 | } 37 | 38 | if (ni == null) ni = new System.Windows.Forms.NotifyIcon(); 39 | ni.Icon = System.Drawing.Icon.FromHandle(img.GetHicon()); 40 | ni.Visible = true; 41 | ni.BalloonTipText = "OKOK"; 42 | ni.ShowBalloonTip(5000); 43 | ni.ContextMenuStrip = new WF.ContextMenuStrip() { }; 44 | ni.ContextMenuStrip.Items.Add("Back", img, delegate 45 | { 46 | bses.EvalCode("history.back()"); 47 | }); 48 | }); 49 | } 50 | 51 | } 52 | 53 |
54 |
55 | 56 |
57 | NotifyIcon 58 |
59 |
60 |
61 | 62 | 63 | 64 | 65 |
66 |
-------------------------------------------------------------------------------- /BlazorCefApp/Demos/PlayMp4/PlayMp4.razor: -------------------------------------------------------------------------------- 1 | @inherits DemoDialogBase 2 | 3 | @inject BlazorSession bses 4 | 5 | @inject Microsoft.AspNetCore.Hosting.IWebHostEnvironment whe 6 | 7 | 8 | @code{ 9 | 10 | BlazorSession bs = BlazorSession.Current; 11 | 12 | // http://w3schools.sinsixx.com/media/media_playerref.asp.htm 13 | 14 | void MediaPlayer1() 15 | { 16 | bses.RunBrowser(browser => 17 | { 18 | string mp4file = System.IO.Path.Combine(whe.WebRootPath, "demo.mp4"); 19 | 20 | //Windows Media Player 6.4 (classic) 21 | //type lib name "MediaPlayer" 22 | //VS command : tlbimp C:\Windows\system32\msdxm.tlb /out:d:\temp\msdxm_out.dll 23 | Type type = Type.GetTypeFromProgID("MediaPlayer.MediaPlayer.1"); 24 | Console.WriteLine(type.GUID); // 22d6f312-b0f6-11d0-94ab-0080c74c7e95 25 | System.Windows.Forms.Form form = new System.Windows.Forms.Form(); 26 | using (MyAxControl player = new MyAxControl(type)) 27 | { 28 | form.Controls.Add(player); 29 | 30 | form.Text = "Media Player 6.4"; 31 | form.MinimumSize = new System.Drawing.Size(400, 300); 32 | form.Size = new System.Drawing.Size(800, 600); 33 | form.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 34 | 35 | //use SetTimeout to make sure the form has loaded 36 | CefLite.CefWin.SetTimeout(100,delegate 37 | { 38 | try 39 | { 40 | //TODO: sometimes throw exception , method not found 41 | type.InvokeMember("Open", System.Reflection.BindingFlags.InvokeMethod, null, player.GetOcx(), new object[] { mp4file }); 42 | } 43 | catch (Exception x) 44 | { 45 | Console.WriteLine(x); 46 | bses.ConsoleError(x.ToString()); 47 | } 48 | //form.WindowState = System.Windows.Forms.FormWindowState.Maximized; 49 | }); 50 | 51 | form.ShowDialog(browser.FindForm()); 52 | } 53 | }); 54 | 55 | } 56 | 57 | void MediaPlayer7() 58 | { 59 | 60 | bses.RunBrowser(browser => 61 | { 62 | string mp4file = System.IO.Path.Combine(whe.WebRootPath, "demo.mp4"); 63 | 64 | //Windows Media Player 7 or later 65 | //tlbimp C:\Windows\system32\wmp.dll /out:d:\temp\wmp_out.dll 66 | //type lib name "WMPLib" 67 | //https://docs.microsoft.com/en-us/windows/win32/wmp/player-object 68 | Type type = Type.GetTypeFromProgID("WMPlayer.OCX"); 69 | Console.WriteLine(type.GUID); // 6bf52a52-394a-11d3-b153-00c04f79faa6 70 | System.Windows.Forms.Form form = new System.Windows.Forms.Form(); 71 | using (MyAxControl player = new MyAxControl(type)) 72 | { 73 | form.Controls.Add(player); 74 | 75 | form.Text = "Media Player 7+"; 76 | form.MinimumSize = new System.Drawing.Size(400, 300); 77 | form.Size = new System.Drawing.Size(800, 600); 78 | form.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 79 | 80 | //use SetTimeout to make sure the form has loaded 81 | CefLite.CefWin.SetTimeout(100, delegate 82 | { 83 | try 84 | { 85 | type.InvokeMember("URL", System.Reflection.BindingFlags.SetProperty, null, player.GetOcx(), new object[] { mp4file }); 86 | } 87 | catch (Exception x) 88 | { 89 | Console.WriteLine(x); 90 | bses.ConsoleError(x.ToString()); 91 | } 92 | //form.WindowState = System.Windows.Forms.FormWindowState.Maximized; 93 | }); 94 | 95 | form.ShowDialog(browser.FindForm()); 96 | } 97 | 98 | }); 99 | } 100 | 101 | class MyAxControl : System.Windows.Forms.AxHost 102 | { 103 | public MyAxControl(Type type) : base(type.GUID.ToString()) 104 | { 105 | this.Dock = System.Windows.Forms.DockStyle.Fill; 106 | } 107 | } 108 | 109 | } 110 | 111 |
112 |
113 | 114 |
115 | WinForms Media Player 116 |
117 |
118 |
119 |

120 | By default , the libcef.dll from http://opensource.spotify.com/cefbuilds/index.html does not support H264 . 121 |
122 | Developer either compile custom libcef.dll to support it , 123 | Or use the ActiveX MediaPlayer in new window 124 |

125 |
126 |

127 | 128 | 129 |

130 |
131 |
-------------------------------------------------------------------------------- /BlazorCefApp/Demos/PopMenu/PopMenu.razor: -------------------------------------------------------------------------------- 1 | @inherits DemoDialogBase 2 | 3 | @using WF = System.Windows.Forms 4 | 5 | @inject BlazorSession bses 6 | 7 | 8 | @code { 9 | 10 | void Show() 11 | { 12 | bses.RunBrowser(browser => 13 | { 14 | 15 | var menu = new System.Windows.Forms.ContextMenuStrip(); 16 | menu.Items.Add("MessageBox", null, delegate 17 | { 18 | System.Windows.MessageBox.Show("Hello World", "Hello"); 19 | }); 20 | menu.Items.Add("Alert", null, delegate 21 | { 22 | this.InvokeAsync(() => 23 | { 24 | bses.Alert("Hello", "Hello World"); 25 | }); 26 | }); 27 | for(int i=0;i<30;i++) 28 | { 29 | menu.Items.Add("Long Menu " + i); 30 | } 31 | 32 | var form = browser.FindForm(); 33 | var pos = form.PointToClient(WF.Control.MousePosition); 34 | menu.Show(form, pos); 35 | }); 36 | } 37 | 38 | } 39 | 40 |
41 |
42 | 43 |
44 | PopMenu 45 |
46 |
47 |
48 | 49 | 50 | 51 | 52 |
53 |
-------------------------------------------------------------------------------- /BlazorCefApp/Demos/ProcList/ProcList.razor: -------------------------------------------------------------------------------- 1 | @inherits DemoDialogBase 2 | 3 | @inject BlazorSession bses 4 | 5 | @code{ 6 | 7 | // check https://github.com/BlazorPlus/BlazorLinuxAdmin 8 | 9 | bool isunix = !Environment.OSVersion.ToString().Contains("Windows"); 10 | 11 | Dictionary procargs = new Dictionary(); 12 | string FindProcArgs(int id) 13 | { 14 | if (!isunix) 15 | return null; 16 | 17 | string cmdline; 18 | if (procargs.TryGetValue(id, out cmdline)) 19 | return cmdline; 20 | 21 | cmdline = System.IO.File.ReadAllText($"/proc/{ id }/cmdline"); 22 | 23 | if (!string.IsNullOrEmpty(cmdline)) 24 | { 25 | int pos = cmdline.IndexOf('\0'); 26 | if (pos != -1) 27 | cmdline = cmdline.Substring(pos + 1).Replace('\0', ' ').Trim(); 28 | } 29 | 30 | procargs[id] = cmdline; 31 | return cmdline; 32 | } 33 | 34 | bool MatchKeyword(System.Diagnostics.Process p, string kw) 35 | { 36 | if (kw == "!") 37 | return true; 38 | if (kw.StartsWith('!')) 39 | return !MatchKeyword(p, kw.Substring(1)); 40 | if (kw.Length == 0) 41 | return true; 42 | if (p.ProcessName.Contains(kw, StringComparison.OrdinalIgnoreCase)) 43 | return true; 44 | 45 | string args = FindProcArgs(p.Id); 46 | if (!string.IsNullOrEmpty(args) && args.Contains(kw, StringComparison.OrdinalIgnoreCase)) 47 | return true; 48 | 49 | try 50 | { 51 | if (p.MainModule.FileName.Contains(kw, StringComparison.OrdinalIgnoreCase)) 52 | return true; 53 | } 54 | catch 55 | { 56 | 57 | } 58 | 59 | return false; 60 | } 61 | 62 | void bdt_ready(BlazorDomTree bdt) 63 | { 64 | PlusControl toolbar = bdt.Root.Create("div"); 65 | PlusControl divpl = bdt.Root.Create("div"); 66 | PlusGridView grid = bdt.Root.Create("class='bpcgridview' style='width:100%;'"); 67 | 68 | System.Diagnostics.Process currproc = System.Diagnostics.Process.GetCurrentProcess(); 69 | 70 | grid.Columns.Add("Id").CssText("text-align:center"); 71 | grid.LastColumn.CellTemplate.CssText = "text-align:right"; 72 | grid.LastColumn.CellTemplate.GetTextHandler = (cell) => 73 | { 74 | return cell.Item.DataItem.As().Id.ToString(); 75 | }; 76 | 77 | grid.Columns.Add("Sid").CssText("text-align:center"); 78 | grid.LastColumn.CellTemplate.CssText = "text-align:center"; 79 | grid.LastColumn.CellTemplate.GetTextHandler = (cell) => 80 | { 81 | return cell.Item.DataItem.As().SessionId.ToString(); 82 | }; 83 | 84 | grid.Columns.Add("Name").CssText("text-align:center"); 85 | grid.LastColumn.CellTemplate.CssText = "text-align:center;max-width:100px;overflow-x:hidden;text-overflow: ellipsis;"; 86 | grid.LastColumn.CellTemplate.GetTextHandler = (cell) => 87 | { 88 | return cell.Item.DataItem.As().ProcessName; 89 | }; 90 | 91 | grid.Columns.Add("File"); 92 | grid.LastColumn.CellTemplate.RenderHandler = (cell, container) => 93 | { 94 | string filename = null; 95 | var p = cell.Item.DataItem.As(); 96 | try 97 | { 98 | filename = p.MainModule.FileName; 99 | } 100 | catch 101 | { 102 | container.InnerText(""); 103 | return; 104 | } 105 | container.Attribute("title", filename); 106 | if (filename.Length > 50) filename = filename.Substring(0, 24) + " ... " + filename.Substring(filename.Length - 24); 107 | container.InnerText(filename); 108 | }; 109 | 110 | grid.Columns.Add("Args"); 111 | grid.LastColumn.CellTemplate.RenderHandler = (cell, container) => 112 | { 113 | string str = ""; 114 | var p = cell.Item.DataItem.As(); 115 | str = FindProcArgs(p.Id); 116 | if (str == null) 117 | return; 118 | container.Attribute("title", str); 119 | if (str.Length > 50) str = str.Substring(0, 24) + " ... " + str.Substring(str.Length - 24); 120 | container.InnerText(str); 121 | }; 122 | 123 | grid.Columns.Add("CPU").CssText("text-align:center"); 124 | grid.LastColumn.CellTemplate.CssText = "text-align:center"; 125 | grid.LastColumn.CellTemplate.GetTextHandler = (cell) => 126 | { 127 | try 128 | { 129 | return cell.Item.DataItem.As().UserProcessorTime.ToString().Split('.')[0]; 130 | } 131 | catch 132 | { 133 | return ""; 134 | } 135 | }; 136 | 137 | 138 | grid.Columns.Add("Memory").CssText("text-align:right"); 139 | grid.LastColumn.CellTemplate.CssText = "text-align:right"; 140 | grid.LastColumn.CellTemplate.GetTextHandler = (cell) => 141 | { 142 | long size = cell.Item.DataItem.As().WorkingSet64; 143 | if (size > 1024 * 1024) 144 | return size / 1024 / 1024 + "MB"; 145 | return size / 1024 + "KB"; 146 | }; 147 | 148 | grid.Columns.Add("op").CssText("text-align:center"); 149 | grid.LastColumn.CellTemplate.CssText = "text-align:center"; 150 | grid.LastColumn.CellTemplate.RenderHandler = (cell, container) => 151 | { 152 | var p = cell.Item.DataItem.As(); 153 | if (currproc.Id == p.Id) 154 | return; 155 | container.Create("button").InnerText("kill").OnClick(delegate 156 | { 157 | BlazorSession.Current.ConfirmYes("KILL", "kill " + p.ProcessName + " ?", () => 158 | { 159 | try 160 | { 161 | p.Kill(); 162 | } 163 | catch (Exception x) 164 | { 165 | BlazorSession.Current.Alert("Error", x.ToString()); 166 | return; 167 | } 168 | grid.Items.Remove(cell.Item); 169 | }); 170 | }); 171 | }; 172 | 173 | string keywords = ""; 174 | List sorts = new List(); 175 | bool show_sid_zero = false; 176 | 177 | void Search() 178 | { 179 | var ps = System.Diagnostics.Process.GetProcesses(); 180 | 181 | if (!show_sid_zero) 182 | ps = ps.Where(v => v.SessionId > 0).ToArray(); 183 | 184 | if (!string.IsNullOrWhiteSpace(keywords)) 185 | { 186 | foreach (string eachkw in keywords.Split(' ')) 187 | { 188 | string kw = eachkw.Trim(); 189 | if (kw.Length == 0) 190 | continue; 191 | ps = ps.Where(v => MatchKeyword(v, kw)).ToArray(); 192 | } 193 | } 194 | 195 | divpl.ClearChildren(); 196 | 197 | divpl.Create("div").InnerText(ps.Length + " items , current id " + currproc.Id); 198 | 199 | grid.Items.Clear(); 200 | 201 | Array.Sort(ps, (a, b) => 202 | { 203 | int c = 0; 204 | foreach (string sortmode in sorts) 205 | { 206 | if (sortmode == "mem") 207 | c = -a.WorkingSet64.CompareTo(b.WorkingSet64); 208 | if (sortmode == "cpu") 209 | { 210 | TimeSpan tsa = TimeSpan.Zero; 211 | TimeSpan tsb = TimeSpan.Zero; 212 | try { tsa = a.UserProcessorTime; } catch { } 213 | try { tsb = b.UserProcessorTime; } catch { } 214 | c = -tsa.CompareTo(tsb); 215 | } 216 | if (sortmode == "name") 217 | c = a.ProcessName.CompareTo(b.ProcessName); 218 | if (sortmode == "id") 219 | c = a.Id.CompareTo(b.Id); 220 | if (sortmode == "sid") 221 | c = a.SessionId.CompareTo(b.SessionId); 222 | 223 | if (c != 0) 224 | return c; 225 | } 226 | return c; 227 | }); 228 | 229 | foreach (var p in ps) 230 | { 231 | var item = grid.Items.Add(p); 232 | item.SetAttribute("onmouseover", "this.style.backgroundColor='wheat'"); 233 | item.SetAttribute("onmouseout", "this.style.backgroundColor=''"); 234 | if (currproc.Id == p.Id) 235 | { 236 | item.CssText("color:red;font-weight:bold;"); 237 | } 238 | } 239 | } 240 | 241 | void AddSort(string newsort) 242 | { 243 | if (string.IsNullOrEmpty(newsort)) 244 | return; 245 | sorts.Remove(newsort); 246 | sorts.Insert(0, newsort); 247 | } 248 | 249 | toolbar.Create("input type=text placeholder='Keyword'").OnChanging((sender, args) => 250 | { 251 | keywords = args.Control.Value; 252 | Search(); 253 | }); 254 | 255 | toolbar.Create("button style='margin:0 12px'").InnerText("Refresh").OnClick(delegate 256 | { 257 | Search(); 258 | }); 259 | 260 | PlusControl selsort = toolbar.Create("select style='height:30px'"); 261 | selsort.AddOption("Id", "id"); 262 | selsort.AddOption("SessionId", "sid"); 263 | selsort.AddOption("Name", "name"); 264 | selsort.AddOption("CPU", "cpu"); 265 | selsort.AddOption("Memory", "mem"); 266 | selsort.Value = "mem"; 267 | 268 | selsort.OnChange(delegate 269 | { 270 | AddSort(selsort.Value); 271 | BlazorSession.Current.ConsoleLog("sort by :", sorts.ToArray()); 272 | Search(); 273 | }); 274 | 275 | PlusControl label_1 = toolbar.Create("label style='margin:0 12px;display:inline-block;'"); 276 | PlusControl cb_szero = label_1.Create("input type=checkbox"); 277 | label_1.Create("span").InnerText("Show-SessionId-0"); 278 | 279 | cb_szero.OnChange(delegate 280 | { 281 | show_sid_zero = cb_szero.Attribute_Checked; 282 | Search(); 283 | }); 284 | 285 | AddSort(selsort.Value); 286 | Search(); 287 | 288 | } 289 | } 290 | 291 | 306 | 307 |
308 |
309 | 310 |
311 | Process List 312 |
313 |
314 |
315 | 316 | 317 | 318 |
319 |
-------------------------------------------------------------------------------- /BlazorCefApp/Demos/RazorLive/RazorDiagnosticJsonConverter.cs: -------------------------------------------------------------------------------- 1 | // Microsoft.VisualStudio.LanguageServices.Razor.Serialization.RazorDiagnosticJsonConverter 2 | using Microsoft.AspNetCore.Razor.Language; 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Globalization; 7 | 8 | internal class RazorDiagnosticJsonConverter : JsonConverter 9 | { 10 | public static readonly RazorDiagnosticJsonConverter Instance = new RazorDiagnosticJsonConverter(); 11 | 12 | private const string RazorDiagnosticMessageKey = "Message"; 13 | 14 | public override bool CanConvert(Type objectType) 15 | { 16 | return typeof(RazorDiagnostic).IsAssignableFrom(objectType); 17 | } 18 | 19 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 20 | { 21 | if (reader.TokenType != JsonToken.StartObject) 22 | { 23 | return null; 24 | } 25 | JObject jObject = JObject.Load(reader); 26 | string id = jObject["Id"].Value(); 27 | int severity = jObject["Severity"].Value(); 28 | string message = jObject["Message"].Value(); 29 | JObject jObject2 = jObject["Span"].Value(); 30 | string filePath = jObject2["FilePath"].Value(); 31 | int absoluteIndex = jObject2["AbsoluteIndex"].Value(); 32 | int lineIndex = jObject2["LineIndex"].Value(); 33 | int characterIndex = jObject2["CharacterIndex"].Value(); 34 | int length = jObject2["Length"].Value(); 35 | RazorDiagnosticDescriptor descriptor = new RazorDiagnosticDescriptor(id, () => message, (RazorDiagnosticSeverity)severity); 36 | SourceSpan span = new SourceSpan(filePath, absoluteIndex, lineIndex, characterIndex, length); 37 | return RazorDiagnostic.Create(descriptor, span); 38 | } 39 | 40 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) 41 | { 42 | RazorDiagnostic razorDiagnostic = (RazorDiagnostic)value; 43 | writer.WriteStartObject(); 44 | WriteProperty(writer, "Id", razorDiagnostic.Id); 45 | WriteProperty(writer, "Severity", (int)razorDiagnostic.Severity); 46 | WriteProperty(writer, "Message", razorDiagnostic.GetMessage(CultureInfo.CurrentCulture)); 47 | writer.WritePropertyName("Span"); 48 | writer.WriteStartObject(); 49 | WriteProperty(writer, "FilePath", razorDiagnostic.Span.FilePath); 50 | WriteProperty(writer, "AbsoluteIndex", razorDiagnostic.Span.AbsoluteIndex); 51 | WriteProperty(writer, "LineIndex", razorDiagnostic.Span.LineIndex); 52 | WriteProperty(writer, "CharacterIndex", razorDiagnostic.Span.CharacterIndex); 53 | WriteProperty(writer, "Length", razorDiagnostic.Span.Length); 54 | writer.WriteEndObject(); 55 | writer.WriteEndObject(); 56 | } 57 | 58 | private void WriteProperty(JsonWriter writer, string key, T value) 59 | { 60 | writer.WritePropertyName(key); 61 | writer.WriteValue(value); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /BlazorCefApp/Demos/RazorLive/RazorLive.razor: -------------------------------------------------------------------------------- 1 | @inherits DemoDialogBase 2 | 3 | @using WF = System.Windows.Forms 4 | 5 | @inject BlazorSession bses 6 | 7 | 8 | @code { 9 | 10 | protected override void OnDialogCancel(string mode) 11 | { 12 | bses.ConfirmYes("Quit?", "Back to main menu ?", () => 13 | { 14 | this.Close(); 15 | }); 16 | } 17 | 18 | int _timerid = 0; 19 | string _lastcode; 20 | PlusControl _textarea; 21 | int _delay = 1000; 22 | long _changetime = 0; 23 | 24 | void select_ready(BlazorDomTree bdt) 25 | { 26 | void GetValue() 27 | { 28 | bdt.Root.EvalCallback((val, err) => 29 | { 30 | _delay = Convert.ToInt32(val); 31 | }, "return this.value"); 32 | } 33 | bdt.Root.OnChange(delegate 34 | { 35 | GetValue(); 36 | }); 37 | GetValue(); 38 | } 39 | 40 | void textarea_ready(BlazorDomTree bdt) 41 | { 42 | _lastcode = Normalize(DEMO_CODE); 43 | _textarea = bdt.Root; 44 | _textarea.Value = _lastcode; 45 | _textarea.OnChanging(delegate 46 | { 47 | string taval = Normalize(_textarea.Value); 48 | if (taval == _lastcode) 49 | return; 50 | 51 | _lastcode = taval; 52 | _changetime = DateTime.Now.Ticks; 53 | 54 | if (_delay == 0) 55 | { 56 | Compile(); 57 | ShowAssembly(); 58 | StateHasChanged(); 59 | return; 60 | } 61 | 62 | _compileError = null; 63 | _ischanging = true; 64 | Compile(); 65 | StateHasChanged(); 66 | 67 | 68 | if (_delay == -1) 69 | return; 70 | _timerid++; 71 | int tid = _timerid; 72 | bses.SetTimeout(_delay, delegate 73 | { 74 | if (tid != _timerid || !_ischanging) return; 75 | _ischanging = false; 76 | ShowAssembly(); 77 | StateHasChanged(); 78 | }); 79 | }); 80 | 81 | _ = Task.Run(delegate 82 | { 83 | try 84 | { 85 | Compile(); 86 | ShowAssembly(); 87 | } 88 | catch (Exception x) 89 | { 90 | _compileError = x.Message; 91 | } 92 | this.InvokeAsync(StateHasChanged); 93 | }); 94 | } 95 | 96 | void ShowAssembly() 97 | { 98 | if (_lastasmdata == null) 99 | return; 100 | System.Reflection.Assembly newasm = System.Reflection.Assembly.Load(_lastasmdata); 101 | OutputComponentType = newasm.GetType("HelloAssembly.MyComponent"); 102 | } 103 | 104 | void Compile() 105 | { 106 | _lastasmdata = null; 107 | _compileError = null; 108 | try 109 | { 110 | _lastasmdata = CompileCode(_lastcode); 111 | } 112 | catch (Exception x) 113 | { 114 | _compileError = x.Message; 115 | } 116 | } 117 | 118 | void ManualRun() 119 | { 120 | if (!_ischanging) return; 121 | if (_delay != -1) return; 122 | _ischanging = false; 123 | ShowAssembly(); 124 | StateHasChanged(); 125 | } 126 | 127 | bool _ischanging; 128 | 129 | string _compileError; 130 | byte[] _lastasmdata; 131 | 132 | public Type OutputComponentType; 133 | 134 | } 135 | 136 |
137 |
138 | 139 |
140 | RazorLive 141 |
142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 |
157 |
158 | 159 |
160 | @if (OutputComponentType == null) 161 | { 162 |
Loading compiler...
163 | } 164 | else 165 | { 166 | __builder.OpenComponent(1, OutputComponentType); 167 | __builder.CloseComponent(); 168 | } 169 | @if (_ischanging || _compileError != null) 170 | { 171 | string clsname = "animate-" + _changetime; 172 | 173 |
174 | @if (_compileError != null) 175 | { 176 |
177 | @_compileError 178 |
179 | } 180 | else if (_delay == -1) 181 | { 182 | 183 | } 184 |
185 | @if (_compileError == null) 186 | { 187 | 203 |
204 |
205 | 206 |
207 | } 208 | } 209 |
210 |
211 |
212 | @_compileError 213 |
214 |
-------------------------------------------------------------------------------- /BlazorCefApp/Demos/RazorLive/RazorLive.razor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Reflection; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | using BlazorPlus; 10 | using Microsoft.AspNetCore.Components; 11 | using Microsoft.AspNetCore.Components.Forms; 12 | using Microsoft.AspNetCore.Components.Web; 13 | using Microsoft.AspNetCore.Hosting; 14 | using Microsoft.AspNetCore.Razor.Language; 15 | using Microsoft.CodeAnalysis.Razor; 16 | using Newtonsoft.Json; 17 | 18 | namespace BlazorCefApp.Demos.RazorLive 19 | { 20 | public partial class RazorLive 21 | { 22 | const string DEMO_CODE = @" 23 | 24 | @code 25 | { 26 | 27 | void SayHello() 28 | { 29 | BlazorPlus.BlazorSession.Current.Alert(""Hello"",""Cooooollll""); 30 | } 31 | 32 | } 33 | 34 | 35 | 36 | "; 37 | 38 | 39 | string Normalize(string code) 40 | { 41 | return code.Replace("\r", ""); 42 | } 43 | 44 | [Inject] 45 | public IWebHostEnvironment WHE { get; set; } 46 | 47 | Microsoft.CodeAnalysis.PortableExecutableReference[] refs; 48 | TagHelperDescriptor[] tagHelpers; 49 | List exts; 50 | 51 | byte[] CompileCode(string code) 52 | { 53 | typeof(EventHandlers).ToString(); 54 | typeof(EditContext).ToString();//ensure more assemblies.. 55 | 56 | if (refs == null) 57 | { 58 | refs = AppDomain.CurrentDomain.GetAssemblies().Select(v => 59 | { 60 | try 61 | { 62 | return Microsoft.CodeAnalysis.MetadataReference.CreateFromFile(v.Location); 63 | } 64 | catch 65 | { 66 | return null; 67 | } 68 | }).Where(v => v != null).ToArray(); 69 | } 70 | 71 | if (exts == null) 72 | { 73 | exts = new List(); 74 | exts.Add(new AssemblyExtension("ComponentBase", typeof(ComponentBase).Assembly)); 75 | exts.Add(new AssemblyExtension("ComponentWeb", typeof(BindAttributes).Assembly)); 76 | 77 | foreach (AssemblyName asm in this.GetType().Assembly.GetReferencedAssemblies()) 78 | { 79 | exts.Add(new AssemblyExtension(asm.FullName, AppDomain.CurrentDomain.Load(asm.FullName))); 80 | } 81 | } 82 | 83 | var config = RazorConfiguration.Create(RazorLanguageVersion.Version_3_0, "Default", exts); 84 | 85 | var proj = new MyProject(); 86 | 87 | if (tagHelpers == null) 88 | { 89 | var rpe1 = RazorProjectEngine.Create(config, proj, b => 90 | { 91 | //Check Microsoft.AspNetCore.Razor.Tools.DiscoverCommand 92 | b.Features.Add(new DefaultMetadataReferenceFeature 93 | { 94 | References = refs 95 | }); 96 | b.Features.Add(new CompilationTagHelperFeature()); 97 | b.Features.Add(new DefaultTagHelperDescriptorProvider()); 98 | CompilerFeatures.Register(b); 99 | }); 100 | 101 | tagHelpers = rpe1.Engine.Features.OfType().Single().GetDescriptors().ToArray(); 102 | } 103 | 104 | if (code == null) 105 | return null; 106 | 107 | var engine = RazorProjectEngine.Create(config, proj, b => 108 | { 109 | var mf = new MyFeatureV2() { TagHelpers = tagHelpers }; 110 | b.Features.Add(mf); 111 | }); 112 | 113 | var projitem = new MyProjectItem() { Name = "MyComponent.razor", Code = code }; 114 | 115 | var razorDoc = engine.Process(projitem); 116 | 117 | var csdoc = razorDoc.GetCSharpDocument(); 118 | 119 | foreach (var diag in csdoc.Diagnostics) 120 | { 121 | switch (diag.Id) 122 | { 123 | case "RZ9980": 124 | case "RZ9981": 125 | throw new Exception("Error : " + diag.Id); 126 | } 127 | } 128 | 129 | string targetCode = csdoc.GeneratedCode; 130 | 131 | if (string.IsNullOrEmpty(targetCode) && csdoc.Diagnostics.Count != 0) 132 | return null; 133 | 134 | var invalidAttrChars = new char[] { '@', '/', '\\' }; 135 | foreach (string eachline in targetCode.Split('\n')) 136 | { 137 | var line = eachline.Trim(); 138 | if (line.StartsWith("__builder.AddAttribute")) 139 | { 140 | int p1 = line.IndexOf('"') + 1; 141 | int p2 = line.IndexOf('"', p1); 142 | var attrname = line.Substring(p1, p2 - p1); 143 | 144 | if (attrname.IndexOfAny(invalidAttrChars) != -1) 145 | throw new Exception("Invalid attribute name [" + attrname + "]"); 146 | 147 | } 148 | } 149 | 150 | System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); 151 | watch.Start(); 152 | 153 | 154 | var st = Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.ParseText(csdoc.GeneratedCode); 155 | var csc = Microsoft.CodeAnalysis.CSharp.CSharpCompilation.Create("new" + DateTime.Now.Ticks) 156 | .WithOptions(new Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions(Microsoft.CodeAnalysis.OutputKind.DynamicallyLinkedLibrary)) 157 | .AddSyntaxTrees(st) 158 | .AddReferences(refs); 159 | 160 | System.IO.MemoryStream ms = new System.IO.MemoryStream(); 161 | var result = csc.Emit(ms); 162 | if (!result.Success) 163 | throw new Exception(result.Diagnostics.First(v => v.Severity == Microsoft.CodeAnalysis.DiagnosticSeverity.Error).ToString()); 164 | 165 | return ms.ToArray(); 166 | 167 | 168 | } 169 | 170 | 171 | class MyFeatureV2 : IConfigureRazorCodeGenerationOptionsFeature, ITagHelperFeature 172 | { 173 | public int Order => 1; 174 | 175 | public RazorEngine Engine { get; set; } 176 | 177 | public void Configure(RazorCodeGenerationOptionsBuilder options) 178 | { 179 | options.RootNamespace = "HelloAssembly"; 180 | } 181 | 182 | public IReadOnlyList TagHelpers { get; set; } 183 | 184 | public IReadOnlyList GetDescriptors() 185 | { 186 | return TagHelpers; 187 | 188 | } 189 | 190 | } 191 | 192 | 193 | class MyProjectItem : RazorProjectItem 194 | { 195 | public override string FileKind => FileKinds.Component; 196 | 197 | public override string BasePath => "/"; 198 | 199 | public override string FilePath => "/" + Name; 200 | 201 | public override string PhysicalPath => "/" + Name; 202 | 203 | public override bool Exists => true; 204 | 205 | public string Name; 206 | 207 | public string Code; 208 | 209 | public override Stream Read() 210 | { 211 | return new MemoryStream(Encoding.UTF8.GetBytes(Code)); 212 | } 213 | 214 | } 215 | 216 | 217 | class MyProject : RazorProjectFileSystem 218 | { 219 | public override IEnumerable EnumerateItems(string basePath) 220 | { 221 | throw new NotImplementedException(); 222 | } 223 | 224 | [Obsolete] 225 | public override RazorProjectItem GetItem(string path) 226 | { 227 | throw new NotImplementedException(); 228 | } 229 | 230 | public override RazorProjectItem GetItem(string path, string fileKind) 231 | { 232 | if (path == "/_Imports.razor") 233 | return new MyProjectItem() { Name = "_Imports.razor", Code = @" 234 | 235 | @using Microsoft.AspNetCore.Authorization 236 | @using Microsoft.AspNetCore.Components.Authorization 237 | @using Microsoft.AspNetCore.Components.Forms 238 | @using Microsoft.AspNetCore.Components.Routing 239 | @using Microsoft.AspNetCore.Components.Web 240 | @using Microsoft.JSInterop 241 | 242 | " }; 243 | 244 | 245 | throw new NotImplementedException(fileKind + ":" + path); 246 | } 247 | } 248 | } 249 | } 250 | -------------------------------------------------------------------------------- /BlazorCefApp/Demos/RazorLive/TagHelperDescriptorJsonConverter.cs: -------------------------------------------------------------------------------- 1 |  2 | // Microsoft.VisualStudio.LanguageServices.Razor.Serialization.TagHelperDescriptorJsonConverter 3 | using Microsoft.AspNetCore.Razor.Language; 4 | using Newtonsoft.Json; 5 | using Newtonsoft.Json.Linq; 6 | using System; 7 | using System.Collections.Generic; 8 | 9 | internal class TagHelperDescriptorJsonConverter : JsonConverter 10 | { 11 | public static readonly TagHelperDescriptorJsonConverter Instance = new TagHelperDescriptorJsonConverter(); 12 | 13 | public override bool CanConvert(Type objectType) 14 | { 15 | return typeof(TagHelperDescriptor).IsAssignableFrom(objectType); 16 | } 17 | 18 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 19 | { 20 | if (reader.TokenType != JsonToken.StartObject) 21 | { 22 | return null; 23 | } 24 | JObject jObject = JObject.Load(reader); 25 | string kind = jObject["Kind"].Value(); 26 | string name = jObject["Name"].Value(); 27 | string assemblyName = jObject["AssemblyName"].Value(); 28 | JArray jArray = jObject["TagMatchingRules"].Value(); 29 | JArray jArray2 = jObject["BoundAttributes"].Value(); 30 | JArray jArray3 = jObject["AllowedChildTags"].Value(); 31 | string documentation = jObject["Documentation"].Value(); 32 | string tagOutputHint = jObject["TagOutputHint"].Value(); 33 | bool caseSensitive = jObject["CaseSensitive"].Value(); 34 | JArray jArray4 = jObject["Diagnostics"].Value(); 35 | JObject jObject2 = jObject["Metadata"].Value(); 36 | TagHelperDescriptorBuilder tagHelperDescriptorBuilder = TagHelperDescriptorBuilder.Create(kind, name, assemblyName); 37 | tagHelperDescriptorBuilder.Documentation = documentation; 38 | tagHelperDescriptorBuilder.TagOutputHint = tagOutputHint; 39 | tagHelperDescriptorBuilder.CaseSensitive = caseSensitive; 40 | foreach (JToken item2 in jArray) 41 | { 42 | JObject rule = item2.Value(); 43 | tagHelperDescriptorBuilder.TagMatchingRule(delegate (TagMatchingRuleDescriptorBuilder b) 44 | { 45 | ReadTagMatchingRule(b, rule, serializer); 46 | }); 47 | } 48 | foreach (JToken item3 in jArray2) 49 | { 50 | JObject attribute = item3.Value(); 51 | tagHelperDescriptorBuilder.BindAttribute(delegate (BoundAttributeDescriptorBuilder b) 52 | { 53 | ReadBoundAttribute(b, attribute, serializer); 54 | }); 55 | } 56 | foreach (JToken item4 in jArray3) 57 | { 58 | JObject tag = item4.Value(); 59 | tagHelperDescriptorBuilder.AllowChildTag(delegate (AllowedChildTagDescriptorBuilder childTagBuilder) 60 | { 61 | ReadAllowedChildTag(childTagBuilder, tag, serializer); 62 | }); 63 | } 64 | foreach (JToken item5 in jArray4) 65 | { 66 | JsonReader reader2 = item5.CreateReader(); 67 | RazorDiagnostic item = serializer.Deserialize(reader2); 68 | tagHelperDescriptorBuilder.Diagnostics.Add(item); 69 | } 70 | JsonReader reader3 = jObject2.CreateReader(); 71 | foreach (KeyValuePair item6 in serializer.Deserialize>(reader3)) 72 | { 73 | tagHelperDescriptorBuilder.Metadata[item6.Key] = item6.Value; 74 | } 75 | return tagHelperDescriptorBuilder.Build(); 76 | } 77 | 78 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) 79 | { 80 | TagHelperDescriptor tagHelperDescriptor = (TagHelperDescriptor)value; 81 | writer.WriteStartObject(); 82 | writer.WritePropertyName("Kind"); 83 | writer.WriteValue(tagHelperDescriptor.Kind); 84 | writer.WritePropertyName("Name"); 85 | writer.WriteValue(tagHelperDescriptor.Name); 86 | writer.WritePropertyName("AssemblyName"); 87 | writer.WriteValue(tagHelperDescriptor.AssemblyName); 88 | writer.WritePropertyName("Documentation"); 89 | writer.WriteValue(tagHelperDescriptor.Documentation); 90 | writer.WritePropertyName("TagOutputHint"); 91 | writer.WriteValue(tagHelperDescriptor.TagOutputHint); 92 | writer.WritePropertyName("CaseSensitive"); 93 | writer.WriteValue(tagHelperDescriptor.CaseSensitive); 94 | writer.WritePropertyName("TagMatchingRules"); 95 | writer.WriteStartArray(); 96 | foreach (TagMatchingRuleDescriptor tagMatchingRule in tagHelperDescriptor.TagMatchingRules) 97 | { 98 | WriteTagMatchingRule(writer, tagMatchingRule, serializer); 99 | } 100 | writer.WriteEndArray(); 101 | writer.WritePropertyName("BoundAttributes"); 102 | writer.WriteStartArray(); 103 | foreach (BoundAttributeDescriptor boundAttribute in tagHelperDescriptor.BoundAttributes) 104 | { 105 | WriteBoundAttribute(writer, boundAttribute, serializer); 106 | } 107 | writer.WriteEndArray(); 108 | writer.WritePropertyName("AllowedChildTags"); 109 | writer.WriteStartArray(); 110 | foreach (AllowedChildTagDescriptor allowedChildTag in tagHelperDescriptor.AllowedChildTags) 111 | { 112 | WriteAllowedChildTags(writer, allowedChildTag, serializer); 113 | } 114 | writer.WriteEndArray(); 115 | writer.WritePropertyName("Diagnostics"); 116 | serializer.Serialize(writer, tagHelperDescriptor.Diagnostics); 117 | writer.WritePropertyName("Metadata"); 118 | WriteMetadata(writer, tagHelperDescriptor.Metadata); 119 | writer.WriteEndObject(); 120 | } 121 | 122 | private static void WriteAllowedChildTags(JsonWriter writer, AllowedChildTagDescriptor allowedChildTag, JsonSerializer serializer) 123 | { 124 | writer.WriteStartObject(); 125 | writer.WritePropertyName("Name"); 126 | writer.WriteValue(allowedChildTag.Name); 127 | writer.WritePropertyName("DisplayName"); 128 | writer.WriteValue(allowedChildTag.DisplayName); 129 | writer.WritePropertyName("Diagnostics"); 130 | serializer.Serialize(writer, allowedChildTag.Diagnostics); 131 | writer.WriteEndObject(); 132 | } 133 | 134 | private static void WriteBoundAttribute(JsonWriter writer, BoundAttributeDescriptor boundAttribute, JsonSerializer serializer) 135 | { 136 | writer.WriteStartObject(); 137 | writer.WritePropertyName("Kind"); 138 | writer.WriteValue(boundAttribute.Kind); 139 | writer.WritePropertyName("Name"); 140 | writer.WriteValue(boundAttribute.Name); 141 | writer.WritePropertyName("TypeName"); 142 | writer.WriteValue(boundAttribute.TypeName); 143 | writer.WritePropertyName("IsEnum"); 144 | writer.WriteValue(boundAttribute.IsEnum); 145 | writer.WritePropertyName("IndexerNamePrefix"); 146 | writer.WriteValue(boundAttribute.IndexerNamePrefix); 147 | writer.WritePropertyName("IndexerTypeName"); 148 | writer.WriteValue(boundAttribute.IndexerTypeName); 149 | writer.WritePropertyName("Documentation"); 150 | writer.WriteValue(boundAttribute.Documentation); 151 | writer.WritePropertyName("Diagnostics"); 152 | serializer.Serialize(writer, boundAttribute.Diagnostics); 153 | writer.WritePropertyName("Metadata"); 154 | WriteMetadata(writer, boundAttribute.Metadata); 155 | writer.WritePropertyName("BoundAttributeParameters"); 156 | writer.WriteStartArray(); 157 | foreach (BoundAttributeParameterDescriptor boundAttributeParameter in boundAttribute.BoundAttributeParameters) 158 | { 159 | WriteBoundAttributeParameter(writer, boundAttributeParameter, serializer); 160 | } 161 | writer.WriteEndArray(); 162 | writer.WriteEndObject(); 163 | } 164 | 165 | private static void WriteBoundAttributeParameter(JsonWriter writer, BoundAttributeParameterDescriptor boundAttributeParameter, JsonSerializer serializer) 166 | { 167 | writer.WriteStartObject(); 168 | writer.WritePropertyName("Kind"); 169 | writer.WriteValue(boundAttributeParameter.Kind); 170 | writer.WritePropertyName("Name"); 171 | writer.WriteValue(boundAttributeParameter.Name); 172 | writer.WritePropertyName("TypeName"); 173 | writer.WriteValue(boundAttributeParameter.TypeName); 174 | writer.WritePropertyName("IsEnum"); 175 | writer.WriteValue(boundAttributeParameter.IsEnum); 176 | writer.WritePropertyName("Documentation"); 177 | writer.WriteValue(boundAttributeParameter.Documentation); 178 | writer.WritePropertyName("Diagnostics"); 179 | serializer.Serialize(writer, boundAttributeParameter.Diagnostics); 180 | writer.WritePropertyName("Metadata"); 181 | WriteMetadata(writer, boundAttributeParameter.Metadata); 182 | writer.WriteEndObject(); 183 | } 184 | 185 | private static void WriteMetadata(JsonWriter writer, IReadOnlyDictionary metadata) 186 | { 187 | writer.WriteStartObject(); 188 | foreach (KeyValuePair metadatum in metadata) 189 | { 190 | writer.WritePropertyName(metadatum.Key); 191 | writer.WriteValue(metadatum.Value); 192 | } 193 | writer.WriteEndObject(); 194 | } 195 | 196 | private static void WriteTagMatchingRule(JsonWriter writer, TagMatchingRuleDescriptor ruleDescriptor, JsonSerializer serializer) 197 | { 198 | writer.WriteStartObject(); 199 | writer.WritePropertyName("TagName"); 200 | writer.WriteValue(ruleDescriptor.TagName); 201 | writer.WritePropertyName("ParentTag"); 202 | writer.WriteValue(ruleDescriptor.ParentTag); 203 | writer.WritePropertyName("TagStructure"); 204 | writer.WriteValue(ruleDescriptor.TagStructure); 205 | writer.WritePropertyName("Attributes"); 206 | writer.WriteStartArray(); 207 | foreach (RequiredAttributeDescriptor attribute in ruleDescriptor.Attributes) 208 | { 209 | WriteRequiredAttribute(writer, attribute, serializer); 210 | } 211 | writer.WriteEndArray(); 212 | writer.WritePropertyName("Diagnostics"); 213 | serializer.Serialize(writer, ruleDescriptor.Diagnostics); 214 | writer.WriteEndObject(); 215 | } 216 | 217 | private static void WriteRequiredAttribute(JsonWriter writer, RequiredAttributeDescriptor requiredAttribute, JsonSerializer serializer) 218 | { 219 | writer.WriteStartObject(); 220 | writer.WritePropertyName("Name"); 221 | writer.WriteValue(requiredAttribute.Name); 222 | writer.WritePropertyName("NameComparison"); 223 | writer.WriteValue(requiredAttribute.NameComparison); 224 | writer.WritePropertyName("Value"); 225 | writer.WriteValue(requiredAttribute.Value); 226 | writer.WritePropertyName("ValueComparison"); 227 | writer.WriteValue(requiredAttribute.ValueComparison); 228 | writer.WritePropertyName("Diagnostics"); 229 | serializer.Serialize(writer, requiredAttribute.Diagnostics); 230 | writer.WritePropertyName("Metadata"); 231 | WriteMetadata(writer, requiredAttribute.Metadata); 232 | writer.WriteEndObject(); 233 | } 234 | 235 | private static void ReadTagMatchingRule(TagMatchingRuleDescriptorBuilder builder, JObject rule, JsonSerializer serializer) 236 | { 237 | string tagName = rule["TagName"].Value(); 238 | JArray jArray = rule["Attributes"].Value(); 239 | string parentTag = rule["ParentTag"].Value(); 240 | int tagStructure = rule["TagStructure"].Value(); 241 | JArray jArray2 = rule["Diagnostics"].Value(); 242 | builder.TagName = tagName; 243 | builder.ParentTag = parentTag; 244 | builder.TagStructure = (TagStructure)tagStructure; 245 | foreach (JToken item2 in jArray) 246 | { 247 | JObject attibuteValue = item2.Value(); 248 | builder.Attribute(delegate (RequiredAttributeDescriptorBuilder b) 249 | { 250 | ReadRequiredAttribute(b, attibuteValue, serializer); 251 | }); 252 | } 253 | foreach (JToken item3 in jArray2) 254 | { 255 | JsonReader reader = item3.CreateReader(); 256 | RazorDiagnostic item = serializer.Deserialize(reader); 257 | builder.Diagnostics.Add(item); 258 | } 259 | } 260 | 261 | private static void ReadRequiredAttribute(RequiredAttributeDescriptorBuilder builder, JObject attribute, JsonSerializer serializer) 262 | { 263 | string name = attribute["Name"].Value(); 264 | int nameComparisonMode = attribute["NameComparison"].Value(); 265 | string value = attribute["Value"].Value(); 266 | int valueComparisonMode = attribute["ValueComparison"].Value(); 267 | JArray jArray = attribute["Diagnostics"].Value(); 268 | JObject jObject = attribute["Metadata"].Value(); 269 | builder.Name = name; 270 | builder.NameComparisonMode = (RequiredAttributeDescriptor.NameComparisonMode)nameComparisonMode; 271 | builder.Value = value; 272 | builder.ValueComparisonMode = (RequiredAttributeDescriptor.ValueComparisonMode)valueComparisonMode; 273 | foreach (JToken item2 in jArray) 274 | { 275 | JsonReader reader = item2.CreateReader(); 276 | RazorDiagnostic item = serializer.Deserialize(reader); 277 | builder.Diagnostics.Add(item); 278 | } 279 | JsonReader reader2 = jObject.CreateReader(); 280 | foreach (KeyValuePair item3 in serializer.Deserialize>(reader2)) 281 | { 282 | builder.Metadata[item3.Key] = item3.Value; 283 | } 284 | } 285 | 286 | private static void ReadAllowedChildTag(AllowedChildTagDescriptorBuilder builder, JObject childTag, JsonSerializer serializer) 287 | { 288 | string name = childTag["Name"].Value(); 289 | string displayName = childTag["DisplayName"].Value(); 290 | JArray jArray = childTag["Diagnostics"].Value(); 291 | builder.Name = name; 292 | builder.DisplayName = displayName; 293 | foreach (JToken item2 in jArray) 294 | { 295 | JsonReader reader = item2.CreateReader(); 296 | RazorDiagnostic item = serializer.Deserialize(reader); 297 | builder.Diagnostics.Add(item); 298 | } 299 | } 300 | 301 | private static void ReadBoundAttribute(BoundAttributeDescriptorBuilder builder, JObject attribute, JsonSerializer serializer) 302 | { 303 | attribute["Kind"].Value(); 304 | string name = attribute["Name"].Value(); 305 | string typeName = attribute["TypeName"].Value(); 306 | bool flag = attribute["IsEnum"].Value(); 307 | string text = attribute["IndexerNamePrefix"].Value(); 308 | string valueTypeName = attribute["IndexerTypeName"].Value(); 309 | string documentation = attribute["Documentation"].Value(); 310 | JArray jArray = attribute["Diagnostics"].Value(); 311 | JObject jObject = attribute["Metadata"].Value(); 312 | JArray jArray2 = attribute["BoundAttributeParameters"].Value(); 313 | builder.Name = name; 314 | builder.TypeName = typeName; 315 | builder.Documentation = documentation; 316 | if (text != null) 317 | { 318 | builder.AsDictionary(text, valueTypeName); 319 | } 320 | if (flag) 321 | { 322 | builder.IsEnum = true; 323 | } 324 | foreach (JToken item2 in jArray) 325 | { 326 | JsonReader reader = item2.CreateReader(); 327 | RazorDiagnostic item = serializer.Deserialize(reader); 328 | builder.Diagnostics.Add(item); 329 | } 330 | JsonReader reader2 = jObject.CreateReader(); 331 | foreach (KeyValuePair item3 in serializer.Deserialize>(reader2)) 332 | { 333 | builder.Metadata[item3.Key] = item3.Value; 334 | } 335 | foreach (JToken item4 in jArray2) 336 | { 337 | JObject parameter = item4.Value(); 338 | builder.BindAttributeParameter(delegate (BoundAttributeParameterDescriptorBuilder b) 339 | { 340 | ReadBoundAttributeParameter(b, parameter, serializer); 341 | }); 342 | } 343 | } 344 | 345 | private static void ReadBoundAttributeParameter(BoundAttributeParameterDescriptorBuilder builder, JObject parameter, JsonSerializer serializer) 346 | { 347 | parameter["Kind"].Value(); 348 | string name = parameter["Name"].Value(); 349 | string typeName = parameter["TypeName"].Value(); 350 | bool num = parameter["IsEnum"].Value(); 351 | string documentation = parameter["Documentation"].Value(); 352 | JArray jArray = parameter["Diagnostics"].Value(); 353 | JObject jObject = parameter["Metadata"].Value(); 354 | builder.Name = name; 355 | builder.TypeName = typeName; 356 | builder.Documentation = documentation; 357 | if (num) 358 | { 359 | builder.IsEnum = true; 360 | } 361 | foreach (JToken item2 in jArray) 362 | { 363 | JsonReader reader = item2.CreateReader(); 364 | RazorDiagnostic item = serializer.Deserialize(reader); 365 | builder.Diagnostics.Add(item); 366 | } 367 | JsonReader reader2 = jObject.CreateReader(); 368 | foreach (KeyValuePair item3 in serializer.Deserialize>(reader2)) 369 | { 370 | builder.Metadata[item3.Key] = item3.Value; 371 | } 372 | } 373 | } 374 | -------------------------------------------------------------------------------- /BlazorCefApp/Demos/RegView/RegView.razor: -------------------------------------------------------------------------------- 1 | @inherits DemoDialogBase 2 | 3 | @inject BlazorSession bses 4 | 5 | @code{ 6 | 7 | Microsoft.Win32.RegistryKey selectedKey; 8 | string selectedHTML; 9 | 10 | abstract class VirtualNode 11 | { 12 | public Microsoft.Win32.RegistryKey RegKey { get; set; } 13 | public string SomethingToSayHTML { get; set; } 14 | public abstract string GetText(); 15 | public abstract IReadOnlyList GetSubNodes(); 16 | } 17 | class MyComputerNode : VirtualNode 18 | { 19 | public override string GetText() => "MyComputer"; 20 | 21 | public override IReadOnlyList GetSubNodes() 22 | { 23 | List list = new List(); 24 | list.Add(new RegistryKeyNode(Microsoft.Win32.Registry.ClassesRoot)); 25 | list.Add(new RegistryKeyNode(Microsoft.Win32.Registry.CurrentUser)); 26 | list.Add(new RegistryKeyNode(Microsoft.Win32.Registry.LocalMachine)); 27 | list.Add(new RegistryKeyNode(Microsoft.Win32.Registry.Users)); 28 | list.Add(new RegistryKeyNode(Microsoft.Win32.Registry.CurrentConfig)); 29 | return list; 30 | } 31 | } 32 | class RegistryKeyNode : VirtualNode 33 | { 34 | string _kname; 35 | public RegistryKeyNode(Microsoft.Win32.RegistryKey key) 36 | { 37 | RegKey = key; 38 | _kname = key.Name; 39 | int lp = _kname.LastIndexOf('\\'); 40 | if (lp != -1) _kname = _kname.Substring(lp + 1); 41 | } 42 | 43 | public override string GetText() => _kname; 44 | 45 | public override IReadOnlyList GetSubNodes() 46 | { 47 | List list = new List(); 48 | foreach (string skn in RegKey.GetSubKeyNames()) 49 | { 50 | try 51 | { 52 | var sk = RegKey.OpenSubKey(skn); 53 | list.Add(new RegistryKeyNode(sk)); 54 | } 55 | catch (Exception x) 56 | { 57 | list.Add(new ErrorKeyNode(skn, x)); 58 | } 59 | } 60 | return list; 61 | } 62 | } 63 | class ErrorKeyNode : VirtualNode 64 | { 65 | string _name; 66 | public ErrorKeyNode(string name, Exception x) 67 | { 68 | _name = name; 69 | SomethingToSayHTML = "
" + System.Text.Encodings.Web.HtmlEncoder.Default.Encode(x.ToString()) + "
"; 70 | } 71 | public override string GetText() => _name; 72 | 73 | public override IReadOnlyList GetSubNodes() 74 | { 75 | return Array.Empty(); 76 | } 77 | } 78 | 79 | PlusControl _lastSelectedControl; 80 | 81 | void leftpanel_ready(BlazorDomTree bdt) 82 | { 83 | BuildTreeNode(bdt.Root, new MyComputerNode(), 0); 84 | } 85 | 86 | void BuildTreeNode(PlusControl container, VirtualNode vnode, int level) 87 | { 88 | PlusControl table = container.Create("table class='regview-treenode'"); 89 | 90 | PlusControl tr = table.Create("tr class='regview-trnode'"); 91 | PlusControl td0 = tr.Create("td class='regview-left' style='width:20px;'"); 92 | PlusControl icon = td0.Create("span class='oi oi-plus'"); 93 | PlusControl td1 = tr.Create("td class='regview-right'"); 94 | PlusControl spantext = td1.Create("span").InnerText(vnode.GetText()); 95 | 96 | PlusControl tr1 = table.Create("tr class='regview-trsubnodes' style='display:none'"); 97 | tr1.Create("td class='regview-left'"); 98 | PlusControl subtd = tr1.Create("td class='regview-right'"); 99 | 100 | void Toggle() 101 | { 102 | if (tr1.GetStyle("display") == "none") 103 | { 104 | if (subtd.GetChildCount() == 0) 105 | { 106 | var ns = vnode.GetSubNodes(); 107 | if (ns.Count > 100) 108 | { 109 | bses.Toast("Opening " + ns.Count + " nodes"); 110 | bses.FlushToClient(); 111 | } 112 | foreach (var subnode in ns) 113 | { 114 | BuildTreeNode(subtd, subnode, level + 1); 115 | } 116 | } 117 | 118 | icon.CssClass("oi oi-minus"); 119 | tr1.SetStyle("display", ""); 120 | } 121 | else 122 | { 123 | icon.CssClass("oi oi-plus"); 124 | tr1.SetStyle("display", "none"); 125 | } 126 | } 127 | 128 | if (level == 0) Toggle(); 129 | 130 | icon.OnClick((s, e) => Toggle()); 131 | spantext.OnDoubleClick((s, e) => Toggle()); 132 | spantext.OnClick(delegate 133 | { 134 | if (_lastSelectedControl != null) _lastSelectedControl.RemoveClass("regview-td-selected"); 135 | td1.AddClass("regview-td-selected"); 136 | _lastSelectedControl = td1; 137 | selectedKey = vnode.RegKey; 138 | selectedHTML = vnode.SomethingToSayHTML; 139 | StateHasChanged(); 140 | }); 141 | 142 | } 143 | 144 | } 145 | 146 | 164 | 165 |
166 |
167 | 168 |
RegView
169 |
170 |
171 | 172 |
173 | @if (selectedKey != null) 174 | { 175 | string[] vnarr = null; 176 | try 177 | { 178 | vnarr = selectedKey.GetValueNames(); 179 | } 180 | catch (Exception x) 181 | { 182 |
@x.ToString()
183 | } 184 | @if (vnarr != null) 185 | { 186 | 187 | 188 | @foreach (string vname in vnarr) 189 | { 190 | string vt = null; 191 | object val = null; 192 | try 193 | { 194 | val = selectedKey.GetValue(vname); 195 | vt = val.GetType().Name; 196 | } 197 | catch (Exception x) 198 | { 199 | vt = "Error"; 200 | val = x.Message; 201 | } 202 | 203 | } 204 |
NameTypeData
@(string.IsNullOrEmpty(vname)?"(DEFAULT)":vname)@vt@val
205 | } 206 | } 207 | @((MarkupString)selectedHTML) 208 |
209 |
210 |
211 | -------------------------------------------------------------------------------- /BlazorCefApp/MyDownloadForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.IO; 7 | using System.Linq; 8 | using System.Security.Policy; 9 | using System.Text; 10 | using System.Windows.Forms; 11 | using CefLite; 12 | 13 | namespace BlazorCefApp 14 | { 15 | public partial class MyDownloadForm : Form 16 | { 17 | static public string TextFormTitle = "MyDownloads"; 18 | static public string TextUrl = "Url"; 19 | static public string TextId = "Id"; 20 | static public string TextFileName = "File Name"; 21 | static public string TextProgress = "Progress"; 22 | static public string TextProgressCompleted = "Completed"; 23 | static public string TextProgressCanceled = "Canceled"; 24 | static public string TextConfirmCancelTitle = "Cancel"; 25 | static public string TextConfirmCancelMessage = "Cancel download file?"; 26 | 27 | public MyDownloadForm() 28 | { 29 | this.Size = new Size(800, 500); 30 | this.MinimumSize = new Size(360, 360); 31 | 32 | if (CefWin.ApplicationIcon != null) 33 | this.Icon = CefWin.ApplicationIcon; 34 | 35 | this.Text = TextFormTitle ?? CefWin.ApplicationTitle; 36 | 37 | this.Controls.Add(ListView); 38 | 39 | ListView.Activation = ItemActivation.Standard; 40 | ListView.ItemActivate += ListView_ItemActivate; 41 | 42 | ListView.Columns.Add(new ColumnHeader() { Name = "Id", Text = TextId, Width = 50 }); 43 | ListView.Columns.Add(new ColumnHeader() { Name = "Url", Text = TextUrl, Width = 360 }); 44 | ListView.Columns.Add(new ColumnHeader() { Name = "FileName", Text = TextFileName, Width = 260 }); 45 | ListView.Columns.Add(new ColumnHeader() { Name = "Progress", Text = TextProgress, Width = 100 }); 46 | } 47 | 48 | private void ListView_ItemActivate(object sender, EventArgs e) 49 | { 50 | foreach (ListViewItem lvi in ListView.SelectedItems) 51 | { 52 | DownloadItem lvitem = (DownloadItem)lvi.Tag; 53 | if (lvitem.IsComplete) 54 | { 55 | System.Diagnostics.Process.Start("Explorer", "/select, " + lvitem.FullPath); 56 | } 57 | else if (lvitem.IsInProgress) 58 | { 59 | if (MessageBox.Show(TextConfirmCancelMessage, TextConfirmCancelTitle, MessageBoxButtons.OKCancel) == DialogResult.OK) 60 | { 61 | lvitem.Cancel(); 62 | lvitem.RemoveFromList(); 63 | } 64 | } 65 | } 66 | } 67 | 68 | public ListView ListView { get; } = new ListView() { Dock = DockStyle.Fill, View = View.Details, HideSelection = false, FullRowSelect = true }; 69 | 70 | 71 | protected override void OnHandleCreated(EventArgs e) 72 | { 73 | base.OnHandleCreated(e); 74 | DownloadItem.DataVersionUpdated += DownloadItem_DataVersionUpdated; 75 | } 76 | 77 | protected override void OnHandleDestroyed(EventArgs e) 78 | { 79 | base.OnHandleDestroyed(e); 80 | DownloadItem.DataVersionUpdated -= DownloadItem_DataVersionUpdated; 81 | } 82 | 83 | 84 | private void DownloadItem_DataVersionUpdated() 85 | { 86 | try 87 | { 88 | RefreshList(); 89 | } 90 | catch (Exception x) 91 | { 92 | Console.WriteLine(x); 93 | } 94 | } 95 | 96 | long _ldv = 0; 97 | void RefreshList() 98 | { 99 | if (_ldv == DownloadItem.DataVersion) 100 | return; 101 | _ldv = DownloadItem.DataVersion; 102 | 103 | ListView.BeginUpdate(); 104 | 105 | var items = DownloadItem.Items.ToList(); 106 | foreach (ListViewItem lvi in new System.Collections.ArrayList(ListView.Items)) 107 | { 108 | DownloadItem lvitem = (DownloadItem)lvi.Tag; 109 | if (!items.Contains(lvitem)) 110 | { 111 | ListView.Items.Remove(lvi); 112 | continue; 113 | } 114 | Update(lvitem, lvi); 115 | items.Remove(lvitem); 116 | } 117 | foreach (DownloadItem item in items) 118 | { 119 | ListViewItem lvi = new ListViewItem(); 120 | for (int i = 0; i < ListView.Columns.Count; i++) 121 | lvi.SubItems.Add(""); 122 | Update(item, lvi); 123 | ListView.Items.Add(lvi); 124 | } 125 | 126 | ListView.EndUpdate(); 127 | } 128 | 129 | void Update(DownloadItem item, ListViewItem lvi) 130 | { 131 | string progress = ""; 132 | if (item.IsInProgress) 133 | { 134 | if (item.TotalBytes > 0) 135 | { 136 | progress = Math.Floor(100.0 * item.ReceivedBytes / (double)item.TotalBytes) + "% " + FormatSize(item.ReceivedBytes); 137 | } 138 | else 139 | { 140 | progress = FormatSize(item.ReceivedBytes); 141 | } 142 | } 143 | else if (item.IsComplete) 144 | { 145 | progress = TextProgressCompleted; 146 | } 147 | else if (item.IsCanceled) 148 | { 149 | progress = TextProgressCanceled; 150 | } 151 | else if (!item.IsValid) 152 | { 153 | progress = "Invalid"; 154 | } 155 | else 156 | { 157 | 158 | } 159 | 160 | lvi.Tag = item; 161 | lvi.Text = item.Id.ToString(); 162 | 163 | lvi.SubItems[1].Text = item.Url; 164 | lvi.SubItems[2].Text = Path.GetFileName(item.FullPath); 165 | 166 | lvi.SubItems[3].Text = progress; 167 | 168 | } 169 | 170 | static string FormatSize(long size) 171 | { 172 | if (size > 1024 * 1024) 173 | return size / 1024 / 1024 + " MB"; 174 | if (size > 1024) 175 | return size / 1024 + "KB"; 176 | return size + " Bytes"; 177 | } 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /BlazorCefApp/MyDownloadForm.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /BlazorCefApp/Pages/Error.razor: -------------------------------------------------------------------------------- 1 | @page "/error" 2 | 3 | 4 |

Error.

5 |

An error occurred while processing your request.

6 | 7 |

Development Mode

8 |

9 | Swapping to Development environment will display more detailed information about the error that occurred. 10 |

11 |

12 | The Development environment shouldn't be enabled for deployed applications. 13 | It can result in displaying sensitive information from exceptions to end users. 14 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 15 | and restarting the app. 16 |

-------------------------------------------------------------------------------- /BlazorCefApp/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | @code{ 4 | void SetZoom(int val) 5 | { 6 | BlazorSession.Current.RunBrowser(browser => 7 | { 8 | var host = browser.Agent.BrowserHost; 9 | double dv = host.GetZoomLevel() + val; 10 | if (dv > 10) dv = 10; 11 | if (dv < -10) dv = -10; 12 | host.SetZoomLevel(dv); 13 | }); 14 | } 15 | } 16 | 17 |
18 |

BlazorCefApp!

19 |

20 | https://github.com/BlazorPlus/BlazorCefApp 21 |
22 | Run Blazor server side as a window application. 23 |
24 | 25 | 26 | 27 | 28 | @**@ 29 | 30 | 31 | 32 |

33 |
34 |
35 | 36 | @{ 37 | RenderFragment RenderItem(string title, string comment) 38 | where T : ComponentBase 39 | => 40 | @ 44 | ; 45 | } 46 | 47 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /BlazorCefApp/Pages/_Host.cshtml: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @namespace BlazorCefApp.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | @{ 5 | Layout = null; 6 | } 7 | 8 | 9 | 10 | 11 | 12 | 13 | BlazorCefApp 14 | 15 | 16 | 17 | 18 | 19 | 20 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
40 | 41 | An error has occurred. This application may no longer respond until reloaded. 42 | 43 | 44 | An unhandled exception has occurred. See browser dev tools for details. 45 | 46 | Reload 47 | 🗙 48 |
49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /BlazorCefApp/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.Extensions.Hosting; 4 | 5 | using CefLite; 6 | 7 | namespace BlazorCefApp 8 | { 9 | public class Program 10 | { 11 | 12 | [STAThread] 13 | static public void Main(string[] args) 14 | { 15 | //TODO:Change the project type to "Windows Application" to hide the console 16 | //If you start the app via Visual Studio , the VS Command Prompt will always show 17 | CefWin.PrintDebugInformation = true; //show debug information in console 18 | 19 | CefWin.ApplicationTitle = "MyBlazorApp"; //as the Default Title 20 | 21 | CefWin.ShowSplashScreen("wwwroot/splash.jpg"); //or show System.Drawing.Image from embedded resource 22 | 23 | if (CefWin.ActivateExistingApp()) // Optional, only allow one instance running 24 | { 25 | Console.WriteLine("Anoter instance is running , So this instance quit."); 26 | return; 27 | } 28 | 29 | //CefWin.SettingAutoSetUserDataStoragePath = false; 30 | //CefWin.SettingAutoSetCacheStoragePath = false; 31 | 32 | CefWin.SetEnableHighDPISupport(); 33 | 34 | CefWin.SearchLibCefSubPathList.Add("chromium"); // search ./chromium/ for libcef.dll 35 | CefInitState initState = CefWin.SearchAndInitialize(); 36 | 37 | if (initState != CefInitState.Initialized) 38 | { 39 | if (initState == CefInitState.Failed) 40 | { 41 | System.Windows.Forms.MessageBox.Show("Failed to start application\r\nCheck the github page about how to deploy the libcef.dll", "Error" 42 | , System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); 43 | } 44 | return; 45 | } 46 | 47 | using IHost host = CreateHostBuilder(args).Build(); 48 | try 49 | { 50 | host.Start(); 51 | } 52 | catch (Exception x) 53 | { 54 | Console.WriteLine(x); 55 | System.Windows.Forms.MessageBox.Show("Failed to start service. Please try again. \r\n" + x.Message, "Error" 56 | , System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); 57 | CefWin.CefShutdown(); 58 | return; 59 | } 60 | 61 | CefWin.ApplicationHost = host; 62 | CefWin.ApplicationTask = host.WaitForShutdownAsync(CefWin.ApplicationCTS.Token); 63 | 64 | MyDownloadForm _mdf = null; 65 | DownloadItem.ShowDownloadFormHandler = (parentForm) => 66 | { 67 | if (_mdf == null || _mdf.IsDisposed) 68 | { 69 | _mdf = new MyDownloadForm(); 70 | _mdf.Show(parentForm); 71 | } 72 | else 73 | { 74 | CefWin.ActivateForm(_mdf); 75 | } 76 | }; 77 | 78 | ShowMainForm(); 79 | 80 | CefWin.RunApplication(); 81 | 82 | } 83 | 84 | static void ShowMainForm() 85 | { 86 | string startUrl = aspnetcoreUrls.Split(';')[0]; 87 | DefaultBrowserForm form = CefWin.OpenBrowser(startUrl); 88 | form.Width = 1120; 89 | form.Height = 777; 90 | form.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 91 | //CefWin.CenterForm(form); 92 | //form.WindowState = System.Windows.Forms.FormWindowState.Maximized; 93 | } 94 | 95 | static string aspnetcoreUrls = "http://127.12.34.56:7890"; 96 | //static string aspnetcoreUrls = "http://127.12.34.56:7890;https://127.12.34.56:7891"; 97 | //static string aspnetcoreUrls = "https://127.12.34.56:7891"; //Force to SSL , not so useful , just a test 98 | //static string aspnetcoreUrls = CefWin.MakeFixedLocalHostUrl(); //make fixed url by user name , so each user can open 1 instance 99 | //static string aspnetcoreUrls = CefWin.MakeRandomLocalHostUrl(); //random url allow multiple instance of this app , but cookie/localStorage will lost when open app again. 100 | 101 | 102 | static public IHostBuilder CreateHostBuilder(string[] args) 103 | { 104 | var builder = Host.CreateDefaultBuilder(args); 105 | 106 | builder.ConfigureWebHostDefaults(webBuilder => 107 | { 108 | Console.WriteLine("aspnetcoreUrls : " + aspnetcoreUrls); 109 | webBuilder.UseUrls(aspnetcoreUrls); 110 | webBuilder.UseStartup(); 111 | }); 112 | 113 | return builder; 114 | } 115 | 116 | 117 | static void OtherIdeas_ProxyServer() 118 | { 119 | //modify the CefAdditionArguments before CefWin.SearchAndInitialize() 120 | 121 | //If you want to add custom server and override system's setting , use this line : 122 | CefWin.CefAdditionArguments.Add("--proxy-server=http://127.0.0.1:8080"); //works.. 123 | } 124 | 125 | 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /BlazorCefApp/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:54051", 7 | "sslPort": 44340 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "BlazorCefApp": { 19 | "commandName": "Project", 20 | "environmentVariables": { 21 | "ASPNETCORE_ENVIRONMENT": "Development" 22 | }, 23 | "applicationUrl": "" 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /BlazorCefApp/Providers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Components.Rendering; 6 | using Microsoft.AspNetCore.Components; 7 | using Microsoft.AspNetCore.Http; 8 | using Microsoft.AspNetCore.Hosting; 9 | using BlazorPlus; 10 | 11 | 12 | namespace BlazorCefApp 13 | { 14 | public class WebCustomizeSession : BlazorSession 15 | { 16 | public IWebHostEnvironment WebHostEnvironment { get; private set; } 17 | 18 | public IHttpContextAccessor HttpContextAccessor { get; private set; } 19 | 20 | public WebCustomizeSession(Microsoft.JSInterop.IJSRuntime jsr,NavigationManager nav 21 | , IWebHostEnvironment whe 22 | , IHttpContextAccessor hca) 23 | : base(jsr,nav) 24 | { 25 | WebHostEnvironment = whe; 26 | HttpContextAccessor = hca; 27 | } 28 | 29 | public override Type TypeGetUIDialogAlert(UIDialogOption option) 30 | { 31 | return typeof(CustomizeUI.UIDialogAlert); 32 | } 33 | public override Type TypeGetUIDialogConfirm(UIDialogOption option) 34 | { 35 | return typeof(CustomizeUI.UIDialogConfirm); 36 | } 37 | public override Type TypeGetUIDialogPrompt(UIDialogOption option) 38 | { 39 | return typeof(CustomizeUI.UIDialogPrompt); 40 | } 41 | 42 | //protected override bool IsValidBrowserUniqueID(string uid) 43 | //{ 44 | // return base.IsValidBrowserUniqueID(uid); 45 | //} 46 | //protected override string GenerateBrowserUniqueID() 47 | //{ 48 | // return base.GenerateBrowserUniqueID(); 49 | //} 50 | 51 | //public override string TranslateTemplate(string code) 52 | //{ 53 | // return base.TranslateTemplate(code); 54 | //} 55 | 56 | //string GetJsonFilePath() 57 | //{ 58 | // //by default , the Browser.UniqueID is base64 string of 59 | // byte[] data = Convert.FromBase64String(this.Browser.UniqueID); 60 | // string group = ((int)data[0]).ToString(); 61 | // string fname = BitConverter.ToString(data).Replace("-", ""); 62 | // string folder = System.IO.Path.Combine(WebHostEnvironment.ContentRootPath, "BrowserStringItems", group, fname); 63 | // if (!System.IO.Directory.Exists(folder)) System.IO.Directory.CreateDirectory(folder); 64 | // return System.IO.Path.Combine(folder, "stringitems.json"); 65 | //} 66 | //protected override async Task GetBrowserStringItemAsync(string key) 67 | //{ 68 | // string filepath = GetJsonFilePath(); 69 | // if (!System.IO.File.Exists(filepath)) 70 | // return null; 71 | // string jsontext = await System.IO.File.ReadAllTextAsync(filepath); 72 | // var dict = System.Text.Json.JsonSerializer.Deserialize>(jsontext); 73 | // string val; 74 | // dict.TryGetValue(key, out val); 75 | // return val; 76 | //} 77 | //protected override async Task SetBrowserStringItemAsync(string key, string value) 78 | //{ 79 | // string filepath = GetJsonFilePath(); 80 | // string jsontext; 81 | // Dictionary dict; 82 | // if (!System.IO.File.Exists(filepath)) 83 | // { 84 | // dict = new Dictionary(); 85 | // } 86 | // else 87 | // { 88 | // jsontext = await System.IO.File.ReadAllTextAsync(filepath); 89 | // dict = System.Text.Json.JsonSerializer.Deserialize>(jsontext); 90 | // } 91 | // dict[key] = value; 92 | // jsontext = System.Text.Json.JsonSerializer.Serialize(dict); 93 | // await System.IO.File.WriteAllTextAsync(filepath, jsontext); 94 | //} 95 | } 96 | 97 | 98 | 99 | 100 | } 101 | -------------------------------------------------------------------------------- /BlazorCefApp/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 | @Body 4 | -------------------------------------------------------------------------------- /BlazorCefApp/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Components; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.AspNetCore.HttpsPolicy; 9 | using Microsoft.Extensions.Configuration; 10 | using Microsoft.Extensions.DependencyInjection; 11 | using Microsoft.Extensions.Hosting; 12 | 13 | namespace BlazorCefApp 14 | { 15 | public class Startup 16 | { 17 | public Startup(IConfiguration configuration) 18 | { 19 | Configuration = configuration; 20 | } 21 | 22 | public IConfiguration Configuration { get; } 23 | 24 | // This method gets called by the runtime. Use this method to add services to the container. 25 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 26 | public void ConfigureServices(IServiceCollection services) 27 | { 28 | services.AddRazorPages(); 29 | services.AddServerSideBlazor().AddCircuitOptions(opt=> 30 | { 31 | //always send detailed error to browser console 32 | opt.DetailedErrors = true; 33 | opt.DisconnectedCircuitMaxRetained = 999999; 34 | opt.DisconnectedCircuitRetentionPeriod = TimeSpan.FromMilliseconds(10); 35 | }).AddHubOptions(opt => 36 | { 37 | opt.MaximumReceiveMessageSize = 64 * 1024 * 1024; 38 | }); 39 | 40 | services.AddHttpContextAccessor(); 41 | 42 | services.AddScoped(); //override 43 | 44 | } 45 | 46 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 47 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 48 | { 49 | if (env.IsDevelopment()) 50 | { 51 | app.UseDeveloperExceptionPage(); 52 | } 53 | else 54 | { 55 | app.UseExceptionHandler("/Error"); 56 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 57 | app.UseHsts(); 58 | } 59 | 60 | //app.UseHttpsRedirection(); 61 | app.UseStaticFiles(); 62 | 63 | app.UseRouting(); 64 | 65 | app.UseEndpoints(endpoints => 66 | { 67 | endpoints.Map("/_blazorplus_handler", BlazorPlus.BlazorSession.ProcessRequestAsync); 68 | 69 | endpoints.MapBlazorHub(); 70 | endpoints.MapFallbackToPage("/_Host"); 71 | }); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /BlazorCefApp/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using Microsoft.AspNetCore.Authorization 3 | @using Microsoft.AspNetCore.Components.Authorization 4 | @using Microsoft.AspNetCore.Components.Forms 5 | @using Microsoft.AspNetCore.Components.Routing 6 | @using Microsoft.AspNetCore.Components.Web 7 | @using Microsoft.JSInterop 8 | @using BlazorCefApp 9 | @using BlazorCefApp.Shared 10 | 11 | @using BlazorPlus -------------------------------------------------------------------------------- /BlazorCefApp/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft": "Warning", 7 | "Microsoft.Hosting.Lifetime": "Information" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /BlazorCefApp/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /BlazorCefApp/wwwroot/css/open-iconic/FONT-LICENSE: -------------------------------------------------------------------------------- 1 | SIL OPEN FONT LICENSE Version 1.1 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | PREAMBLE 6 | The goals of the Open Font License (OFL) are to stimulate worldwide 7 | development of collaborative font projects, to support the font creation 8 | efforts of academic and linguistic communities, and to provide a free and 9 | open framework in which fonts may be shared and improved in partnership 10 | with others. 11 | 12 | The OFL allows the licensed fonts to be used, studied, modified and 13 | redistributed freely as long as they are not sold by themselves. The 14 | fonts, including any derivative works, can be bundled, embedded, 15 | redistributed and/or sold with any software provided that any reserved 16 | names are not used by derivative works. The fonts and derivatives, 17 | however, cannot be released under any other type of license. The 18 | requirement for fonts to remain under this license does not apply 19 | to any document created using the fonts or their derivatives. 20 | 21 | DEFINITIONS 22 | "Font Software" refers to the set of files released by the Copyright 23 | Holder(s) under this license and clearly marked as such. This may 24 | include source files, build scripts and documentation. 25 | 26 | "Reserved Font Name" refers to any names specified as such after the 27 | copyright statement(s). 28 | 29 | "Original Version" refers to the collection of Font Software components as 30 | distributed by the Copyright Holder(s). 31 | 32 | "Modified Version" refers to any derivative made by adding to, deleting, 33 | or substituting -- in part or in whole -- any of the components of the 34 | Original Version, by changing formats or by porting the Font Software to a 35 | new environment. 36 | 37 | "Author" refers to any designer, engineer, programmer, technical 38 | writer or other person who contributed to the Font Software. 39 | 40 | PERMISSION & CONDITIONS 41 | Permission is hereby granted, free of charge, to any person obtaining 42 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 43 | redistribute, and sell modified and unmodified copies of the Font 44 | Software, subject to the following conditions: 45 | 46 | 1) Neither the Font Software nor any of its individual components, 47 | in Original or Modified Versions, may be sold by itself. 48 | 49 | 2) Original or Modified Versions of the Font Software may be bundled, 50 | redistributed and/or sold with any software, provided that each copy 51 | contains the above copyright notice and this license. These can be 52 | included either as stand-alone text files, human-readable headers or 53 | in the appropriate machine-readable metadata fields within text or 54 | binary files as long as those fields can be easily viewed by the user. 55 | 56 | 3) No Modified Version of the Font Software may use the Reserved Font 57 | Name(s) unless explicit written permission is granted by the corresponding 58 | Copyright Holder. This restriction only applies to the primary font name as 59 | presented to the users. 60 | 61 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 62 | Software shall not be used to promote, endorse or advertise any 63 | Modified Version, except to acknowledge the contribution(s) of the 64 | Copyright Holder(s) and the Author(s) or with their explicit written 65 | permission. 66 | 67 | 5) The Font Software, modified or unmodified, in part or in whole, 68 | must be distributed entirely under this license, and must not be 69 | distributed under any other license. The requirement for fonts to 70 | remain under this license does not apply to any document created 71 | using the Font Software. 72 | 73 | TERMINATION 74 | This license becomes null and void if any of the above conditions are 75 | not met. 76 | 77 | DISCLAIMER 78 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 79 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 80 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 81 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 82 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 83 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 84 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 85 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 86 | OTHER DEALINGS IN THE FONT SOFTWARE. 87 | -------------------------------------------------------------------------------- /BlazorCefApp/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /BlazorCefApp/wwwroot/css/open-iconic/README.md: -------------------------------------------------------------------------------- 1 | [Open Iconic v1.1.1](http://useiconic.com/open) 2 | =========== 3 | 4 | ### Open Iconic is the open source sibling of [Iconic](http://useiconic.com). It is a hyper-legible collection of 223 icons with a tiny footprint—ready to use with Bootstrap and Foundation. [View the collection](http://useiconic.com/open#icons) 5 | 6 | 7 | 8 | ## What's in Open Iconic? 9 | 10 | * 223 icons designed to be legible down to 8 pixels 11 | * Super-light SVG files - 61.8 for the entire set 12 | * SVG sprite—the modern replacement for icon fonts 13 | * Webfont (EOT, OTF, SVG, TTF, WOFF), PNG and WebP formats 14 | * Webfont stylesheets (including versions for Bootstrap and Foundation) in CSS, LESS, SCSS and Stylus formats 15 | * PNG and WebP raster images in 8px, 16px, 24px, 32px, 48px and 64px. 16 | 17 | 18 | ## Getting Started 19 | 20 | #### For code samples and everything else you need to get started with Open Iconic, check out our [Icons](http://useiconic.com/open#icons) and [Reference](http://useiconic.com/open#reference) sections. 21 | 22 | ### General Usage 23 | 24 | #### Using Open Iconic's SVGs 25 | 26 | We like SVGs and we think they're the way to display icons on the web. Since Open Iconic are just basic SVGs, we suggest you display them like you would any other image (don't forget the `alt` attribute). 27 | 28 | ``` 29 | icon name 30 | ``` 31 | 32 | #### Using Open Iconic's SVG Sprite 33 | 34 | Open Iconic also comes in a SVG sprite which allows you to display all the icons in the set with a single request. It's like an icon font, without being a hack. 35 | 36 | Adding an icon from an SVG sprite is a little different than what you're used to, but it's still a piece of cake. *Tip: To make your icons easily style able, we suggest adding a general class to the* `` *tag and a unique class name for each different icon in the* `` *tag.* 37 | 38 | ``` 39 | 40 | 41 | 42 | ``` 43 | 44 | Sizing icons only needs basic CSS. All the icons are in a square format, so just set the `` tag with equal width and height dimensions. 45 | 46 | ``` 47 | .icon { 48 | width: 16px; 49 | height: 16px; 50 | } 51 | ``` 52 | 53 | Coloring icons is even easier. All you need to do is set the `fill` rule on the `` tag. 54 | 55 | ``` 56 | .icon-account-login { 57 | fill: #f00; 58 | } 59 | ``` 60 | 61 | To learn more about SVG Sprites, read [Chris Coyier's guide](http://css-tricks.com/svg-sprites-use-better-icon-fonts/). 62 | 63 | #### Using Open Iconic's Icon Font... 64 | 65 | 66 | ##### …with Bootstrap 67 | 68 | You can find our Bootstrap stylesheets in `font/css/open-iconic-bootstrap.{css, less, scss, styl}` 69 | 70 | 71 | ``` 72 | 73 | ``` 74 | 75 | 76 | ``` 77 | 78 | ``` 79 | 80 | ##### …with Foundation 81 | 82 | You can find our Foundation stylesheets in `font/css/open-iconic-foundation.{css, less, scss, styl}` 83 | 84 | ``` 85 | 86 | ``` 87 | 88 | 89 | ``` 90 | 91 | ``` 92 | 93 | ##### …on its own 94 | 95 | You can find our default stylesheets in `font/css/open-iconic.{css, less, scss, styl}` 96 | 97 | ``` 98 | 99 | ``` 100 | 101 | ``` 102 | 103 | ``` 104 | 105 | 106 | ## License 107 | 108 | ### Icons 109 | 110 | All code (including SVG markup) is under the [MIT License](http://opensource.org/licenses/MIT). 111 | 112 | ### Fonts 113 | 114 | All fonts are under the [SIL Licensed](http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web). 115 | -------------------------------------------------------------------------------- /BlazorCefApp/wwwroot/css/open-iconic/font/css/open-iconic-bootstrap.min.css: -------------------------------------------------------------------------------- 1 | @font-face{font-family:Icons;src:url(../fonts/open-iconic.eot);src:url(../fonts/open-iconic.eot?#iconic-sm) format('embedded-opentype'),url(../fonts/open-iconic.woff) format('woff'),url(../fonts/open-iconic.ttf) format('truetype'),url(../fonts/open-iconic.otf) format('opentype'),url(../fonts/open-iconic.svg#iconic-sm) format('svg');font-weight:400;font-style:normal}.oi{position:relative;top:1px;display:inline-block;speak:none;font-family:Icons;font-style:normal;font-weight:400;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.oi:empty:before{width:1em;text-align:center;box-sizing:content-box}.oi.oi-align-center:before{text-align:center}.oi.oi-align-left:before{text-align:left}.oi.oi-align-right:before{text-align:right}.oi.oi-flip-horizontal:before{-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.oi.oi-flip-vertical:before{-webkit-transform:scale(1,-1);-ms-transform:scale(-1,1);transform:scale(1,-1)}.oi.oi-flip-horizontal-vertical:before{-webkit-transform:scale(-1,-1);-ms-transform:scale(-1,1);transform:scale(-1,-1)}.oi-account-login:before{content:'\e000'}.oi-account-logout:before{content:'\e001'}.oi-action-redo:before{content:'\e002'}.oi-action-undo:before{content:'\e003'}.oi-align-center:before{content:'\e004'}.oi-align-left:before{content:'\e005'}.oi-align-right:before{content:'\e006'}.oi-aperture:before{content:'\e007'}.oi-arrow-bottom:before{content:'\e008'}.oi-arrow-circle-bottom:before{content:'\e009'}.oi-arrow-circle-left:before{content:'\e00a'}.oi-arrow-circle-right:before{content:'\e00b'}.oi-arrow-circle-top:before{content:'\e00c'}.oi-arrow-left:before{content:'\e00d'}.oi-arrow-right:before{content:'\e00e'}.oi-arrow-thick-bottom:before{content:'\e00f'}.oi-arrow-thick-left:before{content:'\e010'}.oi-arrow-thick-right:before{content:'\e011'}.oi-arrow-thick-top:before{content:'\e012'}.oi-arrow-top:before{content:'\e013'}.oi-audio-spectrum:before{content:'\e014'}.oi-audio:before{content:'\e015'}.oi-badge:before{content:'\e016'}.oi-ban:before{content:'\e017'}.oi-bar-chart:before{content:'\e018'}.oi-basket:before{content:'\e019'}.oi-battery-empty:before{content:'\e01a'}.oi-battery-full:before{content:'\e01b'}.oi-beaker:before{content:'\e01c'}.oi-bell:before{content:'\e01d'}.oi-bluetooth:before{content:'\e01e'}.oi-bold:before{content:'\e01f'}.oi-bolt:before{content:'\e020'}.oi-book:before{content:'\e021'}.oi-bookmark:before{content:'\e022'}.oi-box:before{content:'\e023'}.oi-briefcase:before{content:'\e024'}.oi-british-pound:before{content:'\e025'}.oi-browser:before{content:'\e026'}.oi-brush:before{content:'\e027'}.oi-bug:before{content:'\e028'}.oi-bullhorn:before{content:'\e029'}.oi-calculator:before{content:'\e02a'}.oi-calendar:before{content:'\e02b'}.oi-camera-slr:before{content:'\e02c'}.oi-caret-bottom:before{content:'\e02d'}.oi-caret-left:before{content:'\e02e'}.oi-caret-right:before{content:'\e02f'}.oi-caret-top:before{content:'\e030'}.oi-cart:before{content:'\e031'}.oi-chat:before{content:'\e032'}.oi-check:before{content:'\e033'}.oi-chevron-bottom:before{content:'\e034'}.oi-chevron-left:before{content:'\e035'}.oi-chevron-right:before{content:'\e036'}.oi-chevron-top:before{content:'\e037'}.oi-circle-check:before{content:'\e038'}.oi-circle-x:before{content:'\e039'}.oi-clipboard:before{content:'\e03a'}.oi-clock:before{content:'\e03b'}.oi-cloud-download:before{content:'\e03c'}.oi-cloud-upload:before{content:'\e03d'}.oi-cloud:before{content:'\e03e'}.oi-cloudy:before{content:'\e03f'}.oi-code:before{content:'\e040'}.oi-cog:before{content:'\e041'}.oi-collapse-down:before{content:'\e042'}.oi-collapse-left:before{content:'\e043'}.oi-collapse-right:before{content:'\e044'}.oi-collapse-up:before{content:'\e045'}.oi-command:before{content:'\e046'}.oi-comment-square:before{content:'\e047'}.oi-compass:before{content:'\e048'}.oi-contrast:before{content:'\e049'}.oi-copywriting:before{content:'\e04a'}.oi-credit-card:before{content:'\e04b'}.oi-crop:before{content:'\e04c'}.oi-dashboard:before{content:'\e04d'}.oi-data-transfer-download:before{content:'\e04e'}.oi-data-transfer-upload:before{content:'\e04f'}.oi-delete:before{content:'\e050'}.oi-dial:before{content:'\e051'}.oi-document:before{content:'\e052'}.oi-dollar:before{content:'\e053'}.oi-double-quote-sans-left:before{content:'\e054'}.oi-double-quote-sans-right:before{content:'\e055'}.oi-double-quote-serif-left:before{content:'\e056'}.oi-double-quote-serif-right:before{content:'\e057'}.oi-droplet:before{content:'\e058'}.oi-eject:before{content:'\e059'}.oi-elevator:before{content:'\e05a'}.oi-ellipses:before{content:'\e05b'}.oi-envelope-closed:before{content:'\e05c'}.oi-envelope-open:before{content:'\e05d'}.oi-euro:before{content:'\e05e'}.oi-excerpt:before{content:'\e05f'}.oi-expand-down:before{content:'\e060'}.oi-expand-left:before{content:'\e061'}.oi-expand-right:before{content:'\e062'}.oi-expand-up:before{content:'\e063'}.oi-external-link:before{content:'\e064'}.oi-eye:before{content:'\e065'}.oi-eyedropper:before{content:'\e066'}.oi-file:before{content:'\e067'}.oi-fire:before{content:'\e068'}.oi-flag:before{content:'\e069'}.oi-flash:before{content:'\e06a'}.oi-folder:before{content:'\e06b'}.oi-fork:before{content:'\e06c'}.oi-fullscreen-enter:before{content:'\e06d'}.oi-fullscreen-exit:before{content:'\e06e'}.oi-globe:before{content:'\e06f'}.oi-graph:before{content:'\e070'}.oi-grid-four-up:before{content:'\e071'}.oi-grid-three-up:before{content:'\e072'}.oi-grid-two-up:before{content:'\e073'}.oi-hard-drive:before{content:'\e074'}.oi-header:before{content:'\e075'}.oi-headphones:before{content:'\e076'}.oi-heart:before{content:'\e077'}.oi-home:before{content:'\e078'}.oi-image:before{content:'\e079'}.oi-inbox:before{content:'\e07a'}.oi-infinity:before{content:'\e07b'}.oi-info:before{content:'\e07c'}.oi-italic:before{content:'\e07d'}.oi-justify-center:before{content:'\e07e'}.oi-justify-left:before{content:'\e07f'}.oi-justify-right:before{content:'\e080'}.oi-key:before{content:'\e081'}.oi-laptop:before{content:'\e082'}.oi-layers:before{content:'\e083'}.oi-lightbulb:before{content:'\e084'}.oi-link-broken:before{content:'\e085'}.oi-link-intact:before{content:'\e086'}.oi-list-rich:before{content:'\e087'}.oi-list:before{content:'\e088'}.oi-location:before{content:'\e089'}.oi-lock-locked:before{content:'\e08a'}.oi-lock-unlocked:before{content:'\e08b'}.oi-loop-circular:before{content:'\e08c'}.oi-loop-square:before{content:'\e08d'}.oi-loop:before{content:'\e08e'}.oi-magnifying-glass:before{content:'\e08f'}.oi-map-marker:before{content:'\e090'}.oi-map:before{content:'\e091'}.oi-media-pause:before{content:'\e092'}.oi-media-play:before{content:'\e093'}.oi-media-record:before{content:'\e094'}.oi-media-skip-backward:before{content:'\e095'}.oi-media-skip-forward:before{content:'\e096'}.oi-media-step-backward:before{content:'\e097'}.oi-media-step-forward:before{content:'\e098'}.oi-media-stop:before{content:'\e099'}.oi-medical-cross:before{content:'\e09a'}.oi-menu:before{content:'\e09b'}.oi-microphone:before{content:'\e09c'}.oi-minus:before{content:'\e09d'}.oi-monitor:before{content:'\e09e'}.oi-moon:before{content:'\e09f'}.oi-move:before{content:'\e0a0'}.oi-musical-note:before{content:'\e0a1'}.oi-paperclip:before{content:'\e0a2'}.oi-pencil:before{content:'\e0a3'}.oi-people:before{content:'\e0a4'}.oi-person:before{content:'\e0a5'}.oi-phone:before{content:'\e0a6'}.oi-pie-chart:before{content:'\e0a7'}.oi-pin:before{content:'\e0a8'}.oi-play-circle:before{content:'\e0a9'}.oi-plus:before{content:'\e0aa'}.oi-power-standby:before{content:'\e0ab'}.oi-print:before{content:'\e0ac'}.oi-project:before{content:'\e0ad'}.oi-pulse:before{content:'\e0ae'}.oi-puzzle-piece:before{content:'\e0af'}.oi-question-mark:before{content:'\e0b0'}.oi-rain:before{content:'\e0b1'}.oi-random:before{content:'\e0b2'}.oi-reload:before{content:'\e0b3'}.oi-resize-both:before{content:'\e0b4'}.oi-resize-height:before{content:'\e0b5'}.oi-resize-width:before{content:'\e0b6'}.oi-rss-alt:before{content:'\e0b7'}.oi-rss:before{content:'\e0b8'}.oi-script:before{content:'\e0b9'}.oi-share-boxed:before{content:'\e0ba'}.oi-share:before{content:'\e0bb'}.oi-shield:before{content:'\e0bc'}.oi-signal:before{content:'\e0bd'}.oi-signpost:before{content:'\e0be'}.oi-sort-ascending:before{content:'\e0bf'}.oi-sort-descending:before{content:'\e0c0'}.oi-spreadsheet:before{content:'\e0c1'}.oi-star:before{content:'\e0c2'}.oi-sun:before{content:'\e0c3'}.oi-tablet:before{content:'\e0c4'}.oi-tag:before{content:'\e0c5'}.oi-tags:before{content:'\e0c6'}.oi-target:before{content:'\e0c7'}.oi-task:before{content:'\e0c8'}.oi-terminal:before{content:'\e0c9'}.oi-text:before{content:'\e0ca'}.oi-thumb-down:before{content:'\e0cb'}.oi-thumb-up:before{content:'\e0cc'}.oi-timer:before{content:'\e0cd'}.oi-transfer:before{content:'\e0ce'}.oi-trash:before{content:'\e0cf'}.oi-underline:before{content:'\e0d0'}.oi-vertical-align-bottom:before{content:'\e0d1'}.oi-vertical-align-center:before{content:'\e0d2'}.oi-vertical-align-top:before{content:'\e0d3'}.oi-video:before{content:'\e0d4'}.oi-volume-high:before{content:'\e0d5'}.oi-volume-low:before{content:'\e0d6'}.oi-volume-off:before{content:'\e0d7'}.oi-warning:before{content:'\e0d8'}.oi-wifi:before{content:'\e0d9'}.oi-wrench:before{content:'\e0da'}.oi-x:before{content:'\e0db'}.oi-yen:before{content:'\e0dc'}.oi-zoom-in:before{content:'\e0dd'}.oi-zoom-out:before{content:'\e0de'} -------------------------------------------------------------------------------- /BlazorCefApp/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlazorPlus/BlazorCefApp/14d066cbe7f736a9cfe1d5ba9539062dd4d596c2/BlazorCefApp/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /BlazorCefApp/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlazorPlus/BlazorCefApp/14d066cbe7f736a9cfe1d5ba9539062dd4d596c2/BlazorCefApp/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /BlazorCefApp/wwwroot/css/open-iconic/font/fonts/open-iconic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | Created by FontForge 20120731 at Tue Jul 1 20:39:22 2014 9 | By P.J. Onori 10 | Created by P.J. Onori with FontForge 2.0 (http://fontforge.sf.net) 11 | 12 | 13 | 14 | 27 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 45 | 47 | 49 | 51 | 53 | 55 | 57 | 59 | 61 | 63 | 65 | 67 | 69 | 71 | 74 | 76 | 79 | 81 | 84 | 86 | 88 | 91 | 93 | 95 | 98 | 100 | 102 | 104 | 106 | 109 | 112 | 115 | 117 | 121 | 123 | 125 | 127 | 130 | 132 | 134 | 136 | 138 | 141 | 143 | 145 | 147 | 149 | 151 | 153 | 155 | 157 | 159 | 162 | 165 | 167 | 169 | 172 | 174 | 177 | 179 | 181 | 183 | 185 | 189 | 191 | 194 | 196 | 198 | 200 | 202 | 205 | 207 | 209 | 211 | 213 | 215 | 218 | 220 | 222 | 224 | 226 | 228 | 230 | 232 | 234 | 236 | 238 | 241 | 243 | 245 | 247 | 249 | 251 | 253 | 256 | 259 | 261 | 263 | 265 | 267 | 269 | 272 | 274 | 276 | 280 | 282 | 285 | 287 | 289 | 292 | 295 | 298 | 300 | 302 | 304 | 306 | 309 | 312 | 314 | 316 | 318 | 320 | 322 | 324 | 326 | 330 | 334 | 338 | 340 | 343 | 345 | 347 | 349 | 351 | 353 | 355 | 358 | 360 | 363 | 365 | 367 | 369 | 371 | 373 | 375 | 377 | 379 | 381 | 383 | 386 | 388 | 390 | 392 | 394 | 396 | 399 | 401 | 404 | 406 | 408 | 410 | 412 | 414 | 416 | 419 | 421 | 423 | 425 | 428 | 431 | 435 | 438 | 440 | 442 | 444 | 446 | 448 | 451 | 453 | 455 | 457 | 460 | 462 | 464 | 466 | 468 | 471 | 473 | 477 | 479 | 481 | 483 | 486 | 488 | 490 | 492 | 494 | 496 | 499 | 501 | 504 | 506 | 509 | 512 | 515 | 517 | 520 | 522 | 524 | 526 | 529 | 532 | 534 | 536 | 539 | 542 | 543 | 544 | -------------------------------------------------------------------------------- /BlazorCefApp/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlazorPlus/BlazorCefApp/14d066cbe7f736a9cfe1d5ba9539062dd4d596c2/BlazorCefApp/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /BlazorCefApp/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlazorPlus/BlazorCefApp/14d066cbe7f736a9cfe1d5ba9539062dd4d596c2/BlazorCefApp/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /BlazorCefApp/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); 2 | 3 | html, body, app { 4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 5 | height: 100%; 6 | display: flex; 7 | flex-direction: column; 8 | user-select: none; 9 | } 10 | 11 | input, textarea { 12 | user-select: text; 13 | } 14 | 15 | a, .btn-link { 16 | color: #0366d6; 17 | } 18 | 19 | .btn-primary { 20 | color: #fff; 21 | background-color: #1b6ec2; 22 | border-color: #1861ac; 23 | } 24 | 25 | .valid.modified:not([type=checkbox]) { 26 | outline: 1px solid #26b050; 27 | } 28 | 29 | .invalid { 30 | outline: 1px solid red; 31 | } 32 | 33 | .validation-message { 34 | color: red; 35 | } 36 | 37 | #blazor-error-ui { 38 | background: lightyellow; 39 | bottom: 0; 40 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 41 | display: none; 42 | left: 0; 43 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 44 | position: fixed; 45 | width: 100%; 46 | z-index: 1000; 47 | } 48 | 49 | #blazor-error-ui .dismiss { 50 | cursor: pointer; 51 | position: absolute; 52 | right: 0.75rem; 53 | top: 0.5rem; 54 | } 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | textarea { 66 | font-family: 'Segoe UI'; 67 | white-space:nowrap; 68 | } 69 | 70 | 71 | 72 | 73 | .main-menu { 74 | padding-right: 20px; 75 | padding-bottom: 20px; 76 | } 77 | 78 | .main-menu-item { 79 | width: 250px; 80 | margin: 20px 0 0 20px; 81 | padding: 12px; 82 | border: 1px solid gray; 83 | font-size: 18px; 84 | cursor: pointer; 85 | } 86 | 87 | .main-menu-item:hover { 88 | border: 1px solid red; 89 | background-color: wheat; 90 | } 91 | 92 | .main-menu-item-title { 93 | text-align: center; 94 | } 95 | 96 | .main-menu-item-comment { 97 | text-align: center; 98 | font-size: 12px; 99 | color: #666; 100 | } 101 | 102 | 103 | @keyframes dialog_layout_show { 104 | 0% { 105 | transform: translate3d(100%,0,0); 106 | } 107 | 108 | 100% { 109 | transform: translate3d(0,0,0); 110 | } 111 | } 112 | 113 | @keyframes dialog_layout_hide { 114 | 0% { 115 | transform: translate3d(0,0,0); 116 | } 117 | 118 | 100% { 119 | transform: translate3d(100%,0,0); 120 | } 121 | } 122 | 123 | 124 | .dialog-content-full { 125 | width: 100%; 126 | height: 100%; 127 | overflow: auto; 128 | background-color: #fff; 129 | animation: dialog_layout_show 0.2s; 130 | display: flex; 131 | flex-direction: column; 132 | } 133 | 134 | .dialog-slide-out { 135 | transform: translate3d(100%,0,0); 136 | animation: dialog_layout_hide 0.2s; 137 | } 138 | -------------------------------------------------------------------------------- /BlazorCefApp/wwwroot/demo.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlazorPlus/BlazorCefApp/14d066cbe7f736a9cfe1d5ba9539062dd4d596c2/BlazorCefApp/wwwroot/demo.mp4 -------------------------------------------------------------------------------- /BlazorCefApp/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlazorPlus/BlazorCefApp/14d066cbe7f736a9cfe1d5ba9539062dd4d596c2/BlazorCefApp/wwwroot/favicon.ico -------------------------------------------------------------------------------- /BlazorCefApp/wwwroot/splash.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlazorPlus/BlazorCefApp/14d066cbe7f736a9cfe1d5ba9539062dd4d596c2/BlazorCefApp/wwwroot/splash.jpg -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) BlazorPlus (http://blazorplus.com) 4 | 5 | All rights reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BlazorCefApp 2 | 3 | Build Desktop application by CEF , Asp.Net Core , Blazor server side 4 | 5 | ![Screenshot](https://github.com/BlazorPlus/BlazorCefApp/raw/master/demoscreenshots/demo-index.png) 6 | 7 | 8 | # Compilation : 9 | 10 | The path of mstscax_interop.dll is correct now. 11 | 12 | 13 | # Now it works 14 | 15 | #### developer must copy the Release/Resources files from 16 | 17 | https://cef-builds.spotifycdn.com/cef_binary_81.3.10%2Bgb223419%2Bchromium-81.0.4044.138_windows32_client.tar.bz2 18 | 19 | **to app /chromium/ folder** 20 | 21 | 22 | # CefLite source code : 23 | 24 | https://github.com/BlazorPlus/CefLite 25 | 26 | 27 | 28 | ## Ralative Links 29 | 30 | https://github.com/aspnet/AspLabs/tree/master/src/ComponentsElectron 31 | 32 | https://blog.stevensanderson.com/2019/11/18/2019-11-18-webwindow-a-cross-platform-webview-for-dotnet-core/ 33 | 34 | https://github.com/chromelyapps/Chromely 35 | 36 | https://github.com/jspuij/BlazorWebView 37 | 38 | 39 | -------------------------------------------------------------------------------- /demoscreenshots/demo-index.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlazorPlus/BlazorCefApp/14d066cbe7f736a9cfe1d5ba9539062dd4d596c2/demoscreenshots/demo-index.png -------------------------------------------------------------------------------- /dllrefs/mstscax_interop.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlazorPlus/BlazorCefApp/14d066cbe7f736a9cfe1d5ba9539062dd4d596c2/dllrefs/mstscax_interop.dll --------------------------------------------------------------------------------