Commit 75314c3c by liulongfei

1. 节目单分组

2. 节目单创建等
parent bdd79e2e
...@@ -30,5 +30,10 @@ namespace VIZ.Package.Domain ...@@ -30,5 +30,10 @@ namespace VIZ.Package.Domain
/// 页模板 /// 页模板
/// </summary> /// </summary>
public const string PAGE_TEMPLATE = "PAGE_TEMPLATE"; public const string PAGE_TEMPLATE = "PAGE_TEMPLATE";
/// <summary>
/// 页分组
/// </summary>
public const string PAGE_GROUP = "PAGE_GROUP";
} }
} }
...@@ -41,9 +41,23 @@ namespace VIZ.Package.Domain ...@@ -41,9 +41,23 @@ namespace VIZ.Package.Domain
#endregion #endregion
#region Order -- 排序
private int order;
/// <summary>
/// 排序
/// </summary>
public int Order
{
get { return order; }
set { order = value; this.RaisePropertyChanged(nameof(Order)); }
}
#endregion
#region Pages -- 页集合 #region Pages -- 页集合
private ObservableCollection<PageModel> pages; private ObservableCollection<PageModel> pages = new ObservableCollection<PageModel>();
/// <summary> /// <summary>
/// 页集合 /// 页集合
/// </summary> /// </summary>
......
...@@ -94,6 +94,7 @@ namespace VIZ.Package.Module ...@@ -94,6 +94,7 @@ namespace VIZ.Package.Module
/// </summary> /// </summary>
private void CreateProject() private void CreateProject()
{ {
// 保存之前的项目
if (ApplicationDomainEx.ProjectDbContext != null) if (ApplicationDomainEx.ProjectDbContext != null)
{ {
var result = DXMessageBox.Show("是否保存当前项目", "提示", System.Windows.MessageBoxButton.YesNo); var result = DXMessageBox.Show("是否保存当前项目", "提示", System.Windows.MessageBoxButton.YesNo);
...@@ -104,6 +105,7 @@ namespace VIZ.Package.Module ...@@ -104,6 +105,7 @@ namespace VIZ.Package.Module
} }
} }
// 创建项目文件
SaveFileDialog sfd = new SaveFileDialog(); SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "viz_pkg files(*.viz_pkg)|*.viz_pkg"; sfd.Filter = "viz_pkg files(*.viz_pkg)|*.viz_pkg";
if (sfd.ShowDialog() != DialogResult.OK) if (sfd.ShowDialog() != DialogResult.OK)
...@@ -112,6 +114,13 @@ namespace VIZ.Package.Module ...@@ -112,6 +114,13 @@ namespace VIZ.Package.Module
this.ProjectName = System.IO.Path.GetFileNameWithoutExtension(sfd.FileName); this.ProjectName = System.IO.Path.GetFileNameWithoutExtension(sfd.FileName);
ApplicationDomainEx.ProjectDbContext = new ProjectDbContext(sfd.FileName); ApplicationDomainEx.ProjectDbContext = new ProjectDbContext(sfd.FileName);
// 为项目添加默认页分组
PageGroupEntity defaultGroup = new PageGroupEntity();
defaultGroup.GroupID = Guid.NewGuid();
defaultGroup.GroupName = "默认分组";
ApplicationDomainEx.ProjectDbContext.PageGroup.Insert(defaultGroup);
// 发送项目打开消息
ProjectOpenMessage msg = new ProjectOpenMessage(); ProjectOpenMessage msg = new ProjectOpenMessage();
ApplicationDomainEx.MessageManager.Send(msg); ApplicationDomainEx.MessageManager.Send(msg);
......
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 PageGroupPluginLifeCycle : IPluginLifeCycle
{
/// <summary>
/// 插件ID
/// </summary>
/// <remarks>
/// 插件ID不能包含点号
/// </remarks>
public const string PLUGIN_ID = ModulePluginIds.PAGE_GROUP;
/// <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(PageGroupView);
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 IPageGroupService : IService
{
/// <summary>
/// 添加页
/// </summary>
/// <param name="template">模板</param>
void AddPage(PageTemplateModel template);
}
}
<dx:ThemedWindow x:Class="VIZ.Package.Module.PageAddWindow"
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:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:fcore="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core"
xmlns:domain="clr-namespace:VIZ.Package.Domain;assembly=VIZ.Package.Domain"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VIZ.Package.Module"
d:DataContext="{d:DesignInstance Type=local:PageAddViewModel}"
mc:Ignorable="d" WindowStartupLocation="CenterScreen"
Title="PageAddWindow" Height="800" Width="1000">
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="Loaded" Command="{Binding Path=LoadedCommand}"></dxmvvm:EventToCommand>
</dxmvvm:Interaction.Behaviors>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
</Grid.RowDefinitions>
<!-- 场景 -->
<TextBlock Text="场景:" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,10,0"></TextBlock>
<dxe:TextEdit Grid.Column="1" Height="30" IsReadOnly="True"
EditValue="{Binding Path=Scene}"></dxe:TextEdit>
<!-- 备注 -->
<TextBlock Text="备注:" Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,10,0"></TextBlock>
<dxe:TextEdit Grid.Row="1" Grid.Column="1" Height="30"
EditValue="{Binding Path=Remark,Mode=TwoWay}"></dxe:TextEdit>
<!-- 层 -->
<TextBlock Text="层:" Grid.Row="2" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,10,0"></TextBlock>
<dxe:ComboBoxEdit Grid.Row="2" Grid.Column="1" Height="30" IsTextEditable="False"
ItemsSource="{Binding Source={x:Static domain:ApplicationConstants.VIZ_LAYERS}}"
SelectedItem="{Binding Path=Layer,Mode=TwoWay}"></dxe:ComboBoxEdit>
<!-- 插件 -->
<TextBlock Text="插件:" Grid.Row="3" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,10,0"></TextBlock>
<dxe:ComboBoxEdit Grid.Row="3" Grid.Column="1" Height="30" IsTextEditable="False"
ItemsSource="{Binding Path=TemplatePlugins}" DisplayMember="DisplayName"
SelectedItem="{Binding Path=SelectedTemplatePlugin,Mode=TwoWay}"></dxe:ComboBoxEdit>
<!-- 按钮组 -->
<StackPanel Grid.Row="4" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal">
<Button Width="80" Height="30" Content="確定" Margin="10" Command="{Binding Path=EnterCommand}"></Button>
<Button Width="80" Height="30" Content="取消" Margin="10" Command="{Binding Path=CancelCommand}"></Button>
</StackPanel>
</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 PageAddWindow.xaml
/// </summary>
public partial class PageAddWindow : ThemedWindow
{
public PageAddWindow()
{
InitializeComponent();
WPFHelper.BindingViewModel(this, new PageAddViewModel());
}
}
}
<dx:ThemedWindow x:Class="VIZ.Package.Module.PageGroupRenameWindow"
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:fcore="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VIZ.Package.Module"
d:DataContext="{d:DesignInstance Type=local:PageGroupRenameViewModel}"
mc:Ignorable="d" WindowStartupLocation="CenterScreen"
Title="节目单命名" Height="100" Width="400">
<dx:ThemedWindow.Resources>
<fcore:StringNotNull2BoolConverter x:Key="StringNotNull2BoolConverter"></fcore:StringNotNull2BoolConverter>
</dx:ThemedWindow.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="节目单名称:"
VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0"></TextBlock>
<TextBox Grid.Column="1" Height="30" VerticalAlignment="Center" Margin="0,0,10,0"
TextWrapping="NoWrap" AcceptsReturn="False" Padding="3" VerticalContentAlignment="Center"
Text="{Binding Path=PageGroupName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"></TextBox>
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right">
<Button Content="确定" Width="80" Height="30" Margin="10" Command="{Binding EnterCommand}"
IsEnabled="{Binding Path=PageGroupName,Converter={StaticResource StringNotNull2BoolConverter},Mode=OneWay}"></Button>
<Button Content="取消" Width="80" Height="30" Margin="10" Command="{Binding CancelCommand}"></Button>
</StackPanel>
</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 PageGroupRenameWindow.xaml
/// </summary>
public partial class PageGroupRenameWindow : ThemedWindow
{
public PageGroupRenameWindow()
{
InitializeComponent();
WPFHelper.BindingViewModel(this, new PageGroupRenameViewModel());
}
}
}
<UserControl x:Class="VIZ.Package.Module.PageGroupView"
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:PageGroupViewModel}"
x:Name="uc"
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 IsEnabled}">
<dx:DXTabControl Grid.Row="1" Margin="0,10,0,0"
ItemsSource="{Binding Path=PageGroupModels}"
SelectedItem="{Binding Path=SelectedPageGroupModel,Mode=TwoWay}">
<dx:DXTabControl.ContextMenu>
<ContextMenu>
<MenuItem Header="新建分组" Command="{Binding Path=PlacementTarget.DataContext.AddGroupCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="重命名分组" Command="{Binding Path=PlacementTarget.DataContext.RenameGroupCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<Separator></Separator>
<MenuItem Header="删除分组" Command="{Binding Path=PlacementTarget.DataContext.DeleteGroupCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="删除节目单项" Command="{Binding Path=PlacementTarget.DataContext.DeleteItemCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
</ContextMenu>
</dx:DXTabControl.ContextMenu>
<dx:DXTabControl.View>
<dx:TabControlStretchView Tag="Stretch"
HeaderLocation="Top"
NewButtonShowMode="InTabPanel"
HideButtonShowMode="InAllTabs"
PinnedTabSize="100">
</dx:TabControlStretchView>
</dx:DXTabControl.View>
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="TabAdding" Command="{Binding TabAddGroupCommand}" PassEventArgsToCommand="True" />
</dxmvvm:Interaction.Behaviors>
<dx:DXTabControl.ItemContainerStyle>
<Style TargetType="dx:DXTabItem">
<Setter Property="Content" Value="{Binding .}" />
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<dxg:GridControl ItemsSource="{Binding Pages}" ShowBorder="False" IsFilterEnabled="False"
SelectedItem="{Binding ElementName=uc, Path=DataContext.SelectedPageModel,Mode=TwoWay}">
<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 Width="120" Source="{Binding Path=Row.ThumbnailBitmap,Converter={StaticResource Bitmap2ImageSourceConverter}}"></Image>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
<dxg:GridColumn Header="场景名" FieldName="Scene" 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:GridColumn Header="模板类型" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False"
Binding="{Binding Path=TemplateType,Converter={StaticResource Enum2EnumDescriptionConverter}}">
</dxg:GridColumn>
<dxg:GridColumn Header="插件" FieldName="PluginName" 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"
ShowFilterPanelMode="Never"
ShowBandsPanel="False"
ShowTotalSummary="False"
ShowFixedTotalSummary="False"
ShowDragDropHint="False"
ShowTargetInfoInDragDropHint="False">
</dxg:TableView>
</dxg:GridControl.View>
</dxg:GridControl>
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="Header" Value="{Binding GroupName}" />
<Setter Property="dx:TabControlStretchView.PinMode" Value="Left" />
</Style>
</dx:DXTabControl.ItemContainerStyle>
</dx:DXTabControl>
<dx:WaitIndicator DeferedVisibility="{Binding IsLoading}" Content="Loading..." Grid.Row="1" />
</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>
/// PageGroupView.xaml 的交互逻辑
/// </summary>
public partial class PageGroupView : UserControl
{
public PageGroupView()
{
InitializeComponent();
WPFHelper.BindingViewModel(this, new PageGroupViewModel());
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using VIZ.Framework.Core;
using VIZ.Package.Domain;
using VIZ.Package.Plugin;
using VIZ.Package.Storage;
namespace VIZ.Package.Module
{
/// <summary>
/// 页添加视图模型
/// </summary>
public class PageAddViewModel : ViewModelBase
{
public PageAddViewModel()
{
// 初始化命令
this.initCommand();
}
/// <summary>
/// 初始化命令
/// </summary>
private void initCommand()
{
this.LoadedCommand = new VCommand(this.Loaded);
this.EnterCommand = new VCommand(this.Enter);
this.CancelCommand = new VCommand(this.Cancel);
}
// ===========================================================
// Property
// ===========================================================
#region Scene -- 场景
private string scene;
/// <summary>
/// 场景
/// </summary>
public string Scene
{
get { return scene; }
set { scene = value; this.RaisePropertyChanged(nameof(Scene)); }
}
#endregion
#region Remark -- 备注
private string remark;
/// <summary>
/// 备注
/// </summary>
public string Remark
{
get { return remark; }
set { remark = value; this.RaisePropertyChanged(nameof(Remark)); }
}
#endregion
#region Layer --
private VizLayer layer;
/// <summary>
/// 层
/// </summary>
public VizLayer Layer
{
get { return layer; }
set { layer = value; this.RaisePropertyChanged(nameof(Layer)); }
}
#endregion
#region TemplatePlugins -- 模板插件集合
private List<PluginInfo> templatePlugins;
/// <summary>
/// 模板插件集合
/// </summary>
public List<PluginInfo> TemplatePlugins
{
get { return templatePlugins; }
set { templatePlugins = value; this.RaisePropertyChanged(nameof(TemplatePlugins)); }
}
#endregion
#region SelectedTemplatePlugin -- 选中的模板插件
private PluginInfo selectedTemplatePlugin;
/// <summary>
/// 选中的模板插件
/// </summary>
public PluginInfo SelectedTemplatePlugin
{
get { return selectedTemplatePlugin; }
set { selectedTemplatePlugin = value; this.RaisePropertyChanged(nameof(SelectedTemplatePlugin)); }
}
#endregion
// ===========================================================
// Command
// ===========================================================
#region LoadedCommand -- 加载命令
/// <summary>
/// 加载命令
/// </summary>
public VCommand LoadedCommand { get; set; }
/// <summary>
/// 加载
/// </summary>
private void Loaded()
{
this.TemplatePlugins = ApplicationDomainEx.PluginInfos.Where(p => p.PluginType == PluginType.Pages).ToList();
// TODO: 选择默认模板
}
#endregion
#region EnterCommand -- 确定命令
/// <summary>
/// 确定命令
/// </summary>
public VCommand EnterCommand { get; set; }
/// <summary>
/// 确定
/// </summary>
private void Enter()
{
Window window = this.GetWindow();
if (window == null)
return;
window.DialogResult = true;
window.Close();
}
#endregion
#region CancelCommand -- 取消命令
/// <summary>
/// 取消命令
/// </summary>
public VCommand CancelCommand { get; set; }
/// <summary>
/// 取消
/// </summary>
private void Cancel()
{
Window window = this.GetWindow();
if (window == null)
return;
window.DialogResult = false;
window.Close();
}
#endregion
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using VIZ.Framework.Core;
namespace VIZ.Package.Module
{
/// <summary>
/// 页分组命名视图模型
/// </summary>
public class PageGroupRenameViewModel : ViewModelBase
{
public PageGroupRenameViewModel()
{
// 初始化命令
this.InitCommand();
}
/// <summary>
/// 初始化命令
/// </summary>
private void InitCommand()
{
this.EnterCommand = new VCommand(this.Enter);
this.CancelCommand = new VCommand(this.Cancel);
}
// ======================================================================================
// Property
// ======================================================================================
#region PageGroupName -- 页分组名称
private string pageGroupName;
/// <summary>
/// 页分组名称
/// </summary>
public string PageGroupName
{
get { return pageGroupName; }
set { pageGroupName = value; this.RaisePropertyChanged(nameof(PageGroupName)); }
}
#endregion
// ======================================================================================
// Command
// ======================================================================================
#region EnterCommand -- 确定命令
/// <summary>
/// 确定命令
/// </summary>
public VCommand EnterCommand { get; set; }
/// <summary>
/// 确定
/// </summary>
private void Enter()
{
Window window = this.GetWindow();
window.DialogResult = true;
window.Close();
}
#endregion
#region CancelCommand -- 取消命令
/// <summary>
/// 取消命令
/// </summary>
public VCommand CancelCommand { get; set; }
/// <summary>
/// 取消
/// </summary>
private void Cancel()
{
Window window = this.GetWindow();
window.DialogResult = false;
window.Close();
}
#endregion
}
}
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
SelectedItem="{Binding Path=SelectedSceneTemplateModel,Mode=TwoWay}"> SelectedItem="{Binding Path=SelectedSceneTemplateModel,Mode=TwoWay}">
<dxg:GridControl.ContextMenu> <dxg:GridControl.ContextMenu>
<ContextMenu> <ContextMenu>
<MenuItem Header="添加至节目单" Command="{Binding Path=PlacementTarget.DataContext.SceneTemplateAddToListCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/> <MenuItem Header="添加至节目单" Command="{Binding Path=PlacementTarget.DataContext.SceneTemplateAddToPageGroupCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="更新模板" Command="{Binding Path=PlacementTarget.DataContext.SceneTemplateUpdateCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/> <MenuItem Header="更新模板" Command="{Binding Path=PlacementTarget.DataContext.SceneTemplateUpdateCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<Separator></Separator> <Separator></Separator>
<MenuItem Header="删除模板" Command="{Binding Path=PlacementTarget.DataContext.SceneTemplateDeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/> <MenuItem Header="删除模板" Command="{Binding Path=PlacementTarget.DataContext.SceneTemplateDeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
</DataTemplate> </DataTemplate>
</dxg:GridColumn.CellTemplate> </dxg:GridColumn.CellTemplate>
</dxg:GridColumn> </dxg:GridColumn>
<dxg:GridColumn Header="场景名" FieldName="SceneName" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False"></dxg:GridColumn> <dxg:GridColumn Header="场景名" FieldName="Scene" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False"></dxg:GridColumn>
<dxg:GridColumn Header="备注" FieldName="Remark" AllowSorting="False" AllowColumnFiltering="False"> <dxg:GridColumn Header="备注" FieldName="Remark" AllowSorting="False" AllowColumnFiltering="False">
<dxg:GridColumn.EditSettings> <dxg:GridColumn.EditSettings>
<dxe:TextEditSettings TextWrapping="Wrap" TextTrimming="CharacterEllipsis" MaxLength="50"></dxe:TextEditSettings> <dxe:TextEditSettings TextWrapping="Wrap" TextTrimming="CharacterEllipsis" MaxLength="50"></dxe:TextEditSettings>
......
...@@ -40,7 +40,7 @@ namespace VIZ.Package.Module ...@@ -40,7 +40,7 @@ namespace VIZ.Package.Module
/// </summary> /// </summary>
private void initCommand() private void initCommand()
{ {
this.SceneTemplateAddToPageGroupCommand = new VCommand(this.SceneTemplateAddToPageGroup);
} }
...@@ -160,6 +160,30 @@ namespace VIZ.Package.Module ...@@ -160,6 +160,30 @@ namespace VIZ.Package.Module
// Command // Command
// ====================================================================================== // ======================================================================================
#region SceneTemplateAddToPageGroupCommand -- 场景模板添加至页分组命令
/// <summary>
/// 场景模板添加至页分组命令
/// </summary>
public VCommand SceneTemplateAddToPageGroupCommand { get; set; }
/// <summary>
/// 场景模板添加至页分组
/// </summary>
private void SceneTemplateAddToPageGroup()
{
if (this.SelectedSceneTemplateModel == null)
return;
IPageGroupService service = ApplicationDomainEx.ServiceManager.GetService<IPageGroupService>(ViewServiceKeys.PAGE_GROUP_SERVICE);
if (service == null)
return;
service.AddPage(this.SelectedSceneTemplateModel);
}
#endregion
// ====================================================================================== // ======================================================================================
// Message // Message
// ====================================================================================== // ======================================================================================
...@@ -172,6 +196,8 @@ namespace VIZ.Package.Module ...@@ -172,6 +196,8 @@ namespace VIZ.Package.Module
{ {
this.IsEnabled = true; this.IsEnabled = true;
this.SceneTemplateModels = null; this.SceneTemplateModels = null;
this.SelectedSceneTemplateModel = null;
this.SelectedOtherTemplateModel = null;
this.IsLoading = true; this.IsLoading = true;
ThreadHelper.SafeRun(() => ThreadHelper.SafeRun(() =>
...@@ -221,6 +247,8 @@ namespace VIZ.Package.Module ...@@ -221,6 +247,8 @@ namespace VIZ.Package.Module
this.IsEnabled = false; this.IsEnabled = false;
this.IsLoading = false; this.IsLoading = false;
this.SceneTemplateModels = null; this.SceneTemplateModels = null;
this.SelectedSceneTemplateModel = null;
this.SelectedOtherTemplateModel = null;
} }
/// <summary> /// <summary>
......
...@@ -92,6 +92,20 @@ ...@@ -92,6 +92,20 @@
<DependentUpon>DebugWindow.xaml</DependentUpon> <DependentUpon>DebugWindow.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Main\ViewModel\MainTopViewModel.cs" /> <Compile Include="Main\ViewModel\MainTopViewModel.cs" />
<Compile Include="Page\Group\ViewModel\PageAddViewModel.cs" />
<Compile Include="Page\Group\View\PageAddWindow.xaml.cs">
<DependentUpon>PageAddWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Page\Group\PageGroupPluginLifeCycle.cs" />
<Compile Include="Page\Group\Service\IPageGroupService.cs" />
<Compile Include="Page\Group\ViewModel\PageGroupRenameViewModel.cs" />
<Compile Include="Page\Group\View\PageGroupRenameWindow.xaml.cs">
<DependentUpon>PageGroupRenameWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Page\Group\ViewModel\PageGroupViewModel.cs" />
<Compile Include="Page\Group\View\PageGroupView.xaml.cs">
<DependentUpon>PageGroupView.xaml</DependentUpon>
</Compile>
<Compile Include="Page\Templage\PageTemplatePluginLifeCycle.cs" /> <Compile Include="Page\Templage\PageTemplatePluginLifeCycle.cs" />
<Compile Include="Page\Templage\Service\IPageTemplateService.cs" /> <Compile Include="Page\Templage\Service\IPageTemplateService.cs" />
<Compile Include="Page\Templage\ViewModel\PageTemplateViewModel.cs" /> <Compile Include="Page\Templage\ViewModel\PageTemplateViewModel.cs" />
...@@ -160,14 +174,24 @@ ...@@ -160,14 +174,24 @@
</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\DebugWindow.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="Page\Group\View\PageAddWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Page\Group\View\PageGroupRenameWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Page\Group\View\PageGroupView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Page\Templage\View\PageTemplateView.xaml"> <Page Include="Page\Templage\View\PageTemplateView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
......
...@@ -2,8 +2,11 @@ ...@@ -2,8 +2,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.Package.Domain; using VIZ.Package.Domain;
using VIZ.Package.Storage; using VIZ.Package.Storage;
...@@ -30,7 +33,7 @@ namespace VIZ.Package.Service ...@@ -30,7 +33,7 @@ namespace VIZ.Package.Service
model.ScenePath = entity.ScenePath; model.ScenePath = entity.ScenePath;
model.ThumbnailUri = entity.ThumbnailUri; model.ThumbnailUri = entity.ThumbnailUri;
model.Remark = entity.Remark; model.Remark = entity.Remark;
model.Layer = (VizLayer)Enum.Parse(typeof(VizLayer), entity.Layer); model.Layer = entity.Layer;
model.EngineType = entity.EngineType; model.EngineType = entity.EngineType;
model.PageType = entity.PageType; model.PageType = entity.PageType;
model.Order = entity.Order; model.Order = entity.Order;
...@@ -43,9 +46,9 @@ namespace VIZ.Package.Service ...@@ -43,9 +46,9 @@ namespace VIZ.Package.Service
} }
/// <summary> /// <summary>
/// 保存页模板 /// 保存页模板集合
/// </summary> /// </summary>
/// <param name="pageTemplates">页模板</param> /// <param name="pageTemplates">页模板集合</param>
public void SavePageTemplates(IList<PageTemplateModel> pageTemplates) public void SavePageTemplates(IList<PageTemplateModel> pageTemplates)
{ {
ApplicationDomainEx.ProjectDbContext.PageTemplate.DeleteAll(); ApplicationDomainEx.ProjectDbContext.PageTemplate.DeleteAll();
...@@ -61,7 +64,7 @@ namespace VIZ.Package.Service ...@@ -61,7 +64,7 @@ namespace VIZ.Package.Service
entity.ScenePath = model.ScenePath; entity.ScenePath = model.ScenePath;
entity.ThumbnailUri = model.ThumbnailUri; entity.ThumbnailUri = model.ThumbnailUri;
entity.Remark = model.Remark; entity.Remark = model.Remark;
entity.Layer = model.Layer.ToString(); entity.Layer = model.Layer;
entity.EngineType = model.EngineType; entity.EngineType = model.EngineType;
entity.PageType = model.PageType; entity.PageType = model.PageType;
entity.Order = model.Order; entity.Order = model.Order;
...@@ -74,6 +77,114 @@ namespace VIZ.Package.Service ...@@ -74,6 +77,114 @@ namespace VIZ.Package.Service
ApplicationDomainEx.ProjectDbContext.PageTemplate.Insert(list); ApplicationDomainEx.ProjectDbContext.PageTemplate.Insert(list);
} }
/// <summary>
/// 加载页分组集合
/// </summary>
/// <returns>页分组集合</returns>
public IList<PageGroupModel> LoadPageGroups()
{
Dictionary<Guid, PageGroupModel> dic = new Dictionary<Guid, PageGroupModel>();
// 页分组
foreach (var entity in ApplicationDomainEx.ProjectDbContext.PageGroup.FindAll())
{
PageGroupModel model = new PageGroupModel();
model.GroupID = entity.GroupID;
model.GroupName = entity.GroupName;
model.Order = entity.Order;
dic[model.GroupID] = model;
}
// 页
foreach (var entity in ApplicationDomainEx.ProjectDbContext.Page.FindAll())
{
if (!dic.TryGetValue(entity.PageGroupID, out PageGroupModel groupModel))
continue;
PageModel model = new PageModel();
model.Scene = entity.Scene;
model.ScenePath = entity.ScenePath;
model.ThumbnailUri = entity.ThumbnailUri;
model.Remark = entity.Remark;
model.Layer = entity.Layer;
model.EngineType = entity.EngineType;
model.PageType = entity.PageType;
model.Order = entity.Order;
model.TemplateID = entity.TemplateID;
model.PageID = entity.PageID;
model.PageGroupID = entity.PageGroupID;
model.TemplateID = entity.TemplateID;
model.PluginID = entity.PluginID;
model.Order = entity.Order;
groupModel.Pages.Add(model);
}
// 页分组排序
foreach (var kv in dic)
{
kv.Value.Pages = kv.Value.Pages.OrderBy(p => p.Order).ToObservableCollection();
}
return dic.Values.OrderBy(p => p.Order).ToList();
}
/// <summary>
/// 保存页分组集合
/// </summary>
/// <param name="pageGroups">页分组集合</param>
public void SavePageGroups(IList<PageGroupModel> pageGroups)
{
List<PageGroupEntity> groups = new List<PageGroupEntity>();
List<PageEntity> pages = new List<PageEntity>();
for (int i = 0; i < pageGroups.Count; i++)
{
PageGroupModel groupModel = pageGroups[i];
// 分组
PageGroupEntity groupEntity = new PageGroupEntity();
groupEntity.GroupID = groupModel.GroupID;
groupEntity.GroupName = groupModel.GroupName;
groupEntity.Order = i;
groups.Add(groupEntity);
// 页
for (int j = 0; j < groupModel.Pages.Count; j++)
{
PageModel pageModel = groupModel.Pages[j];
PageEntity pageEntity = new PageEntity();
pageEntity.Scene = pageModel.Scene;
pageEntity.ScenePath = pageModel.ScenePath;
pageEntity.ThumbnailUri = pageModel.ThumbnailUri;
pageEntity.Remark = pageModel.Remark;
pageEntity.Layer = pageModel.Layer;
pageEntity.EngineType = pageModel.EngineType;
pageEntity.PageType = pageModel.PageType;
pageEntity.Order = pageModel.Order;
pageEntity.TemplateID = pageModel.TemplateID;
pageEntity.PageID = pageModel.PageID;
pageEntity.PageGroupID = pageModel.PageGroupID;
pageEntity.TemplateID = pageModel.TemplateID;
pageEntity.PluginID = pageModel.PluginID;
pageEntity.Order = j;
pages.Add(pageEntity);
}
}
ApplicationDomainEx.ProjectDbContext.PageGroup.DeleteAll();
ApplicationDomainEx.ProjectDbContext.Page.DeleteAll();
ApplicationDomainEx.ProjectDbContext.PageGroup.Insert(groups);
ApplicationDomainEx.ProjectDbContext.Page.Insert(pages);
}
} }
} }
...@@ -40,9 +40,8 @@ namespace VIZ.Package.Storage ...@@ -40,9 +40,8 @@ namespace VIZ.Package.Storage
/// <summary> /// <summary>
/// 包装层 /// 包装层
/// VIZ: <see cref="VizLayer"/>
/// </summary> /// </summary>
public string Layer { get; set; } public VizLayer Layer { get; set; }
/// <summary> /// <summary>
/// 引擎类型 /// 引擎类型
......
...@@ -21,5 +21,10 @@ namespace VIZ.Package.Storage ...@@ -21,5 +21,10 @@ namespace VIZ.Package.Storage
/// 分组名称 /// 分组名称
/// </summary> /// </summary>
public string GroupName { get; set; } public string GroupName { get; set; }
/// <summary>
/// 排序
/// </summary>
public int Order { get; set; }
} }
} }
...@@ -5,6 +5,7 @@ using System.Collections.Generic; ...@@ -5,6 +5,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 System.Web.UI.WebControls;
namespace VIZ.Package.Storage namespace VIZ.Package.Storage
{ {
...@@ -34,6 +35,8 @@ namespace VIZ.Package.Storage ...@@ -34,6 +35,8 @@ namespace VIZ.Package.Storage
this.Database = new LiteDatabase(path); this.Database = new LiteDatabase(path);
this.PageTemplate = this.Database.GetCollection<PageTemplateEntity>(); this.PageTemplate = this.Database.GetCollection<PageTemplateEntity>();
this.PageGroup = this.Database.GetCollection<PageGroupEntity>();
this.Page = this.Database.GetCollection<PageEntity>();
} }
/// <summary> /// <summary>
...@@ -47,11 +50,23 @@ namespace VIZ.Package.Storage ...@@ -47,11 +50,23 @@ namespace VIZ.Package.Storage
public ILiteCollection<PageTemplateEntity> PageTemplate { get; private set; } public ILiteCollection<PageTemplateEntity> PageTemplate { get; private set; }
/// <summary> /// <summary>
/// 页分组
/// </summary>
public ILiteCollection<PageGroupEntity> PageGroup { get; private set; }
/// <summary>
/// 页
/// </summary>
public ILiteCollection<PageEntity> Page { get; private set; }
/// <summary>
/// 销毁 /// 销毁
/// </summary> /// </summary>
public void Dispose() public void Dispose()
{ {
this.PageTemplate = null; this.PageTemplate = null;
this.PageGroup = null;
this.Page = null;
this.Database?.Dispose(); this.Database?.Dispose();
} }
......
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