From 2e54b439c64e0adbb7e010243c1f33aa5fc5f503 Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期二, 11 三月 2025 14:08:57 +0800
Subject: [PATCH] 完善程序; Merge branch 'master' of http://58.211.88.246:3600/r/WPF/WPFProject
---
WPFProject/LoadingWindow.xaml.cs | 81 ++++++++++++++++++++++++++++++++++------
1 files changed, 69 insertions(+), 12 deletions(-)
diff --git a/WPFProject/LoadingWindow.xaml.cs b/WPFProject/LoadingWindow.xaml.cs
index 49b44ce..b929c03 100644
--- a/WPFProject/LoadingWindow.xaml.cs
+++ b/WPFProject/LoadingWindow.xaml.cs
@@ -1,35 +1,41 @@
-锘縰sing System;
+锘縰sing HMI.Base;
+using Panuon.WPF.UI;
+using System;
using System.Threading.Tasks;
using System.Windows;
-using HMI.Base;
+using System.Windows.Documents;
namespace WPFProject
{
/// <summary>
/// LoadingWindow.xaml 鐨勪氦浜掗�昏緫
/// </summary>
- public partial class LoadingWindow : Window
+ public partial class LoadingWindow : WindowX
{
+
+ private string consoleText = "";
+
+ public string ConsoleText
+ {
+ get { return consoleText; }
+ set { Set(ref consoleText, value); }
+ }
+
public LoadingWindow()
{
+ DataContext = this;
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
- PluginLoader loader = PluginLoader.GetLoader();
- loader.LoadMessageAppend += Loader_LoadMessageAppend;
- loader.LoadMenuAndPlugin();
- Button_Click(null,null);
+
}
-
private void Loader_LoadMessageAppend(object sender, string e)
{
- this.Dispatcher.BeginInvoke((Action)delegate ()
- {
- Console.Text = Console.Text + $"{e}\r\n";
- });
+ Add(e);
}
+
private void Button_Click(object sender, RoutedEventArgs e)
{
@@ -37,5 +43,56 @@
window.Show();
this.Close();
}
+
+ private void WindowX_ContentRendered(object sender, System.EventArgs e)
+ {
+ PluginLoader loader = PluginLoader.GetLoader();
+ loader.LoadMessageAppend += Loader_LoadMessageAppend;
+ loader.Loaded += Loader_Loaded;
+ Task.Run(() =>
+ {
+ loader.LoadMenuAndPlugin(Dispatcher);
+ //
+ });
+ }
+
+ private void Loader_Loaded(object sender, EventArgs e)
+ {
+ Dispatcher.Invoke(() =>
+ {
+ Button_Click(null, null);
+ });
+ }
+
+ public void Add(string text)
+ {
+ string t = string.Format("{0:G}", DateTime.Now);
+ Run run = new Run();
+ run.Text = t + " 淇℃伅锛�" + text;
+ //run.Foreground = new Brush();
+
+ Paragraph paragraph = new Paragraph(run) {
+ LineHeight =1
+ };
+ //rtxtLog.Document.Blocks.InsertAfter(); ;
+ //鎻掑叆鍒版渶鍓嶉潰
+ Console.Document.Blocks.InsertAfter(Console.Document.Blocks.LastBlock, paragraph);
+ //涔熷彲浠ユ彃鍏ュ埌鏈�鍚庨潰
+ //rtxtLog.Document.Blocks.Add(paragraph);
+
+ // 婊氬姩鑷虫渶鍚庤
+ //rtxtLog.ScrollToEnd();
+ //Console.ScrollToHome();
+ Console.ScrollToEnd();
+ // 鍒犻櫎
+ //if (Console.Document.Blocks.Count > 10000)
+ //{
+ // for (int i = 1000; i < Console.Document.Blocks.Count; i++)
+ // {
+ // _ = Console.Document.Blocks.Remove(Console.Document.Blocks.FirstBlock);
+ // }
+ //}
+
+ }
}
}
--
Gitblit v1.9.1