Commit bfc47cfa by liulongfei

Viz 命令日志窗口

异常日志窗口
parent e9a78921
using log4net.Appender;
using log4net.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Common
{
/// <summary>
/// 错误消息附加
/// </summary>
public class ErrorMessageAppender : IAppender
{
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; } = "ErrorMessageAppender";
/// <summary>
/// 关闭
/// </summary>
public void Close()
{
// nothing to do.
}
/// <summary>
/// 执行
/// </summary>
/// <param name="loggingEvent">日志事件</param>
public void DoAppend(LoggingEvent loggingEvent)
{
if (loggingEvent.Level != Level.Error)
return;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Domain.Message.Log
{
internal class ErrorLogMessaeg
{
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Domain
{
/// <summary>
/// 错误日志消息
/// </summary>
public class ErrorLogMessage
{
/// <summary>
/// 错误
/// </summary>
public string Error { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Domain
{
/// <summary>
/// Viz命令日志消息
/// </summary>
public class VizCommandLogMessage
{
/// <summary>
/// 日志信息
/// </summary>
public string Log { get; set; }
}
}
<dx:ThemedWindow x:Class="VIZ.Package.Module.ErrorWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VIZ.Package.Module"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=local:ErrorWindowModel}"
Title="Viz命令窗口" Height="800" Width="1200"
WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Button Width="80" Height="20" Content="清除" Command="{Binding Path=ClearCommand}" HorizontalAlignment="Left"></Button>
<TextBox x:Name="tb" IsReadOnly="True" AcceptsReturn="False" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"
Grid.Row="1"></TextBox>
</Grid>
</dx:ThemedWindow>
using DevExpress.Xpf.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using VIZ.Framework.Core;
namespace VIZ.Package.Module
{
/// <summary>
/// Interaction logic for ErrorWindow.xaml
/// </summary>
public partial class ErrorWindow : ThemedWindow
{
public ErrorWindow()
{
InitializeComponent();
WPFHelper.BindingViewModel(this, new ErrorWindowModel());
this.Closing += VizCommandWindow_Closing;
}
private void VizCommandWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
this.Visibility = Visibility.Collapsed;
}
}
}
<dx:ThemedWindow
x:Class="VIZ.Package.Module.ErrorWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
Title="ErrorWindow" Height="800" Width="1000"
>
<Grid>
</Grid>
</dx:ThemedWindow>
using DevExpress.Xpf.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace VIZ.Package.Module
{
/// <summary>
/// Interaction logic for ErrorWindow.xaml
/// </summary>
public partial class ErrorWindow : ThemedWindow
{
public ErrorWindow()
{
InitializeComponent();
}
}
}
<dx:ThemedWindow
x:Class="VIZ.Package.Module.VizCommandWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
Title="VizCommandWindow" Height="800" Width="1000"
>
<Grid>
</Grid>
</dx:ThemedWindow>
using DevExpress.Xpf.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace VIZ.Package.Module
{
/// <summary>
/// Interaction logic for VizCommandWindow.xaml
/// </summary>
public partial class VizCommandWindow : ThemedWindow
{
public VizCommandWindow()
{
InitializeComponent();
}
}
}
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.Package.Domain;
namespace VIZ.Package.Module
{
/// <summary>
/// 错误窗口模型
/// </summary>
public class ErrorWindowModel : ViewModelBase
{
/// <summary>
/// 日志
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(ErrorWindowModel));
/// <summary>
/// 错误窗口模型
/// </summary>
public ErrorWindowModel()
{
// 初始化命令
this.InitCommand();
// 初始化消息
this.InitMessage();
}
/// <summary>
/// 初始化命令
/// </summary>
private void InitCommand()
{
this.ClearCommand = new VCommand(this.Clear);
}
/// <summary>
/// 初始化消息
/// </summary>
private void InitMessage()
{
ApplicationDomainEx.MessageManager.Register<VizCommandLogMessage>(this, this.OnVizCommandLogMessage);
}
// ==================================================================================
// Command
// ==================================================================================
#region ClearCommand -- 清除消息
/// <summary>
/// 清除消息
/// </summary>
public VCommand ClearCommand { get; set; }
/// <summary>
/// 清除
/// </summary>
private void Clear()
{
VizCommandWindow view = this.GetView<VizCommandWindow>();
if (view == null)
return;
view.tb.Clear();
}
#endregion
// ==================================================================================
// Message
// ==================================================================================
/// <summary>
/// Viz命令日志
/// </summary>
/// <param name="msg">消息</param>
private void OnVizCommandLogMessage(VizCommandLogMessage msg)
{
WPFHelper.BeginInvoke(() =>
{
VizCommandWindow view = this.GetView<VizCommandWindow>();
if (view == null)
return;
string log = $"{DateTime.Now.ToString("HH:mm:ss")} {msg.Log}";
view.tb.AppendText($"{log}\r\n");
view.tb.ScrollToEnd();
});
}
// ==================================================================================
// Public Function
// ==================================================================================
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Module.Log.ViewModel
{
internal class ErrorWindowModel
{
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Module.Log.ViewModel
{
internal class VizCommandWindowModel
{
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment