Commit 8aa14ee6 by liulongfei

图片编辑支持

parent 5dd7ad70
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;
...@@ -17,7 +18,7 @@ namespace VIZ.Package.Module ...@@ -17,7 +18,7 @@ namespace VIZ.Package.Module
public ImageEditPanelModel() public ImageEditPanelModel()
{ {
this.GHResourceEditPartModel.FilterResourceFileType = ResourceFileType.IMAGE; this.GHResourceEditPartModel.FilterResourceFileType = ResourceFileType.IMAGE;
this.GHResourceEditPartModel.OnSelectedFileModelChanged += GHResourceEditPartModel_OnSelectedFileModelChanged; this.GHResourceEditPartModel.OnFileDoubleClick += GHResourceEditPartModel_OnFileDoubleClick;
// 初始化命令 // 初始化命令
this.InitCommand(); this.InitCommand();
...@@ -106,7 +107,27 @@ namespace VIZ.Package.Module ...@@ -106,7 +107,27 @@ namespace VIZ.Package.Module
{ {
base.Update(controlObject, controlField); base.Update(controlObject, controlField);
this.IsSendToPreview = false;
this.Path = controlField?.Value; this.Path = controlField?.Value;
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.Path = dic?[columnDefinition.FieldName]?.ToString();
this.IsSendToPreview = true;
} }
// ===================================================================== // =====================================================================
...@@ -130,21 +151,41 @@ namespace VIZ.Package.Module ...@@ -130,21 +151,41 @@ namespace VIZ.Package.Module
if (this.ControlObject == null || this.ControlField == null) if (this.ControlObject == null || this.ControlField == null)
return; return;
this.ControlField.Value = this.Path; if (this.FieldEditMode == FieldEditMode.Normal)
{
this.ControlField.Value = this.Path;
this.VizCommandControlObjectService.SetControlObjectValue( this.VizCommandControlObjectService.SetControlObjectValue(
ApplicationDomainEx.PreviewConn, ApplicationDomainEx.PreviewConn,
this.ControlObject.TreeNodePath, this.ControlObject.TreeNodePath,
this.ControlField.FieldIdentifier, this.ControlField.FieldIdentifier,
this.ControlField.Value); this.ControlField.Value);
return;
}
// 没有列信息或行数据
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.Path;
this.ListCellEdit.UpdateEditValue(this.ColumnDefinition, this.RowHandle, this.Row);
return;
}
} }
/// <summary> /// <summary>
/// GH库文件选择改变时触发 /// GH库双击文件时触发
/// </summary> /// </summary>
private void GHResourceEditPartModel_OnSelectedFileModelChanged(object sender, GHResourceSelectedFileChangedEventArgs e) private void GHResourceEditPartModel_OnFileDoubleClick(object sender, GHResourceFileDoubleClickEventArgs e)
{ {
if (e.File == null || string.IsNullOrWhiteSpace(e.File.ResourcePath)) if (e.File == null)
return; return;
this.Path = e.File?.ResourcePath; this.Path = e.File?.ResourcePath;
......
...@@ -16,6 +16,6 @@ ...@@ -16,6 +16,6 @@
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="30" d:DesignWidth="200"> d:DesignHeight="30" d:DesignWidth="200">
<Grid> <Grid>
<dxe:CheckEdit x:Name="PART_Check" EditValueChanged="EditValueChanged"></dxe:CheckEdit> <dxe:CheckEdit x:Name="PART_Check" EditValueChanged="EditValueChanged" Margin="10,0,0,0" HorizontalAlignment="Left"></dxe:CheckEdit>
</Grid> </Grid>
</local:ListCellEditBase> </local:ListCellEditBase>
<local:ListCellEditBase x:Class="VIZ.Package.Module.ImageListCellEdit"
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" IsReadOnly="True" 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>
/// ImageListCellEdit.xaml 的交互逻辑
/// </summary>
public partial class ImageListCellEdit : ListCellEditBase
{
public ImageListCellEdit()
{
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();
}
}
}
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
</local:ListEditPanelCellTemplateSelector.BooleanDataTemplate> </local:ListEditPanelCellTemplateSelector.BooleanDataTemplate>
<local:ListEditPanelCellTemplateSelector.ImageDataTemplate> <local:ListEditPanelCellTemplateSelector.ImageDataTemplate>
<DataTemplate> <DataTemplate>
<local:ImageListCellEdit></local:ImageListCellEdit>
</DataTemplate> </DataTemplate>
</local:ListEditPanelCellTemplateSelector.ImageDataTemplate> </local:ListEditPanelCellTemplateSelector.ImageDataTemplate>
</local:ListEditPanelCellTemplateSelector> </local:ListEditPanelCellTemplateSelector>
......
...@@ -74,7 +74,7 @@ namespace VIZ.Package.Module ...@@ -74,7 +74,7 @@ namespace VIZ.Package.Module
IDictionary<string, object> dic = row as IDictionary<string, object>; IDictionary<string, object> dic = row as IDictionary<string, object>;
this.IsSendToPreview = false; this.IsSendToPreview = false;
this.Text = dic == null ? null : dic[columnDefinition.FieldName]?.ToString(); this.Text = dic?[columnDefinition.FieldName]?.ToString();
this.IsSendToPreview = true; this.IsSendToPreview = true;
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
d:DataContext="{d:DesignInstance Type=local:FieldEditWindowModel}" d:DataContext="{d:DesignInstance Type=local:FieldEditWindowModel}"
mc:Ignorable="d" WindowStartupLocation="CenterScreen" mc:Ignorable="d" WindowStartupLocation="CenterScreen"
Title="列表字段编辑" Title="列表字段编辑"
Width="600" Height="450"> Width="1000" Height="600">
<common:NavigationControl ItemsSource="{Binding Path=NavigationConfigs}" <common:NavigationControl ItemsSource="{Binding Path=NavigationConfigs}"
SelectedValue="{Binding Path=SelectedNavigationConfig,Mode=OneWay}"></common:NavigationControl> SelectedValue="{Binding Path=SelectedNavigationConfig,Mode=OneWay}"></common:NavigationControl>
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Package.Domain;
namespace VIZ.Package.Module
{
/// <summary>
/// GH资源选择文件双击事件参数
/// </summary>
public class GHResourceFileDoubleClickEventArgs : EventArgs
{
/// <summary>
/// 文件
/// </summary>
public GHResourceFileModel File { get; set; }
}
}
...@@ -57,8 +57,11 @@ ...@@ -57,8 +57,11 @@
<dxg:GridControl x:Name="fileGrid" Grid.Column="1" ShowBorder="False" <dxg:GridControl x:Name="fileGrid" Grid.Column="1" ShowBorder="False"
ContextMenu="{Binding Path=FileContextMenu,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:GHResourcePanel}}}" ContextMenu="{Binding Path=FileContextMenu,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:GHResourcePanel}}}"
CustomRowFilterCommand="{Binding Path=FileRowFilterCommand}" CustomRowFilterCommand="{Binding Path=FileRowFilterCommand}"
ItemsSource="{Binding Path=FileModels}" ItemsSource="{Binding Path=FileModels}"
SelectedItem="{Binding Path=SelectedFileModel,Mode=TwoWay}"> SelectedItem="{Binding Path=SelectedFileModel,Mode=TwoWay}">
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="MouseDoubleClick" Command="{Binding Path=FileDoubleClickCommand}"></dxmvvm:EventToCommand>
</dxmvvm:Interaction.Behaviors>
<dxg:GridControl.Resources> <dxg:GridControl.Resources>
<!-- 定义Card模板 --> <!-- 定义Card模板 -->
<DataTemplate x:Key="CardTemplate"> <DataTemplate x:Key="CardTemplate">
...@@ -91,6 +94,9 @@ ...@@ -91,6 +94,9 @@
SearchColumns="Name" SearchColumns="Name"
NavigationStyle="Row" NavigationStyle="Row"
CardTemplate="{StaticResource CardTemplate}"/> CardTemplate="{StaticResource CardTemplate}"/>
</dxg:GridControl.View> </dxg:GridControl.View>
</dxg:GridControl> </dxg:GridControl>
......
...@@ -45,6 +45,7 @@ namespace VIZ.Package.Module ...@@ -45,6 +45,7 @@ namespace VIZ.Package.Module
this.RefreshFolderCommand = new VCommand(this.RefreshFolder); this.RefreshFolderCommand = new VCommand(this.RefreshFolder);
this.RefreshFileCommand = new VCommand(this.RefreshFile); this.RefreshFileCommand = new VCommand(this.RefreshFile);
this.FileFilterCommand = new VCommand<ResourceFileType>(this.FileFilter); this.FileFilterCommand = new VCommand<ResourceFileType>(this.FileFilter);
this.FileDoubleClickCommand = new VCommand(this.FileDoubleClick);
} }
/// <summary> /// <summary>
...@@ -65,6 +66,11 @@ namespace VIZ.Package.Module ...@@ -65,6 +66,11 @@ namespace VIZ.Package.Module
/// </summary> /// </summary>
public event EventHandler<GHResourceSelectedFileChangedEventArgs> OnSelectedFileModelChanged; public event EventHandler<GHResourceSelectedFileChangedEventArgs> OnSelectedFileModelChanged;
/// <summary>
/// 文件双击时触发
/// </summary>
public event EventHandler<GHResourceFileDoubleClickEventArgs> OnFileDoubleClick;
// ================================================================================== // ==================================================================================
// Property // Property
// ================================================================================== // ==================================================================================
...@@ -300,6 +306,23 @@ namespace VIZ.Package.Module ...@@ -300,6 +306,23 @@ namespace VIZ.Package.Module
#endregion #endregion
#region FileDoubleClickCommand -- 文件双击命令
/// <summary>
/// 文件双击命令
/// </summary>
public VCommand FileDoubleClickCommand { get; set; }
/// <summary>
/// 文件双击
/// </summary>
private void FileDoubleClick()
{
this.OnFileDoubleClick?.Invoke(this, new GHResourceFileDoubleClickEventArgs { File = this.SelectedFileModel });
}
#endregion
// ================================================================================== // ==================================================================================
// Public Function // Public Function
// ================================================================================== // ==================================================================================
......
...@@ -98,6 +98,9 @@ ...@@ -98,6 +98,9 @@
<Compile Include="ControlObject\FieldEdit\Edit\ListEdit\CellEdit\BooleanListCellEdit.xaml.cs"> <Compile Include="ControlObject\FieldEdit\Edit\ListEdit\CellEdit\BooleanListCellEdit.xaml.cs">
<DependentUpon>BooleanListCellEdit.xaml</DependentUpon> <DependentUpon>BooleanListCellEdit.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="ControlObject\FieldEdit\Edit\ListEdit\CellEdit\ImageListCellEdit.xaml.cs">
<DependentUpon>ImageListCellEdit.xaml</DependentUpon>
</Compile>
<Compile Include="ControlObject\FieldEdit\Edit\ListEdit\ListCellEditBase.cs" /> <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\ListEditPanelModel.cs" /> <Compile Include="ControlObject\FieldEdit\Edit\ListEdit\ListEditPanelModel.cs" />
...@@ -139,6 +142,7 @@ ...@@ -139,6 +142,7 @@
<Compile Include="Plugin\View\PluginView.xaml.cs"> <Compile Include="Plugin\View\PluginView.xaml.cs">
<DependentUpon>PluginView.xaml</DependentUpon> <DependentUpon>PluginView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Resource\GHResource\Core\GHResourceFileDoubleClickEventArgs.cs" />
<Compile Include="Resource\GHResource\Core\GHResourceSelectedFileChangedEventArgs.cs" /> <Compile Include="Resource\GHResource\Core\GHResourceSelectedFileChangedEventArgs.cs" />
<Compile Include="Resource\MediaResource\MediaResourcePluginLifeCycle.cs" /> <Compile Include="Resource\MediaResource\MediaResourcePluginLifeCycle.cs" />
<Compile Include="Resource\MediaResource\ViewModel\MediaResourceViewModel.cs" /> <Compile Include="Resource\MediaResource\ViewModel\MediaResourceViewModel.cs" />
...@@ -243,6 +247,10 @@ ...@@ -243,6 +247,10 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Include="ControlObject\FieldEdit\Edit\ListEdit\CellEdit\ImageListCellEdit.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>
......
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