Commit 2a9a359d by liulongfei

GH 资源

parent ff203f1c
<UserControl x:Class="VIZ.Package.Module.DebugView"
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:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VIZ.Package.Module"
d:DataContext="{d:DesignInstance Type=local:DebugViewModel}"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<Style TargetType="GroupBox">
<Setter Property="Margin" Value="10"></Setter>
</Style>
<Style TargetType="Button">
<Setter Property="Width" Value="100"></Setter>
<Setter Property="Height" Value="30"></Setter>
<Setter Property="Margin" Value="10"></Setter>
</Style>
</UserControl.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<GroupBox Header="Docking测试">
<StackPanel>
<Button Content="保存布局" Command="{Binding SaveLayoutCommand}"></Button>
<Button Content="加载布局" Command="{Binding LoadLayoutCommand}"></Button>
</StackPanel>
</GroupBox>
<GroupBox Header="日志测试" Grid.Column="1">
<StackPanel>
<Button Content="添加日志" Command="{Binding AddLogCommand}"></Button>
<Button Content="清理日志" Command="{Binding ClearLogCommand}"></Button>
</StackPanel>
</GroupBox>
</Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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.Navigation;
using System.Windows.Shapes;
using VIZ.Framework.Core;
namespace VIZ.Package.Module
{
/// <summary>
/// DebugView.xaml 的交互逻辑
/// </summary>
public partial class DebugView : UserControl
{
public DebugView()
{
InitializeComponent();
WPFHelper.BindingViewModel(this, new DebugViewModel());
}
}
}
<dx:ThemedWindow x:Class="VIZ.Package.Module.DebugWindow"
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:DebugViewModel}"
Title="调试窗口" Height="600" Width="800"
WindowStartupLocation="CenterScreen">
<local:DebugView></local:DebugView>
</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 DebugWindow.xaml
/// </summary>
public partial class DebugWindow : ThemedWindow
{
public DebugWindow()
{
InitializeComponent();
}
}
}
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 DebugViewModel : ViewModelBase
{
public DebugViewModel()
{
// 初始化命令
this.InitCommand();
}
/// <summary>
/// 初试化命令
/// </summary>
private void InitCommand()
{
// Docking
this.SaveLayoutCommand = new VCommand(this.SaveLayout);
this.LoadLayoutCommand = new VCommand(this.LoadLayout);
// 日志
this.AddLogCommand = new VCommand(this.AddLog);
this.ClearLogCommand = new VCommand(this.ClearLog);
}
// ======================================================================
// Command
// ======================================================================
// ---------------------------------------------------------
// Docking
#region SaveLayoutCommand -- 保存布局命令
/// <summary>
/// 保存布局命令
/// </summary>
public VCommand SaveLayoutCommand { get; set; }
/// <summary>
/// 保存布局
/// </summary>
private void SaveLayout()
{
IMainViewService service = ApplicationDomainEx.ServiceManager.GetService<IMainViewService>(ViewServiceKeys.MAIN_VIEW_SERVICE);
if (service == null)
return;
service.SaveLayout();
}
#endregion
#region LoadLayoutCommand -- 加载布局命令
/// <summary>
/// 加载布局命令
/// </summary>
public VCommand LoadLayoutCommand { get; set; }
/// <summary>
/// 加载布局
/// </summary>
private void LoadLayout()
{
IMainViewService service = ApplicationDomainEx.ServiceManager.GetService<IMainViewService>(ViewServiceKeys.MAIN_VIEW_SERVICE);
if (service == null)
return;
service.LoadLayout();
}
#endregion
// ---------------------------------------------------------
// 日志
#region AddLogCommand -- 添加日志命令
/// <summary>
/// 添加日志命令
/// </summary>
public VCommand AddLogCommand { get; set; }
/// <summary>
/// 添加日志
/// </summary>
private void AddLog()
{
ILogService service = ApplicationDomainEx.ServiceManager.GetService<ILogService>(ViewServiceKeys.LOG_VIEW_SERVICE);
if (service == null)
return;
service.AppendLog("this is a try.");
}
#endregion
#region ClearLogCommand -- 清理日志命令
/// <summary>
/// 清理日志命令
/// </summary>
public VCommand ClearLogCommand { get; set; }
/// <summary>
/// 清理日志
/// </summary>
private void ClearLog()
{
ILogService service = ApplicationDomainEx.ServiceManager.GetService<ILogService>(ViewServiceKeys.LOG_VIEW_SERVICE);
if (service == null)
return;
service.ClearLog();
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Package.Domain;
using VIZ.Package.Plugin;
namespace VIZ.Package.Module
{
/// <summary>
/// 日志插件生命周期
/// </summary>
public class LogPluginLifeCycle : IPluginLifeCycle
{
/// <summary>
/// 插件ID
/// </summary>
/// <remarks>
/// 插件ID不能包含点号
/// </remarks>
public const string PLUGIN_ID = ModulePluginIds.LOG;
/// <summary>
/// 插件名称
/// </summary>
public const string PLUGIN_NAME = "日志";
/// <summary>
/// 注册
/// </summary>
/// <returns>插件信息</returns>
public PluginInfo Register()
{
PluginInfo info = new PluginInfo();
info.ID = PLUGIN_ID;
info.Name = PLUGIN_NAME;
info.ViewType = typeof(LogView);
return info;
}
/// <summary>
/// 初始化
/// </summary>
public void Initialize()
{
}
/// <summary>
/// 销毁
/// </summary>
public void Dispose()
{
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
namespace VIZ.Package.Module
{
/// <summary>
/// 日志服务
/// </summary>
public interface ILogService : IService
{
/// <summary>
/// 添加日志
/// </summary>
/// <param name="log">日志</param>
void AppendLog(string log);
/// <summary>
/// 清理日志
/// </summary>
void ClearLog();
}
}
\ No newline at end of file
<UserControl x:Class="VIZ.Package.Module.LogView"
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:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VIZ.Package.Module"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<TextBox x:Name="tb" IsReadOnly="True" AcceptsReturn="False" VerticalScrollBarVisibility="Auto"></TextBox>
</Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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.Navigation;
using System.Windows.Shapes;
using VIZ.Framework.Core;
namespace VIZ.Package.Module
{
/// <summary>
/// LogView.xaml 的交互逻辑
/// </summary>
public partial class LogView : UserControl
{
public LogView()
{
InitializeComponent();
WPFHelper.BindingViewModel(this, new LogViewModel());
}
}
}
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 LogViewModel : ViewModelBase, ILogService
{
/// <summary>
/// 日志
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(LogViewModel));
/// <summary>
/// 日志视图模型
/// </summary>
public LogViewModel()
{
ApplicationDomainEx.ServiceManager.AddService(ViewServiceKeys.LOG_VIEW_SERVICE, this);
}
// ==================================================================================
// Public Function
// ==================================================================================
/// <summary>
/// 添加日志
/// </summary>
/// <param name="log"></param>
public void AppendLog(string log)
{
WPFHelper.BeginInvoke(() =>
{
LogView view = this.GetView<LogView>();
if (view == null)
return;
view.tb.AppendText($"{log}\r\n");
});
}
/// <summary>
/// 清理日志
/// </summary>
public void ClearLog()
{
WPFHelper.BeginInvoke(() =>
{
LogView view = this.GetView<LogView>();
if (view == null)
return;
view.tb.Clear();
});
}
}
}
\ No newline at end of file
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