更新粘贴乱码问题

This commit is contained in:
Colin 2023-08-31 10:58:27 +08:00
parent 54ec14c527
commit 305201f23e
3 changed files with 49 additions and 1 deletions

View File

@ -16,8 +16,8 @@ using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Forms;
using MaterialSkin;
#if MD
using MaterialSkin;
using MaterialSkin.Controls;
#endif

View File

@ -1,10 +1,13 @@
using AIMS.PublicUI.UI;
using AIMSModel;
using CCIS.Shared;
using DCSoft.Writer;
using DCSoft.Writer.Data;
using DCSoft.Writer.Dom;
using DocumentManagement;
using DrawGraph;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Data;
@ -18,6 +21,7 @@ namespace AIMS.OremrUserControl
{
public partial class ucDocument : UserControl
{
ILogger<ucDocument> logger = SharedContext.StaticInstance.ServiceProvider.GetService<ILoggerFactory>().CreateLogger<ucDocument>();
//模板Model
private PrintTemplate TModel = new PrintTemplate();
//文档Model
@ -43,6 +47,7 @@ namespace AIMS.OremrUserControl
public ucDocument(int tempId, int docId, PatientRecord patient)
{
InitializeComponent();
Patient = patient;
@ -250,6 +255,7 @@ namespace AIMS.OremrUserControl
}
catch (Exception exp)
{
logger.LogError(exp,"保存文档出错");
MessageBox.Show(exp.Message, "提示");
}
}

View File

@ -38,11 +38,47 @@ namespace DocumentManagement
eet.KeyUp += Eet_KeyUp;
eet.ContentChanged += new ContentChangedEventHandler(eet_ContentChanged);
myEditControl.GlobalEventTemplate_Element = eet;
eet.ContentChanging += Eet_ContentChanging;
}
private void Eet_ContentChanging(object eventSender, ContentChangingEventArgs args)
{
if (eventSender is XTextInputFieldElement xife)
{
var txtAll = args.InsertingElements.Select(c => c.Text).ToList();
var txt = string.Concat(txtAll);
if (txtAll.Any(c=>c.Contains("<22>")))
{
var clip = Clipboard.GetText().Trim();
xife.Text = clip;
args.Cancel = true;
return;
args.InsertingElements.Clear();
args.InsertingElements.Add(new XTextStringElement() { Text = clip });
}
byte[] originalBytes = Encoding.UTF8.GetBytes(txt); // 这里使用 UTF8 是假设或猜测
string decodedString = Encoding.GetEncoding("GB2312").GetString(originalBytes); // 用其他编码尝试解码
byte[] originalBytes2 = Encoding.GetEncoding("GB2312").GetBytes(txt); // 这里使用 UTF8 是假设或猜测
string decodedString2 = Encoding.UTF8.GetString(originalBytes2); // 用其他编码尝试解码
}
}
private void Eet_KeyUp(object eventSender, ElementKeyEventArgs args)
{
// 判断 Ctrl 键是否被按下
if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
{
// 判断 V 键是否被按下
if (args.KeyCode == Keys.V)
{
// Ctrl+V 被按下,执行相应的操作
MessageBox.Show("Ctrl+V was pressed!");
}
}
if (args.KeyCode == Keys.V && args.Control == true)
{
if ((eventSender as XTextDocument).CurrentInputField != null)
@ -50,10 +86,16 @@ namespace DocumentManagement
var element = (eventSender as XTextDocument).CurrentInputField;
if (element != null)
{
var etxt = element.Text;
element.Text = element.Text.Replace("\r", "").Replace("\n", "");
}
}
}
else
{
}
}
public CompilerErrorCollection Errors { get { return cr.Errors; } }