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.
119 lines
3.7 KiB
C#
119 lines
3.7 KiB
C#
using DevExpress.Utils;
|
|
using DevExpress.XtraEditors;
|
|
using GeoSigmaDrawLib;
|
|
using MeshProcess;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
|
|
namespace KepGridEditor
|
|
{
|
|
public partial class FormVolumeStats : XtraForm
|
|
{
|
|
public event EventHandler<int> ModeChanged; // 构造图/等厚图 改变
|
|
public event EventHandler<int> MethodChanged; // 容积法/等值线法 改变
|
|
|
|
public FormVolumeStats()
|
|
{
|
|
InitializeComponent();
|
|
|
|
this.radioGroupMode.SelectedIndexChanged += RadioGroupMode_SelectedIndexChanged;
|
|
this.radioGroupMethod.SelectedIndexChanged += RadioGroupMethod_SelectedIndexChanged;
|
|
|
|
SetColumnFormat(this.colArea);
|
|
SetColumnFormat(this.colVolumn);
|
|
SetColumnFormat(this.colAreaVolumn);
|
|
|
|
this.gridViewData.OptionsMenu.EnableColumnMenu = false;
|
|
this.gridViewData.OptionsCustomization.AllowGroup = false;
|
|
|
|
this.radioGroupMethod.SelectedIndex = 0;
|
|
|
|
UpdateControlVisibility();
|
|
}
|
|
|
|
public class VolumeDisplayItem
|
|
{
|
|
public string Name { get; set; }
|
|
public double Area { get; set; }
|
|
public double Volumn { get; set; }
|
|
public double AreaVolumn { get; set; }
|
|
|
|
public VolumeDisplayItem(LineVolumnData data)
|
|
{
|
|
this.Name = data.Name;
|
|
this.Area = data.Area;
|
|
this.Volumn = data.Volumn;
|
|
this.AreaVolumn = data.AreaVolumn;
|
|
}
|
|
}
|
|
|
|
public void SetDataSource(LineVolumnData[] data)
|
|
{
|
|
if (data == null)
|
|
{
|
|
this.gridControlData.DataSource = null;
|
|
return;
|
|
}
|
|
|
|
List<VolumeDisplayItem> displayList = new List<VolumeDisplayItem>();
|
|
foreach (var item in data)
|
|
{
|
|
displayList.Add(new VolumeDisplayItem(item));
|
|
}
|
|
this.gridControlData.DataSource = displayList;
|
|
this.gridViewData.RefreshData();
|
|
}
|
|
|
|
// 构造图/等厚图 切换
|
|
private void RadioGroupMode_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
ModeChanged?.Invoke(this, GetCurrentMode());
|
|
}
|
|
|
|
// 容积法/等值线法 切换
|
|
private void RadioGroupMethod_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
UpdateControlVisibility();
|
|
|
|
int selectedMethod = this.radioGroupMethod.SelectedIndex;
|
|
MethodChanged?.Invoke(this, selectedMethod);
|
|
}
|
|
|
|
// 控制显隐及逻辑
|
|
private void UpdateControlVisibility()
|
|
{
|
|
bool isVolumeMethod = (this.radioGroupMethod.SelectedIndex == 0);
|
|
|
|
if (isVolumeMethod)
|
|
{
|
|
// 容积法:启用控件
|
|
this.radioGroupMode.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
// 等值线法:强制选中“等厚图” (Value = 1) 并禁用
|
|
this.radioGroupMode.EditValue = 1;
|
|
this.radioGroupMode.Enabled = false;
|
|
}
|
|
}
|
|
|
|
// 获取当前统计模式 (0:构造图, 1:等厚图)
|
|
public int GetCurrentMode()
|
|
{
|
|
return Convert.ToInt32(this.radioGroupMode.EditValue);
|
|
}
|
|
|
|
// 获取当前计算方式 (0:容积法, 1:等值线法)
|
|
public int GetCurrentMethod()
|
|
{
|
|
return this.radioGroupMethod.SelectedIndex;
|
|
}
|
|
|
|
private void SetColumnFormat(DevExpress.XtraGrid.Columns.GridColumn col)
|
|
{
|
|
col.DisplayFormat.FormatType = FormatType.Numeric;
|
|
col.DisplayFormat.FormatString = "f6";
|
|
}
|
|
}
|
|
} |