Commit bdd79e2e by liulongfei

1. 顶部菜单按钮

2. 模板模块
parent db792da2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Package.Storage;
namespace VIZ.Package.Domain
{
/// <summary>
/// 应用程序常量
/// </summary>
public static class ApplicationConstants
{
/// <summary>
/// Viz 层集合
/// </summary>
public readonly static List<VizLayer> VIZ_LAYERS = new List<VizLayer> { VizLayer.FRONT_LAYER, VizLayer.MAIN_LAYER, VizLayer.BACK_LAYER };
}
}
...@@ -45,6 +45,11 @@ namespace VIZ.Package.Domain ...@@ -45,6 +45,11 @@ namespace VIZ.Package.Domain
/// </summary> /// </summary>
public static LocalDbContext LocalDbContext { get; set; } public static LocalDbContext LocalDbContext { get; set; }
/// <summary>
/// 项目数据
/// </summary>
public static ProjectDbContext ProjectDbContext { get; set; }
// ============================================================= // =============================================================
// 配置 // 配置
// ============================================================= // =============================================================
......
...@@ -25,5 +25,10 @@ namespace VIZ.Package.Domain ...@@ -25,5 +25,10 @@ namespace VIZ.Package.Domain
/// GH场景 /// GH场景
/// </summary> /// </summary>
public const string GH_SCENE = "GH_SCENE"; public const string GH_SCENE = "GH_SCENE";
/// <summary>
/// 页模板
/// </summary>
public const string PAGE_TEMPLATE = "PAGE_TEMPLATE";
} }
} }
...@@ -20,5 +20,15 @@ namespace VIZ.Package.Domain ...@@ -20,5 +20,15 @@ namespace VIZ.Package.Domain
/// 日志服务 /// 日志服务
/// </summary> /// </summary>
public const string LOG_VIEW_SERVICE = "LOG_VIEW_SERVICE"; public const string LOG_VIEW_SERVICE = "LOG_VIEW_SERVICE";
/// <summary>
/// 页模板服务
/// </summary>
public const string PAGE_TEMPLATE_SERVICE = "PAGE_TEMPLATE_SERVICE";
/// <summary>
/// 页分组服务
/// </summary>
public const string PAGE_GROUP_SERVICE = "PAGE_GROUP_SERVICE";
} }
} }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Domain
{
/// <summary>
/// 项目关闭消息
/// </summary>
public class ProjectCloseMessage
{
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Domain
{
/// <summary>
/// 项目打开消息
/// </summary>
public class ProjectOpenMessage
{
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Domain
{
/// <summary>
/// 项目保存消息
/// </summary>
public class ProjectSaveMessage
{
}
}
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
...@@ -71,11 +72,11 @@ namespace VIZ.Package.Domain ...@@ -71,11 +72,11 @@ namespace VIZ.Package.Domain
#region Layer -- 包装层 #region Layer -- 包装层
private string layer; private VizLayer layer;
/// <summary> /// <summary>
/// 包装层 /// 包装层
/// </summary> /// </summary>
public string Layer public VizLayer Layer
{ {
get { return layer; } get { return layer; }
set { layer = value; this.RaisePropertyChanged(nameof(Layer)); } set { layer = value; this.RaisePropertyChanged(nameof(Layer)); }
...@@ -97,5 +98,46 @@ namespace VIZ.Package.Domain ...@@ -97,5 +98,46 @@ namespace VIZ.Package.Domain
#endregion #endregion
#region PageType -- 页类型
private PageType pageType;
/// <summary>
/// 页类型
/// </summary>
public PageType PageType
{
get { return pageType; }
set { pageType = value; this.RaisePropertyChanged(nameof(PageType)); }
}
#endregion
#region Order -- 排序索引
private int order;
/// <summary>
/// 排序索引
/// </summary>
public int Order
{
get { return order; }
set { order = value; this.RaisePropertyChanged(nameof(Order)); }
}
#endregion
#region ThumbnailBitmap -- 缩略图
private Bitmap thumbnailBitmap;
/// <summary>
/// 缩略图
/// </summary>
public Bitmap ThumbnailBitmap
{
get { return thumbnailBitmap; }
set { thumbnailBitmap = value; this.RaisePropertyChanged(nameof(ThumbnailBitmap)); }
}
#endregion
} }
} }
...@@ -67,11 +67,15 @@ ...@@ -67,11 +67,15 @@
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="ApplicationConstants.cs" />
<Compile Include="ApplicationDomainEx.cs" /> <Compile Include="ApplicationDomainEx.cs" />
<Compile Include="Enum\ModulePluginIds.cs" /> <Compile Include="Enum\ModulePluginIds.cs" />
<Compile Include="Enum\ViewServiceKeys.cs" /> <Compile Include="Enum\ViewServiceKeys.cs" />
<Compile Include="Message\Page\PageChangedMessage.cs" /> <Compile Include="Message\Page\PageChangedMessage.cs" />
<Compile Include="Message\Page\PageInitedMessage.cs" /> <Compile Include="Message\Page\PageInitedMessage.cs" />
<Compile Include="Message\Project\ProjectSaveMessage.cs" />
<Compile Include="Message\Project\ProjectCloseMessage.cs" />
<Compile Include="Message\Project\ProjectOpenMessage.cs" />
<Compile Include="Message\Viz\VizPreviewReadyMessage.cs" /> <Compile Include="Message\Viz\VizPreviewReadyMessage.cs" />
<Compile Include="Model\Conn\ConnGroupModel.cs" /> <Compile Include="Model\Conn\ConnGroupModel.cs" />
<Compile Include="Model\Conn\ConnModel.cs" /> <Compile Include="Model\Conn\ConnModel.cs" />
......
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace VIZ.Package.Module.Resource
{
/// <summary>
/// 行号转化器
/// </summary>
public class RowHandleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
DevExpress.Xpf.Data.RowHandle rowHandle = value as DevExpress.Xpf.Data.RowHandle;
if (rowHandle == null)
return null;
return rowHandle.Value + 1;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
...@@ -22,7 +22,7 @@ namespace VIZ.Package.Module.Resource.Properties { ...@@ -22,7 +22,7 @@ namespace VIZ.Package.Module.Resource.Properties {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources { public class Resources {
private static global::System.Resources.ResourceManager resourceMan; private static global::System.Resources.ResourceManager resourceMan;
...@@ -36,7 +36,7 @@ namespace VIZ.Package.Module.Resource.Properties { ...@@ -36,7 +36,7 @@ namespace VIZ.Package.Module.Resource.Properties {
/// 返回此类使用的缓存的 ResourceManager 实例。 /// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager { public static global::System.Resources.ResourceManager ResourceManager {
get { get {
if (object.ReferenceEquals(resourceMan, null)) { if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("VIZ.Package.Module.Resource.Properties.Resources", typeof(Resources).Assembly); global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("VIZ.Package.Module.Resource.Properties.Resources", typeof(Resources).Assembly);
...@@ -51,7 +51,7 @@ namespace VIZ.Package.Module.Resource.Properties { ...@@ -51,7 +51,7 @@ namespace VIZ.Package.Module.Resource.Properties {
/// 使用此强类型资源类的所有资源查找执行重写。 /// 使用此强类型资源类的所有资源查找执行重写。
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture { public static global::System.Globalization.CultureInfo Culture {
get { get {
return resourceCulture; return resourceCulture;
} }
...@@ -63,7 +63,7 @@ namespace VIZ.Package.Module.Resource.Properties { ...@@ -63,7 +63,7 @@ namespace VIZ.Package.Module.Resource.Properties {
/// <summary> /// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。 /// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary> /// </summary>
internal static System.Drawing.Bitmap cmd_template { public static System.Drawing.Bitmap cmd_template {
get { get {
object obj = ResourceManager.GetObject("cmd_template", resourceCulture); object obj = ResourceManager.GetObject("cmd_template", resourceCulture);
return ((System.Drawing.Bitmap)(obj)); return ((System.Drawing.Bitmap)(obj));
......
...@@ -83,6 +83,7 @@ ...@@ -83,6 +83,7 @@
</Page> </Page>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Converter\RowHandleConverter.cs" />
<Compile Include="Properties\AssemblyInfo.cs"> <Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
...@@ -97,7 +98,7 @@ ...@@ -97,7 +98,7 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile> </Compile>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
......
<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>
...@@ -10,6 +10,34 @@ ...@@ -10,6 +10,34 @@
Title="调试窗口" Height="600" Width="800" Title="调试窗口" Height="600" Width="800"
WindowStartupLocation="CenterScreen"> WindowStartupLocation="CenterScreen">
<local:DebugView></local:DebugView> <dx:ThemedWindow.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>
</dx:ThemedWindow.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>
</dx:ThemedWindow> </dx:ThemedWindow>
...@@ -23,6 +23,8 @@ namespace VIZ.Package.Module ...@@ -23,6 +23,8 @@ namespace VIZ.Package.Module
public DebugWindow() public DebugWindow()
{ {
InitializeComponent(); InitializeComponent();
WPFHelper.BindingViewModel(this, new DebugViewModel());
} }
} }
} }
...@@ -3,10 +3,30 @@ ...@@ -3,10 +3,30 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
d:DataContext="{d:DesignInstance Type=local:MainTopViewModel}"
xmlns:local="clr-namespace:VIZ.Package.Module" xmlns:local="clr-namespace:VIZ.Package.Module"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"> d:DesignHeight="450" d:DesignWidth="800">
<Grid> <StackPanel Orientation="Horizontal">
<dxb:MainMenuControl Caption="MainMenu" VerticalAlignment="Center">
</Grid> <dxb:BarSubItem Content="项目" IsEnabled="{Binding Path=IsVizPreviewReady}">
<dxb:BarButtonItem Content="新建" Command="{Binding Path=CreateProjectCommand}" />
<dxb:BarButtonItem Content="打开" Command="{Binding Path=OpenProjectCommand}" />
<dxb:BarButtonItem Content="保存" Command="{Binding Path=SaveProjectCommand}" />
<dxb:BarButtonItem Content="关闭" Command="{Binding Path=CloseProjectCommand}" />
</dxb:BarSubItem>
<dxb:BarSubItem Content="设置" Command="{Binding Path=SettingCommand}">
</dxb:BarSubItem>
<dxb:BarSubItem Content="帮助">
<dxb:BarButtonItem Content="关于" />
</dxb:BarSubItem>
</dxb:MainMenuControl>
<Border Background="#44000000" VerticalAlignment="Center" Padding="10,3,10,3">
<TextBlock Foreground="White" Text="{Binding Path=ProjectName}" VerticalAlignment="Center"></TextBlock>
</Border>
</StackPanel>
</UserControl> </UserControl>
...@@ -12,6 +12,7 @@ using System.Windows.Media; ...@@ -12,6 +12,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Navigation; using System.Windows.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
using VIZ.Framework.Core;
namespace VIZ.Package.Module namespace VIZ.Package.Module
{ {
...@@ -23,6 +24,8 @@ namespace VIZ.Package.Module ...@@ -23,6 +24,8 @@ namespace VIZ.Package.Module
public MainTopView() public MainTopView()
{ {
InitializeComponent(); InitializeComponent();
WPFHelper.BindingViewModel(this, new MainTopViewModel());
} }
} }
} }
using DevExpress.Xpf.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using VIZ.Framework.Core;
using VIZ.Package.Domain;
using VIZ.Package.Storage;
namespace VIZ.Package.Module
{
/// <summary>
/// 主视图顶部视图模型
/// </summary>
public class MainTopViewModel : ViewModelBase
{
public MainTopViewModel()
{
// 初始化命令
this.InitCommand();
// 初始化消息
this.InitMessage();
}
/// <summary>
/// 初始化命令
/// </summary>
private void InitCommand()
{
this.CreateProjectCommand = new VCommand(this.CreateProject);
this.OpenProjectCommand = new VCommand(this.OpenProject);
this.SaveProjectCommand = new VCommand(this.SaveProject, this.CanSaveProject);
this.CloseProjectCommand = new VCommand(this.CloseProject, this.CanCloseProject);
this.SettingCommand = new VCommand(this.Setting);
}
/// <summary>
/// 初始化消息
/// </summary>
private void InitMessage()
{
ApplicationDomainEx.MessageManager.Register<VizPreviewReadyMessage>(this, this.OnVizPreviewReadyMessage);
}
// =====================================================================
// Property
// =====================================================================
#region ProjectName -- 项目名
private string projectName;
/// <summary>
/// 项目名
/// </summary>
public string ProjectName
{
get { return projectName; }
set { projectName = value; this.RaisePropertyChanged(nameof(ProjectName)); }
}
#endregion
#region IsVizPreviewReady -- Viz预览是否准备完毕
private bool isVizPreviewReady;
/// <summary>
/// Viz预览是否准备完毕
/// </summary>
public bool IsVizPreviewReady
{
get { return isVizPreviewReady; }
set { isVizPreviewReady = value; this.RaisePropertyChanged(nameof(IsVizPreviewReady)); }
}
#endregion
// =====================================================================
// Command
// =====================================================================
#region CreateProjectCommand -- 创建项目命令
/// <summary>
/// 创建项目命令
/// </summary>
public VCommand CreateProjectCommand { get; set; }
/// <summary>
/// 创建项目
/// </summary>
private void CreateProject()
{
if (ApplicationDomainEx.ProjectDbContext != null)
{
var result = DXMessageBox.Show("是否保存当前项目", "提示", System.Windows.MessageBoxButton.YesNo);
if (result == System.Windows.MessageBoxResult.Yes)
{
this.SaveProject();
}
}
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "viz_pkg files(*.viz_pkg)|*.viz_pkg";
if (sfd.ShowDialog() != DialogResult.OK)
return;
this.ProjectName = System.IO.Path.GetFileNameWithoutExtension(sfd.FileName);
ApplicationDomainEx.ProjectDbContext = new ProjectDbContext(sfd.FileName);
ProjectOpenMessage msg = new ProjectOpenMessage();
ApplicationDomainEx.MessageManager.Send(msg);
this.UpdateCommandStatus();
}
#endregion
#region OpenProjectCommand -- 打开项目命令
/// <summary>
/// 打开项目命令
/// </summary>
public VCommand OpenProjectCommand { get; set; }
/// <summary>
/// 打开项目
/// </summary>
private void OpenProject()
{
if (ApplicationDomainEx.ProjectDbContext != null)
{
var result = DXMessageBox.Show("是否保存当前项目", "提示", System.Windows.MessageBoxButton.YesNo);
if (result == System.Windows.MessageBoxResult.Yes)
{
this.SaveProject();
}
}
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "viz_pkg files(*.viz_pkg)|*.viz_pkg";
ofd.Multiselect = false;
if (ofd.ShowDialog() != DialogResult.OK)
return;
this.ProjectName = System.IO.Path.GetFileNameWithoutExtension(ofd.FileName);
ApplicationDomainEx.ProjectDbContext = new ProjectDbContext(ofd.FileName);
ProjectOpenMessage msg = new ProjectOpenMessage();
ApplicationDomainEx.MessageManager.Send(msg);
this.UpdateCommandStatus();
}
#endregion
#region SaveProjectCommand -- 保存项目命令
/// <summary>
/// 保存项目命令
/// </summary>
public VCommand SaveProjectCommand { get; set; }
/// <summary>
/// 是否可以执行保存项目命令
/// </summary>
/// <returns>是否可以执行保存项目命令</returns>
private bool CanSaveProject()
{
return ApplicationDomainEx.ProjectDbContext != null;
}
/// <summary>
/// 保存项目
/// </summary>
private void SaveProject()
{
ProjectSaveMessage msg = new ProjectSaveMessage();
ApplicationDomainEx.MessageManager.Send(msg);
}
#endregion
#region CloseProjectCommand -- 关闭项目命令
/// <summary>
/// 关闭项目命令
/// </summary>
public VCommand CloseProjectCommand { get; set; }
/// <summary>
/// 是否可以执行关闭项目
/// </summary>
/// <returns>是否可以执行关闭项目</returns>
private bool CanCloseProject()
{
return ApplicationDomainEx.ProjectDbContext != null;
}
/// <summary>
/// 关闭项目
/// </summary>
private void CloseProject()
{
if (ApplicationDomainEx.ProjectDbContext != null)
{
var result = DXMessageBox.Show("是否保存当前项目", "提示", System.Windows.MessageBoxButton.YesNo);
if (result == System.Windows.MessageBoxResult.Yes)
{
this.SaveProject();
}
}
this.ProjectName = null;
ApplicationDomainEx.ProjectDbContext = null;
ProjectCloseMessage msg = new ProjectCloseMessage();
ApplicationDomainEx.MessageManager.Send(msg);
this.UpdateCommandStatus();
}
#endregion
#region SettingCommand -- 设置命令
/// <summary>
/// 设置命令
/// </summary>
public VCommand SettingCommand { get; set; }
/// <summary>
/// 设置
/// </summary>
private void Setting()
{
}
#endregion
// =====================================================================
// Message
// =====================================================================
/// <summary>
/// Viz预览准备完毕消息
/// </summary>
/// <param name="msg">消息</param>
private void OnVizPreviewReadyMessage(VizPreviewReadyMessage msg)
{
this.IsVizPreviewReady = true;
}
// =====================================================================
// Public Function
// =====================================================================
/// <summary>
/// 更新命令状态
/// </summary>
public void UpdateCommandStatus()
{
this.SaveProjectCommand.RaiseCanExecute();
this.CloseProjectCommand.RaiseCanExecute();
}
}
}
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 PageTemplatePluginLifeCycle : IPluginLifeCycle
{
/// <summary>
/// 插件ID
/// </summary>
/// <remarks>
/// 插件ID不能包含点号
/// </remarks>
public const string PLUGIN_ID = ModulePluginIds.PAGE_TEMPLATE;
/// <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(PageTemplateView);
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;
using VIZ.Package.Domain;
namespace VIZ.Package.Module
{
/// <summary>
/// 页模板服务
/// </summary>
public interface IPageTemplateService : IService
{
/// <summary>
/// 添加场景模板
/// </summary>
/// <param name="fileModel">文件模型</param>
void AddSceneTemplate(GHResourceFileModel fileModel);
}
}
<UserControl x:Class="VIZ.Package.Module.PageTemplateView"
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:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:fcore="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core"
xmlns:storage="clr-namespace:VIZ.Package.Storage;assembly=VIZ.Package.Storage"
xmlns:resource="clr-namespace:VIZ.Package.Module.Resource;assembly=VIZ.Package.Module.Resource"
xmlns:local="clr-namespace:VIZ.Package.Module"
xmlns:domain="clr-namespace:VIZ.Package.Domain;assembly=VIZ.Package.Domain"
d:DataContext="{d:DesignInstance Type=local:PageTemplateViewModel}"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<ResourceDictionary>
<resource:RowHandleConverter x:Key="RowHandleConverter"></resource:RowHandleConverter>
<fcore:Bitmap2ImageSourceConverter x:Key="Bitmap2ImageSourceConverter"></fcore:Bitmap2ImageSourceConverter>
<fcore:Enum2EnumDescriptionConverter x:Key="Enum2EnumDescriptionConverter" EnumType="{x:Type storage:PageType}"></fcore:Enum2EnumDescriptionConverter>
</ResourceDictionary>
</UserControl.Resources>
<Grid IsEnabled="{Binding Path=IsEnabled}">
<dx:DXTabControl Margin="0,10,0,10">
<dx:DXTabItem Header="场景模板">
<dxg:GridControl ItemsSource="{Binding Path=SceneTemplateModels}" ShowBorder="False"
SelectedItem="{Binding Path=SelectedSceneTemplateModel,Mode=TwoWay}">
<dxg:GridControl.ContextMenu>
<ContextMenu>
<MenuItem Header="添加至节目单" Command="{Binding Path=PlacementTarget.DataContext.SceneTemplateAddToListCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="更新模板" Command="{Binding Path=PlacementTarget.DataContext.SceneTemplateUpdateCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<Separator></Separator>
<MenuItem Header="删除模板" Command="{Binding Path=PlacementTarget.DataContext.SceneTemplateDeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
</ContextMenu>
</dxg:GridControl.ContextMenu>
<dxg:GridControl.Columns>
<dxg:GridColumn Header="序号" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False" Width="40" AllowResizing="False">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<TextBlock Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding RowData.RowHandle,Converter={StaticResource RowHandleConverter}}"></TextBlock>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
<dxg:GridColumn Header="缩略图" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False" Width="120" AllowResizing="False">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding Path=Row.ThumbnailBitmap,Converter={StaticResource Bitmap2ImageSourceConverter}}"></Image>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
<dxg:GridColumn Header="场景名" FieldName="SceneName" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False"></dxg:GridColumn>
<dxg:GridColumn Header="备注" FieldName="Remark" AllowSorting="False" AllowColumnFiltering="False">
<dxg:GridColumn.EditSettings>
<dxe:TextEditSettings TextWrapping="Wrap" TextTrimming="CharacterEllipsis" MaxLength="50"></dxe:TextEditSettings>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn Header="层" FieldName="Layer" AllowSorting="False" AllowColumnFiltering="False">
<dxg:GridColumn.EditSettings>
<dxe:ComboBoxEditSettings ItemsSource="{Binding Source={x:Static domain:ApplicationConstants.VIZ_LAYERS}}"
IsTextEditable="False"></dxe:ComboBoxEditSettings>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn Header="引擎类型" FieldName="EngineType" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False"></dxg:GridColumn>
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView AllowEditing="True" ShowIndicator="True"
NavigationStyle="Cell"
ShowGroupPanel="False"
AllowDragDrop="True"
ShowBandsPanel="False"
ShowTotalSummary="False"
ShowFixedTotalSummary="False"
ShowDragDropHint="False"
ShowTargetInfoInDragDropHint="false">
</dxg:TableView>
</dxg:GridControl.View>
</dxg:GridControl>
</dx:DXTabItem>
<dx:DXTabItem Header="其他模板">
<dxg:GridControl ItemsSource="{Binding Path=OtherTemplateModels}" ShowBorder="False"
SelectedItem="{Binding Path=SelectedOtherTemplateModel,Mode=TwoWay}">
<dxg:GridControl.ContextMenu>
<ContextMenu>
<MenuItem Header="添加至节目单" Command="{Binding Path=PlacementTarget.DataContext.OtherTemplateAddToListCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
</ContextMenu>
</dxg:GridControl.ContextMenu>
<dxg:GridControl.Columns>
<dxg:GridColumn Header="序号" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False" Width="40" AllowResizing="False">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<TextBlock Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding RowData.RowHandle,Converter={StaticResource RowHandleConverter}}"></TextBlock>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
<dxg:GridColumn Header="缩略图" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False" Width="120" AllowResizing="False">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding Path=Row.ThumbnailBitmap,Converter={StaticResource Bitmap2ImageSourceConverter}}"></Image>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
<dxg:GridColumn Header="备注" FieldName="Remark" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False"></dxg:GridColumn>
<dxg:GridColumn Header="引擎类型" FieldName="EngineType" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False"></dxg:GridColumn>
<dxg:GridColumn Header="模板类型" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False"
Binding="{Binding Path=TemplateType,Converter={StaticResource Enum2EnumDescriptionConverter}}">
</dxg:GridColumn>
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView AllowEditing="True" ShowIndicator="True"
NavigationStyle="Cell"
ShowGroupPanel="False"
AllowDragDrop="True"
ShowBandsPanel="False"
ShowTotalSummary="False"
ShowFixedTotalSummary="False"
ShowDragDropHint="False"
ShowTargetInfoInDragDropHint="false">
</dxg:TableView>
</dxg:GridControl.View>
</dxg:GridControl>
</dx:DXTabItem>
</dx:DXTabControl>
<dx:WaitIndicator DeferedVisibility="{Binding IsProgramTemplateLoading}" Content="Loading..." />
</Grid>
</UserControl>
...@@ -17,15 +17,15 @@ using VIZ.Framework.Core; ...@@ -17,15 +17,15 @@ using VIZ.Framework.Core;
namespace VIZ.Package.Module namespace VIZ.Package.Module
{ {
/// <summary> /// <summary>
/// DebugView.xaml 的交互逻辑 /// PageTemplateView.xaml 的交互逻辑
/// </summary> /// </summary>
public partial class DebugView : UserControl public partial class PageTemplateView : UserControl
{ {
public DebugView() public PageTemplateView()
{ {
InitializeComponent(); InitializeComponent();
WPFHelper.BindingViewModel(this, new DebugViewModel()); WPFHelper.BindingViewModel(this, new PageTemplateViewModel());
} }
} }
} }
using DevExpress.Xpf.Core;
using log4net;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.Package.Domain;
using VIZ.Package.Service;
using VIZ.Package.Storage;
namespace VIZ.Package.Module
{
/// <summary>
/// 页模板视图模型
/// </summary>
public class PageTemplateViewModel : ViewModelBase, IPageTemplateService
{
/// <summary>
/// 日志
/// </summary>
private readonly static ILog log = LogManager.GetLogger(typeof(PageTemplateViewModel));
public PageTemplateViewModel()
{
// 初始化命令
this.initCommand();
// 初始化消息
this.initMessage();
// 注册服务
ApplicationDomainEx.ServiceManager.AddService(ViewServiceKeys.PAGE_TEMPLATE_SERVICE, this);
}
/// <summary>
/// 初始化命令
/// </summary>
private void initCommand()
{
}
/// <summary>
/// 初始化消息
/// </summary>
private void initMessage()
{
ApplicationDomainEx.MessageManager.Register<ProjectOpenMessage>(this, this.OnProjectOpenMessage);
ApplicationDomainEx.MessageManager.Register<ProjectCloseMessage>(this, this.OnProjectCloseMessage);
ApplicationDomainEx.MessageManager.Register<ProjectSaveMessage>(this, this.OnProjectSaveMessage);
}
// ======================================================================================
// Field
// ======================================================================================
/// <summary>
/// GH服务
/// </summary>
private GHService ghService = new GHService();
/// <summary>
/// 页服务
/// </summary>
private PageService pageService = new PageService();
// ======================================================================================
// Property
// ======================================================================================
#region IsEnabled -- 是否可用
private bool isEnabled;
/// <summary>
/// 是否可用
/// </summary>
public bool IsEnabled
{
get { return isEnabled; }
set { isEnabled = value; this.RaisePropertyChanged(nameof(IsEnabled)); }
}
#endregion
#region IsLoading -- 是否正在加载
private bool isLoading;
/// <summary>
/// 是否正在加载
/// </summary>
public bool IsLoading
{
get { return isLoading; }
set { isLoading = value; this.RaisePropertyChanged(nameof(IsLoading)); }
}
#endregion
#region SceneTemplateModels -- 场景模板模型集合
private ObservableCollection<PageTemplateModel> sceneTemplateModels;
/// <summary>
/// 场景模板集合
/// </summary>
public ObservableCollection<PageTemplateModel> SceneTemplateModels
{
get { return sceneTemplateModels; }
set { sceneTemplateModels = value; this.RaisePropertyChanged(nameof(SceneTemplateModels)); }
}
#endregion
#region SelectedSceneTemplateModel -- 当前选中的场景模板模型
private PageTemplateModel selectedSceneTemplateModel;
/// <summary>
/// 当前选中的场景模板模型
/// </summary>
public PageTemplateModel SelectedSceneTemplateModel
{
get { return selectedSceneTemplateModel; }
set { selectedSceneTemplateModel = value; this.RaisePropertyChanged(nameof(SelectedSceneTemplateModel)); }
}
#endregion
#region OtherTemplateModels -- 其他模板模型集合
private ObservableCollection<PageTemplateModel> otherTemplateModels;
/// <summary>
/// 其他模板模型集合
/// </summary>
public ObservableCollection<PageTemplateModel> OtherTemplateModels
{
get { return otherTemplateModels; }
set { otherTemplateModels = value; this.RaisePropertyChanged(nameof(OtherTemplateModels)); }
}
#endregion
#region SelectedOtherTemplateModel -- 当前选中的其他模板模型
private PageTemplateModel selectedOtherTemplateModel;
/// <summary>
/// 当前选中的其他模板模型
/// </summary>
public PageTemplateModel SelectedOtherTemplateModel
{
get { return selectedOtherTemplateModel; }
set { selectedOtherTemplateModel = value; this.RaisePropertyChanged(nameof(SelectedOtherTemplateModel)); }
}
#endregion
// ======================================================================================
// Command
// ======================================================================================
// ======================================================================================
// Message
// ======================================================================================
/// <summary>
/// 项目打开消息
/// </summary>
/// <param name="msg">消息</param>
private void OnProjectOpenMessage(ProjectOpenMessage msg)
{
this.IsEnabled = true;
this.SceneTemplateModels = null;
this.IsLoading = true;
ThreadHelper.SafeRun(() =>
{
// 场景模板
var sceneTemplateModels = this.pageService.LoadPageTemplates().ToObservableCollection();
// 其他模板
var otherTemplateModels = new ObservableCollection<PageTemplateModel>();
// 命令模板
PageTemplateModel cmd = new PageTemplateModel();
cmd.PageType = PageType.Command;
cmd.Remark = "命令模板";
cmd.EngineType = EngineType.VIZ;
cmd.ThumbnailBitmap = VIZ.Package.Module.Resource.Properties.Resources.cmd_template;
otherTemplateModels.Add(cmd);
// 更新界面
WPFHelper.BeginInvoke(() =>
{
this.SceneTemplateModels = sceneTemplateModels;
this.OtherTemplateModels = otherTemplateModels;
this.IsLoading = false;
});
// 获取场景模板缩略图
foreach (var model in sceneTemplateModels)
{
var bitmap = ghService.GetImage(model.ThumbnailUri);
WPFHelper.BeginInvoke(() =>
{
model.ThumbnailBitmap = bitmap;
});
}
});
}
/// <summary>
/// 项目关闭消息
/// </summary>
/// <param name="msg">消息</param>
private void OnProjectCloseMessage(ProjectCloseMessage msg)
{
this.IsEnabled = false;
this.IsLoading = false;
this.SceneTemplateModels = null;
}
/// <summary>
/// 项目保存消息
/// </summary>
/// <param name="msg">消息</param>
private void OnProjectSaveMessage(ProjectSaveMessage msg)
{
this.IsLoading = true;
Task.Run(() =>
{
try
{
this.pageService.SavePageTemplates(this.SceneTemplateModels);
}
catch (Exception ex)
{
log.Error(ex);
}
WPFHelper.BeginInvoke(() =>
{
this.IsLoading = false;
});
});
}
// ======================================================================================
// Public Function
// ======================================================================================
/// <summary>
/// 添加场景模板
/// </summary>
/// <param name="fileModel">文件模型</param>
public void AddSceneTemplate(GHResourceFileModel fileModel)
{
// 如果场景中已经拥有该模板,那么不处理
if (this.SceneTemplateModels.Any(p => p.Scene == fileModel.Name))
return;
PageTemplateModel model = new PageTemplateModel();
model.TemplateID = Guid.NewGuid();
model.Scene = fileModel.Name;
model.ScenePath = fileModel.Path;
model.Layer = VizLayer.MAIN_LAYER;
model.PageType = PageType.Scene;
model.EngineType = EngineType.VIZ;
model.ThumbnailUri = fileModel.Thumbnail;
model.ThumbnailBitmap = fileModel.ThumbnailBitmap;
// 获取缩略图
if (model.ThumbnailBitmap == null)
{
ThreadHelper.SafeRun(() =>
{
var bitmap = this.ghService.GetImage(model.ThumbnailUri);
WPFHelper.BeginInvoke(() =>
{
model.ThumbnailBitmap = bitmap;
});
});
}
this.SceneTemplateModels.Add(model);
}
}
}
\ No newline at end of file
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
<local:GHResourcePanel.FileContextMenu> <local:GHResourcePanel.FileContextMenu>
<ContextMenu> <ContextMenu>
<MenuItem Header="刷新" Command="{Binding Path=PlacementTarget.DataContext.RefreshFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/> <MenuItem Header="刷新" Command="{Binding Path=PlacementTarget.DataContext.RefreshFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<Separator/>
<MenuItem Header="添加场景模板" Command="{Binding Path=PlacementTarget.DataContext.AddSceneTemplateCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
</ContextMenu> </ContextMenu>
</local:GHResourcePanel.FileContextMenu> </local:GHResourcePanel.FileContextMenu>
</local:GHResourcePanel> </local:GHResourcePanel>
......
...@@ -3,6 +3,7 @@ using System.Collections.Generic; ...@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.Package.Domain; using VIZ.Package.Domain;
namespace VIZ.Package.Module namespace VIZ.Package.Module
...@@ -15,8 +16,45 @@ namespace VIZ.Package.Module ...@@ -15,8 +16,45 @@ namespace VIZ.Package.Module
public GHSceneViewModel() public GHSceneViewModel()
{ {
this.FilterResourceFileType = ResourceFileType.SCENE; this.FilterResourceFileType = ResourceFileType.SCENE;
// 初始化命令
this.InitCommand();
}
/// <summary>
/// 初始化命令
/// </summary>
private void InitCommand()
{
this.AddSceneTemplateCommand = new VCommand(this.AddSceneTemplate);
} }
// ===========================================================================
// Command
// ===========================================================================
#region AddSceneTemplateCommand -- 添加场景模板命令
/// <summary>
/// 添加场景模板命令
/// </summary>
public VCommand AddSceneTemplateCommand { get; set; }
/// <summary>
/// 添加场景模板
/// </summary>
private void AddSceneTemplate()
{
if (this.SelectedFileModel == null)
return;
IPageTemplateService service = ApplicationDomainEx.ServiceManager.GetService<IPageTemplateService>(ViewServiceKeys.PAGE_TEMPLATE_SERVICE);
if (service == null)
return;
service.AddSceneTemplate(this.SelectedFileModel);
}
#endregion
} }
} }
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Web" /> <Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
...@@ -86,13 +87,17 @@ ...@@ -86,13 +87,17 @@
<Reference Include="WindowsFormsIntegration" /> <Reference Include="WindowsFormsIntegration" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Debug\View\DebugView.xaml.cs">
<DependentUpon>DebugView.xaml</DependentUpon>
</Compile>
<Compile Include="Debug\ViewModel\DebugViewModel.cs" /> <Compile Include="Debug\ViewModel\DebugViewModel.cs" />
<Compile Include="Debug\View\DebugWindow.xaml.cs"> <Compile Include="Debug\View\DebugWindow.xaml.cs">
<DependentUpon>DebugWindow.xaml</DependentUpon> <DependentUpon>DebugWindow.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Main\ViewModel\MainTopViewModel.cs" />
<Compile Include="Page\Templage\PageTemplatePluginLifeCycle.cs" />
<Compile Include="Page\Templage\Service\IPageTemplateService.cs" />
<Compile Include="Page\Templage\ViewModel\PageTemplateViewModel.cs" />
<Compile Include="Page\Templage\View\PageTemplateView.xaml.cs">
<DependentUpon>PageTemplateView.xaml</DependentUpon>
</Compile>
<Compile Include="Resource\GHResource\GHScenePluginLifeCycle.cs" /> <Compile Include="Resource\GHResource\GHScenePluginLifeCycle.cs" />
<Compile Include="Resource\GHResource\ViewModel\GHSceneViewModel.cs" /> <Compile Include="Resource\GHResource\ViewModel\GHSceneViewModel.cs" />
<Compile Include="Resource\GHResource\View\GHSceneView.xaml.cs"> <Compile Include="Resource\GHResource\View\GHSceneView.xaml.cs">
...@@ -155,13 +160,15 @@ ...@@ -155,13 +160,15 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Main\Controller\" /> <Folder Include="Main\Controller\" />
<Folder Include="Page\Group\ViewModel\" />
<Folder Include="Page\Group\View\" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Page Include="Debug\View\DebugView.xaml"> <Page Include="Debug\View\DebugWindow.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Debug\View\DebugWindow.xaml"> <Page Include="Page\Templage\View\PageTemplateView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
......
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Package.Domain;
using VIZ.Package.Storage;
namespace VIZ.Package.Service
{
/// <summary>
/// 页服务
/// </summary>
public class PageService
{
/// <summary>
/// 加载页模板集合
/// </summary>
/// <returns>节目模板集合</returns>
public IList<PageTemplateModel> LoadPageTemplates()
{
List<PageTemplateModel> list = new List<PageTemplateModel>();
foreach (var entity in ApplicationDomainEx.ProjectDbContext.PageTemplate.FindAll())
{
PageTemplateModel model = new PageTemplateModel();
model.Scene = entity.Scene;
model.ScenePath = entity.ScenePath;
model.ThumbnailUri = entity.ThumbnailUri;
model.Remark = entity.Remark;
model.Layer = (VizLayer)Enum.Parse(typeof(VizLayer), entity.Layer);
model.EngineType = entity.EngineType;
model.PageType = entity.PageType;
model.Order = entity.Order;
model.TemplateID = entity.TemplateID;
list.Add(model);
}
return list.OrderBy(p => p.Order).ToList();
}
/// <summary>
/// 保存页模板
/// </summary>
/// <param name="pageTemplates">页模板</param>
public void SavePageTemplates(IList<PageTemplateModel> pageTemplates)
{
ApplicationDomainEx.ProjectDbContext.PageTemplate.DeleteAll();
List<PageTemplateEntity> list = new List<PageTemplateEntity>();
for (int i = 0; i < pageTemplates.Count; i++)
{
PageTemplateModel model = pageTemplates[i];
PageTemplateEntity entity = new PageTemplateEntity();
entity.Scene = model.Scene;
entity.ScenePath = model.ScenePath;
entity.ThumbnailUri = model.ThumbnailUri;
entity.Remark = model.Remark;
entity.Layer = model.Layer.ToString();
entity.EngineType = model.EngineType;
entity.PageType = model.PageType;
entity.Order = model.Order;
entity.TemplateID = model.TemplateID;
entity.Order = i;
list.Add(entity);
}
ApplicationDomainEx.ProjectDbContext.PageTemplate.Insert(list);
}
}
}
...@@ -49,6 +49,9 @@ ...@@ -49,6 +49,9 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="LiteDB, Version=5.0.15.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
<HintPath>..\packages\LiteDB.5.0.15\lib\net45\LiteDB.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=2.0.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.14\lib\net45\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.14\lib\net45\log4net.dll</HintPath>
</Reference> </Reference>
...@@ -65,6 +68,7 @@ ...@@ -65,6 +68,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="DB\Page\PageService.cs" />
<Compile Include="Logic\Plugin\PluginService.cs" /> <Compile Include="Logic\Plugin\PluginService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Viz\GHResourceService.cs" /> <Compile Include="Viz\GHResourceService.cs" />
...@@ -74,9 +78,7 @@ ...@@ -74,9 +78,7 @@
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup />
<Folder Include="DB\" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\VIZ.Framework\VIZ.Framework.Core\VIZ.Framework.Core.csproj"> <ProjectReference Include="..\..\VIZ.Framework\VIZ.Framework.Core\VIZ.Framework.Core.csproj">
<Project>{75b39591-4bc3-4b09-bd7d-ec9f67efa96e}</Project> <Project>{75b39591-4bc3-4b09-bd7d-ec9f67efa96e}</Project>
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="LiteDB" version="5.0.15" targetFramework="net48" />
<package id="log4net" version="2.0.14" targetFramework="net48" /> <package id="log4net" version="2.0.14" targetFramework="net48" />
</packages> </packages>
\ No newline at end of file
...@@ -48,5 +48,15 @@ namespace VIZ.Package.Storage ...@@ -48,5 +48,15 @@ namespace VIZ.Package.Storage
/// 引擎类型 /// 引擎类型
/// </summary> /// </summary>
public EngineType EngineType { get; set; } public EngineType EngineType { get; set; }
/// <summary>
/// 页类型
/// </summary>
public PageType PageType { get; set; }
/// <summary>
/// 排序索引
/// </summary>
public int Order { get; set; }
} }
} }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Storage
{
/// <summary>
/// 页类型
/// </summary>
public enum PageType
{
/// <summary>
/// 场景
/// </summary>
Scene,
/// <summary>
/// 命令
/// </summary>
Command
}
}
using LiteDB;
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Storage
{
/// <summary>
/// 项目数据上下文
/// </summary>
public class ProjectDbContext
{
/// <summary>
/// 日志
/// </summary>
private static ILog log = LogManager.GetLogger(typeof(ProjectDbContext));
/// <summary>
/// 数据库
/// </summary>
private ILiteDatabase Database;
/// <summary>
/// LiteDB数据库
/// </summary>
/// <param name="path">数据库路径</param>
public ProjectDbContext(string path)
{
this.Path = path;
this.Database = new LiteDatabase(path);
this.PageTemplate = this.Database.GetCollection<PageTemplateEntity>();
}
/// <summary>
/// 数据库文件路径
/// </summary>
public string Path { get; private set; }
/// <summary>
/// 页模板
/// </summary>
public ILiteCollection<PageTemplateEntity> PageTemplate { get; private set; }
/// <summary>
/// 销毁
/// </summary>
public void Dispose()
{
this.PageTemplate = null;
this.Database?.Dispose();
}
}
}
\ No newline at end of file
...@@ -76,8 +76,10 @@ ...@@ -76,8 +76,10 @@
<Compile Include="Entity\Config\VizConfigEntity.cs" /> <Compile Include="Entity\Config\VizConfigEntity.cs" />
<Compile Include="Enum\EngineFullType.cs" /> <Compile Include="Enum\EngineFullType.cs" />
<Compile Include="Enum\EngineType.cs" /> <Compile Include="Enum\EngineType.cs" />
<Compile Include="Enum\PageType.cs" />
<Compile Include="Enum\VizLayer.cs" /> <Compile Include="Enum\VizLayer.cs" />
<Compile Include="LocalDbContext.cs" /> <Compile Include="LocalDbContext.cs" />
<Compile Include="ProjectDbContext.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Xml\ControlObject\Node\ControlObject_Element_Node.cs" /> <Compile Include="Xml\ControlObject\Node\ControlObject_Element_Node.cs" />
<Compile Include="Xml\ControlObject\Node\ControlObject_Entry_Node.cs" /> <Compile Include="Xml\ControlObject\Node\ControlObject_Entry_Node.cs" />
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:module="clr-namespace:VIZ.Package.Module;assembly=VIZ.Package.Module" xmlns:module="clr-namespace:VIZ.Package.Module;assembly=VIZ.Package.Module"
Title="咪咕播控系统" Height="1000" Width="1600" Title="咪咕播控系统" Height="1000" Width="1600" ShowTitle="False"
WindowStartupLocation="CenterScreen" WindowState="Maximized"> WindowStartupLocation="CenterScreen" WindowState="Maximized">
<dx:ThemedWindow.ToolbarItems> <dx:ThemedWindow.ToolbarItems>
<!-- 主视图顶部 --> <!-- 主视图顶部 -->
......
...@@ -12,6 +12,7 @@ using System.Windows.Media; ...@@ -12,6 +12,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Shapes; using System.Windows.Shapes;
using VIZ.Framework.Module; using VIZ.Framework.Module;
using VIZ.Package.Domain;
namespace VIZ.Package namespace VIZ.Package
{ {
......
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