From cef00923a8bef33df604e485b32e0d063ad21089 Mon Sep 17 00:00:00 2001 From: fyf Date: Sat, 3 Dec 2022 15:17:34 +0800 Subject: [PATCH] 1 --- BPASmartClient.ScreenLib/Helper/Main.cs | 35 +++++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/BPASmartClient.ScreenLib/Helper/Main.cs b/BPASmartClient.ScreenLib/Helper/Main.cs index 1b5b041c..c376e510 100644 --- a/BPASmartClient.ScreenLib/Helper/Main.cs +++ b/BPASmartClient.ScreenLib/Helper/Main.cs @@ -1,16 +1,22 @@ using BPA.Communication; using BPA.Helper; using BPA.Message; +using IWshRuntimeLibrary; using Microsoft.Web.WebView2.Wpf; using Newtonsoft.Json; using System; using System.Collections.Concurrent; using System.Collections.Generic; +using System.Drawing; +using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Controls; +using System.Windows.Forms; +using System.Windows.Shapes; +using System.Xml; namespace BPASmartClient.ScreenLib { @@ -223,7 +229,7 @@ namespace BPASmartClient.ScreenLib /// /// /// - public async void InitView2(string input, WebView2 view2, GroupBox group) + public async void InitView2(string input, WebView2 view2, System.Windows.Controls.GroupBox group) { var height = 540; var width = 940; @@ -231,10 +237,29 @@ namespace BPASmartClient.ScreenLib StringBuilder sb = new StringBuilder(); sb.Append("" + input + ""); var html = sb.ToString(); - await view2.EnsureCoreWebView2Async(null); - view2.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false; - view2.CoreWebView2.Settings.AreDevToolsEnabled = false; - view2.CoreWebView2.NavigateToString(html); + + string name = $"{Application.StartupPath}\\Html\\{Name}.html"; + if (!System.IO.Directory.Exists($"{Application.StartupPath}\\Html")) + { + System.IO.Directory.CreateDirectory($"{Application.StartupPath}\\Html");//不存在就创建文件夹 } + } + if (!System.IO.File.Exists(name)) + { + //----------生成htm文件------------------―― + try + { + using (StreamWriter sw = new StreamWriter(name, false, System.Text.Encoding.GetEncoding("UTF-8"))) //保存地址 + { + sw.WriteLine(html); + sw.Flush(); + sw.Close(); + } + } + catch + { + } + } + view2.Source = new Uri(name); } /// /// 读取配置