用户信息和数据库的增删改查修改
This commit is contained in:
1 parent
10611241d1
commit
5d9ab90ed3
16 files changed
+511
-23
No files matched your search
+15
-8
@@ -10,25 +10,32 @@ namespace SunlightAggregationManager.UserClass
|
||||
public class ControlWriter : TextWriter
|
||||
{
|
||||
private readonly TextBox _textbox;
|
||||
private readonly Action<string> _logGingDataAction;
|
||||
|
||||
public ControlWriter(TextBox textbox)
|
||||
public ControlWriter(TextBox textbox,Action<string> logGingDataAction)
|
||||
{
|
||||
_textbox = textbox;
|
||||
_logGingDataAction = logGingDataAction;
|
||||
}
|
||||
|
||||
public override void Write(char value) => AppendText(DateTime.Now + ": " + value.ToString());
|
||||
public override void Write(string? value) => AppendText(DateTime.Now + ": " + value);
|
||||
public override void WriteLine(string? value) => AppendText(DateTime.Now + ": "+value + Environment.NewLine);
|
||||
public override void Write(char value) => AppendText(DateTime.Now + ": " + value.ToString(), true);
|
||||
public override void Write(string? value) => AppendText(DateTime.Now + ": " + value, true);
|
||||
public override void WriteLine(string? value) => AppendText(DateTime.Now + ": "+value + Environment.NewLine, true);
|
||||
|
||||
private void AppendText(string text)
|
||||
private void AppendText(string text, bool invokeExternalLog)
|
||||
{
|
||||
if (!_textbox.Dispatcher.CheckAccess())
|
||||
{
|
||||
_textbox.Dispatcher.Invoke(DispatcherPriority.Background, new Action(() => AppendText(text)));
|
||||
_textbox.Dispatcher.Invoke(DispatcherPriority.Background, new Action(() => AppendText(text, true)));
|
||||
return;
|
||||
}
|
||||
_textbox.AppendText(text);
|
||||
_textbox.ScrollToEnd();
|
||||
|
||||
if (invokeExternalLog)
|
||||
{
|
||||
_logGingDataAction?.Invoke(text);
|
||||
}
|
||||
}
|
||||
|
||||
public override Encoding Encoding => Encoding.UTF8;
|
||||
@@ -41,10 +48,10 @@ namespace SunlightAggregationManager.UserClass
|
||||
|
||||
// 【核心功能】注册目标 TextBox
|
||||
// 子页面加载时调用这个方法
|
||||
public static void RegisterTarget(TextBox logBox)
|
||||
public static void RegisterTarget(TextBox logBox ,Action<string> logGingDataAction)
|
||||
{
|
||||
// 创建新的 Writer
|
||||
_currentWriter = new ControlWriter(logBox);
|
||||
_currentWriter = new ControlWriter(logBox, logGingDataAction);
|
||||
|
||||
// 【关键】将 Console 的输出重定向到这个 Writer
|
||||
// 这样 Console.WriteLine("...") 就会自动写入到 logBox 中
|
||||
|
||||
Reference in new issue
Block a user