Commit 0a7cf5aa by liulongfei

1. 关闭系统时提示是否关闭Viz引擎

2. 添加Float类型编辑器
parent cf62a529
<UserControl x:Class="VIZ.Package.Module.FloatEditPanel"
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:DataContext="{d:DesignInstance Type=local:FloatEditPanelModel}"
d:Background="White"
mc:Ignorable="d"
d:DesignHeight="50" d:DesignWidth="600">
<Grid VerticalAlignment="Top" Margin="0,20,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="40"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="值:" VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
<dxe:TextEdit AcceptsReturn="True" VerticalAlignment="Top" HorizontalAlignment="Left"
Width="200" Grid.Column="1"
MaskType="Numeric" Margin="20,0,0,0"
EditValue="{Binding Path=EditValue,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"></dxe:TextEdit>
</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>
/// FloatEditPanel.xaml 的交互逻辑
/// </summary>
public partial class FloatEditPanel : UserControl
{
public FloatEditPanel()
{
InitializeComponent();
WPFHelper.BindingViewModel(this, new FloatEditPanelModel());
}
}
}
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.Package.Domain;
using VIZ.Package.Service;
namespace VIZ.Package.Module
{
/// <summary>
/// 浮点数字编辑面板模型
/// </summary>
public class FloatEditPanelModel : EditPanelModelBase
{
// ============================================================
// Property
// ============================================================
private double editValue;
/// <summary>
/// 编辑值
/// </summary>
public double EditValue
{
get { return editValue; }
set
{
editValue = value;
this.RaisePropertyChanged(nameof(EditValue));
this.OnEditValueChanged();
}
}
// ============================================================
// Message
// ============================================================
// ============================================================
// Public Function
// ============================================================
/// <summary>
/// 更新
/// </summary>
/// <param name="controlObject">控制对象</param>
/// <param name="controlField">控制字段</param>
public override void Update(ControlObjectModel controlObject, ControlFieldNodeModel controlField)
{
base.Update(controlObject, controlField);
this.IsSendToPreview = false;
double.TryParse(controlField?.Value, out double value);
this.EditValue = 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;
double.TryParse(dic?[columnDefinition.FieldName]?.ToString(), out double value);
this.EditValue = value;
this.IsSendToPreview = true;
}
/// <summary>
/// 获取字段值
/// </summary>
/// <returns>字段值</returns>
public override string GetFieldValue()
{
return this.EditValue.ToString();
}
// ============================================================
// Private Function
// ============================================================
/// <summary>
/// 值改变时触发
/// </summary>
private void OnEditValueChanged()
{
// 不需要向预览发送值
if (!this.IsSendToPreview)
return;
// 没有预览连接
if (ApplicationDomainEx.PreviewConn == null)
return;
// 没有控制对象或控制字段
if (this.ControlObject == null || this.ControlField == null)
return;
// 正常模式编辑
if (this.FieldEditMode == FieldEditMode.Normal)
{
this.ControlField.Value = this.EditValue.ToString();
this.VizCommandControlObjectService.SetControlObjectValue(
ApplicationDomainEx.PreviewConn,
this.ControlObject.TreeNodePath,
this.ControlField.FieldIdentifier,
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.EditValue.ToString();
this.ListCellEdit.UpdateEditValue(this.ColumnDefinition, this.RowHandle, this.Row);
return;
}
}
}
}
<local:ListCellEditBase x:Class="VIZ.Package.Module.FloatListCellEdit"
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:TextEdit x:Name="PART_Text"
MaskType="Numeric" EditValueChanged="EditValueChanged"></dxe:TextEdit>
</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>
/// FloatListCellEdit.xaml 的交互逻辑
/// </summary>
public partial class FloatListCellEdit : ListCellEditBase
{
public FloatListCellEdit()
{
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;
double.TryParse(cellData?.Value?.ToString(), out double value);
this.PART_Text.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;
// 向Viz发送指令
this.VizCommandControlObjectService.SetControlObjectListValue(
ApplicationDomainEx.PreviewConn,
columnDefinition.ControlObject.TreeNodePath,
columnDefinition.ControlField.FieldIdentifier,
cellData.RowData.RowHandle.Value,
columnDefinition.FieldName,
e.NewValue?.ToString());
}
}
}
...@@ -78,6 +78,12 @@ ...@@ -78,6 +78,12 @@
<local:IntegerListCellEdit></local:IntegerListCellEdit> <local:IntegerListCellEdit></local:IntegerListCellEdit>
</DataTemplate> </DataTemplate>
</local:ListEditPanelCellTemplateSelector.IntegerDataTemplate> </local:ListEditPanelCellTemplateSelector.IntegerDataTemplate>
<!-- 浮点数字 -->
<local:ListEditPanelCellTemplateSelector.FloatDataTemplate>
<DataTemplate>
<local:FloatListCellEdit></local:FloatListCellEdit>
</DataTemplate>
</local:ListEditPanelCellTemplateSelector.FloatDataTemplate>
</local:ListEditPanelCellTemplateSelector> </local:ListEditPanelCellTemplateSelector>
<!-- 列定义模板 --> <!-- 列定义模板 -->
......
...@@ -43,6 +43,11 @@ namespace VIZ.Package.Module ...@@ -43,6 +43,11 @@ namespace VIZ.Package.Module
public DataTemplate IntegerDataTemplate { get; set; } public DataTemplate IntegerDataTemplate { get; set; }
/// <summary> /// <summary>
/// 浮点数字
/// </summary>
public DataTemplate FloatDataTemplate { get; set; }
/// <summary>
/// 二元组 /// 二元组
/// </summary> /// </summary>
public DataTemplate DupletDataTemplate { get; set; } public DataTemplate DupletDataTemplate { get; set; }
...@@ -72,6 +77,7 @@ namespace VIZ.Package.Module ...@@ -72,6 +77,7 @@ namespace VIZ.Package.Module
case VizControlFieldType.text: return this.TextDataTemplate; case VizControlFieldType.text: return this.TextDataTemplate;
case VizControlFieldType.boolean: return this.BooleanDataTemplate; case VizControlFieldType.boolean: return this.BooleanDataTemplate;
case VizControlFieldType.integer: return this.IntegerDataTemplate; case VizControlFieldType.integer: return this.IntegerDataTemplate;
case VizControlFieldType.@float: return this.FloatDataTemplate;
case VizControlFieldType.richtext: return this.RichTextDataTemplate; case VizControlFieldType.richtext: return this.RichTextDataTemplate;
case VizControlFieldType.image: return this.ImageDataTemplate; case VizControlFieldType.image: return this.ImageDataTemplate;
case VizControlFieldType.list: return this.TextDataTemplate; case VizControlFieldType.list: return this.TextDataTemplate;
......
...@@ -79,6 +79,14 @@ namespace VIZ.Package.Module ...@@ -79,6 +79,14 @@ namespace VIZ.Package.Module
ViewCreated = this.OnViewCreated ViewCreated = this.OnViewCreated
}); });
// 浮点数字
this.NavigationConfigs.Add(new NavigationConfig
{
Key = VizControlFieldType.@float.ToString(),
ViewType = typeof(FloatEditPanel),
ViewCreated = this.OnViewCreated
});
// 二元编辑 // 二元编辑
this.NavigationConfigs.Add(new NavigationConfig this.NavigationConfigs.Add(new NavigationConfig
{ {
......
using log4net; using DevExpress.Xpf.Core;
using log4net;
using System; using System;
using System.Collections.Generic; 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.Windows;
using VIZ.Framework.Core; using VIZ.Framework.Core;
using VIZ.Package.Connection; using VIZ.Package.Connection;
using VIZ.Package.Domain; using VIZ.Package.Domain;
...@@ -69,6 +71,7 @@ namespace VIZ.Package.Module ...@@ -69,6 +71,7 @@ namespace VIZ.Package.Module
private void initMessage() private void initMessage()
{ {
ApplicationDomainEx.MessageManager.Register<PageOpenMessage>(this, this.OnPageOpenMessage); ApplicationDomainEx.MessageManager.Register<PageOpenMessage>(this, this.OnPageOpenMessage);
ApplicationDomainEx.MessageManager.Register<ApplicationCloseMessage>(this, this.OnApplicationCloseMessage);
} }
// ================================================================================ // ================================================================================
...@@ -488,6 +491,28 @@ namespace VIZ.Package.Module ...@@ -488,6 +491,28 @@ namespace VIZ.Package.Module
}); });
} }
/// <summary>
/// 应用程序关闭消息
/// </summary>
/// <param name="msg">消息</param>
private void OnApplicationCloseMessage(ApplicationCloseMessage msg)
{
if (ApplicationDomainEx.VizPreviewProcess == null || ApplicationDomainEx.VizPreviewProcess.HasExited)
return;
if (DXMessageBox.Show("是否关闭Viz引擎?", "提示", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
return;
try
{
ApplicationDomainEx.VizPreviewProcess.Kill();
}
catch (Exception ex)
{
log.Error(ex);
}
}
// ================================================================================ // ================================================================================
// Public Function // Public Function
// ================================================================================ // ================================================================================
......
...@@ -90,6 +90,13 @@ ...@@ -90,6 +90,13 @@
<Reference Include="WindowsFormsIntegration" /> <Reference Include="WindowsFormsIntegration" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="ControlObject\FieldEdit\Edit\FloatEdit\FloatEditPanel.xaml.cs">
<DependentUpon>FloatEditPanel.xaml</DependentUpon>
</Compile>
<Compile Include="ControlObject\FieldEdit\Edit\FloatEdit\FloatEditPanelModel.cs" />
<Compile Include="ControlObject\FieldEdit\Edit\ListEdit\CellEdit\FloatListCellEdit.xaml.cs">
<DependentUpon>FloatListCellEdit.xaml</DependentUpon>
</Compile>
<Compile Include="Help\About\View\AboutWindow.xaml.cs"> <Compile Include="Help\About\View\AboutWindow.xaml.cs">
<DependentUpon>AboutWindow.xaml</DependentUpon> <DependentUpon>AboutWindow.xaml</DependentUpon>
</Compile> </Compile>
...@@ -334,6 +341,14 @@ ...@@ -334,6 +341,14 @@
<Folder Include="Main\Controller\" /> <Folder Include="Main\Controller\" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Page Include="ControlObject\FieldEdit\Edit\FloatEdit\FloatEditPanel.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="ControlObject\FieldEdit\Edit\ListEdit\CellEdit\FloatListCellEdit.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Help\About\View\AboutWindow.xaml"> <Page Include="Help\About\View\AboutWindow.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
......
...@@ -28,6 +28,7 @@ namespace VIZ.Package.Service ...@@ -28,6 +28,7 @@ namespace VIZ.Package.Service
VizControlFieldType.boolean, VizControlFieldType.boolean,
VizControlFieldType.image, VizControlFieldType.image,
VizControlFieldType.integer, VizControlFieldType.integer,
VizControlFieldType.@float,
VizControlFieldType.duplet, VizControlFieldType.duplet,
VizControlFieldType.triplet VizControlFieldType.triplet
}; };
...@@ -376,6 +377,9 @@ namespace VIZ.Package.Service ...@@ -376,6 +377,9 @@ namespace VIZ.Package.Service
if (type == "integer") if (type == "integer")
return VizControlFieldType.integer; return VizControlFieldType.integer;
if (type == "float")
return VizControlFieldType.@float;
if (type == "duplet") if (type == "duplet")
return VizControlFieldType.duplet; return VizControlFieldType.duplet;
......
...@@ -55,6 +55,12 @@ namespace VIZ.Package.Storage ...@@ -55,6 +55,12 @@ namespace VIZ.Package.Storage
integer, integer,
/// <summary> /// <summary>
/// 浮点数字
/// </summary>
[Description("浮点数字")]
@float,
/// <summary>
/// 二元组 /// 二元组
/// </summary> /// </summary>
[Description("二元组")] [Description("二元组")]
......
...@@ -31,13 +31,14 @@ namespace VIZ.Package ...@@ -31,13 +31,14 @@ namespace VIZ.Package
{ {
InitializeComponent(); InitializeComponent();
this.Closing += MainWindow_Closing;
this.Closed += MainWindow_Closed; this.Closed += MainWindow_Closed;
} }
/// <summary> /// <summary>
/// 关闭窗口 /// 关闭窗口前触发
/// </summary> /// </summary>
private void MainWindow_Closed(object sender, EventArgs e) private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{ {
// 发送系统关闭消息 // 发送系统关闭消息
try try
...@@ -49,7 +50,13 @@ namespace VIZ.Package ...@@ -49,7 +50,13 @@ namespace VIZ.Package
{ {
log.Error(ex); log.Error(ex);
} }
}
/// <summary>
/// 关闭窗口
/// </summary>
private void MainWindow_Closed(object sender, EventArgs e)
{
// 启动结束流程 // 启动结束流程
AppSetup.ShutDown(); AppSetup.ShutDown();
......
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