// ***********************************************************************
// Assembly : Construction
// Author : flythink
// Created : 06-15-2020
//
// Last Modified By : flythink
// Last Modified On : 09-01-2020
// ***********************************************************************
//
// Copyright (c) jindongfang. All rights reserved.
//
//
// ***********************************************************************
namespace WellWorkDataUI.CustomControls
{
using Fk.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using WorkData.Entity;
///
/// 层位选择
///
public partial class FrmExportPicker : DevExpress.XtraEditors.XtraForm
{
private List layerData = new List();
private SlowDownTimer onceTimer = new SlowDownTimer(1000);
///
/// Initializes a new instance of the class.
///
/// SysDataTree collection
public FrmExportPicker(IEnumerable collection)
{
this.InitializeComponent();
this.layerData.AddRange(collection.Select(o => new ExportData(o)));
this.gridControl1.DataSource = this.layerData;
}
///
/// Gets the selected layers.
///
/// The selected layers.
public List SelectedItems => this.layerData
.Where(r => r.Checked)
.Select(o => o.Data)
.ToList();
private void BtnCancel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
this.DialogResult = DialogResult.Cancel;
}
private void BtnCheck_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
this.winExplorerView1.BeginDataUpdate();
foreach (ExportData item in this.layerData)
{
item.Checked = true;
}
this.winExplorerView1.EndDataUpdate();
}
private void BtnOK_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
this.DialogResult = DialogResult.OK;
}
private void BtnReverseCheck_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
this.winExplorerView1.BeginDataUpdate();
foreach (ExportData item in this.layerData)
{
item.Checked = !item.Checked;
}
this.winExplorerView1.EndDataUpdate();
}
private void FilterView(string text)
{
if (!string.IsNullOrWhiteSpace(text))
{
this.winExplorerView1.ActiveFilterString = string.Format("Contains([gcName],'{0}')", text);
}
else
{
this.winExplorerView1.ActiveFilterString = string.Empty;
}
}
private void Grid_CustomUnboundColumnData(
object sender,
DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
{
if (e.Row is ExportData data)
{
if (e.IsGetData)
{
if (e.Column == this.gcCheck)
{
e.Value = data.Checked;
}
else if (e.Column == this.gcName)
{
e.Value = data.Name;
}
else if (e.Column == this.gcGroup)
{
e.Value = data.Group;
}
}
else if (e.IsSetData)
{
if (e.Column == this.gcCheck)
{
data.Checked = Convert.ToBoolean(e.Value);
}
}
}
}
private void RepositoryItemSearchControl1_EditValueChanging(
object sender,
DevExpress.XtraEditors.Controls.ChangingEventArgs e)
{
this.onceTimer.Invoke(() => this.FilterView(e.NewValue?.ToString()));
}
///
/// Class ExportData.
///
public class ExportData
{
///
/// Initializes a new instance of the class.
///
/// The wb.
public ExportData(SysDataTree data)
{
this.Data = data;
}
///
/// Gets the well.
///
public SysDataTree Data { get; private set; }
///
/// Gets or sets a value indicating whether this is checked.
///
/// true if checked; otherwise, false.
public bool Checked { get; set; }
///
/// Gets or sets the group.
///
/// The group.
public string Group { get; set; }
///
/// Gets or sets the identifier.
///
/// The identifier.
public int ID => this.Data.SYSDATATREE_ID;
///
/// Gets or sets the name.
///
/// The name.
public string Name => this.Data.DATANAME;
}
}
}