using DevExpress.XtraPrinting;
|
|
namespace HStation.WinFrmUI
|
{
|
public partial class XhsProjectImportRevitAnalysisResultCtrl : DevExpress.XtraEditors.XtraUserControl
|
{
|
public XhsProjectImportRevitAnalysisResultCtrl()
|
{
|
InitializeComponent();
|
this.gridView1.SetNormalView(30);
|
this.gridView1.RegistCustomDrawRowIndicator(40);
|
InitialPropStatus();
|
this.generalSearchAndExportCtrl1.SearchEvent += Search;
|
this.generalSearchAndExportCtrl1.ClearEvent += Clear;
|
this.generalSearchAndExportCtrl1.ExportEvent += Export;
|
}
|
|
|
|
|
|
private List<XhsProjectImportRevitAnalysisResultViewModel> _allList = null;
|
private List<XhsProjectImportRevitAnalysisResultViewModel> _allBindingList;
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(Model.RevitModel revitModel)
|
{
|
if (revitModel == null)
|
{
|
return;
|
}
|
_allList = new List<XhsProjectImportRevitAnalysisResultViewModel>();
|
var allParterList = revitModel.GetAllParters();
|
foreach (var parter in allParterList)
|
{
|
if (parter.PropStatusList != null && parter.PropStatusList.Count > 0)
|
{
|
foreach (var propStatus in parter.PropStatusList)
|
{
|
if (propStatus.PropStatus == Revit.ePropStatus.Normal)
|
{
|
continue;
|
}
|
_allList.Add(new XhsProjectImportRevitAnalysisResultViewModel(parter, propStatus));
|
}
|
}
|
}
|
Search();
|
}
|
|
//查询
|
private void Search()
|
{
|
_allBindingList = _allList?.ToList();
|
var catalog = this.txtCatalog.Text.Trim();
|
if (!string.IsNullOrEmpty(catalog))
|
{
|
_allBindingList = _allBindingList?.Where(x => !string.IsNullOrEmpty(x.Catalog) && x.Catalog.Contains(catalog)).ToList();
|
}
|
var name = this.txtName.Text.Trim();
|
if (!string.IsNullOrEmpty(name))
|
{
|
_allBindingList = _allBindingList?.Where(x => !string.IsNullOrEmpty(x.Name) && x.Name.Contains(name)).ToList();
|
}
|
var code = this.txtCode.Text.Trim();
|
if (!string.IsNullOrEmpty(code))
|
{
|
_allBindingList = _allBindingList?.Where(x => !string.IsNullOrEmpty(x.Code) && x.Code.Contains(code)).ToList();
|
}
|
Revit.ePropStatus? propStatus = this.imgCmbPropStatus.EditValue == null ? null : (Revit.ePropStatus)this.imgCmbPropStatus.EditValue;
|
if (propStatus.HasValue)
|
{
|
_allBindingList = _allBindingList?.Where(x => x.PropStatus == propStatus.Value).ToList();
|
}
|
this.xhsProjectImportRevitAnalysisResultViewModelBindingSource.DataSource = _allBindingList;
|
this.xhsProjectImportRevitAnalysisResultViewModelBindingSource.ResetBindings(false);
|
}
|
|
//清理
|
private void Clear()
|
{
|
this.txtCatalog.EditValue = null;
|
this.txtName.EditValue = null;
|
this.txtCode.EditValue = null;
|
this.imgCmbPropStatus.EditValue = null;
|
Search();
|
}
|
|
//导出
|
private void Export()
|
{
|
var dlg = new SaveFileDialog();
|
dlg.Title = "Excel导出";
|
dlg.Filter = "Excel文件|*.xls";
|
if (dlg.ShowDialog() == DialogResult.OK)
|
{
|
this.gridView1.ExportToXls(dlg.FileName);
|
}
|
}
|
|
private void InitialPropStatus()
|
{
|
this.imgCmbPropStatus.Properties.BeginUpdate();
|
this.imgCmbPropStatus.Properties.Items.Clear();
|
this.imgCmbPropStatus.Properties.Items.Add("全部", null, -1);
|
this.imgCmbPropStatus.Properties.Items.Add(Revit.ePropStatus.Lack.GetDisplayText(), Revit.ePropStatus.Lack, -1);
|
this.imgCmbPropStatus.Properties.Items.Add(Revit.ePropStatus.Abnormal.GetDisplayText(), Revit.ePropStatus.Abnormal, -1);
|
this.imgCmbPropStatus.Properties.Items.Add(Revit.ePropStatus.Error.GetDisplayText(), Revit.ePropStatus.Error, -1);
|
this.imgCmbPropStatus.Properties.EndUpdate();
|
}
|
|
//自定义单元格颜色
|
private void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
|
{
|
var row = this.gridView1.GetRow(e.RowHandle) as XhsProjectImportRevitAnalysisResultViewModel;
|
if (row == null)
|
{
|
return;
|
}
|
if (e.RowHandle != this.gridView1.FocusedRowHandle)
|
{
|
switch (row.PropStatus)
|
{
|
case Revit.ePropStatus.Lack:
|
{
|
e.Appearance.BackColor = Color.Gray;
|
e.Appearance.ForeColor = Color.White;
|
}
|
break;
|
case Revit.ePropStatus.Abnormal:
|
{
|
e.Appearance.BackColor = Color.Orange;
|
e.Appearance.ForeColor = Color.White;
|
}
|
break;
|
case Revit.ePropStatus.Error:
|
{
|
e.Appearance.BackColor = Color.Red;
|
e.Appearance.ForeColor = Color.White;
|
}
|
break;
|
default: break;
|
}
|
};
|
}
|
|
|
}
|
}
|