fyf před 2 roky
rodič
revize
cef00923a8
1 změnil soubory, kde provedl 30 přidání a 5 odebrání
  1. +30
    -5
      BPASmartClient.ScreenLib/Helper/Main.cs

+ 30
- 5
BPASmartClient.ScreenLib/Helper/Main.cs Zobrazit soubor

@@ -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
/// </summary>
/// <param name="input"></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 width = 940;
@@ -231,10 +237,29 @@ namespace BPASmartClient.ScreenLib
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>");
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>
/// 读取配置


Načítá se…
Zrušit
Uložit