using DevExpress.Utils;
using DevExpress.Utils.Win;
using DevExpress.Xpo.Helpers;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using HStation.Vmo;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HStation.WinFrmUI
{
public partial class PhartDiagramRelationListCtrl : DevExpress.XtraEditors.XtraUserControl
{
public PhartDiagramRelationListCtrl()
{
InitializeComponent();
}
///
/// 边框可见性
///
public bool BorderVisible
{
get
{
return this.imageListBoxControl1.BorderStyle != BorderStyles.NoBorder;
}
set
{
this.imageListBoxControl1.BorderStyle = value ? BorderStyles.Default : BorderStyles.NoBorder;
}
}
///
/// 选择改变事件
///
public event Action SelectedChangedEvent;
private List _allBindingList = null;
///
/// 绑定数据
///
public void SetBindingData(List allList)
{
_allBindingList = new List();
allList?.OrderBy(x => x.SortCode).ToList()
.ForEach(x => _allBindingList.Add(new PhartDiagramRelationListItemViewModel(x)));
this.phartDiagramRelationListItemViewModelBindingSource.DataSource = _allBindingList;
this.phartDiagramRelationListItemViewModelBindingSource.ResetBindings(false);
}
//选择改变
private void imageListBoxControl1_SelectedValueChanged(object sender, EventArgs e)
{
if (_allBindingList == null)
{
return;
}
var item = this.imageListBoxControl1.SelectedItem;
var vm = item as PhartDiagramRelationListItemViewModel;
if (vm == null)
{
return;
}
this.SelectedChangedEvent?.Invoke(vm.Vmo);
}
private void toolTipController1_GetActiveObjectInfo(object sender, DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventArgs e)
{
if (e.SelectedControl == this.imageListBoxControl1)
{
//e.Info = new ToolTipControlInfo(item, tooltipText);
}
}
}
}