2025-09-04 18:28:02 +08:00
|
|
|
|
using Bricscad.ApplicationServices;
|
2025-08-15 16:34:31 +08:00
|
|
|
|
using Bricscad.EditorInput;
|
|
|
|
|
using Prism.Events;
|
|
|
|
|
using Prism.Ioc;
|
2025-09-04 18:28:02 +08:00
|
|
|
|
using Prism.Services.Dialogs;
|
2025-10-09 18:08:19 +08:00
|
|
|
|
using SWS.CAD.Base;
|
2025-08-15 16:34:31 +08:00
|
|
|
|
using SWS.CAD.CADFunc;
|
|
|
|
|
using SWS.CAD.Event;
|
|
|
|
|
using SWS.CAD.Views;
|
2025-09-04 18:28:02 +08:00
|
|
|
|
using SWS.Commons;
|
|
|
|
|
using SWS.Model;
|
|
|
|
|
using SWS.Service;
|
2025-08-15 16:34:31 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using Telerik.Windows.Controls;
|
|
|
|
|
using Unity;
|
|
|
|
|
using AttributeCollection = System.ComponentModel.AttributeCollection;
|
|
|
|
|
using MessageBox = System.Windows.MessageBox;
|
|
|
|
|
using Visibility = System.Windows.Visibility;
|
|
|
|
|
namespace SWS.CAD.ViewModels
|
|
|
|
|
{
|
|
|
|
|
public class RightPanelViewModel : ViewModelBase
|
|
|
|
|
{
|
|
|
|
|
#region binding
|
|
|
|
|
private ObservableCollection<ec_property> _objecttypeP;
|
|
|
|
|
|
|
|
|
|
public ObservableCollection<ec_property> objecttypeP
|
|
|
|
|
{
|
|
|
|
|
get { return _objecttypeP; }
|
|
|
|
|
set { _objecttypeP = value; RaisePropertyChanged(nameof(objecttypeP)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ObservableCollection<propertyModel> _listShowProperty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 显示属性列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ObservableCollection<propertyModel> listShowProperty
|
|
|
|
|
{
|
|
|
|
|
get { return _listShowProperty; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_listShowProperty = value;
|
|
|
|
|
RaisePropertyChanged(nameof(listShowProperty));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private ObservableCollection<PropertyObjectModel> _listObjects;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 属性列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ObservableCollection<PropertyObjectModel> listObjects
|
|
|
|
|
{
|
|
|
|
|
get { return _listObjects; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_listObjects = value;
|
|
|
|
|
RaisePropertyChanged(nameof(listObjects));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private PropertyObjectModel _SelectObject;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 选中属性
|
|
|
|
|
/// </summary>
|
|
|
|
|
public PropertyObjectModel SelectObject
|
|
|
|
|
{
|
|
|
|
|
get { return _SelectObject; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_SelectObject = value;
|
|
|
|
|
RaisePropertyChanged(nameof(SelectObject));
|
|
|
|
|
changeProObj(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private string _objectTypeName;
|
|
|
|
|
|
|
|
|
|
public string objectTypeName
|
|
|
|
|
{
|
|
|
|
|
get { return _objectTypeName; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(value))
|
|
|
|
|
{ PropertyVisibility = Visibility.Collapsed; }
|
|
|
|
|
else { PropertyVisibility = Visibility.Visible; }
|
|
|
|
|
_objectTypeName = value;
|
|
|
|
|
RaisePropertyChanged(nameof(objectTypeName));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Visibility _PropertyVisibility = Visibility.Collapsed;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否显示属性名称框
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Visibility PropertyVisibility
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _PropertyVisibility;
|
|
|
|
|
}
|
|
|
|
|
set { _PropertyVisibility = value; RaisePropertyChanged(nameof(PropertyVisibility)); }
|
|
|
|
|
}
|
|
|
|
|
private List<ec_enginedata> listEnginedata = new List<ec_enginedata>();
|
|
|
|
|
|
|
|
|
|
private ImageSource _lockImage;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 属性锁
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ImageSource lockImage
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _lockImage;
|
|
|
|
|
}
|
|
|
|
|
set { _lockImage = value; RaisePropertyChanged(nameof(lockImage)); }
|
|
|
|
|
}
|
|
|
|
|
private ImageSource _lock2Image;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 属性锁 Enable为false时灰色
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ImageSource lock2Image
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _lock2Image;
|
|
|
|
|
}
|
|
|
|
|
set { _lock2Image = value; RaisePropertyChanged(nameof(lock2Image)); }
|
|
|
|
|
}
|
|
|
|
|
private ImageSource _historyImage;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 历史属性
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ImageSource historyImage
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _historyImage;
|
|
|
|
|
}
|
|
|
|
|
set { _historyImage = value; RaisePropertyChanged(nameof(historyImage)); }
|
|
|
|
|
}
|
|
|
|
|
private ImageSource _history2Image;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 历史属性 Enable为false时灰色
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ImageSource history2Image
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _history2Image;
|
|
|
|
|
}
|
|
|
|
|
set { _history2Image = value; RaisePropertyChanged(nameof(history2Image)); }
|
|
|
|
|
}
|
|
|
|
|
private ImageSource _qiehuanImage;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 切换属性视图
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ImageSource qiehuanImage
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _qiehuanImage;
|
|
|
|
|
}
|
|
|
|
|
set { _qiehuanImage = value; RaisePropertyChanged(nameof(qiehuanImage)); }
|
|
|
|
|
}
|
|
|
|
|
private string _lockTooltip = "属性未锁定";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 属性锁提示文本
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string lockTooltip
|
|
|
|
|
{
|
|
|
|
|
get { return _lockTooltip; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_lockTooltip = value;
|
|
|
|
|
RaisePropertyChanged(nameof(lockTooltip));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool _isLocked;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否锁定属性
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool isLocked
|
|
|
|
|
{
|
|
|
|
|
get { return _isLocked; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
isEnabledGridProterty = !value;
|
|
|
|
|
isEnabledHistory = !value;
|
|
|
|
|
_isLocked = value;
|
|
|
|
|
RaisePropertyChanged(nameof(isLocked));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private bool _isEnabledGridProterty = true;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Grid是否启用
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool isEnabledGridProterty
|
|
|
|
|
{
|
|
|
|
|
get { return _isEnabledGridProterty; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_isEnabledGridProterty = value;
|
|
|
|
|
RaisePropertyChanged(nameof(isEnabledGridProterty));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private bool _isEnabledLock = false;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 属性锁、查看属性历史 功能是否启用
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool isEnabledLock
|
|
|
|
|
{
|
|
|
|
|
get { return _isEnabledLock; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_isEnabledLock = value;
|
|
|
|
|
RaisePropertyChanged(nameof(isEnabledLock));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private bool _isEnabledHistory = false;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查看属性历史 功能是否启用
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool isEnabledHistory
|
|
|
|
|
{
|
|
|
|
|
get { return _isEnabledHistory; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_isEnabledHistory = value;
|
|
|
|
|
RaisePropertyChanged(nameof(isEnabledHistory));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private string _CurrentPropertyName ;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 选中的属性名称
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string CurrentPropertyName
|
|
|
|
|
{
|
|
|
|
|
get { return _CurrentPropertyName; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_CurrentPropertyName = value;
|
|
|
|
|
RaisePropertyChanged(nameof(CurrentPropertyName));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private bool _isBasicGroup = true;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否属性常用分组
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool isBasicGroup
|
|
|
|
|
{
|
|
|
|
|
get { return _isBasicGroup; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_isBasicGroup = value;
|
|
|
|
|
RaisePropertyChanged(nameof(isBasicGroup));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 绑定事件
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 历史属性
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ICommand Command_History { get; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 属性锁
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ICommand Command_Lock { get; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 切换属性视图
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ICommand Command_Qiehuan { get; }
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
ObjectTypeService _objectTypeService { get; set; }
|
|
|
|
|
private readonly IDialogService _dialogService;
|
|
|
|
|
private Editor _editor = null;
|
|
|
|
|
private Document doc = null;
|
|
|
|
|
private BackgroundWorker _bgwGetProperty = new BackgroundWorker();
|
|
|
|
|
private DateTime workTime = DateTime.Now;
|
|
|
|
|
private List<string> handles = new List<string>();
|
|
|
|
|
private EnginedataService _enginedataService;
|
|
|
|
|
private ImageSource lockImg;
|
|
|
|
|
private ImageSource unlockImg;
|
|
|
|
|
IEventAggregator eventAggregator;
|
|
|
|
|
public RightPanelViewModel(IEventAggregator eventAggregator)
|
|
|
|
|
{
|
|
|
|
|
this.eventAggregator = eventAggregator;
|
|
|
|
|
_objectTypeService = GlobalObject.container.Resolve<ObjectTypeService>();
|
|
|
|
|
_enginedataService = GlobalObject.container.Resolve<EnginedataService>();
|
|
|
|
|
_dialogService = GlobalObject._prismContainer.Resolve<IDialogService>();
|
|
|
|
|
eventAggregator.GetEvent<treeNodeChangeEvent>().Subscribe(onTypeChange, ThreadOption.UIThread, true);
|
|
|
|
|
eventAggregator.GetEvent<tagChangeEvent>().Subscribe(onTagChange, ThreadOption.UIThread, true);
|
|
|
|
|
eventAggregator.GetEvent<drawingChangeEvent>().Subscribe(onDrawingChange, ThreadOption.UIThread, true);
|
|
|
|
|
eventAggregator.GetEvent<selectPixelsEvent>().Subscribe(onSelectPixels, ThreadOption.UIThread, true);
|
|
|
|
|
eventAggregator.GetEvent<propertyChangeEvent>().Subscribe(onPropertyChange, ThreadOption.UIThread, true);
|
|
|
|
|
eventAggregator.GetEvent<getPropertyEvent>().Subscribe(onGetProperty, ThreadOption.UIThread, true);
|
|
|
|
|
listShowProperty = new ObservableCollection<propertyModel>();
|
|
|
|
|
listObjects = new ObservableCollection<PropertyObjectModel>();
|
|
|
|
|
_bgwGetProperty.DoWork += bgwGetProperty_DoWork;
|
|
|
|
|
lockImg = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"SWS.CAD.Images.Lock.png");
|
|
|
|
|
unlockImg = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"SWS.CAD.Images.UnLock.png");
|
|
|
|
|
lockImage = lockImg;
|
|
|
|
|
lock2Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"SWS.CAD.Images.Lock2.png");
|
|
|
|
|
historyImage = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"SWS.CAD.Images.history.png");
|
|
|
|
|
history2Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"SWS.CAD.Images.history2.png");
|
|
|
|
|
qiehuanImage = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"SWS.CAD.Images.qiehuan.png");
|
|
|
|
|
Command_History = new DelegateCommand(onHistory);
|
|
|
|
|
Command_Lock = new DelegateCommand(onLock);
|
|
|
|
|
Command_Qiehuan = new DelegateCommand(onQiehuan);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 在图纸上选择句柄,获取属性
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取选中句柄属性
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="flag"></param>
|
|
|
|
|
private void onGetProperty(List<string> hands)
|
|
|
|
|
{
|
|
|
|
|
handles = hands;
|
|
|
|
|
workTime = DateTime.Now;
|
|
|
|
|
if (!_bgwGetProperty.IsBusy)
|
|
|
|
|
{ _bgwGetProperty.RunWorkerAsync(); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void bgwGetProperty_DoWork(object sender, DoWorkEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var sp = DateTime.Now - workTime;
|
|
|
|
|
if (sp.TotalMilliseconds > 500)//选中句柄500毫秒后去获取属性
|
|
|
|
|
{
|
|
|
|
|
ObservableCollection<PropertyObjectModel> listProObj = new ObservableCollection<PropertyObjectModel>();
|
|
|
|
|
GlobalObject.currentTagNumber = "";
|
|
|
|
|
var dwgName = General.GetDwgName();
|
|
|
|
|
var dwg = GlobalObject.ListDwgOpened.FirstOrDefault(a => a.Path == dwgName);
|
|
|
|
|
if (dwg == null)
|
|
|
|
|
{ return; }
|
|
|
|
|
eventAggregator.GetEvent<GetdwgFileIdEvent>().Publish(dwg.Id);
|
|
|
|
|
//var handles = General.GetSelectedHandles();//通过此方法获取到选中句柄后,会自动取消选中状态
|
|
|
|
|
foreach (var handlId in handles)
|
|
|
|
|
{
|
|
|
|
|
var listEnginedataTemp = new List<ec_enginedata>();
|
|
|
|
|
var dwgFileId = dwg.Id;
|
|
|
|
|
var res = await _objectTypeService.GetTagInfosByPixels(dwgFileId, handlId);//GlobalObject.drawingFileId
|
|
|
|
|
if (res == null || !res.Any())
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (res.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
var item = res[0];
|
|
|
|
|
var objTypeName = item.ObjectTypeName;
|
|
|
|
|
GlobalObject.currentTagNumber = item.tags[0].TagNumber;
|
|
|
|
|
var proObj = listProObj.FirstOrDefault(a => a.objectTypeName == objTypeName);
|
|
|
|
|
if (proObj != null)
|
|
|
|
|
{
|
|
|
|
|
proObj.listHandels.Add(handlId);
|
|
|
|
|
#region 属性
|
|
|
|
|
var listProData = item.tags[0].EngineDataProperty;
|
|
|
|
|
foreach (var data in listProData)
|
|
|
|
|
{
|
|
|
|
|
var pro = proObj.listBasicTypeP.FirstOrDefault(a => a.DisplayText == data.PropertyName);
|
|
|
|
|
if (pro != null)
|
|
|
|
|
{
|
|
|
|
|
pro.DetailId += ";" + data.EngineDataPropertyID;
|
|
|
|
|
if (pro.PropertyValue != data.PropertyValue)
|
|
|
|
|
{
|
|
|
|
|
pro.PropertyValue = "*"; //当属性值不一致时显示*号
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#region 把属性加到缓存列表里,后续修改属性值要用到
|
|
|
|
|
var enginedata = new ec_enginedata()
|
|
|
|
|
{
|
|
|
|
|
EngineDataID = data.EngineDataID,
|
|
|
|
|
TagNumber = item.tags[0].TagNumber,
|
|
|
|
|
ObjectTypeID = item.ObjectTypeID,
|
|
|
|
|
};
|
|
|
|
|
List<ec_enginedata_property> listProperty = new List<ec_enginedata_property>()
|
|
|
|
|
{
|
|
|
|
|
new ec_enginedata_property(){
|
|
|
|
|
EngineDataPropertyID=data.EngineDataPropertyID,
|
|
|
|
|
EngineDataID= data.EngineDataID,
|
|
|
|
|
PropertyName=data.PropertyName,
|
|
|
|
|
PropertyValue=data.PropertyValue,
|
|
|
|
|
MeasuringUnit=data.MeasuringUnit
|
|
|
|
|
} };
|
|
|
|
|
enginedata.EngineDataProperty = listProperty;
|
|
|
|
|
listEnginedataTemp.Add(enginedata);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
proObj.listData.Add(new ProtertyData() { listEnginedata = listEnginedataTemp });
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
proObj = new PropertyObjectModel();
|
|
|
|
|
proObj.listHandels.Add(handlId);
|
|
|
|
|
proObj.objectTypeName = objTypeName;
|
|
|
|
|
proObj.tagNumber = item.tags[0].TagNumber;
|
|
|
|
|
proObj.CreateUserID = item.tags[0].CreateUserID;
|
|
|
|
|
proObj.EngineDataID = item.tags[0].EngineDataID;
|
|
|
|
|
isLocked = item.tags[0].Locked == "1" ? true : false;
|
|
|
|
|
changeLocked(isLocked, proObj.CreateUserID);
|
|
|
|
|
isEnabledLock = true;
|
|
|
|
|
#region 属性
|
|
|
|
|
var model = new propertyModel()
|
|
|
|
|
{
|
|
|
|
|
DisplayText = "位号",
|
|
|
|
|
PropertyValue = item.tags[0].TagNumber,
|
|
|
|
|
ControlTypeName = PROPERTYType.TextBox,
|
|
|
|
|
IsEnable = false,
|
|
|
|
|
IsBasicGroup=true,
|
|
|
|
|
GroupName = item.props[0].PropertyGroupName
|
|
|
|
|
};
|
|
|
|
|
proObj.listBasicTypeP.Add(model);
|
|
|
|
|
var listProData = item.tags[0].EngineDataProperty;
|
|
|
|
|
foreach (var p in item.props)
|
|
|
|
|
{
|
|
|
|
|
model = new propertyModel()
|
|
|
|
|
{
|
|
|
|
|
Id = p.PropertyID,
|
|
|
|
|
DisplayText = p.PropertyName,
|
|
|
|
|
PropertyValue = p.DefaultValue,
|
|
|
|
|
IsReturnChanged = true,
|
|
|
|
|
IsBasicGroup = p.BasicGroup,
|
|
|
|
|
GroupName = p.PropertyGroupName
|
|
|
|
|
};
|
|
|
|
|
switch (p.PropertyType)
|
|
|
|
|
{
|
|
|
|
|
case "00001"://字符
|
|
|
|
|
case "00004"://扩展程序
|
|
|
|
|
model.ControlTypeName = PROPERTYType.TextBox;
|
|
|
|
|
break;
|
|
|
|
|
case "00002"://数字(含小数、负数)
|
|
|
|
|
model.ControlTypeName = PROPERTYType.Number;
|
|
|
|
|
break;
|
|
|
|
|
case "00005"://uom 单位类型 ,例:10 A
|
|
|
|
|
model.UnitTypeId = p.MeasuringUnitTypeID;
|
|
|
|
|
model.ControlTypeName = PROPERTYType.Folder;
|
|
|
|
|
break;
|
|
|
|
|
case "00003"://单选下拉框
|
|
|
|
|
//if (model.DisplayText == "电缆规格")
|
|
|
|
|
//{ model.ControlTypeName = PROPERTYType.MultiSelectComboBox; }
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// model.ControlTypeName = PROPERTYType.ComboBox;
|
|
|
|
|
//}
|
|
|
|
|
model.ControlTypeName = PROPERTYType.ComboBox;
|
|
|
|
|
if (!string.IsNullOrEmpty(p.EnumDataCode))
|
|
|
|
|
{
|
|
|
|
|
var data = p.EnumDataCode.Split(',');
|
|
|
|
|
Dictionary<string, string> items = new Dictionary<string, string>();
|
|
|
|
|
foreach (var k in data)
|
|
|
|
|
{
|
|
|
|
|
items.Add(k, k);
|
|
|
|
|
}
|
|
|
|
|
model.Item = items;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "00006"://多选下拉框
|
|
|
|
|
model.ControlTypeName = PROPERTYType.MultiSelectComboBox;
|
|
|
|
|
if (!string.IsNullOrEmpty(p.EnumDataCode))
|
|
|
|
|
{
|
|
|
|
|
var dataMult = p.EnumDataCode.Split(',');
|
|
|
|
|
Dictionary<string, string> itemsMult = new Dictionary<string, string>();
|
|
|
|
|
foreach (var k in dataMult)
|
|
|
|
|
{
|
|
|
|
|
itemsMult.Add(k, k);
|
|
|
|
|
}
|
|
|
|
|
model.Item = itemsMult;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
var pro = listProData.FirstOrDefault(a => a.PropertyName == p.PropertyName);
|
|
|
|
|
if (pro != null)
|
|
|
|
|
{
|
|
|
|
|
model.Id = pro.EngineDataID;
|
|
|
|
|
model.DetailId = pro.EngineDataPropertyID;
|
|
|
|
|
model.PropertyValue = pro.PropertyValue;
|
|
|
|
|
model.Unit = pro.MeasuringUnit;
|
|
|
|
|
#region 把属性加到缓存列表里,后续修改属性值要用到
|
|
|
|
|
|
|
|
|
|
var enginedata = new ec_enginedata()
|
|
|
|
|
{
|
|
|
|
|
EngineDataID = pro.EngineDataID,
|
|
|
|
|
TagNumber = item.tags[0].TagNumber,
|
|
|
|
|
ObjectTypeID = item.ObjectTypeID,
|
|
|
|
|
};
|
|
|
|
|
List<ec_enginedata_property> listProperty = new List<ec_enginedata_property>()
|
|
|
|
|
{
|
|
|
|
|
new ec_enginedata_property(){
|
|
|
|
|
EngineDataPropertyID=pro.EngineDataPropertyID,
|
|
|
|
|
EngineDataID= pro.EngineDataID,
|
|
|
|
|
PropertyName=pro.PropertyName,
|
|
|
|
|
PropertyValue=pro.PropertyValue,
|
|
|
|
|
MeasuringUnit=pro.MeasuringUnit
|
|
|
|
|
} };
|
|
|
|
|
enginedata.EngineDataProperty = listProperty;
|
|
|
|
|
listEnginedataTemp.Add(enginedata);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
proObj.listBasicTypeP.Add(model);
|
|
|
|
|
}
|
|
|
|
|
proObj.listData.Add(new ProtertyData() { listEnginedata = listEnginedataTemp });
|
|
|
|
|
#endregion
|
|
|
|
|
listProObj.Add(proObj);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
SelectObject = null;
|
|
|
|
|
listObjects = listProObj;
|
|
|
|
|
if (listObjects.Any())
|
|
|
|
|
{
|
|
|
|
|
SelectObject = listObjects[0];
|
|
|
|
|
listShowProperty = SelectObject.listBasicTypeP;
|
|
|
|
|
}
|
|
|
|
|
else { listShowProperty = new ObservableCollection<propertyModel>(); }
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(ex.Message);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下拉框选择不一样的元件类型
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void changeProObj(PropertyObjectModel proObj)
|
|
|
|
|
{
|
|
|
|
|
if (proObj != null)
|
|
|
|
|
{
|
|
|
|
|
listShowProperty = proObj.listBasicTypeP;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 左边列表选中元件类型,右边出现对应属性,左下方出现图元列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="node"></param>
|
2025-09-04 18:28:02 +08:00
|
|
|
|
private async void onTypeChange(Model.TreeModel node)
|
2025-08-15 16:34:31 +08:00
|
|
|
|
{
|
|
|
|
|
if (node != null)
|
|
|
|
|
{
|
|
|
|
|
#region 获取属性,并显示出来
|
|
|
|
|
listShowProperty.Clear();
|
|
|
|
|
var listBasic = new ObservableCollection<propertyModel>();
|
|
|
|
|
var res = await _objectTypeService.GetObjectTypePById(node.ID);
|
|
|
|
|
if (res == null || !res.Any())
|
|
|
|
|
{
|
|
|
|
|
listObjects = new ObservableCollection<PropertyObjectModel>()
|
|
|
|
|
{ new PropertyObjectModel(){
|
|
|
|
|
objectTypeName=node.Text,
|
|
|
|
|
listBasicTypeP=listBasic,
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
SelectObject = listObjects[0];
|
|
|
|
|
isEnabledLock = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 添加位号列表
|
|
|
|
|
//位号下拉列表
|
|
|
|
|
var listTag = await _objectTypeService.GetTagNumberById_Brief(node.ID);
|
|
|
|
|
var pro = new propertyModel()
|
|
|
|
|
{
|
|
|
|
|
DisplayText = "位号",
|
|
|
|
|
ControlTypeName = PROPERTYType.ComboBox,
|
|
|
|
|
IsEnable = true,
|
|
|
|
|
IsBasicGroup = true,
|
|
|
|
|
GroupName = res[0].PropertyGroupName
|
|
|
|
|
};
|
|
|
|
|
if (listTag.Any())
|
|
|
|
|
{
|
|
|
|
|
Dictionary<string, string> items = new Dictionary<string, string>();
|
|
|
|
|
foreach (var dto in listTag)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(dto.Text))
|
|
|
|
|
{ continue; }
|
|
|
|
|
if (items.ContainsKey(dto.Text))
|
|
|
|
|
{ continue; }
|
|
|
|
|
items.Add(dto.Text, dto.Text);
|
|
|
|
|
}
|
|
|
|
|
pro.Item = items;
|
|
|
|
|
listBasic.Add(pro);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
//添加属性
|
|
|
|
|
foreach (var p in res)
|
|
|
|
|
{
|
|
|
|
|
var model = new propertyModel()
|
|
|
|
|
{
|
|
|
|
|
Id = p.PropertyID,
|
|
|
|
|
DisplayText = p.PropertyNameEN,
|
|
|
|
|
PropertyValue = p.DefaultValue,
|
|
|
|
|
Unit = p.DefaultUnitName,
|
|
|
|
|
UnitId = p.DefaultUnit,
|
|
|
|
|
UnitTypeId = p.MeasuringUnitTypeID,
|
|
|
|
|
IsBasicGroup = p.BasicGroup,
|
|
|
|
|
GroupName = p.PropertyGroupName,
|
|
|
|
|
ControlTypeName = PROPERTYType.TextBox
|
|
|
|
|
};
|
|
|
|
|
switch (p.PropertyType)
|
|
|
|
|
{
|
|
|
|
|
case "00001"://字符
|
|
|
|
|
case "00004"://扩展程序
|
|
|
|
|
model.ControlTypeName = PROPERTYType.TextBox;
|
|
|
|
|
break;
|
|
|
|
|
case "00002"://数字(含小数、负数)
|
|
|
|
|
model.ControlTypeName = PROPERTYType.Number;
|
|
|
|
|
break;
|
|
|
|
|
case "00005"://uom 单位类型 ,例:10 A
|
|
|
|
|
model.UnitTypeId = p.MeasuringUnitTypeID;
|
|
|
|
|
model.ControlTypeName = PROPERTYType.Folder;
|
|
|
|
|
break;
|
|
|
|
|
case "00003"://单选下拉框
|
|
|
|
|
model.ControlTypeName = PROPERTYType.ComboBox;
|
|
|
|
|
if (!string.IsNullOrEmpty(p.EnumDataCode))
|
|
|
|
|
{
|
|
|
|
|
var data = p.EnumDataCode.Split(',');
|
|
|
|
|
Dictionary<string, string> items = new Dictionary<string, string>();
|
|
|
|
|
foreach (var e in data)
|
|
|
|
|
{
|
|
|
|
|
items.Add(e, e);
|
|
|
|
|
}
|
|
|
|
|
model.Item = items;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "00006"://多选下拉框
|
|
|
|
|
model.ControlTypeName = PROPERTYType.MultiSelectComboBox;
|
|
|
|
|
if (!string.IsNullOrEmpty(p.EnumDataCode))
|
|
|
|
|
{
|
|
|
|
|
var dataMult = p.EnumDataCode.Split(',');
|
|
|
|
|
Dictionary<string, string> itemsMult = new Dictionary<string, string>();
|
|
|
|
|
foreach (var e in dataMult)
|
|
|
|
|
{
|
|
|
|
|
itemsMult.Add(e, e);
|
|
|
|
|
}
|
|
|
|
|
model.Item = itemsMult;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
listBasic.Add(model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
listObjects = new ObservableCollection<PropertyObjectModel>()
|
|
|
|
|
{ new PropertyObjectModel(){
|
|
|
|
|
objectTypeName=node.Text,
|
|
|
|
|
listBasicTypeP=listBasic,
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
SelectObject = listObjects[0];
|
|
|
|
|
isEnabledLock = false;
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 左边列表选中Tag类型,右边出现对应属性
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="node"></param>
|
2025-09-04 18:28:02 +08:00
|
|
|
|
private async void onTagChange(Model.TreeModel node)
|
2025-08-15 16:34:31 +08:00
|
|
|
|
{
|
|
|
|
|
if (node != null)
|
|
|
|
|
{
|
|
|
|
|
objectTypeName = node.Text;
|
|
|
|
|
#region 获取属性,并显示出来
|
|
|
|
|
listShowProperty.Clear();
|
|
|
|
|
var listBasic = new ObservableCollection<propertyModel>();
|
|
|
|
|
var res = await _objectTypeService.GetTagInfosByTags(node.Text);
|
|
|
|
|
if (!res.Any())
|
|
|
|
|
{
|
|
|
|
|
listShowProperty = listBasic;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (res.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
var item = res[0];
|
|
|
|
|
ShowProperty(item);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
listShowProperty = listBasic;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 左边列表选中图纸,右边出现图纸对应属性
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="node"></param>
|
2025-09-04 18:28:02 +08:00
|
|
|
|
private void onDrawingChange(SWS.Model.ec_drawing_file dwgObj)
|
2025-08-15 16:34:31 +08:00
|
|
|
|
{
|
|
|
|
|
if (dwgObj != null)
|
|
|
|
|
{
|
|
|
|
|
objectTypeName = dwgObj.DrawingFileName;
|
|
|
|
|
|
|
|
|
|
#region 获取属性,并显示出来
|
|
|
|
|
listShowProperty.Clear();
|
|
|
|
|
var listBasic = new ObservableCollection<propertyModel>();
|
|
|
|
|
foreach (System.Reflection.PropertyInfo pro in dwgObj.GetType().GetProperties())
|
|
|
|
|
{
|
|
|
|
|
AttributeCollection attributes = TypeDescriptor.GetProperties(dwgObj)[pro.Name].Attributes;
|
|
|
|
|
DescriptionAttribute myAttribute = (DescriptionAttribute)attributes[typeof(DescriptionAttribute)];
|
|
|
|
|
if (!string.IsNullOrEmpty(myAttribute.Description))
|
|
|
|
|
{
|
|
|
|
|
var model = new propertyModel();
|
|
|
|
|
model.DisplayText = myAttribute.Description;
|
|
|
|
|
var v = dwgObj.GetType().GetProperty(pro.Name).GetValue(dwgObj, null);
|
|
|
|
|
model.PropertyValue = v == null ? "" : v.ToString();
|
|
|
|
|
model.ControlTypeName = PROPERTYType.TextBox;
|
|
|
|
|
model.IsBasicGroup = true;
|
|
|
|
|
model.IsEnable = false;
|
|
|
|
|
var groupAttr = (GroupAttribute)attributes[typeof(GroupAttribute)];
|
|
|
|
|
if (groupAttr != null)
|
|
|
|
|
{
|
|
|
|
|
model.GroupName = groupAttr.GroupName;
|
|
|
|
|
}
|
|
|
|
|
listBasic.Add(model);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
listObjects = new ObservableCollection<PropertyObjectModel>()
|
|
|
|
|
{ new PropertyObjectModel(){ objectTypeName=dwgObj.DrawingFileName} };
|
|
|
|
|
SelectObject = listObjects[0];
|
|
|
|
|
listShowProperty = listBasic;
|
|
|
|
|
isEnabledLock = false;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 图纸上选中元素,则取元素句柄对应属性
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 图纸上选中元素,则取元素句柄对应属性
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="handlId"></param>
|
|
|
|
|
private async void onSelectPixels(string handlId)
|
|
|
|
|
{
|
|
|
|
|
listShowProperty.Clear();
|
|
|
|
|
objectTypeName = "";
|
|
|
|
|
GlobalObject.currentTagNumber = "";
|
|
|
|
|
var dwgName = General.GetDwgName();
|
|
|
|
|
var dwg = GlobalObject.ListDwgOpened.FirstOrDefault(a => a.Path == dwgName);
|
|
|
|
|
if (dwg == null)
|
|
|
|
|
{ return; }
|
|
|
|
|
var listBasic = new ObservableCollection<propertyModel>();
|
|
|
|
|
var dwgFileId = dwg.Id;
|
|
|
|
|
var res = await _objectTypeService.GetTagInfosByPixels(dwgFileId, handlId);//GlobalObject.drawingFileId
|
|
|
|
|
if (!res.Any())
|
|
|
|
|
{
|
|
|
|
|
listShowProperty = listBasic;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (res.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
var item = res[0];
|
|
|
|
|
ShowProperty(item);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
listShowProperty = listBasic;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 把位号的属性显示出来
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 把位号的属性显示出来
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item"></param>
|
|
|
|
|
/// <param name="isReturnChanged">是否属性值改变后,返回事件更新到服务器</param>
|
2025-09-04 18:28:02 +08:00
|
|
|
|
private void ShowProperty(SWS.Model.ec_objecttype item, bool isReturnChanged = false)
|
2025-08-15 16:34:31 +08:00
|
|
|
|
{
|
|
|
|
|
var listBasic = new ObservableCollection<propertyModel>();
|
|
|
|
|
listEnginedata.Clear();
|
|
|
|
|
listObjects = new ObservableCollection<PropertyObjectModel>()
|
|
|
|
|
{ new PropertyObjectModel(){ objectTypeName=item.ObjectTypeName} };
|
|
|
|
|
SelectObject = listObjects[0];
|
|
|
|
|
if (item.tags.Any())
|
|
|
|
|
{
|
|
|
|
|
GlobalObject.currentTagNumber = item.tags[0].TagNumber;
|
|
|
|
|
var model = new propertyModel()
|
|
|
|
|
{
|
|
|
|
|
DisplayText = "位号",
|
|
|
|
|
PropertyValue = item.tags[0].TagNumber,
|
|
|
|
|
ControlTypeName = PROPERTYType.TextBox,
|
|
|
|
|
IsEnable = false,
|
|
|
|
|
IsBasicGroup = true,
|
|
|
|
|
GroupName = item.props[0].PropertyGroupName
|
|
|
|
|
};
|
|
|
|
|
listBasic.Add(model);
|
|
|
|
|
}
|
|
|
|
|
var listPro = item.tags[0].EngineDataProperty;
|
|
|
|
|
foreach (var p in item.props)
|
|
|
|
|
{
|
|
|
|
|
var model = new propertyModel()
|
|
|
|
|
{
|
|
|
|
|
Id = p.PropertyID,
|
|
|
|
|
DisplayText = p.PropertyName,
|
|
|
|
|
PropertyValue = p.DefaultValue,
|
|
|
|
|
IsReturnChanged = isReturnChanged,
|
|
|
|
|
IsBasicGroup = p.BasicGroup,
|
|
|
|
|
GroupName = p.PropertyGroupName
|
|
|
|
|
};
|
|
|
|
|
switch (p.PropertyType)
|
|
|
|
|
{
|
|
|
|
|
case "00001"://字符
|
|
|
|
|
case "00004"://扩展程序
|
|
|
|
|
model.ControlTypeName = PROPERTYType.TextBox;
|
|
|
|
|
break;
|
|
|
|
|
case "00002"://数字(含小数、负数)
|
|
|
|
|
model.ControlTypeName = PROPERTYType.Number;
|
|
|
|
|
break;
|
|
|
|
|
case "00005"://uom 单位类型 ,例:10 A
|
|
|
|
|
//model.UnitId= p.DefaultUnitName;
|
|
|
|
|
//model.Unit = p.DefaultUnitName;
|
|
|
|
|
model.UnitTypeId = p.MeasuringUnitTypeID;
|
|
|
|
|
model.ControlTypeName = PROPERTYType.Folder;
|
|
|
|
|
break;
|
|
|
|
|
case "00003"://单选下拉框
|
|
|
|
|
//if (model.DisplayText == "设备厂家")
|
|
|
|
|
//{ model.ControlTypeName = PROPERTYType.MultiSelectComboBox; }
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// model.ControlTypeName = PROPERTYType.ComboBox;
|
|
|
|
|
//}
|
|
|
|
|
model.ControlTypeName = PROPERTYType.ComboBox;
|
|
|
|
|
if (!string.IsNullOrEmpty(p.EnumDataCode))
|
|
|
|
|
{
|
|
|
|
|
var data = p.EnumDataCode.Split(',');
|
|
|
|
|
Dictionary<string, string> items = new Dictionary<string, string>();
|
|
|
|
|
foreach (var e in data)
|
|
|
|
|
{
|
|
|
|
|
items.Add(e, e);
|
|
|
|
|
}
|
|
|
|
|
model.Item = items;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "00006"://多选下拉框
|
|
|
|
|
model.ControlTypeName = PROPERTYType.MultiSelectComboBox;
|
|
|
|
|
var dataMult = p.EnumDataCode.Split(',');
|
|
|
|
|
Dictionary<string, string> itemsMult = new Dictionary<string, string>();
|
|
|
|
|
foreach (var e in dataMult)
|
|
|
|
|
{
|
|
|
|
|
itemsMult.Add(e, e);
|
|
|
|
|
}
|
|
|
|
|
model.Item = itemsMult;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
var pro = listPro.FirstOrDefault(a => a.PropertyName == p.PropertyName);
|
|
|
|
|
if (pro != null)
|
|
|
|
|
{
|
|
|
|
|
model.Id = pro.EngineDataID;
|
|
|
|
|
model.DetailId = pro.EngineDataPropertyID;
|
|
|
|
|
model.PropertyValue = pro.PropertyValue;
|
|
|
|
|
model.Unit = pro.MeasuringUnit;
|
|
|
|
|
#region 把属性加到缓存列表里,后续修改属性值要用到
|
|
|
|
|
//var enginedata = new ec_enginedata()
|
|
|
|
|
//{
|
|
|
|
|
// EngineDataID = pro.EngineDataID,
|
|
|
|
|
// TagNumber = item.tags[0].TagNumber,
|
|
|
|
|
// ObjectTypeID = item.ObjectTypeID,
|
|
|
|
|
//};
|
|
|
|
|
//List<ec_enginedata_property> listProperty = new List<ec_enginedata_property>()
|
|
|
|
|
// {
|
|
|
|
|
// new ec_enginedata_property(){
|
|
|
|
|
// EngineDataPropertyID=pro.EngineDataPropertyID,
|
|
|
|
|
// EngineDataID= pro.EngineDataID,
|
|
|
|
|
// PropertyName=pro.PropertyName,
|
|
|
|
|
// PropertyValue=pro.PropertyValue,
|
|
|
|
|
// MeasuringUnit=pro.MeasuringUnit
|
|
|
|
|
// } };
|
|
|
|
|
//enginedata.EngineDataProperty = listProperty;
|
|
|
|
|
//listEnginedata.Add(enginedata);
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
listBasic.Add(model);
|
|
|
|
|
}
|
|
|
|
|
listShowProperty = listBasic;
|
|
|
|
|
isEnabledLock = false;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 属性值改变事件
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 属性值改变事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="model"></param>
|
|
|
|
|
private async void onPropertyChange(propertyModel model)
|
|
|
|
|
{
|
2025-09-04 18:28:02 +08:00
|
|
|
|
SWS.Model.ec_enginedata dto = null;
|
2025-08-15 16:34:31 +08:00
|
|
|
|
string strOldValue = "";
|
|
|
|
|
string strOldUnit = "";
|
|
|
|
|
if (SelectObject == null)
|
|
|
|
|
{ return; }
|
|
|
|
|
if (model.PropertyValue=="*")
|
|
|
|
|
{ return; }
|
|
|
|
|
foreach (var data in SelectObject.listData)
|
|
|
|
|
{
|
|
|
|
|
foreach (var enginedata in data.listEnginedata)
|
|
|
|
|
{
|
|
|
|
|
var pro = enginedata.EngineDataProperty.FirstOrDefault(a => model.DetailId.Contains(a.EngineDataPropertyID));
|
|
|
|
|
if (pro != null)
|
|
|
|
|
{
|
|
|
|
|
strOldValue = pro.PropertyValue;
|
|
|
|
|
strOldUnit = pro.MeasuringUnit;
|
|
|
|
|
pro.PropertyValue = model.PropertyValue;
|
|
|
|
|
pro.MeasuringUnit = model.Unit;
|
|
|
|
|
dto = enginedata;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (dto != null && (strOldValue != model.PropertyValue || strOldUnit != model.Unit))
|
|
|
|
|
{
|
2025-09-04 18:28:02 +08:00
|
|
|
|
var flag = await _objectTypeService.UpdatePixelAndPropBatch(new List<SWS.Model.ec_enginedata>() { dto });
|
2025-08-15 16:34:31 +08:00
|
|
|
|
string strUnit = string.IsNullOrEmpty(model.Unit) ? "" : $",单位:{model.Unit}";
|
|
|
|
|
General.SendMessage($"属性:{model.DisplayText},值:{model.PropertyValue} {strUnit} 保存成功!");
|
|
|
|
|
|
|
|
|
|
#region 更新列表里属性数据
|
|
|
|
|
|
|
|
|
|
var item = listShowProperty.FirstOrDefault(a => a.DetailId == model.DetailId);
|
|
|
|
|
if (item != null)
|
|
|
|
|
{
|
|
|
|
|
item.PropertyValue = model.PropertyValue;
|
|
|
|
|
}
|
|
|
|
|
item.PropertyValue = model.PropertyValue;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
//刷新UI
|
|
|
|
|
if (model.IsRefreshUI)
|
|
|
|
|
{
|
|
|
|
|
listShowProperty = new ObservableCollection<propertyModel>(listShowProperty);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 历史属性
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 历史属性
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void onHistory(object obj)
|
|
|
|
|
{
|
|
|
|
|
if (SelectObject == null ||string.IsNullOrEmpty(SelectObject.tagNumber))
|
|
|
|
|
{ return; }
|
|
|
|
|
if ( string.IsNullOrEmpty(CurrentPropertyName))
|
|
|
|
|
{ return; }
|
2025-09-04 18:28:02 +08:00
|
|
|
|
IDialogParameters x = new Prism.Services.Dialogs.DialogParameters();
|
2025-08-15 16:34:31 +08:00
|
|
|
|
x.Add(GlobalObject.dialogPar.para1.ToString(), SelectObject.tagNumber);
|
|
|
|
|
x.Add(GlobalObject.dialogPar.para2.ToString(), CurrentPropertyName);
|
|
|
|
|
var _dialogService = GlobalObject._prismContainer.Resolve<IDialogService>();
|
|
|
|
|
_dialogService.ShowDialog(nameof(DialogPropertyHistory), x, (RES) =>
|
|
|
|
|
{
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 属性锁
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 属性锁
|
|
|
|
|
/// </summary>
|
|
|
|
|
private async void onLock(object obj)
|
|
|
|
|
{
|
|
|
|
|
if (SelectObject == null)
|
|
|
|
|
{ return; }
|
|
|
|
|
if (SelectObject.CreateUserID.ToLower() != GlobalObject.userInfo.userId.ToLower())
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("抱歉,非元件创建者您没有该元件锁定与解锁权限!", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (isLocked)
|
|
|
|
|
{
|
|
|
|
|
//进行解锁
|
|
|
|
|
var msg = await _enginedataService.LockTag(SelectObject.EngineDataID, "0");
|
|
|
|
|
if (string.IsNullOrEmpty(msg))
|
|
|
|
|
{
|
|
|
|
|
changeLocked(false);
|
|
|
|
|
General.SendMessage($"元件:{SelectObject.objectTypeName},已解锁!");
|
|
|
|
|
}
|
|
|
|
|
else { MessageBox.Show(msg); }
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//进行锁定属性
|
|
|
|
|
var msg = await _enginedataService.LockTag(SelectObject.EngineDataID, "1");
|
|
|
|
|
if (string.IsNullOrEmpty(msg))
|
|
|
|
|
{
|
|
|
|
|
changeLocked(true, GlobalObject.userInfo.userId);
|
|
|
|
|
General.SendMessage($"元件:{SelectObject.objectTypeName},已被【{GlobalObject.userInfo.userId}】锁定!");
|
|
|
|
|
}
|
|
|
|
|
else { MessageBox.Show(msg); }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 改变属性锁状态
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="flag">是否锁定</param>
|
|
|
|
|
/// <param name="userId">锁定属性的用户id</param>
|
|
|
|
|
private void changeLocked(bool flag, string userId = "")
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (flag)
|
|
|
|
|
{
|
|
|
|
|
isLocked = true;
|
|
|
|
|
lockTooltip = $"属性被({userId})锁定";
|
|
|
|
|
lockImage = lockImg;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
isLocked = false;
|
|
|
|
|
lockTooltip = "属性未锁定";
|
|
|
|
|
lockImage = unlockImg;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 历史属性
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 历史属性
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void onQiehuan(object obj)
|
|
|
|
|
{
|
|
|
|
|
if (listShowProperty.Any())
|
|
|
|
|
{
|
|
|
|
|
isBasicGroup = !isBasicGroup;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|