Commit 5dd7ad70 by liulongfei

列表编辑支持

parent b5b386d5
...@@ -36,6 +36,11 @@ namespace VIZ.Package.Domain ...@@ -36,6 +36,11 @@ namespace VIZ.Package.Domain
/// </summary> /// </summary>
public static Type MainWindowType { get; set; } public static Type MainWindowType { get; set; }
/// <summary>
/// 字段编辑窗口
/// </summary>
public static Window FieldEditWindow { get; set; }
// ============================================================= // =============================================================
// 数据 // 数据
// ============================================================= // =============================================================
......
...@@ -6,13 +6,14 @@ using System.Text; ...@@ -6,13 +6,14 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using VIZ.Framework.Core; using VIZ.Framework.Core;
using VIZ.Package.Storage;
namespace VIZ.Package.Module namespace VIZ.Package.Domain
{ {
/// <summary> /// <summary>
/// 列表编辑面板列定义 /// 列定义
/// </summary> /// </summary>
public class ListEditPanelColumnDefinition public class GridColumnDefinition
{ {
/// <summary> /// <summary>
/// 绑定字段 /// 绑定字段
...@@ -38,5 +39,25 @@ namespace VIZ.Package.Module ...@@ -38,5 +39,25 @@ namespace VIZ.Package.Module
/// 是否只读 /// 是否只读
/// </summary> /// </summary>
public bool ReadOnly { get; set; } public bool ReadOnly { get; set; }
/// <summary>
/// 是否启用编辑
/// </summary>
public bool AllowEditing { get; set; }
/// <summary>
/// 字段类型
/// </summary>
public VizControlFieldType Type { get; set; }
/// <summary>
/// 控制对象
/// </summary>
public ControlObjectModel ControlObject { get; set; }
/// <summary>
/// 控制字段
/// </summary>
public ControlFieldNodeModel ControlField { get; set; }
} }
} }
...@@ -28,16 +28,16 @@ namespace VIZ.Package.Domain ...@@ -28,16 +28,16 @@ namespace VIZ.Package.Domain
#endregion #endregion
#region TreeNodePath -- 树节点路径 #region Num -- 编号
private string treeNodePath; private string num;
/// <summary> /// <summary>
/// 树节点路径 /// 编号
/// </summary> /// </summary>
public string TreeNodePath public string Num
{ {
get { return treeNodePath; } get { return num; }
set { treeNodePath = value; this.RaisePropertyChanged(nameof(TreeNodePath)); } set { num = value; this.RaisePropertyChanged(nameof(Num)); }
} }
#endregion #endregion
......
...@@ -49,6 +49,11 @@ ...@@ -49,6 +49,11 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="DevExpress.Mvvm.v22.1, Version=22.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.Xpf.Core.v22.1, Version=22.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.Xpf.Grid.v22.1, Version=22.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.Xpf.Grid.v22.1.Core, Version=22.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.Xpf.Grid.v22.1.Extensions, Version=22.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<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>
...@@ -69,6 +74,7 @@ ...@@ -69,6 +74,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="ApplicationConstants.cs" /> <Compile Include="ApplicationConstants.cs" />
<Compile Include="ApplicationDomainEx.cs" /> <Compile Include="ApplicationDomainEx.cs" />
<Compile Include="Core\GridColumnDefinition.cs" />
<Compile Include="Enum\ModulePluginIds.cs" /> <Compile Include="Enum\ModulePluginIds.cs" />
<Compile Include="Enum\ViewServiceKeys.cs" /> <Compile Include="Enum\ViewServiceKeys.cs" />
<Compile Include="Info\VizTreeNodeInfo.cs" /> <Compile Include="Info\VizTreeNodeInfo.cs" />
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Module
{
/// <summary>
/// 字段编辑模式
/// </summary>
public enum FieldEditMode
{
/// <summary>
/// 正常模式
/// </summary>
Normal,
/// <summary>
/// 动态模式
/// </summary>
Dynamic
}
}
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Dynamic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
...@@ -44,6 +45,20 @@ namespace VIZ.Package.Module ...@@ -44,6 +45,20 @@ namespace VIZ.Package.Module
#endregion #endregion
#region FieldEditMode -- 字段编辑模式
private FieldEditMode fieldEditMode;
/// <summary>
/// 字段编辑模式
/// </summary>
public FieldEditMode FieldEditMode
{
get { return fieldEditMode; }
set { fieldEditMode = value; this.RaisePropertyChanged(nameof(FieldEditMode)); }
}
#endregion
#region ControlObject -- 控制对象 #region ControlObject -- 控制对象
private ControlObjectModel controlObject; private ControlObjectModel controlObject;
...@@ -72,6 +87,62 @@ namespace VIZ.Package.Module ...@@ -72,6 +87,62 @@ namespace VIZ.Package.Module
#endregion #endregion
#region ColumnDefinition -- 列定义
private GridColumnDefinition columnDefinition;
/// <summary>
/// 列定义
/// </summary>
public GridColumnDefinition ColumnDefinition
{
get { return columnDefinition; }
set { columnDefinition = value; this.RaisePropertyChanged(nameof(ColumnDefinition)); }
}
#endregion
#region RowHandle -- 行和号
private int rowHandle;
/// <summary>
/// 行号
/// </summary>
public int RowHandle
{
get { return rowHandle; }
set { rowHandle = value; this.RaisePropertyChanged(nameof(RowHandle)); }
}
#endregion
#region Row -- 行数据
private ExpandoObject row;
/// <summary>
/// 行数据
/// </summary>
public ExpandoObject Row
{
get { return row; }
set { row = value; this.RaisePropertyChanged(nameof(Row)); }
}
#endregion
#region ListCellEdit -- 单元格编辑控件
private ListCellEditBase listCellEdit;
/// <summary>
/// 单元格编辑控件
/// </summary>
public ListCellEditBase ListCellEdit
{
get { return listCellEdit; }
set { listCellEdit = value; this.RaisePropertyChanged(nameof(ListCellEdit)); }
}
#endregion
/// <summary> /// <summary>
/// 更新 /// 更新
/// </summary> /// </summary>
...@@ -84,5 +155,24 @@ namespace VIZ.Package.Module ...@@ -84,5 +155,24 @@ namespace VIZ.Package.Module
this.IsSendToPreview = true; this.IsSendToPreview = true;
} }
/// <summary>
/// 更新动态数据
/// </summary>
/// <param name="listCellEdit">列单元格编辑器</param>
/// <param name="columnDefinition">列定义</param>
/// <param name="rowHandle">行号</param>
/// <param name="row">行数据</param>
public virtual void UpdateDynamic(ListCellEditBase listCellEdit, GridColumnDefinition columnDefinition, int rowHandle, ExpandoObject row)
{
this.ListCellEdit = listCellEdit;
this.ControlObject = columnDefinition.ControlObject;
this.ControlField = columnDefinition.ControlField;
this.ColumnDefinition = columnDefinition;
this.RowHandle = rowHandle;
this.Row = row;
this.IsSendToPreview = true;
}
} }
} }
<local:ListCellEditBase x:Class="VIZ.Package.Module.BooleanListCellEdit"
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"
d:Background="White"
mc:Ignorable="d"
d:DesignHeight="30" d:DesignWidth="200">
<Grid>
<dxe:CheckEdit x:Name="PART_Check" EditValueChanged="EditValueChanged"></dxe:CheckEdit>
</Grid>
</local:ListCellEditBase>
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.Package.Domain;
using VIZ.Package.Service;
namespace VIZ.Package.Module
{
/// <summary>
/// BooleanListCellEdit.xaml 的交互逻辑
/// </summary>
public partial class BooleanListCellEdit : ListCellEditBase
{
public BooleanListCellEdit()
{
InitializeComponent();
}
/// <summary>
/// 数据上下文改变时触发
/// </summary>
/// <param name="e">事件参数</param>
protected override void OnDataContextChanged(DependencyPropertyChangedEventArgs e)
{
DevExpress.Xpf.Grid.EditGridCellData cellData = e.NewValue as DevExpress.Xpf.Grid.EditGridCellData;
this.IsSendToPreview = false;
bool.TryParse(cellData?.Value?.ToString(), out bool value);
this.PART_Check.EditValue = value;
this.IsSendToPreview = true;
}
/// <summary>
/// 值改变时触发
/// </summary>
private void EditValueChanged(object sender, DevExpress.Xpf.Editors.EditValueChangedEventArgs e)
{
// 是否需要发送至预览
if (!this.IsSendToPreview)
return;
// 预览连接不存在
if (ApplicationDomainEx.PreviewConn == null)
return;
DevExpress.Xpf.Grid.EditGridCellData cellData = this.DataContext as DevExpress.Xpf.Grid.EditGridCellData;
if (cellData == null)
return;
GridColumnDefinition columnDefinition = cellData.Column.DataContext as GridColumnDefinition;
if (columnDefinition == null)
return;
bool.TryParse(e.NewValue?.ToString(), out bool value);
// 向Viz发送指令
this.VizCommandControlObjectService.SetControlObjectListValue(
ApplicationDomainEx.PreviewConn,
columnDefinition.ControlObject.TreeNodePath,
columnDefinition.ControlField.FieldIdentifier,
cellData.RowData.RowHandle.Value,
columnDefinition.FieldName,
value ? "1" : "0");
}
}
}
<local:ListCellEditBase x:Class="VIZ.Package.Module.TextListCellEdit"
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"
d:Background="White"
mc:Ignorable="d"
d:DesignHeight="30" d:DesignWidth="200">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="30"></ColumnDefinition>
</Grid.ColumnDefinitions>
<dxe:TextEdit x:Name="PART_Text" EditValueChanged="EditValueChanged"></dxe:TextEdit>
<Button x:Name="PART_Show" Content=".." Grid.Column="1" Click="EditClick"></Button>
</Grid>
</local:ListCellEditBase>
using System;
using System.Collections.Generic;
using System.Dynamic;
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.Package.Domain;
using VIZ.Package.Service;
namespace VIZ.Package.Module
{
/// <summary>
/// TextListCellEdit.xaml 的交互逻辑
/// </summary>
public partial class TextListCellEdit : ListCellEditBase
{
public TextListCellEdit()
{
InitializeComponent();
}
/// <summary>
/// 数据上下文改变时触发
/// </summary>
/// <param name="e">事件参数</param>
protected override void OnDataContextChanged(DependencyPropertyChangedEventArgs e)
{
DevExpress.Xpf.Grid.EditGridCellData cellData = e.NewValue as DevExpress.Xpf.Grid.EditGridCellData;
this.IsSendToPreview = false;
this.PART_Text.EditValue = cellData?.Value?.ToString();
this.IsSendToPreview = true;
}
/// <summary>
/// 值改变时触发
/// </summary>
private void EditValueChanged(object sender, DevExpress.Xpf.Editors.EditValueChangedEventArgs e)
{
// 是否需要发送至预览
if (!this.IsSendToPreview)
return;
// 预览连接不存在
if (ApplicationDomainEx.PreviewConn == null)
return;
DevExpress.Xpf.Grid.EditGridCellData cellData = this.DataContext as DevExpress.Xpf.Grid.EditGridCellData;
if (cellData == null)
return;
GridColumnDefinition columnDefinition = cellData.Column.DataContext as GridColumnDefinition;
if (columnDefinition == null)
return;
// 向Viz发送指令
this.VizCommandControlObjectService.SetControlObjectListValue(
ApplicationDomainEx.PreviewConn,
columnDefinition.ControlObject.TreeNodePath,
columnDefinition.ControlField.FieldIdentifier,
cellData.RowData.RowHandle.Value,
columnDefinition.FieldName,
e.NewValue?.ToString() ?? string.Empty);
}
/// <summary>
/// 显示编辑窗口
/// </summary>
private void EditClick(object sender, RoutedEventArgs e)
{
DevExpress.Xpf.Grid.EditGridCellData cellData = this.DataContext as DevExpress.Xpf.Grid.EditGridCellData;
if (cellData == null)
return;
GridColumnDefinition columnDefinition = cellData.Column.DataContext as GridColumnDefinition;
if (columnDefinition == null)
return;
FieldEditWindow window = this.GetFieldEditWindow();
FieldEditWindowModel vm = window.DataContext as FieldEditWindowModel;
vm.Update(this, columnDefinition, cellData.RowData.RowHandle.Value, cellData.Row as ExpandoObject);
window.ShowInTaskbar = true;
window.Visibility = Visibility.Visible;
}
/// <summary>
/// 更新
/// </summary>
/// <param name="columnDefinition">列定义</param>
/// <param name="rowHandle">行号</param>
/// <param name="row">行数据</param>
public override void UpdateEditValue(GridColumnDefinition columnDefinition, int rowHandle, ExpandoObject row)
{
IDictionary<string, object> dic = row as IDictionary<string, object>;
if (dic == null)
{
this.PART_Text.EditValue = null;
return;
}
this.PART_Text.EditValue = dic[columnDefinition.FieldName].ToString();
}
}
}
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using VIZ.Package.Domain;
using VIZ.Package.Service;
namespace VIZ.Package.Module
{
/// <summary>
/// 单元格编辑基类
/// </summary>
public abstract class ListCellEditBase : UserControl
{
public ListCellEditBase()
{
this.DataContextChanged += CellEditBase_DataContextChanged;
}
/// <summary>
/// 是否向预览发送命令
/// </summary>
protected bool IsSendToPreview;
/// <summary>
/// Viz控制对象服务
/// </summary>
protected VizCommandControlObjectService VizCommandControlObjectService = new VizCommandControlObjectService();
/// <summary>
/// 获取字段编辑窗口
/// </summary>
/// <returns>字段编辑窗口</returns>
protected FieldEditWindow GetFieldEditWindow()
{
if (ApplicationDomainEx.FieldEditWindow == null)
{
ApplicationDomainEx.FieldEditWindow = new FieldEditWindow();
}
return ApplicationDomainEx.FieldEditWindow as FieldEditWindow;
}
/// <summary>
/// 数据上下文改变时触发
/// </summary>
/// <param name="e">事件参数</param>
protected virtual void OnDataContextChanged(System.Windows.DependencyPropertyChangedEventArgs e)
{
}
/// <summary>
/// 数据上下文改变时触发
/// </summary>
private void CellEditBase_DataContextChanged(object sender, System.Windows.DependencyPropertyChangedEventArgs e)
{
this.OnDataContextChanged(e);
}
/// <summary>
/// 更新
/// </summary>
/// <param name="columnDefinition">列定义</param>
/// <param name="rowHandle">行号</param>
/// <param name="row">行数据</param>
public virtual void UpdateEditValue(GridColumnDefinition columnDefinition, int rowHandle, ExpandoObject row)
{
}
}
}
...@@ -21,7 +21,33 @@ ...@@ -21,7 +21,33 @@
<!-- 行号转化器 --> <!-- 行号转化器 -->
<resource:RowHandleConverter x:Key="RowHandleConverter"></resource:RowHandleConverter> <resource:RowHandleConverter x:Key="RowHandleConverter"></resource:RowHandleConverter>
<!-- 单元格编辑模板选择器 -->
<local:ListEditPanelCellTemplateSelector x:Key="CellTemplateSelector">
<local:ListEditPanelCellTemplateSelector.BooleanDataTemplate>
<DataTemplate>
<local:BooleanListCellEdit></local:BooleanListCellEdit>
</DataTemplate>
</local:ListEditPanelCellTemplateSelector.BooleanDataTemplate>
<local:ListEditPanelCellTemplateSelector.ImageDataTemplate>
<DataTemplate>
</DataTemplate>
</local:ListEditPanelCellTemplateSelector.ImageDataTemplate>
</local:ListEditPanelCellTemplateSelector>
<!-- 单元格编辑模板选择器 -->
<local:ListEditPanelCellTemplateSelector x:Key="CellEditTemplateSelector">
<local:ListEditPanelCellTemplateSelector.TextDataTemplate>
<DataTemplate>
<local:TextListCellEdit></local:TextListCellEdit>
</DataTemplate>
</local:ListEditPanelCellTemplateSelector.TextDataTemplate>
<local:ListEditPanelCellTemplateSelector.TripletDataTemplate>
<DataTemplate>
<Border></Border>
</DataTemplate>
</local:ListEditPanelCellTemplateSelector.TripletDataTemplate>
</local:ListEditPanelCellTemplateSelector>
<!-- 列定义模板 --> <!-- 列定义模板 -->
<DataTemplate x:Key="ColumnTemplate"> <DataTemplate x:Key="ColumnTemplate">
...@@ -29,8 +55,10 @@ ...@@ -29,8 +55,10 @@
<dxg:GridColumn FieldName="{Binding FieldName}" Width="{Binding Width}" <dxg:GridColumn FieldName="{Binding FieldName}" Width="{Binding Width}"
MinWidth="{Binding MinWidth}" MinWidth="{Binding MinWidth}"
Header="{Binding Header}" ReadOnly="{Binding ReadOnly}" Header="{Binding Header}" ReadOnly="{Binding ReadOnly}"
AllowEditing="True" AllowSorting="False" AllowColumnFiltering="False" CellTemplateSelector="{StaticResource CellTemplateSelector}"
/> CellEditTemplateSelector="{StaticResource CellEditTemplateSelector}"
AllowEditing="{Binding AllowEditing}"
AllowSorting="False" AllowColumnFiltering="False"/>
</ContentControl> </ContentControl>
</DataTemplate> </DataTemplate>
</ResourceDictionary> </ResourceDictionary>
......
...@@ -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 ListEditPanel() public ListEditPanel()
{ {
InitializeComponent(); InitializeComponent();
WPFHelper.BindingViewModel(this, new ListEditPanelModel());
} }
} }
} }
...@@ -7,6 +7,7 @@ using System.Text; ...@@ -7,6 +7,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using VIZ.Package.Domain;
using VIZ.Package.Storage; using VIZ.Package.Storage;
namespace VIZ.Package.Module namespace VIZ.Package.Module
...@@ -45,22 +46,19 @@ namespace VIZ.Package.Module ...@@ -45,22 +46,19 @@ namespace VIZ.Package.Module
public override DataTemplate SelectTemplate(object item, DependencyObject container) public override DataTemplate SelectTemplate(object item, DependencyObject container)
{ {
GridCellData data = (GridCellData)item; GridCellData data = (GridCellData)item;
GridColumnDefinition definition = data.Column.DataContext as GridColumnDefinition;
//ExpandoObject model = data.RowData.Row as ExpandoObject; switch (definition.Type)
//if (model == null) {
// return null; case VizControlFieldType.none: return null;
case VizControlFieldType.text: return this.TextDataTemplate;
//switch (model.Type) case VizControlFieldType.boolean: return this.BooleanDataTemplate;
//{ case VizControlFieldType.richtext: return this.TextDataTemplate;
// case VizControlFieldType.none: return null; case VizControlFieldType.image: return this.ImageDataTemplate;
// case VizControlFieldType.text: return this.TextDataTemplate; case VizControlFieldType.list: return this.TextDataTemplate;
// case VizControlFieldType.boolean: return this.BooleanDataTemplate; case VizControlFieldType.triplet: return this.TripletDataTemplate;
// case VizControlFieldType.richtext: return this.TextDataTemplate; default: return null;
// case VizControlFieldType.image: return this.ImageDataTemplate; }
// case VizControlFieldType.list: return this.TextDataTemplate;
// case VizControlFieldType.triplet: return this.TripletDataTemplate;
// default: return null;
//}
} }
} }
} }
\ No newline at end of file
...@@ -4,6 +4,8 @@ using System.Dynamic; ...@@ -4,6 +4,8 @@ using System.Dynamic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using VIZ.Package.Domain;
using VIZ.Package.Service;
namespace VIZ.Package.Module namespace VIZ.Package.Module
{ {
...@@ -13,6 +15,15 @@ namespace VIZ.Package.Module ...@@ -13,6 +15,15 @@ namespace VIZ.Package.Module
public class ListEditPanelModel : EditPanelModelBase public class ListEditPanelModel : EditPanelModelBase
{ {
// =================================================================== // ===================================================================
// Service & Controller
// ===================================================================
/// <summary>
/// 控制对象服务
/// </summary>
private VizCommandControlObjectService vizCommandControlObjectService = new VizCommandControlObjectService();
// ===================================================================
// Property // Property
// =================================================================== // ===================================================================
...@@ -32,16 +43,43 @@ namespace VIZ.Package.Module ...@@ -32,16 +43,43 @@ namespace VIZ.Package.Module
#region Columns -- 列信息 #region Columns -- 列信息
private List<ListEditPanelColumnDefinition> columns; private List<GridColumnDefinition> columns;
/// <summary> /// <summary>
/// 列信息 /// 列信息
/// </summary> /// </summary>
public List<ListEditPanelColumnDefinition> Columns public List<GridColumnDefinition> Columns
{ {
get { return columns; } get { return columns; }
set { columns = value; this.RaisePropertyChanged(nameof(Columns)); } set { columns = value; this.RaisePropertyChanged(nameof(Columns)); }
} }
#endregion #endregion
/// <summary>
/// 更新
/// </summary>
/// <param name="controlObject">控制对象</param>
/// <param name="controlField">控制字段</param>
public override void Update(ControlObjectModel controlObject, ControlFieldNodeModel controlField)
{
base.Update(controlObject, controlField);
this.ItemsSource = null;
this.Columns = null;
if (controlField == null)
return;
List<GridColumnDefinition> columns = this.vizCommandControlObjectService.GetControlObjectListColumn(controlField.TypeSchema);
List<ExpandoObject> items = this.vizCommandControlObjectService.GetControlObjectListData(controlField.Value);
foreach (GridColumnDefinition column in columns)
{
column.ControlObject = this.ControlObject;
column.ControlField = this.ControlField;
}
this.Columns = columns;
this.ItemsSource = items;
}
} }
} }
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Dynamic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
...@@ -59,6 +60,24 @@ namespace VIZ.Package.Module ...@@ -59,6 +60,24 @@ namespace VIZ.Package.Module
this.IsSendToPreview = true; this.IsSendToPreview = true;
} }
/// <summary>
/// 更新动态数据
/// </summary>
/// <param name="listCellEdit">列单元格编辑器</param>
/// <param name="columnDefinition">列定义</param>
/// <param name="rowHandle">行号</param>
/// <param name="row">行数据</param>
public override void UpdateDynamic(ListCellEditBase listCellEdit, GridColumnDefinition columnDefinition, int rowHandle, ExpandoObject row)
{
base.UpdateDynamic(listCellEdit, columnDefinition, rowHandle, row);
IDictionary<string, object> dic = row as IDictionary<string, object>;
this.IsSendToPreview = false;
this.Text = dic == null ? null : dic[columnDefinition.FieldName]?.ToString();
this.IsSendToPreview = true;
}
// ============================================================ // ============================================================
// Private Function // Private Function
// ============================================================ // ============================================================
...@@ -80,13 +99,34 @@ namespace VIZ.Package.Module ...@@ -80,13 +99,34 @@ namespace VIZ.Package.Module
if (this.ControlObject == null || this.ControlField == null) if (this.ControlObject == null || this.ControlField == null)
return; return;
this.ControlField.Value = this.Text; // 正常模式编辑
if (this.FieldEditMode == FieldEditMode.Normal)
{
this.ControlField.Value = this.Text;
this.VizCommandControlObjectService.SetControlObjectValue(
ApplicationDomainEx.PreviewConn,
this.ControlObject.TreeNodePath,
this.ControlField.FieldIdentifier,
this.ControlField.Value);
this.VizCommandControlObjectService.SetControlObjectValue( return;
ApplicationDomainEx.PreviewConn, }
this.ControlObject.TreeNodePath,
this.ControlField.FieldIdentifier, // 没有列信息或行数据
this.ControlField.Value); if (this.ColumnDefinition == null || this.Row == null)
return;
// 动态模式编辑
if (this.FieldEditMode == FieldEditMode.Dynamic)
{
IDictionary<string, object> dic = this.Row as IDictionary<string, object>;
dic[this.ColumnDefinition.FieldName] = this.Text;
this.ListCellEdit.UpdateEditValue(this.ColumnDefinition, this.RowHandle, this.Row);
return;
}
} }
} }
} }
<dx:ThemedWindow x:Class="VIZ.Package.Module.FieldEditWindow"
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:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:local="clr-namespace:VIZ.Package.Module"
xmlns:common="clr-namespace:VIZ.Framework.Common;assembly=VIZ.Framework.Common"
d:DataContext="{d:DesignInstance Type=local:FieldEditWindowModel}"
mc:Ignorable="d" WindowStartupLocation="CenterScreen"
Title="列表字段编辑"
Width="600" Height="450">
<common:NavigationControl ItemsSource="{Binding Path=NavigationConfigs}"
SelectedValue="{Binding Path=SelectedNavigationConfig,Mode=OneWay}"></common:NavigationControl>
</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 FieldEditWindow.xaml
/// </summary>
public partial class FieldEditWindow : ThemedWindow
{
public FieldEditWindow()
{
InitializeComponent();
this.Closing += FieldEditWindow_Closing;
WPFHelper.BindingViewModel(this, new FieldEditWindowModel());
}
/// <summary>
/// 窗口关闭之前触发
/// </summary>
private void FieldEditWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
this.ShowInTaskbar = false;
this.Visibility = Visibility.Collapsed;
}
}
}
...@@ -53,6 +53,14 @@ namespace VIZ.Package.Module ...@@ -53,6 +53,14 @@ namespace VIZ.Package.Module
ViewType = typeof(ImageEditPanel), ViewType = typeof(ImageEditPanel),
ViewCreated = this.OnViewCreated ViewCreated = this.OnViewCreated
}); });
// 列表编辑
this.NavigationConfigs.Add(new NavigationConfig
{
Key = VizControlFieldType.list.ToString(),
ViewType = typeof(ListEditPanel),
ViewCreated = this.OnViewCreated
});
} }
// ============================================================= // =============================================================
...@@ -139,12 +147,12 @@ namespace VIZ.Package.Module ...@@ -139,12 +147,12 @@ namespace VIZ.Package.Module
if (config != null && config.View != null && config.View.TryGetTarget(out object target)) if (config != null && config.View != null && config.View.TryGetTarget(out object target))
{ {
FrameworkElement view = target as FrameworkElement; FrameworkElement view = target as FrameworkElement;
EditPanelModelBase model = view?.DataContext as EditPanelModelBase;
if (view != null) if (model != null)
{ {
EditPanelModelBase model = view.DataContext as EditPanelModelBase; model.FieldEditMode = FieldEditMode.Normal;
model.Update(this.ControlObject, this.ControlField);
model?.Update(this.ControlObject, this.ControlField);
} }
} }
...@@ -170,6 +178,7 @@ namespace VIZ.Package.Module ...@@ -170,6 +178,7 @@ namespace VIZ.Package.Module
if (model == null) if (model == null)
return; return;
model.FieldEditMode = FieldEditMode.Normal;
model.Update(this.ControlObject, this.ControlField); model.Update(this.ControlObject, this.ControlField);
} }
} }
......
using DevExpress.Mvvm.POCO;
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using VIZ.Framework.Common;
using VIZ.Framework.Core;
using VIZ.Package.Domain;
using VIZ.Package.Storage;
namespace VIZ.Package.Module
{
/// <summary>
/// 字段编辑窗口视图模型
/// </summary>
public class FieldEditWindowModel : ViewModelBase
{
public FieldEditWindowModel()
{
// 初始化导航配置
this.InitNavigationConfigs();
}
/// <summary>
/// 初始化导航配置
/// </summary>
private void InitNavigationConfigs()
{
// 文本编辑器
this.NavigationConfigs.Add(new NavigationConfig
{
Key = VizControlFieldType.text.ToString(),
ViewType = typeof(TextEditPanel),
ViewCreated = this.OnViewCreated
});
// 图片选择
this.NavigationConfigs.Add(new NavigationConfig
{
Key = VizControlFieldType.image.ToString(),
ViewType = typeof(ImageEditPanel),
ViewCreated = this.OnViewCreated
});
// 列表编辑
this.NavigationConfigs.Add(new NavigationConfig
{
Key = VizControlFieldType.list.ToString(),
ViewType = typeof(ListEditPanel),
ViewCreated = this.OnViewCreated
});
}
// =============================================================
// Property
// =============================================================
#region NavigationConfigs -- 导航配置
private List<NavigationConfig> navigationConfigs = new List<NavigationConfig>();
/// <summary>
/// 导航配置
/// </summary>
public List<NavigationConfig> NavigationConfigs
{
get { return navigationConfigs; }
set { navigationConfigs = value; this.RaisePropertyChanged(nameof(NavigationConfigs)); }
}
#endregion
#region SelectedNavigationConfig -- 当前选中的导航配置
private NavigationConfig selectedNavigationConfig;
/// <summary>
/// 当前选中的导航配置
/// </summary>
public NavigationConfig SelectedNavigationConfig
{
get { return selectedNavigationConfig; }
set { selectedNavigationConfig = value; this.RaisePropertyChanged(nameof(SelectedNavigationConfig)); }
}
#endregion
#region ColumnDefinition -- 列定义
private GridColumnDefinition columnDefinition;
/// <summary>
/// 列定义
/// </summary>
public GridColumnDefinition ColumnDefinition
{
get { return columnDefinition; }
set { columnDefinition = value; this.RaisePropertyChanged(nameof(ColumnDefinition)); }
}
#endregion
#region RowHandle -- 行号
private int rowHandle;
/// <summary>
/// 行号
/// </summary>
public int RowHandle
{
get { return rowHandle; }
set { rowHandle = value; this.RaisePropertyChanged(nameof(RowHandle)); }
}
#endregion
#region Row -- 行数据
private ExpandoObject row;
/// <summary>
/// 行数据
/// </summary>
public ExpandoObject Row
{
get { return row; }
set { row = value; this.RaisePropertyChanged(nameof(Row)); }
}
#endregion
#region ListCellEdit -- 单元格编辑控件
private ListCellEditBase listCellEdit;
/// <summary>
/// 单元格编辑控件
/// </summary>
public ListCellEditBase ListCellEdit
{
get { return listCellEdit; }
set { listCellEdit = value; this.RaisePropertyChanged(nameof(ListCellEdit)); }
}
#endregion
// =============================================================
// Public Function
// =============================================================
/// <summary>
/// 更新
/// </summary>
/// <param name="listCellEdit">列表单元格编辑控件</param>
/// <param name="columnDefinition">列定义</param>
/// <param name="rowHandle">行号</param>
/// <param name="row">行数据</param>
public void Update(ListCellEditBase listCellEdit, GridColumnDefinition columnDefinition, int rowHandle, ExpandoObject row)
{
this.ListCellEdit = listCellEdit;
this.ColumnDefinition = columnDefinition;
this.RowHandle = rowHandle;
this.Row = row;
if (this.ColumnDefinition == null || this.ColumnDefinition.ControlObject == null || this.ColumnDefinition.ControlField == null)
{
this.SelectedNavigationConfig = null;
return;
}
NavigationConfig config = this.NavigationConfigs.FirstOrDefault(p => p.Key == this.ColumnDefinition.Type.ToString());
if (config != null && config.View != null && config.View.TryGetTarget(out object target))
{
FrameworkElement view = target as FrameworkElement;
EditPanelModelBase model = view?.DataContext as EditPanelModelBase;
if (model != null)
{
model.FieldEditMode = FieldEditMode.Dynamic;
model.UpdateDynamic(this.ListCellEdit, this.ColumnDefinition, this.RowHandle, this.Row);
}
}
this.SelectedNavigationConfig = config;
}
// =============================================================
// Private Function
// =============================================================
/// <summary>
/// 视图创建后触发
/// </summary>
/// <param name="config">导航配置</param>
/// <param name="obj">视图</param>
private void OnViewCreated(NavigationConfig config, object obj)
{
FrameworkElement view = obj as FrameworkElement;
if (view == null)
return;
EditPanelModelBase model = view.DataContext as EditPanelModelBase;
if (model == null)
return;
model.FieldEditMode = FieldEditMode.Dynamic;
model.UpdateDynamic(this.ListCellEdit, this.ColumnDefinition, this.RowHandle, this.Row);
}
}
}
\ No newline at end of file
...@@ -92,16 +92,21 @@ ...@@ -92,16 +92,21 @@
<Compile Include="ControlObject\Command\View\CommandView.xaml.cs"> <Compile Include="ControlObject\Command\View\CommandView.xaml.cs">
<DependentUpon>CommandView.xaml</DependentUpon> <DependentUpon>CommandView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="ControlObject\FieldEdit\Core\FieldEditMode.cs" />
<Compile Include="ControlObject\FieldEdit\Edit\EditPanelModelBase.cs" /> <Compile Include="ControlObject\FieldEdit\Edit\EditPanelModelBase.cs" />
<Compile Include="ControlObject\FieldEdit\Edit\ImageEdit\ImageEditPanelModel.cs" /> <Compile Include="ControlObject\FieldEdit\Edit\ImageEdit\ImageEditPanelModel.cs" />
<Compile Include="ControlObject\FieldEdit\Edit\ListEdit\CellEdit\BooleanListCellEdit.xaml.cs">
<DependentUpon>BooleanListCellEdit.xaml</DependentUpon>
</Compile>
<Compile Include="ControlObject\FieldEdit\Edit\ListEdit\ListCellEditBase.cs" />
<Compile Include="ControlObject\FieldEdit\Edit\ListEdit\ListEditPanelCellTemplateSelector.cs" /> <Compile Include="ControlObject\FieldEdit\Edit\ListEdit\ListEditPanelCellTemplateSelector.cs" />
<Compile Include="ControlObject\FieldEdit\Edit\ListEdit\ListEditPanelColumnDefinition.cs" />
<Compile Include="ControlObject\FieldEdit\Edit\ListEdit\ListEditPanelModel.cs" /> <Compile Include="ControlObject\FieldEdit\Edit\ListEdit\ListEditPanelModel.cs" />
<Compile Include="ControlObject\FieldEdit\Edit\ResourceEdit\GHResourceEditPartModel.cs" /> <Compile Include="ControlObject\FieldEdit\Edit\ResourceEdit\GHResourceEditPartModel.cs" />
<Compile Include="ControlObject\FieldEdit\Edit\ResourceEdit\ResourceEditPanelModelBase.cs" /> <Compile Include="ControlObject\FieldEdit\Edit\ResourceEdit\ResourceEditPanelModelBase.cs" />
<Compile Include="ControlObject\FieldEdit\Edit\TextEdit\TextEditPanelModel.cs" /> <Compile Include="ControlObject\FieldEdit\Edit\TextEdit\TextEditPanelModel.cs" />
<Compile Include="ControlObject\FieldEdit\FieldEditPluginLifeCycle.cs" /> <Compile Include="ControlObject\FieldEdit\FieldEditPluginLifeCycle.cs" />
<Compile Include="ControlObject\FieldEdit\ViewModel\FieldEditViewModel.cs" /> <Compile Include="ControlObject\FieldEdit\ViewModel\FieldEditViewModel.cs" />
<Compile Include="ControlObject\FieldEdit\ViewModel\FieldEditWindowModel.cs" />
<Compile Include="ControlObject\FieldTree\FieldTreePluginLifeCycle.cs" /> <Compile Include="ControlObject\FieldTree\FieldTreePluginLifeCycle.cs" />
<Compile Include="ControlObject\FieldTree\ViewModel\FieldTreeViewModel.cs" /> <Compile Include="ControlObject\FieldTree\ViewModel\FieldTreeViewModel.cs" />
<Compile Include="Control\ControlPluginLifeCycle.cs" /> <Compile Include="Control\ControlPluginLifeCycle.cs" />
...@@ -125,6 +130,9 @@ ...@@ -125,6 +130,9 @@
<Compile Include="ControlObject\FieldEdit\Edit\ListEdit\ListEditPanel.xaml.cs"> <Compile Include="ControlObject\FieldEdit\Edit\ListEdit\ListEditPanel.xaml.cs">
<DependentUpon>ListEditPanel.xaml</DependentUpon> <DependentUpon>ListEditPanel.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="ControlObject\FieldEdit\View\FieldEditWindow.xaml.cs">
<DependentUpon>FieldEditWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Main\ViewModel\MainTopViewModel.cs" /> <Compile Include="Main\ViewModel\MainTopViewModel.cs" />
<Compile Include="Plugin\PluginPluginLifeCycle.cs" /> <Compile Include="Plugin\PluginPluginLifeCycle.cs" />
<Compile Include="Plugin\ViewModel\PluginViewModel.cs" /> <Compile Include="Plugin\ViewModel\PluginViewModel.cs" />
...@@ -209,6 +217,9 @@ ...@@ -209,6 +217,9 @@
<Compile Include="ControlObject\FieldEdit\Edit\TextEdit\TextEditPanel.xaml.cs"> <Compile Include="ControlObject\FieldEdit\Edit\TextEdit\TextEditPanel.xaml.cs">
<DependentUpon>TextEditPanel.xaml</DependentUpon> <DependentUpon>TextEditPanel.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="ControlObject\FieldEdit\Edit\ListEdit\CellEdit\TextListCellEdit.xaml.cs">
<DependentUpon>TextListCellEdit.xaml</DependentUpon>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
...@@ -228,6 +239,10 @@ ...@@ -228,6 +239,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="ControlObject\FieldEdit\Edit\ListEdit\CellEdit\BooleanListCellEdit.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Control\View\ControlView.xaml"> <Page Include="Control\View\ControlView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
...@@ -252,6 +267,10 @@ ...@@ -252,6 +267,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="ControlObject\FieldEdit\View\FieldEditWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Plugin\View\PluginView.xaml"> <Page Include="Plugin\View\PluginView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
...@@ -308,6 +327,10 @@ ...@@ -308,6 +327,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="ControlObject\FieldEdit\Edit\ListEdit\CellEdit\TextListCellEdit.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Generic.xaml"> <Page Include="Themes\Generic.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
......
...@@ -17,63 +17,83 @@ namespace VIZ.Package.Service ...@@ -17,63 +17,83 @@ namespace VIZ.Package.Service
public class VizCommandControlObjectService public class VizCommandControlObjectService
{ {
/// <summary> /// <summary>
/// 获取控制对象XML数据 /// 不启用编辑类型
/// </summary>
private static readonly List<VizControlFieldType> ALLOW_EDITING_FALSE_TYPES = new List<VizControlFieldType>
{
VizControlFieldType.none,
VizControlFieldType.boolean,
VizControlFieldType.image
};
/// <summary>
/// 获取控制对象List列定义
/// </summary> /// </summary>
/// <param name="xml">xml内容</param>
/// <param name="schema">定义信息</param> /// <param name="schema">定义信息</param>
/// <param name="columns">列信息</param> /// <returns>列定义</returns>
/// <param name="items">数据源</param> public List<GridColumnDefinition> GetControlObjectListColumn(string schema)
/// <returns></returns> {
//public void GetControlObjectXmlData(string xml, ControlObject_Schema_Node schema, out List<GridColumnDefinition> columns, out List<ExpandoObject> items) List<GridColumnDefinition> columns = new List<GridColumnDefinition>();
//{
// columns = new List<GridColumnDefinition>(); using (System.IO.MemoryStream ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(schema)))
// items = new List<ExpandoObject>(); {
XElement element = XElement.Load(ms);
// bool isCreatedColumns = false; XElement elementSchema = element.Element("schema");
if (elementSchema == null)
// using (System.IO.MemoryStream ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(xml))) return columns;
// {
// XElement element = XElement.Load(ms); ControlObject_Schema_Node schemaNode = new ControlObject_Schema_Node();
schemaNode.FromXmlElement(elementSchema);
// ControlObject_Entry_Node root = new ControlObject_Entry_Node();
// root.FromXmlElement(element); foreach (ControlObject_Field_node field in schemaNode.Fields)
{
// foreach (var row in root.Elements) GridColumnDefinition column = new GridColumnDefinition();
// { column.Header = (field.Name == field.Description) ? field.Name : $"({field.Description}){field.Name}";
// IDictionary<string, object> obj = new ExpandoObject(); column.FieldName = field.Name;
// ControlObject_Entry_Node data = row.Entrys.FirstOrDefault(p => p.Name == "data"); column.Type = this.GetControlFieldType(field.Type);
// if (data == null) column.AllowEditing = !ALLOW_EDITING_FALSE_TYPES.Contains(column.Type);
// continue;
columns.Add(column);
// foreach (var cell in data.Entrys) }
// { }
// obj[cell.Name] = cell.Value;
return columns;
// if (!isCreatedColumns) }
// {
// ControlObject_Field_node node = schema.Fields.FirstOrDefault(p => p.Name == cell.Name); /// <summary>
/// 获取控制对象List数据
// GridColumnDefinition column = new GridColumnDefinition(); /// </summary>
// column.FieldName = cell.Name; /// <param name="xml">数据</param>
// if (cell.Name == node?.Description) /// <returns>数据</returns>
// { public List<ExpandoObject> GetControlObjectListData(string xml)
// column.Header = cell.Name; {
// } List<ExpandoObject> items = new List<ExpandoObject>();
// else
// { using (System.IO.MemoryStream ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(xml)))
// column.Header = $"({node?.Description}){cell.Name}"; {
// } XElement element = XElement.Load(ms);
// columns.Add(column); ControlObject_Entry_Node root = new ControlObject_Entry_Node();
// } root.FromXmlElement(element);
// }
foreach (var row in root.Elements)
// isCreatedColumns = true; {
IDictionary<string, object> obj = new ExpandoObject();
// items.Add(obj as ExpandoObject); ControlObject_Entry_Node data = row.Entrys.FirstOrDefault(p => p.Name == "data");
// } if (data == null)
// } continue;
//}
foreach (var cell in data.Entrys)
{
obj[cell.Name] = cell.Value;
}
items.Add(obj as ExpandoObject);
}
}
return items;
}
/// <summary> /// <summary>
/// 获取控制对象XML数据 /// 获取控制对象XML数据
...@@ -104,7 +124,6 @@ namespace VIZ.Package.Service ...@@ -104,7 +124,6 @@ namespace VIZ.Package.Service
return $"<?xml version=\"1.0\"?>{root_element.ToString(SaveOptions.DisableFormatting)}"; return $"<?xml version=\"1.0\"?>{root_element.ToString(SaveOptions.DisableFormatting)}";
} }
/// <summary> /// <summary>
/// 获取场景树节点信息 /// 获取场景树节点信息
/// </summary> /// </summary>
...@@ -195,14 +214,11 @@ namespace VIZ.Package.Service ...@@ -195,14 +214,11 @@ namespace VIZ.Package.Service
string[] pars = fieldDetail.Split(':'); string[] pars = fieldDetail.Split(':');
string num = pars[1].Split('*').FirstOrDefault(); string num = pars[1].Split('*').FirstOrDefault();
if (!treeNodeDic.TryGetValue(num, out VizTreeNodeInfo treeNodeInfo))
continue;
ControlFieldNodeModel node = new ControlFieldNodeModel(); ControlFieldNodeModel node = new ControlFieldNodeModel();
node.FieldIdentifier = pars[0]; node.FieldIdentifier = pars[0];
node.Route = node.FieldIdentifier.Split('.').ToList(); node.Route = node.FieldIdentifier.Split('.').ToList();
node.TreeNodePath = treeNodeInfo.Path; node.Num = num;
node.TypeSchema = pars[2]; node.TypeSchema = pars[2];
node.Type = this.GetControlFieldType(node.TypeSchema); node.Type = this.GetControlFieldType(node.TypeSchema);
node.Value = this.GetControlFieldValue(conn, obj.TreeNodePath, node.FieldIdentifier); node.Value = this.GetControlFieldValue(conn, obj.TreeNodePath, node.FieldIdentifier);
...@@ -225,8 +241,8 @@ namespace VIZ.Package.Service ...@@ -225,8 +241,8 @@ namespace VIZ.Package.Service
foreach (ControlFieldNodeModel item in items) foreach (ControlFieldNodeModel item in items)
{ {
string parentTreeNodePath = string.Join(".", item.Route.Take(count - 1)); string parentFieldIdentifier = string.Join(".", item.Route.Take(count - 1));
ControlFieldNodeModel parent = parents.FirstOrDefault(p => p.TreeNodePath == parentTreeNodePath); ControlFieldNodeModel parent = parents.FirstOrDefault(p => p.FieldIdentifier == parentFieldIdentifier);
if (parent == null) if (parent == null)
continue; continue;
...@@ -323,13 +339,14 @@ namespace VIZ.Package.Service ...@@ -323,13 +339,14 @@ namespace VIZ.Package.Service
/// 设置列表控制对象的值 /// 设置列表控制对象的值
/// </summary> /// </summary>
/// <param name="connection">连接</param> /// <param name="connection">连接</param>
/// <param name="treeNodePath">场景节点路径</param>
/// <param name="listName">列表名称</param> /// <param name="listName">列表名称</param>
/// <param name="listLine">列表值位序</param> /// <param name="listLine">列表值位序</param>
/// <param name="fieldIdentifier">字段</param> /// <param name="fieldIdentifier">字段</param>
/// <param name="value">值</param> /// <param name="value">值</param>
public void SetxControlObjectListValue(ConnModel connection, string listName, int listLine, string fieldIdentifier, string value) public void SetControlObjectListValue(ConnModel connection, string treeNodePath, string listName, int listLine, string fieldIdentifier, string value)
{ {
connection.EndpointManager.Send($"MAIN_SCENE*TREE*$object*FUNCTION*ControlObject*in SET WITH {listName} INDEX {listLine} ON {fieldIdentifier} SET {value}"); connection.EndpointManager.Send($"MAIN_SCENE*TREE*{treeNodePath}*FUNCTION*ControlObject*in SET WITH {listName} INDEX {listLine} ON {fieldIdentifier} SET {value}");
} }
/// <summary> /// <summary>
......
[Application] [Application]
APPLICATION_IS_DEBUG=true APPLICATION_IS_DEBUG=false
[Viz] [Viz]
VIZ_IMAGE_FILTER=ͼƬ|*.jpg;*.jpeg;*.bmp;*.png; VIZ_IMAGE_FILTER=ͼƬ|*.jpg;*.jpeg;*.bmp;*.png;
\ 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