You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

183 lines
5.7 KiB
C#

// ***********************************************************************
// Assembly : Construction
// Author : flythink
// Created : 06-15-2020
//
// Last Modified By : flythink
// Last Modified On : 09-01-2020
// ***********************************************************************
// <copyright file="FrmWellPicker.cs" company="jindongfang">
// Copyright (c) jindongfang. All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
namespace WellWorkDataUI.CustomControls
{
using Fk.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using WorkData.Entity;
/// <summary>
/// 层位选择
/// </summary>
public partial class FrmExportPicker : DevExpress.XtraEditors.XtraForm
{
private List<ExportData> layerData = new List<ExportData>();
private SlowDownTimer onceTimer = new SlowDownTimer(1000);
/// <summary>
/// Initializes a new instance of the <see cref="FrmExportPicker"/> class.
/// </summary>
/// <param name="collection">SysDataTree collection</param>
public FrmExportPicker(IEnumerable<SysDataTree> collection)
{
this.InitializeComponent();
this.layerData.AddRange(collection.Select(o => new ExportData(o)));
this.gridControl1.DataSource = this.layerData;
}
/// <summary>
/// Gets the selected layers.
/// </summary>
/// <value>The selected layers.</value>
public List<SysDataTree> 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()));
}
/// <summary>
/// Class ExportData.
/// </summary>
public class ExportData
{
/// <summary>
/// Initializes a new instance of the <see cref="ExportData"/> class.
/// </summary>
/// <param name="data">The wb.</param>
public ExportData(SysDataTree data)
{
this.Data = data;
}
/// <summary>
/// Gets the well.
/// </summary>
public SysDataTree Data { get; private set; }
/// <summary>
/// Gets or sets a value indicating whether this <see cref="LayerData" /> is checked.
/// </summary>
/// <value><c>true</c> if checked; otherwise, <c>false</c>.</value>
public bool Checked { get; set; }
/// <summary>
/// Gets or sets the group.
/// </summary>
/// <value>The group.</value>
public string Group { get; set; }
/// <summary>
/// Gets or sets the identifier.
/// </summary>
/// <value>The identifier.</value>
public int ID => this.Data.SYSDATATREE_ID;
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
public string Name => this.Data.DATANAME;
}
}
}