| | |
| | | using DevExpress.XtraEditors; |
| | | using HStation.Vmo; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | | using HStation.Vmo; |
| | | using System.Data; |
| | | using System.Drawing; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using System.Windows.Forms; |
| | | using Yw; |
| | | |
| | | namespace HStation.WinFrmUI |
| | |
| | | { |
| | | InitializeComponent(); |
| | | this.gridView1.SetNormalView(); |
| | | this.gridView1.RegistCustomDrawCell(Color.BurlyWood, Color.White); |
| | | this.gridView1.RegistCustomDrawCell(); |
| | | } |
| | | |
| | | private List<PhartDiagramRelationGridItemViewModel> _allBindingList = null;//所有绑定列表 |
| | | |
| | | private string _objectType; |
| | | |
| | | public Action<PhartDiagramRelationExtensionsVmo> SelectDataEvent; |
| | | |
| | | /// <summary> |
| | | /// 绑定数据 |
| | | /// </summary> |
| | | public async void SetBindingData(string objectType, long objectId) |
| | | public async void SetBindingData(string objectType, long objectId, long? curveId) |
| | | { |
| | | _objectType = objectType; |
| | | var allList = await BLLFactory<HStation.BLL.PhartDiagramRelation>.Instance.GetByObjectTypeAndObjectID(objectType, objectId); |
| | | SetBindingData(allList); |
| | | SetBindingData(allList, curveId); |
| | | gridView1_FocusedRowChanged(null, null); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 绑定数据 |
| | | /// </summary> |
| | | public void SetBindingData(List<PhartDiagramRelationVmo> allList) |
| | | public void SetBindingData(List<PhartDiagramRelationVmo> allList, long? curveId) |
| | | { |
| | | _allBindingList = new List<PhartDiagramRelationGridItemViewModel>(); |
| | | allList?.OrderBy(x => x.SortCode).ToList().ForEach(x => _allBindingList.Add(new PhartDiagramRelationGridItemViewModel(x))); |
| | | this.phartDiagramRelationGridItemViewModelBindingSource.DataSource = _allBindingList; |
| | | this.phartDiagramRelationGridItemViewModelBindingSource.ResetBindings(false); |
| | | if (curveId != null) |
| | | { |
| | | for (int i = 0; i < _allBindingList.Count; i++) |
| | | { |
| | | if (_allBindingList[i].ID == curveId) |
| | | { |
| | | gridView1.FocusedRowHandle = i; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //行点击事件 |
| | |
| | | dlg.ShowDialog(); |
| | | } |
| | | } |
| | | |
| | | //行变化事件 |
| | | private async void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) |
| | | { |
| | | var vm = this.gridView1.GetCurrentViewModel(_allBindingList); |
| | | if (vm == null) |
| | | return; |
| | | var list = await new BLL.PhartDiagramRelation().GetExByObjectTypeAndObjectID(_objectType, vm.Vmo.ObjectID); |
| | | var targetItem = list.FirstOrDefault(x => x.ID == vm.ID); |
| | | if (targetItem != null) |
| | | { |
| | | SelectDataEvent.Invoke(targetItem); |
| | | } |
| | | } |
| | | } |
| | | } |