|
@@ -1,16 +1,22 @@ |
|
|
using BPA.Communication; |
|
|
using BPA.Communication; |
|
|
using BPA.Helper; |
|
|
using BPA.Helper; |
|
|
using BPA.Message; |
|
|
using BPA.Message; |
|
|
|
|
|
using IWshRuntimeLibrary; |
|
|
using Microsoft.Web.WebView2.Wpf; |
|
|
using Microsoft.Web.WebView2.Wpf; |
|
|
using Newtonsoft.Json; |
|
|
using Newtonsoft.Json; |
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Concurrent; |
|
|
using System.Collections.Concurrent; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
|
|
|
using System.Drawing; |
|
|
|
|
|
using System.IO; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using System.Text; |
|
|
using System.Text; |
|
|
using System.Threading; |
|
|
using System.Threading; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
using System.Windows.Controls; |
|
|
using System.Windows.Controls; |
|
|
|
|
|
using System.Windows.Forms; |
|
|
|
|
|
using System.Windows.Shapes; |
|
|
|
|
|
using System.Xml; |
|
|
|
|
|
|
|
|
namespace BPASmartClient.ScreenLib |
|
|
namespace BPASmartClient.ScreenLib |
|
|
{ |
|
|
{ |
|
@@ -223,7 +229,7 @@ namespace BPASmartClient.ScreenLib |
|
|
/// </summary> |
|
|
/// </summary> |
|
|
/// <param name="input"></param> |
|
|
/// <param name="input"></param> |
|
|
/// <param name="view2"></param> |
|
|
/// <param name="view2"></param> |
|
|
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 height = 540; |
|
|
var width = 940; |
|
|
var width = 940; |
|
@@ -231,10 +237,29 @@ namespace BPASmartClient.ScreenLib |
|
|
StringBuilder sb = new StringBuilder(); |
|
|
StringBuilder sb = new StringBuilder(); |
|
|
sb.Append("<html><style>body {width: " + width + "px;height: " + height + "px;margin: 0;padding:0;}body p {width: " + width + "px;height: " + height + "px;}body p img {width: 100%;height: 100%;}</style><script>function Set(width, height) { var body = document.getElementsByTagName('body')[0]; body.style.width = width + 'px';body.style.height = height + 'px';var p = document.getElementsByTagName('p')[0]; p.style.width = width + 'px';p.style.height = height + 'px';}</script><body>" + input + "</body></html>"); |
|
|
sb.Append("<html><style>body {width: " + width + "px;height: " + height + "px;margin: 0;padding:0;}body p {width: " + width + "px;height: " + height + "px;}body p img {width: 100%;height: 100%;}</style><script>function Set(width, height) { var body = document.getElementsByTagName('body')[0]; body.style.width = width + 'px';body.style.height = height + 'px';var p = document.getElementsByTagName('p')[0]; p.style.width = width + 'px';p.style.height = height + 'px';}</script><body>" + input + "</body></html>"); |
|
|
var html = sb.ToString(); |
|
|
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); |
|
|
} |
|
|
} |
|
|
/// <summary> |
|
|
/// <summary> |
|
|
/// 读取配置 |
|
|
/// 读取配置 |
|
|