基线:全量源码首提(D1 版本控制落地,含第一轮优化 B1-B4/A1/A4/缩放修复)

This commit is contained in:
dqb-dev
2026-10-01 22:15:22 +08:00
commit 1e65792b09
499 changed files with 204579 additions and 0 deletions
@@ -0,0 +1,224 @@
namespace 成套报价软件
{
public partial class GCS推荐铜排窗口 : System.Windows.Forms.Form
{
/// <summary>必需的设计器变量。</summary>
private System.ComponentModel.IContainer components = null;
/// <summary>清理正在使用的资源。</summary>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
private void InitializeComponent()
{
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
this.lblLengthCaption = new System.Windows.Forms.Label();
this.txtLength = new System.Windows.Forms.TextBox();
this.lblLengthUnit = new System.Windows.Forms.Label();
this.lblInfo = new System.Windows.Forms.Label();
this.gridResult = new Smart.CustomComponents.EnhancedDataGridView();
this.colSpec = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colRate = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colMeters = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.gridResult)).BeginInit();
this.SuspendLayout();
//
// lblLengthCaption
//
this.lblLengthCaption.BackColor = System.Drawing.Color.White;
this.lblLengthCaption.Font = new System.Drawing.Font("宋体", 10F);
this.lblLengthCaption.ForeColor = System.Drawing.SystemColors.ControlText;
this.lblLengthCaption.Location = new System.Drawing.Point(124, 34);
this.lblLengthCaption.Name = "lblLengthCaption";
this.lblLengthCaption.Size = new System.Drawing.Size(120, 24);
this.lblLengthCaption.TabIndex = 1;
this.lblLengthCaption.Text = "每回路铜排长度:";
this.lblLengthCaption.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtLength
//
this.txtLength.BackColor = System.Drawing.SystemColors.Window;
this.txtLength.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtLength.Font = new System.Drawing.Font("宋体", 10F);
this.txtLength.ForeColor = System.Drawing.SystemColors.WindowText;
this.txtLength.Location = new System.Drawing.Point(252, 34);
this.txtLength.MaxLength = 10;
this.txtLength.Name = "txtLength";
this.txtLength.Size = new System.Drawing.Size(80, 23);
this.txtLength.TabIndex = 2;
this.txtLength.Text = "1.5";
this.txtLength.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// lblLengthUnit
//
this.lblLengthUnit.BackColor = System.Drawing.Color.White;
this.lblLengthUnit.Font = new System.Drawing.Font("宋体", 10F);
this.lblLengthUnit.ForeColor = System.Drawing.SystemColors.ControlText;
this.lblLengthUnit.Location = new System.Drawing.Point(338, 34);
this.lblLengthUnit.Name = "lblLengthUnit";
this.lblLengthUnit.Size = new System.Drawing.Size(80, 24);
this.lblLengthUnit.TabIndex = 3;
this.lblLengthUnit.Text = "米/回路";
this.lblLengthUnit.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// lblInfo
//
this.lblInfo.AutoEllipsis = true;
this.lblInfo.BackColor = System.Drawing.Color.White;
this.lblInfo.Font = new System.Drawing.Font("宋体", 9F);
this.lblInfo.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.lblInfo.Location = new System.Drawing.Point(12, 82);
this.lblInfo.Name = "lblInfo";
this.lblInfo.Size = new System.Drawing.Size(560, 30);
this.lblInfo.TabIndex = 4;
this.lblInfo.Text = "说明: 按每回路原始电流,选 35°C 水平下载流量 ≥ 该电流的最小铜排规格。相同规格的回路数 × 每回路长度 = 需要总米数。";
//
// gridResult
//
this.gridResult.AllowUserToAddRows = false;
this.gridResult.AllowUserToDeleteRows = false;
this.gridResult.AllowUserToResizeRows = false;
this.gridResult.BackgroundColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F);
dataGridViewCellStyle1.ForeColor = System.Drawing.Color.Black;
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.Black;
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.gridResult.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
this.gridResult.ColumnHeadersHeight = 32;
this.gridResult.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.colSpec,
this.colRate,
this.colCount,
this.colMeters});
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle2.BackColor = System.Drawing.Color.White;
dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 9F);
dataGridViewCellStyle2.ForeColor = System.Drawing.Color.Black;
dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.White;
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.Black;
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.gridResult.DefaultCellStyle = dataGridViewCellStyle2;
this.gridResult.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
this.gridResult.EnableHeadersVisualStyles = false;
this.gridResult.Location = new System.Drawing.Point(12, 120);
this.gridResult.MultiSelect = false;
this.gridResult.Name = "gridResult";
this.gridResult.ReadOnly = true;
this.gridResult.RightToLeft = System.Windows.Forms.RightToLeft.No;
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 9F);
dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.gridResult.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
this.gridResult.RowHeadersVisible = false;
this.gridResult.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.gridResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.gridResult.Size = new System.Drawing.Size(560, 380);
this.gridResult.TabIndex = 5;
//
// colSpec
//
this.colSpec.HeaderText = "铜排规格";
this.colSpec.Name = "colSpec";
this.colSpec.ReadOnly = true;
this.colSpec.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.colSpec.Width = 160;
//
// colRate
//
this.colRate.HeaderText = "载流量(A) 35°C水平";
this.colRate.Name = "colRate";
this.colRate.ReadOnly = true;
this.colRate.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.colRate.Width = 160;
//
// colCount
//
this.colCount.HeaderText = "回路数";
this.colCount.Name = "colCount";
this.colCount.ReadOnly = true;
this.colCount.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.colCount.Width = 80;
//
// colMeters
//
this.colMeters.HeaderText = "需要米数";
this.colMeters.Name = "colMeters";
this.colMeters.ReadOnly = true;
this.colMeters.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.colMeters.Width = 120;
//
// button1
//
this.button1.BackColor = System.Drawing.SystemColors.Control;
this.button1.Font = new System.Drawing.Font("宋体", 9F);
this.button1.ForeColor = System.Drawing.SystemColors.ControlText;
this.button1.Location = new System.Drawing.Point(43, 32);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 6;
this.button1.Text = "插入铜排";
this.button1.UseVisualStyleBackColor = true;
//
// GCS推荐铜排窗口
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.AutoValidate = System.Windows.Forms.AutoValidate.EnablePreventFocusChange;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(584, 513);
this.Controls.Add(this.button1);
this.Controls.Add(this.lblLengthCaption);
this.Controls.Add(this.txtLength);
this.Controls.Add(this.lblLengthUnit);
this.Controls.Add(this.lblInfo);
this.Controls.Add(this.gridResult);
this.Font = new System.Drawing.Font("宋体", 9F);
this.ForeColor = System.Drawing.SystemColors.ControlText;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(600, 552);
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(600, 552);
this.Name = "GCS推荐铜排窗口";
this.ShowInTaskbar = false;
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "抽屉铜牌";
((System.ComponentModel.ISupportInitialize)(this.gridResult)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label lblLengthCaption;
private System.Windows.Forms.TextBox txtLength;
private System.Windows.Forms.Label lblLengthUnit;
private System.Windows.Forms.Label lblInfo;
private Smart.CustomComponents.EnhancedDataGridView gridResult;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.DataGridViewTextBoxColumn colSpec;
private System.Windows.Forms.DataGridViewTextBoxColumn colRate;
private System.Windows.Forms.DataGridViewTextBoxColumn colCount;
private System.Windows.Forms.DataGridViewTextBoxColumn colMeters;
}
}
@@ -0,0 +1,472 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Windows.Forms;
using Smart.CustomComponents;
namespace 成套报价软件
{
/// <summary>
/// 推荐铜排窗口 —— 按每回路原始电流,选 35°C 水平载流量下的最小合适铜排规格,
/// 统计每个规格被多少回路使用,再乘以"每回路长度"得到该规格需要的总米数。
/// 从独立项目 GCS铜排壳体计算 集成进成套报价软件。
/// </summary>
public partial class GCS推荐铜排窗口
{
// ============================================================
// 常量:35°C 水平铜排载流量对照表 (TMY 系列,铜排,单根水平铺设)
// 数据来源:用户提供的 35°C 水平载流量图片。
// 规格 / 载流量(A) 按截面积从小到大排列,选型时取第一个 ≥ 需求电流的规格。
// ============================================================
private static readonly string[] BusbarSpecs35C =
{
"TMY-15×3", "TMY-20×3", "TMY-25×3", "TMY-30×3", "TMY-30×4",
"TMY-30×5", "TMY-30×6", "TMY-40×4", "TMY-40×5", "TMY-40×6",
"TMY-50×5", "TMY-50×6", "TMY-60×6"
};
private static readonly double[] BusbarRatings35C =
{
184, 242, 299, 339, 418,
475, 536, 550, 616, 708,
756, 840, 990
};
// ============================================================
// 表格列索引 (gridResult)
// ============================================================
private const int COL_SPEC = 0; // 铜排规格
private const int COL_RATE = 1; // 载流量 (A)
private const int COL_COUNT = 2; // 回路数
private const int COL_METERS = 3; // 需要米数
/// <summary>推荐行高亮色 (与主窗口一致)。</summary>
private static readonly Color RecommendBackColor = Color.FromArgb(146, 208, 80);
// ============================================================
// 状态
// ============================================================
/// <summary>主窗口传来的所有回路原始电流列表。</summary>
private List<double> _circuitCurrents;
/// <summary>宿主(GCS 母排计算窗口):点"插入"前实时重取回路电流用。</summary>
internal GCS母排计算窗口 宿主;
// ============================================================
// 入口
// ============================================================
public GCS推荐铜排窗口()
{
InitializeComponent();
MainForm.写日志("[推荐铜排] 窗口已构造");
LoadAppIcon(); // 设窗口/任务栏图标(从 exe 自身提取嵌入的图标)
LoadSavedLength(); // 从 铜排长度.cfg 读取上次保存的每回路长度
BuildResultGrid(); // 重建表格列/行(覆盖 ui.cs 可能预建的列)
WireEvents();
Recalculate();
}
/// <summary>把 exe 内嵌入的图标加载为窗口/任务栏图标。
/// 与主窗口一致,从 exe 自身资源提取,不依赖外部文件。</summary>
private void LoadAppIcon()
{
try
{
this.Icon = System.Drawing.Icon.ExtractAssociatedIcon(
System.Windows.Forms.Application.ExecutablePath);
}
catch { /* 提取失败不影响运行,只是用默认图标 */ }
}
// ============================================================
// 每回路长度 自动保存 (铜排长度.cfg,与 exe 同目录)
// ============================================================
/// <summary>每回路铜排长度的配置文件路径。
/// 存放在用户应用数据目录 %APPDATA%\GCS铜排壳体计算\铜排长度.cfg,
/// 而不是 exe 同目录(安装到 Program Files 后 exe 目录无写入权限)。</summary>
private string LengthFilePath
{
get
{
string dir = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"GCS铜排壳体计算");
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
return Path.Combine(dir, "铜排长度.cfg");
}
}
/// <summary>启动时读取上次保存的每回路长度。文件不存在或无效则保持 txtLength 默认值(1.5)。</summary>
private void LoadSavedLength()
{
try
{
if (!File.Exists(LengthFilePath)) return;
string s = File.ReadAllText(LengthFilePath, System.Text.Encoding.UTF8).Trim();
double v;
if (double.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out v) && v >= 0)
{
txtLength.Text = v.ToString("0.####", CultureInfo.InvariantCulture);
}
}
catch { /* 读取失败不影响运行,用默认值 */ }
}
/// <summary>把当前 txtLength 的值写入 铜排长度.cfg。
/// 在 TextChanged 事件里调用,实现"修改后自动保存"。无效值不保存。</summary>
private void SaveLength()
{
try
{
double v;
if (double.TryParse(txtLength.Text.Trim(), NumberStyles.Any,
CultureInfo.InvariantCulture, out v) && v >= 0)
{
File.WriteAllText(LengthFilePath,
v.ToString("0.####", CultureInfo.InvariantCulture),
System.Text.Encoding.UTF8);
}
}
catch { /* 保存失败静默忽略,不影响使用 */ }
}
/// <summary>主窗口调用:把回路的原始电流传进来,并触发首次计算。
/// scopeLabel:当前统计范围(如 "全部" 或 "2#"),显示在窗口标题上,让用户知道算的是哪列。</summary>
public void SetCircuitCurrents(List<double> currents, string scopeLabel)
{
_circuitCurrents = currents;
// 标题显示当前统计范围
if (!string.IsNullOrEmpty(scopeLabel))
{
this.Text = "每回路推荐铜排 (" + scopeLabel + " · 35°C 水平)";
}
Recalculate();
}
// ============================================================
// 构建表格
// ============================================================
/// <summary>构建结果表格:4 列 (规格/载流量/回路数/需要米数)。
/// 无论 ui.cs 是否预建列,这里先 Clear 再重建,确保列结构一致。
/// 初始 18 行对应全部铜排规格(载流量预填),未使用的回路数=0。</summary>
private void BuildResultGrid()
{
gridResult.SuspendLayout();
gridResult.Columns.Clear();
gridResult.Rows.Clear();
var colSpec = new DataGridViewTextBoxColumn
{
Name = "colSpec",
HeaderText = "铜排规格",
Width = 130,
SortMode = DataGridViewColumnSortMode.NotSortable
};
var colRate = new DataGridViewTextBoxColumn
{
Name = "colRate",
HeaderText = "载流量(A) 35°C水平",
Width = 150,
SortMode = DataGridViewColumnSortMode.NotSortable
};
var colCount = new DataGridViewTextBoxColumn
{
Name = "colCount",
HeaderText = "回路数",
Width = 80,
SortMode = DataGridViewColumnSortMode.NotSortable
};
var colMeters = new DataGridViewTextBoxColumn
{
Name = "colMeters",
HeaderText = "需要米数",
Width = 120,
SortMode = DataGridViewColumnSortMode.NotSortable
};
gridResult.Columns.Add(colSpec);
gridResult.Columns.Add(colRate);
gridResult.Columns.Add(colCount);
gridResult.Columns.Add(colMeters);
// 预填 18 行:规格 + 载流量,回路数和米数先置 0
for (int i = 0; i < BusbarSpecs35C.Length; i++)
{
int idx = gridResult.Rows.Add();
gridResult.Rows[idx].Cells[COL_SPEC].Value = BusbarSpecs35C[i];
gridResult.Rows[idx].Cells[COL_RATE].Value = BusbarRatings35C[i].ToString("0") + "A";
gridResult.Rows[idx].Cells[COL_COUNT].Value = "0";
gridResult.Rows[idx].Cells[COL_METERS].Value = "0";
}
gridResult.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing;
gridResult.ColumnHeadersHeight = 32;
gridResult.AllowUserToResizeRows = false;
// 平均分配列宽(适应窗口)
RelayoutColumns();
// 关闭 ADGV 列头筛选按钮
DisableAdgvFilterButtons(gridResult);
gridResult.ClearSelection();
gridResult.ResumeLayout();
}
/// <summary>按 gridResult 当前宽度平均分配 4 列宽度。</summary>
private void RelayoutColumns()
{
if (gridResult.Columns.Count < 4) return;
int totalW = gridResult.ClientSize.Width;
if (totalW <= 20) return;
// 按 130:150:80:120 ≈ 规格/载流量/回路数/米数 的比例分配
int[] weights = { 130, 150, 80, 120 };
int sum = 0;
for (int i = 0; i < weights.Length; i++) sum += weights[i];
int used = 0;
for (int i = 0; i < weights.Length - 1; i++)
{
int w = totalW * weights[i] / sum;
gridResult.Columns[i].Width = w;
used += w;
}
gridResult.Columns[weights.Length - 1].Width = totalW - used;
}
// ============================================================
// 事件绑定
// ============================================================
private void WireEvents()
{
// 米数输入框:值变化即重算 + 自动保存
txtLength.TextChanged += (s, e) => { Recalculate(); SaveLength(); };
txtLength.Validating += (s, e) =>
{
double v;
if (!double.TryParse(txtLength.Text.Trim(), NumberStyles.Any,
CultureInfo.InvariantCulture, out v) || v < 0)
{
// 输入无效不强制阻止,但给提示并恢复默认
txtLength.Text = "1.5";
}
};
// 窗口尺寸变化时重排列宽
this.SizeChanged += (s, e) => RelayoutColumns();
// "插入铜排"按钮:把已选型的铜排(规格+米数)插入主窗口元件表
button1.Click += (s, e) => { _上次插入执行 = DateTime.Now; button1_Click(s, e); };
// ★MouseUp 直触发兜底(2026-09-26 23:36 实测:特定状态下 Click 会被吞而 MouseDown 正常)——
// 左键且弹起点在按钮内即执行插入;与 Click 双通道并存,1 秒防重避免双插
button1.MouseUp += button1_MouseUp兜底;
// ★鼠标落点记录仪(2026-09-26 排"点击未达按钮"专项):MouseDown 在任何控件 stealing
// Click 之前触发——下次用户点击后,日志精确显示点击落在窗口哪个坐标/哪个控件上
button1.MouseDown += (s, e) => MainForm.写日志("[推荐铜排] button1 MouseDown(" + e.X + "," + e.Y + ")");
this.MouseClick += (s, e) => MainForm.写日志("[推荐铜排] 窗体空白处点击(" + e.X + "," + e.Y + ")");
gridResult.MouseClick += (s, e) => MainForm.写日志("[推荐铜排] 表格区点击(" + e.X + "," + e.Y + ")");
// 回车键=插入(键盘通道对照/备用)
this.AcceptButton = button1;
// ★不要在这里加 Activated 自动刷新——SetCircuitCurrents 改标题/重算表格会再次触发
// Activated,形成每 200ms 一轮的无限刷新风暴把界面拖死(2026-09-26 22:57 实测 37 轮)。
// 数据同步只在点"插入"时做一次(见 button1_Click 开头)。
}
/// <summary>上次插入执行时刻(Click 与 MouseUp 双通道的 1 秒防重)。</summary>
private DateTime _上次插入执行 = DateTime.MinValue;
/// <summary>MouseUp 直触发兜底:左键弹起点在按钮内即执行插入(Click 被吞时保底)。</summary>
private void button1_MouseUp兜底(object sender, MouseEventArgs e)
{
if (e.Button != System.Windows.Forms.MouseButtons.Left) return;
if (!button1.ClientRectangle.Contains(e.Location)) return;
if (DateTime.Now - _上次插入执行 < TimeSpan.FromSeconds(1))
{
MainForm.写日志("[推荐铜排] MouseUp 兜底:1秒防重跳过(Click 通道已执行)");
return;
}
MainForm.写日志("[推荐铜排] MouseUp 兜底触发(Click 通道未达)");
_上次插入执行 = DateTime.Now;
button1_Click(sender, e);
}
/// <summary>
/// 在打开的窗体中查找主窗口(MyApp.MainForm)实例。
/// 推荐铜排窗口由 GCS母排计算窗口 弹出,GCS母排计算窗口 又由主窗口弹出,
/// 通过遍历 OpenForms 找主窗口最可靠。
/// </summary>
private MainForm FindMainForm()
{
foreach (Form f in Application.OpenForms)
{
if (f is MainForm) return (MainForm)f;
}
return null;
}
/// <summary>
/// "插入铜排"按钮:遍历结果表中所有"回路数 > 0"的行(即被选用的规格),
/// 把每行的铜排规格 + 需要米数 插入到主窗口的元件表(advancedDataGridView5)。
/// 表价由主窗口按母排界面当前铜价自动计算。
/// ★插入前先向 GCS 窗口实时重取回路电流重算(2026-09-26 修:先开推荐窗后输电流时
/// 旧快照回路数全 0,插入被"没有铜排"挡住=用户报"无法正常插入")。
/// </summary>
private void button1_Click(object sender, EventArgs e)
{
MainForm main = FindMainForm();
if (main == null)
{
MainForm.写日志("[推荐铜排] 插入失败:找不到 MainForm");
MessageBox.Show("未找到MainForm,无法插入。", "提示",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
// ★先实时刷新:GCS 窗口当前电流表 → 重算结果表(用户可能在打开推荐窗后才输入/修改电流)
bool 宿主可用 = 宿主 != null && !宿主.IsDisposed;
if (宿主可用)
宿主.刷新推荐窗口数据();
MainForm.写日志("[推荐铜排] 点插入: 宿主可用=" + 宿主可用);
// 收集所有被选用的铜排(回路数 > 0)
var items = new List<KeyValuePair<string, double>>();
for (int i = 0; i < gridResult.Rows.Count; i++)
{
var row = gridResult.Rows[i];
int cnt;
int.TryParse((row.Cells[COL_COUNT].Value ?? "").ToString(), out cnt);
if (cnt <= 0) continue;
string 规格 = (row.Cells[COL_SPEC].Value ?? "").ToString().Trim();
double 米数;
double.TryParse((row.Cells[COL_METERS].Value ?? "").ToString(),
NumberStyles.Any, CultureInfo.InvariantCulture, out 米数);
if (string.IsNullOrWhiteSpace(规格) || 米数 <= 0) continue;
items.Add(new KeyValuePair<string, double>(规格, 米数));
}
MainForm.写日志("[推荐铜排] 收集到 " + items.Count + " 种铜排(结果表 " + gridResult.Rows.Count + " 行)");
if (items.Count == 0)
{
MessageBox.Show("当前没有计算出的铜排(回路数都为 0)。请先在垂直母排计算窗口输入回路电流,再点插入。",
"提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// 逐条插入主窗口元件表
int okCount = 0;
foreach (var kv in items)
{
if (main.InsertGcs母排(kv.Key, kv.Value)) okCount++;
}
MainForm.写日志("[推荐铜排] 插入完成: 成功 " + okCount + "/" + items.Count + " 种");
MessageBox.Show("已插入 " + okCount + " 种铜排到报价元件表。", "插入完成",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
// ============================================================
// 核心计算
// ============================================================
/// <summary>重算:对每个回路电流选最小合适铜排规格,统计每规格回路数,乘米数得总米数。
/// 只更新被使用的行(回路数>0),高亮显示;未使用的规格保持 0 并取消高亮。</summary>
private void Recalculate()
{
double lengthPerCircuit = GetLengthPerCircuit();
// 计数桶:每规格被多少回路使用
int[] counts = new int[BusbarSpecs35C.Length];
int overflowCount = 0; // 电流超过最大规格(1120A)的回路数
if (_circuitCurrents != null)
{
foreach (double current in _circuitCurrents)
{
if (current <= 0) continue;
int idx = PickBusbarIndex(current);
if (idx >= 0)
counts[idx]++;
else
overflowCount++;
}
}
// 回写表格
gridResult.SuspendLayout();
for (int i = 0; i < BusbarSpecs35C.Length; i++)
{
var row = gridResult.Rows[i];
int cnt = counts[i];
row.Cells[COL_COUNT].Value = cnt.ToString("0");
double meters = cnt * lengthPerCircuit;
row.Cells[COL_METERS].Value = meters.ToString("0.##");
// 被使用的规格高亮
bool used = cnt > 0;
for (int c = 0; c < row.Cells.Count; c++)
{
row.Cells[c].Style.BackColor = used ? RecommendBackColor : Color.White;
row.Cells[c].Style.SelectionBackColor = used ? RecommendBackColor : Color.White;
row.Cells[c].Style.Font = used
? new Font("宋体", 9, FontStyle.Bold)
: new Font("宋体", 9);
}
}
gridResult.ResumeLayout();
// 若有超规格电流,在标题提示
if (overflowCount > 0)
{
lblInfo.Text = "提示: 有 " + overflowCount + " 个回路电流超过最大规格 (TMY-60×6, 990A),无法选型!";
}
else
{
lblInfo.Text = "说明: 按每回路原始电流,选 35°C 水平下载流量 ≥ 该电流的最小铜排规格。相同规格的回路数 × 每回路长度 = 需要总米数。";
}
}
/// <summary>选型:返回第一个载流量 ≥ need 的规格索引;都不够返回 -1。</summary>
private int PickBusbarIndex(double needCurrent)
{
if (needCurrent <= 0) return -1;
for (int i = 0; i < BusbarRatings35C.Length; i++)
{
if (BusbarRatings35C[i] >= needCurrent)
return i;
}
return -1; // 超过最大规格
}
/// <summary>解析"每回路长度"输入框,默认 1.5。无效输入返回 1.5。</summary>
private double GetLengthPerCircuit()
{
try
{
double v;
if (double.TryParse(txtLength.Text.Trim(), NumberStyles.Any,
CultureInfo.InvariantCulture, out v))
{
if (v >= 0) return v;
}
}
catch { }
return 1.5;
}
// ============================================================
// 辅助:关闭 ADGV 列头筛选按钮 (与主窗口逻辑一致)
// ============================================================
/// <summary>彻底关闭 ADGV 列头的筛选/排序按钮:
/// 把每列列头换成标准 DataGridViewColumnHeaderCell 并复位 MinimumWidth。</summary>
private void DisableAdgvFilterButtons(Smart.CustomComponents.EnhancedDataGridView grid)
{
// Smart EnhancedDataGridView 没有内置筛选按钮,无需禁用
}
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,649 @@
namespace 成套报价软件
{
public partial class GCS母排计算窗口 : System.Windows.Forms.Form
{
/// <summary>必需的设计器变量。</summary>
private System.ComponentModel.IContainer components = null;
/// <summary>清理正在使用的资源。</summary>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
private void InitializeComponent()
{
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle();
this.grpBusbar = new System.Windows.Forms.GroupBox();
this.gridBusbar = new Smart.CustomComponents.EnhancedDataGridView();
this.bspec = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.brate = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.panel1 = new System.Windows.Forms.Panel();
this.lblRecommend = new System.Windows.Forms.Label();
this.button3 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.grpQuote = new System.Windows.Forms.GroupBox();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.gridQuote = new Smart.CustomComponents.EnhancedDataGridView();
this.colItem = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colPrice = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colQty = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colSub = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.lblTotalCaption = new System.Windows.Forms.Label();
this.lblTotalPrice = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.btnClear = new System.Windows.Forms.Button();
this.grpCurrent = new System.Windows.Forms.GroupBox();
this.gridCurrents = new Smart.CustomComponents.EnhancedDataGridView();
this.col_0 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.col_1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.col_2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.col_3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.col_4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.col_5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.col_6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.col_7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.col_8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.col_9 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.col_10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.lblHint = new System.Windows.Forms.Label();
this.lblKsRules = new System.Windows.Forms.Label();
this.grpBusbar.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.gridBusbar)).BeginInit();
this.panel1.SuspendLayout();
this.grpQuote.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.gridQuote)).BeginInit();
this.grpCurrent.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.gridCurrents)).BeginInit();
this.SuspendLayout();
//
// grpBusbar
//
this.grpBusbar.BackColor = System.Drawing.SystemColors.Control;
this.grpBusbar.Controls.Add(this.gridBusbar);
this.grpBusbar.Controls.Add(this.panel1);
this.grpBusbar.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpBusbar.Font = new System.Drawing.Font("宋体", 9F);
this.grpBusbar.ForeColor = System.Drawing.SystemColors.ControlText;
this.grpBusbar.Location = new System.Drawing.Point(1, 478);
this.grpBusbar.Name = "grpBusbar";
this.grpBusbar.Padding = new System.Windows.Forms.Padding(0);
this.grpBusbar.Size = new System.Drawing.Size(453, 139);
this.grpBusbar.TabIndex = 6;
this.grpBusbar.TabStop = false;
this.grpBusbar.Text = "垂直母排推荐";
//
// gridBusbar
//
this.gridBusbar.AllowUserToAddRows = false;
this.gridBusbar.AllowUserToDeleteRows = false;
this.gridBusbar.BackgroundColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F);
dataGridViewCellStyle1.ForeColor = System.Drawing.Color.Black;
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.Black;
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.gridBusbar.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
this.gridBusbar.ColumnHeadersHeight = 28;
this.gridBusbar.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.bspec,
this.brate});
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle2.BackColor = System.Drawing.Color.White;
dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 9F);
dataGridViewCellStyle2.ForeColor = System.Drawing.Color.Black;
dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.White;
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.Black;
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.gridBusbar.DefaultCellStyle = dataGridViewCellStyle2;
this.gridBusbar.Dock = System.Windows.Forms.DockStyle.Fill;
this.gridBusbar.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
this.gridBusbar.EnableHeadersVisualStyles = false;
this.gridBusbar.Location = new System.Drawing.Point(0, 50);
this.gridBusbar.MultiSelect = false;
this.gridBusbar.Name = "gridBusbar";
this.gridBusbar.ReadOnly = true;
this.gridBusbar.RightToLeft = System.Windows.Forms.RightToLeft.No;
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 9F);
dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.gridBusbar.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
this.gridBusbar.RowHeadersVisible = false;
this.gridBusbar.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.gridBusbar.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.gridBusbar.Size = new System.Drawing.Size(453, 89);
this.gridBusbar.TabIndex = 8;
//
// bspec
//
this.bspec.HeaderText = "铜排规格";
this.bspec.Name = "bspec";
this.bspec.ReadOnly = true;
this.bspec.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// brate
//
this.brate.HeaderText = "载流量 (A)";
this.brate.Name = "brate";
this.brate.ReadOnly = true;
this.brate.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// panel1
//
this.panel1.BackColor = System.Drawing.SystemColors.Control;
this.panel1.Controls.Add(this.lblRecommend);
this.panel1.Controls.Add(this.button3);
this.panel1.Controls.Add(this.button2);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Font = new System.Drawing.Font("宋体", 9F);
this.panel1.ForeColor = System.Drawing.SystemColors.ControlText;
this.panel1.Location = new System.Drawing.Point(0, 14);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(453, 36);
this.panel1.TabIndex = 11;
//
// lblRecommend
//
this.lblRecommend.BackColor = System.Drawing.SystemColors.Control;
this.lblRecommend.Font = new System.Drawing.Font("宋体", 11F);
this.lblRecommend.ForeColor = System.Drawing.SystemColors.ControlText;
this.lblRecommend.Location = new System.Drawing.Point(0, 4);
this.lblRecommend.Name = "lblRecommend";
this.lblRecommend.Size = new System.Drawing.Size(253, 29);
this.lblRecommend.TabIndex = 7;
this.lblRecommend.Text = "推荐铜排:\r\n (请先在上方输入各回路电流)";
//
// button3
//
this.button3.BackColor = System.Drawing.SystemColors.Control;
this.button3.Font = new System.Drawing.Font("宋体", 9F);
this.button3.ForeColor = System.Drawing.SystemColors.ControlText;
this.button3.Location = new System.Drawing.Point(274, 2);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(66, 31);
this.button3.TabIndex = 10;
this.button3.Text = "插入铜排";
this.button3.UseVisualStyleBackColor = true;
//
// button2
//
this.button2.BackColor = System.Drawing.SystemColors.Control;
this.button2.Font = new System.Drawing.Font("宋体", 9F);
this.button2.ForeColor = System.Drawing.SystemColors.ControlText;
this.button2.Location = new System.Drawing.Point(341, 2);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(109, 31);
this.button2.TabIndex = 9;
this.button2.Text = "查看抽屉推荐铜排";
this.button2.UseVisualStyleBackColor = true;
//
// grpQuote
//
this.grpQuote.BackColor = System.Drawing.SystemColors.Control;
this.grpQuote.Controls.Add(this.checkBox2);
this.grpQuote.Controls.Add(this.comboBox1);
this.grpQuote.Controls.Add(this.gridQuote);
this.grpQuote.Controls.Add(this.checkBox1);
this.grpQuote.Controls.Add(this.lblTotalCaption);
this.grpQuote.Controls.Add(this.lblTotalPrice);
this.grpQuote.Controls.Add(this.button1);
this.grpQuote.Controls.Add(this.btnClear);
this.grpQuote.Dock = System.Windows.Forms.DockStyle.Bottom;
this.grpQuote.Font = new System.Drawing.Font("宋体", 9F);
this.grpQuote.ForeColor = System.Drawing.SystemColors.ControlText;
this.grpQuote.Location = new System.Drawing.Point(1, 617);
this.grpQuote.Name = "grpQuote";
this.grpQuote.Padding = new System.Windows.Forms.Padding(0);
this.grpQuote.Size = new System.Drawing.Size(453, 343);
this.grpQuote.TabIndex = 9;
this.grpQuote.TabStop = false;
this.grpQuote.Text = "壳体 / 抽屉合价";
//
// checkBox2
//
this.checkBox2.BackColor = System.Drawing.SystemColors.Control;
this.checkBox2.Font = new System.Drawing.Font("宋体", 9F);
this.checkBox2.ForeColor = System.Drawing.SystemColors.ControlText;
this.checkBox2.Location = new System.Drawing.Point(249, 261);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(91, 29);
this.checkBox2.TabIndex = 52;
this.checkBox2.Text = " 63A以下用\r\n1/2抽屉计算";
this.checkBox2.UseVisualStyleBackColor = true;
//
// comboBox1
//
this.comboBox1.BackColor = System.Drawing.SystemColors.Window;
this.comboBox1.DropDownWidth = 121;
this.comboBox1.Font = new System.Drawing.Font("宋体", 9F);
this.comboBox1.ForeColor = System.Drawing.SystemColors.WindowText;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.ItemHeight = 12;
this.comboBox1.Location = new System.Drawing.Point(348, 267);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(91, 20);
this.comboBox1.TabIndex = 51;
this.comboBox1.Text = "1#";
//
// gridQuote
//
this.gridQuote.AllowUserToAddRows = false;
this.gridQuote.AllowUserToDeleteRows = false;
this.gridQuote.AllowUserToResizeRows = false;
this.gridQuote.BackgroundColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
dataGridViewCellStyle4.Font = new System.Drawing.Font("宋体", 9F);
dataGridViewCellStyle4.ForeColor = System.Drawing.Color.Black;
dataGridViewCellStyle4.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
dataGridViewCellStyle4.SelectionForeColor = System.Drawing.Color.Black;
dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.gridQuote.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4;
this.gridQuote.ColumnHeadersHeight = 30;
this.gridQuote.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.colItem,
this.colPrice,
this.colQty,
this.colSub});
dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle5.BackColor = System.Drawing.Color.White;
dataGridViewCellStyle5.Font = new System.Drawing.Font("宋体", 9F);
dataGridViewCellStyle5.ForeColor = System.Drawing.Color.Black;
dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.White;
dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.Black;
dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.gridQuote.DefaultCellStyle = dataGridViewCellStyle5;
this.gridQuote.Dock = System.Windows.Forms.DockStyle.Top;
this.gridQuote.EnableHeadersVisualStyles = false;
this.gridQuote.Location = new System.Drawing.Point(0, 14);
this.gridQuote.MultiSelect = false;
this.gridQuote.Name = "gridQuote";
this.gridQuote.RightToLeft = System.Windows.Forms.RightToLeft.No;
dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle6.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle6.Font = new System.Drawing.Font("宋体", 9F);
dataGridViewCellStyle6.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle6.SelectionBackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle6.SelectionForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.gridQuote.RowHeadersDefaultCellStyle = dataGridViewCellStyle6;
this.gridQuote.RowHeadersVisible = false;
this.gridQuote.ScrollBars = System.Windows.Forms.ScrollBars.None;
this.gridQuote.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
this.gridQuote.Size = new System.Drawing.Size(453, 241);
this.gridQuote.TabIndex = 50;
//
// colItem
//
this.colItem.HeaderText = "项目";
this.colItem.Name = "colItem";
this.colItem.ReadOnly = true;
this.colItem.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.colItem.Width = 120;
//
// colPrice
//
this.colPrice.HeaderText = "单价(元)";
this.colPrice.Name = "colPrice";
this.colPrice.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// colQty
//
this.colQty.HeaderText = "数量";
this.colQty.Name = "colQty";
this.colQty.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.colQty.Width = 80;
//
// colSub
//
this.colSub.HeaderText = "小计(元)";
this.colSub.Name = "colSub";
this.colSub.ReadOnly = true;
this.colSub.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.colSub.Width = 120;
//
// checkBox1
//
this.checkBox1.BackColor = System.Drawing.SystemColors.Control;
this.checkBox1.Checked = true;
this.checkBox1.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBox1.Font = new System.Drawing.Font("宋体", 9F);
this.checkBox1.ForeColor = System.Drawing.SystemColors.ControlText;
this.checkBox1.Location = new System.Drawing.Point(109, 266);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(123, 24);
this.checkBox1.TabIndex = 49;
this.checkBox1.Text = "自动计算所需抽屉";
this.checkBox1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.checkBox1.UseVisualStyleBackColor = true;
//
// lblTotalCaption
//
this.lblTotalCaption.BackColor = System.Drawing.SystemColors.Control;
this.lblTotalCaption.Font = new System.Drawing.Font("宋体", 11F);
this.lblTotalCaption.ForeColor = System.Drawing.SystemColors.ControlText;
this.lblTotalCaption.Location = new System.Drawing.Point(3, 261);
this.lblTotalCaption.Name = "lblTotalCaption";
this.lblTotalCaption.Size = new System.Drawing.Size(100, 30);
this.lblTotalCaption.TabIndex = 42;
this.lblTotalCaption.Text = "合计总价(元)";
this.lblTotalCaption.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// lblTotalPrice
//
this.lblTotalPrice.BackColor = System.Drawing.SystemColors.Window;
this.lblTotalPrice.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblTotalPrice.Font = new System.Drawing.Font("宋体", 18F);
this.lblTotalPrice.ForeColor = System.Drawing.SystemColors.WindowText;
this.lblTotalPrice.Location = new System.Drawing.Point(3, 293);
this.lblTotalPrice.Name = "lblTotalPrice";
this.lblTotalPrice.Size = new System.Drawing.Size(220, 42);
this.lblTotalPrice.TabIndex = 43;
this.lblTotalPrice.Text = "0";
this.lblTotalPrice.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// button1
//
this.button1.BackColor = System.Drawing.SystemColors.Control;
this.button1.Font = new System.Drawing.Font("宋体", 9F);
this.button1.ForeColor = System.Drawing.SystemColors.ControlText;
this.button1.Location = new System.Drawing.Point(249, 293);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(80, 42);
this.button1.TabIndex = 50;
this.button1.Text = "保存";
this.button1.UseVisualStyleBackColor = true;
//
// btnClear
//
this.btnClear.BackColor = System.Drawing.SystemColors.Control;
this.btnClear.Font = new System.Drawing.Font("宋体", 9F);
this.btnClear.ForeColor = System.Drawing.SystemColors.ControlText;
this.btnClear.Location = new System.Drawing.Point(348, 293);
this.btnClear.Name = "btnClear";
this.btnClear.Size = new System.Drawing.Size(91, 42);
this.btnClear.TabIndex = 48;
this.btnClear.Text = "清空数据";
this.btnClear.UseVisualStyleBackColor = true;
//
// grpCurrent
//
this.grpCurrent.BackColor = System.Drawing.SystemColors.Control;
this.grpCurrent.Controls.Add(this.gridCurrents);
this.grpCurrent.Controls.Add(this.lblHint);
this.grpCurrent.Controls.Add(this.lblKsRules);
this.grpCurrent.Dock = System.Windows.Forms.DockStyle.Top;
this.grpCurrent.Font = new System.Drawing.Font("宋体", 9F);
this.grpCurrent.ForeColor = System.Drawing.SystemColors.ControlText;
this.grpCurrent.Location = new System.Drawing.Point(1, 1);
this.grpCurrent.Name = "grpCurrent";
this.grpCurrent.Padding = new System.Windows.Forms.Padding(0);
this.grpCurrent.Size = new System.Drawing.Size(453, 477);
this.grpCurrent.TabIndex = 1;
this.grpCurrent.TabStop = false;
this.grpCurrent.Text = "母排电流计算 (抽屉回路电流 A)";
//
// gridCurrents
//
this.gridCurrents.AllowUserToAddRows = false;
this.gridCurrents.AllowUserToDeleteRows = false;
this.gridCurrents.BackgroundColor = System.Drawing.SystemColors.Window;
this.gridCurrents.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle7.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
dataGridViewCellStyle7.Font = new System.Drawing.Font("宋体", 9F);
dataGridViewCellStyle7.ForeColor = System.Drawing.Color.Black;
dataGridViewCellStyle7.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
dataGridViewCellStyle7.SelectionForeColor = System.Drawing.Color.Black;
dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.gridCurrents.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle7;
this.gridCurrents.ColumnHeadersHeight = 30;
this.gridCurrents.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.col_0,
this.col_1,
this.col_2,
this.col_3,
this.col_4,
this.col_5,
this.col_6,
this.col_7,
this.col_8,
this.col_9,
this.col_10});
dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle8.BackColor = System.Drawing.Color.White;
dataGridViewCellStyle8.Font = new System.Drawing.Font("宋体", 9F);
dataGridViewCellStyle8.ForeColor = System.Drawing.Color.Black;
dataGridViewCellStyle8.SelectionBackColor = System.Drawing.Color.White;
dataGridViewCellStyle8.SelectionForeColor = System.Drawing.Color.Black;
dataGridViewCellStyle8.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.gridCurrents.DefaultCellStyle = dataGridViewCellStyle8;
this.gridCurrents.Dock = System.Windows.Forms.DockStyle.Fill;
this.gridCurrents.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter;
this.gridCurrents.EnableHeadersVisualStyles = false;
this.gridCurrents.Location = new System.Drawing.Point(0, 32);
this.gridCurrents.Name = "gridCurrents";
this.gridCurrents.RightToLeft = System.Windows.Forms.RightToLeft.No;
dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle9.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle9.Font = new System.Drawing.Font("宋体", 9F);
dataGridViewCellStyle9.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle9.SelectionBackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle9.SelectionForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle9.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.gridCurrents.RowHeadersDefaultCellStyle = dataGridViewCellStyle9;
this.gridCurrents.RowHeadersWidth = 95;
this.gridCurrents.Size = new System.Drawing.Size(453, 352);
this.gridCurrents.TabIndex = 3;
//
// col_0
//
this.col_0.HeaderText = "1#";
this.col_0.Name = "col_0";
this.col_0.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.col_0.Width = 80;
//
// col_1
//
this.col_1.HeaderText = "2#";
this.col_1.Name = "col_1";
this.col_1.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.col_1.Width = 80;
//
// col_2
//
this.col_2.HeaderText = "3#";
this.col_2.Name = "col_2";
this.col_2.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.col_2.Width = 80;
//
// col_3
//
this.col_3.HeaderText = "4#";
this.col_3.Name = "col_3";
this.col_3.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.col_3.Width = 80;
//
// col_4
//
this.col_4.HeaderText = "5#";
this.col_4.Name = "col_4";
this.col_4.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.col_4.Width = 80;
//
// col_5
//
this.col_5.HeaderText = "6#";
this.col_5.Name = "col_5";
this.col_5.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.col_5.Width = 80;
//
// col_6
//
this.col_6.HeaderText = "7#";
this.col_6.Name = "col_6";
this.col_6.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.col_6.Width = 80;
//
// col_7
//
this.col_7.HeaderText = "8#";
this.col_7.Name = "col_7";
this.col_7.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.col_7.Width = 80;
//
// col_8
//
this.col_8.HeaderText = "9#";
this.col_8.Name = "col_8";
this.col_8.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.col_8.Width = 80;
//
// col_9
//
this.col_9.HeaderText = "10#";
this.col_9.Name = "col_9";
this.col_9.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.col_9.Width = 80;
//
// col_10
//
this.col_10.HeaderText = "n#";
this.col_10.Name = "col_10";
this.col_10.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.col_10.Width = 80;
//
// lblHint
//
this.lblHint.BackColor = System.Drawing.SystemColors.Control;
this.lblHint.Dock = System.Windows.Forms.DockStyle.Top;
this.lblHint.Font = new System.Drawing.Font("宋体", 9F);
this.lblHint.ForeColor = System.Drawing.SystemColors.ControlText;
this.lblHint.Location = new System.Drawing.Point(0, 14);
this.lblHint.Name = "lblHint";
this.lblHint.Size = new System.Drawing.Size(453, 18);
this.lblHint.TabIndex = 2;
this.lblHint.Text = "提示: 绿色单元格 = 输入各回路电流(A)";
//
// lblKsRules
//
this.lblKsRules.BackColor = System.Drawing.Color.White;
this.lblKsRules.Dock = System.Windows.Forms.DockStyle.Bottom;
this.lblKsRules.Font = new System.Drawing.Font("宋体", 9F);
this.lblKsRules.ForeColor = System.Drawing.SystemColors.ControlText;
this.lblKsRules.Location = new System.Drawing.Point(0, 384);
this.lblKsRules.Name = "lblKsRules";
this.lblKsRules.Size = new System.Drawing.Size(453, 93);
this.lblKsRules.TabIndex = 5;
this.lblKsRules.Text = "回路数量 与 同时系数 ks 对照:\r\n\r\n 组件全部使用 ............ ks = 0.9\r\n 2 ~ 3 回路 ................" +
" ks = 0.9\r\n 4 ~ 5 回路 ................ ks = 0.8\r\n 6 ~ 9 回路 ................ ks " +
"= 0.7\r\n 10 回路以上 ............. ks = 0.6";
//
// GCS母排计算窗口
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.AutoValidate = System.Windows.Forms.AutoValidate.EnablePreventFocusChange;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(455, 961);
this.Controls.Add(this.grpBusbar);
this.Controls.Add(this.grpCurrent);
this.Controls.Add(this.grpQuote);
this.Font = new System.Drawing.Font("宋体", 9F);
this.ForeColor = System.Drawing.SystemColors.ControlText;
this.MaximizeBox = false;
this.MinimumSize = new System.Drawing.Size(471, 1000);
this.Name = "GCS母排计算窗口";
this.Padding = new System.Windows.Forms.Padding(1);
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "垂直母排载流量核算 (GCS 计算壳体)";
this.grpBusbar.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.gridBusbar)).EndInit();
this.panel1.ResumeLayout(false);
this.grpQuote.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.gridQuote)).EndInit();
this.grpCurrent.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.gridCurrents)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox grpBusbar;
private System.Windows.Forms.Button button2;
private Smart.CustomComponents.EnhancedDataGridView gridBusbar;
private System.Windows.Forms.DataGridViewTextBoxColumn colBusbar1;
private System.Windows.Forms.DataGridViewTextBoxColumn colBusbar2;
private System.Windows.Forms.Label lblRecommend;
private System.Windows.Forms.GroupBox grpQuote;
private System.Windows.Forms.CheckBox checkBox2;
private System.Windows.Forms.ComboBox comboBox1;
private Smart.CustomComponents.EnhancedDataGridView gridQuote;
private System.Windows.Forms.DataGridViewTextBoxColumn colQuote1;
private System.Windows.Forms.DataGridViewTextBoxColumn colQuote2;
private System.Windows.Forms.DataGridViewTextBoxColumn colQuote3;
private System.Windows.Forms.DataGridViewTextBoxColumn colQuote4;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.Label lblTotalCaption;
private System.Windows.Forms.Label lblTotalPrice;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button btnClear;
private System.Windows.Forms.GroupBox grpCurrent;
private Smart.CustomComponents.EnhancedDataGridView gridCurrents;
private System.Windows.Forms.DataGridViewTextBoxColumn colCurrents1;
private System.Windows.Forms.DataGridViewTextBoxColumn colCurrents2;
private System.Windows.Forms.DataGridViewTextBoxColumn colCurrents3;
private System.Windows.Forms.DataGridViewTextBoxColumn colCurrents4;
private System.Windows.Forms.DataGridViewTextBoxColumn colCurrents5;
private System.Windows.Forms.DataGridViewTextBoxColumn colCurrents6;
private System.Windows.Forms.DataGridViewTextBoxColumn colCurrents7;
private System.Windows.Forms.DataGridViewTextBoxColumn colCurrents8;
private System.Windows.Forms.DataGridViewTextBoxColumn colCurrents9;
private System.Windows.Forms.DataGridViewTextBoxColumn colCurrents10;
private System.Windows.Forms.DataGridViewTextBoxColumn colCurrents11;
private System.Windows.Forms.Label lblKsRules;
private System.Windows.Forms.Label lblHint;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.DataGridViewTextBoxColumn bspec;
private System.Windows.Forms.DataGridViewTextBoxColumn brate;
private System.Windows.Forms.DataGridViewTextBoxColumn colItem;
private System.Windows.Forms.DataGridViewTextBoxColumn colPrice;
private System.Windows.Forms.DataGridViewTextBoxColumn colQty;
private System.Windows.Forms.DataGridViewTextBoxColumn colSub;
private System.Windows.Forms.DataGridViewTextBoxColumn col_0;
private System.Windows.Forms.DataGridViewTextBoxColumn col_1;
private System.Windows.Forms.DataGridViewTextBoxColumn col_2;
private System.Windows.Forms.DataGridViewTextBoxColumn col_3;
private System.Windows.Forms.DataGridViewTextBoxColumn col_4;
private System.Windows.Forms.DataGridViewTextBoxColumn col_5;
private System.Windows.Forms.DataGridViewTextBoxColumn col_6;
private System.Windows.Forms.DataGridViewTextBoxColumn col_7;
private System.Windows.Forms.DataGridViewTextBoxColumn col_8;
private System.Windows.Forms.DataGridViewTextBoxColumn col_9;
private System.Windows.Forms.DataGridViewTextBoxColumn col_10;
}
}
@@ -0,0 +1,783 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Windows.Forms;
using Smart.CustomComponents;
namespace 成套报价软件
{
/// <summary>
/// 垂直母排载流量核算 (GCS 计算壳体) —— 交互逻辑。
/// 从独立项目 GCS铜排壳体计算 集成进成套报价软件,由母排页"垂直母排计算"按钮弹出。
/// UI 布局定义见 GCS母排计算窗口.ui.cs。
/// </summary>
public partial class GCS母排计算窗口
{
// ============================================================
// 常量:列/行/铜排/抽屉型号
// ============================================================
private const int ColumnCount = 11;
private const int CircuitRows = 18;
private const int SummaryRows = 5;
private static readonly double[] SummaryFactors = { 1.0, 0.9, 0.8, 0.7, 0.6 };
private static readonly string[] SummaryLabels = { "SUM", "SUM×0.9", "SUM×0.8", "SUM×0.7", "SUM×0.6" };
private static readonly string[] ColumnHeaders =
{ "1#", "2#", "3#", "4#", "5#", "6#", "7#", "8#", "9#", "10#", "n#" };
private static readonly string[] BusbarSpecs =
{ "TMY-30×6", "TMY-40×6", "TMY-50×6", "TMY-60×6", "TMY-80×6", "TMY-100×6", "TMY-120×6" };
private static readonly double[] BusbarRatings =
{ 540, 710, 840, 990, 1302, 1593, 1877 };
private static readonly string[] QuoteItems =
{ "柜体", "抽屉 1/2", "抽屉 125", "抽屉 250", "抽屉 400", "抽屉 630", "抽屉 800" };
private static readonly double[] DefaultDrawerPrices = { 450, 400, 500, 600, 700, 1000 };
private const double DefaultCabinetPrice = 2100;
private const double DefaultCabinetQty = 1;
private static readonly Color InputCellBackColor = Color.FromArgb(204, 255, 204);
private static readonly Color SummaryRowBackColor = Color.FromArgb(255, 255, 204);
private static readonly Color SumRowBackColor = Color.FromArgb(255, 242, 204);
private static readonly Color RecommendBackColor = Color.FromArgb(146, 208, 80);
private const int QCOL_ITEM = 0;
private const int QCOL_PRICE = 1;
private const int QCOL_QTY = 2;
private const int QCOL_SUB = 3;
private bool _isCalculating;
private double _maxLoadCurrent;
/// <summary>推荐铜排窗口引用(非模态打开,防重复弹出)。</summary>
private GCS推荐铜排窗口 _recommendForm;
public GCS母排计算窗口()
{
InitializeComponent();
SetupRecommendLabel();
BuildCurrentsGrid();
BuildBusbarGrid();
BuildQuoteGrid();
InitDefaultValues();
InitComboBox();
WireEvents();
RecalculateAll();
this.Load += (s, e) => FitRecommendText();
}
private void SetupRecommendLabel()
{
lblRecommend.Anchor = AnchorStyles.Top | AnchorStyles.Left;
lblRecommend.AutoSize = false;
lblRecommend.AutoEllipsis = false;
lblRecommend.TextAlign = ContentAlignment.MiddleLeft;
// 保持设计器布局(在 panel1 内,Location(0,4),Size(253,29)),不要覆盖位置/尺寸
grpBusbar.SizeChanged += (s, e) => FitRecommendText();
}
private void FitRecommendText()
{
if (lblRecommend == null) return;
string text = lblRecommend.Text;
if (string.IsNullOrEmpty(text)) return;
// 固定使用设计器设置的宽度(253),不修改位置/尺寸,避免覆盖右侧"插入铜排/查看抽屉推荐铜排"按钮。
int fixedWidth = lblRecommend.Width;
if (fixedWidth <= 0) fixedWidth = 253;
// 从大到小试字号,找单行能在固定宽度内放下的最大字号
float[] fontSizes = { 11F, 10F, 9F, 8F };
Font chosenFont = null;
foreach (float fs in fontSizes)
{
var f = new Font("宋体", fs);
var size = TextRenderer.MeasureText(text, f,
new Size(int.MaxValue, int.MaxValue),
TextFormatFlags.NoPadding);
if (size.Width <= fixedWidth)
{
chosenFont = f;
break;
}
}
if (chosenFont != null)
{
lblRecommend.Font = chosenFont;
}
else
{
lblRecommend.Font = new Font("宋体", 8F);
}
lblRecommend.Invalidate();
}
private void InitComboBox()
{
comboBox1.Items.Clear();
comboBox1.Items.Add("全部");
for (int c = 0; c < ColumnCount; c++)
{
comboBox1.Items.Add(ColumnHeaders[c]);
}
comboBox1.SelectedIndex = 1; // ★默认"1#"(原始行为,2026-09-26 曾被擅改为"全部"已恢复)
}
private void BuildCurrentsGrid()
{
gridCurrents.SuspendLayout();
gridCurrents.Columns.Clear();
gridCurrents.Rows.Clear();
for (int c = 0; c < ColumnCount; c++)
{
var col = new DataGridViewTextBoxColumn
{
Name = "col_" + c,
HeaderText = ColumnHeaders[c],
Width = 80,
SortMode = DataGridViewColumnSortMode.NotSortable
};
gridCurrents.Columns.Add(col);
}
for (int r = 0; r < CircuitRows; r++)
{
int idx = gridCurrents.Rows.Add();
gridCurrents.Rows[idx].HeaderCell.Value = "第" + (r + 1) + "路(A)";
gridCurrents.Rows[idx].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
}
for (int s = 0; s < SummaryRows; s++)
{
int idx = gridCurrents.Rows.Add();
var row = gridCurrents.Rows[idx];
row.HeaderCell.Value = SummaryLabels[s];
row.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
row.HeaderCell.Style.Font = new Font("宋体", 9, FontStyle.Bold);
row.ReadOnly = true;
Color bg = s == 0 ? SumRowBackColor : SummaryRowBackColor;
for (int c = 0; c < ColumnCount; c++)
{
row.Cells[c].Style.BackColor = bg;
row.Cells[c].Style.Font = new Font("宋体", 9, FontStyle.Bold);
row.Cells[c].Value = "";
}
}
for (int r = 0; r < CircuitRows; r++)
{
for (int c = 0; c < ColumnCount; c++)
{
gridCurrents.Rows[r].Cells[c].Style.BackColor = InputCellBackColor;
}
}
gridCurrents.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing;
gridCurrents.ColumnHeadersHeight = 30;
gridCurrents.RowHeadersWidth = 95;
gridCurrents.AllowUserToResizeRows = false;
DisableAdgvFilterButtons(gridCurrents);
gridCurrents.ResumeLayout();
}
private void BuildBusbarGrid()
{
gridBusbar.SuspendLayout();
gridBusbar.Columns.Clear();
gridBusbar.Rows.Clear();
var colSpec = new DataGridViewTextBoxColumn
{
Name = "bspec",
HeaderText = "铜排规格",
Width = 160,
SortMode = DataGridViewColumnSortMode.NotSortable
};
var colRate = new DataGridViewTextBoxColumn
{
Name = "brate",
HeaderText = "载流量 (A)",
Width = 160,
SortMode = DataGridViewColumnSortMode.NotSortable
};
gridBusbar.Columns.Add(colSpec);
gridBusbar.Columns.Add(colRate);
for (int i = 0; i < BusbarSpecs.Length; i++)
{
int idx = gridBusbar.Rows.Add();
gridBusbar.Rows[idx].Cells[0].Value = BusbarSpecs[i];
gridBusbar.Rows[idx].Cells[1].Value = BusbarRatings[i].ToString("0") + "A";
}
gridBusbar.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing;
gridBusbar.ColumnHeadersHeight = 28;
int totalW = gridBusbar.ClientSize.Width;
if (totalW > 20)
{
gridBusbar.Columns[0].Width = totalW / 2;
gridBusbar.Columns[1].Width = totalW - totalW / 2;
}
gridBusbar.ClearSelection();
gridBusbar.ScrollBars = ScrollBars.Vertical;
DisableAdgvFilterButtons(gridBusbar);
gridBusbar.ResumeLayout();
}
private void BuildQuoteGrid()
{
gridQuote.SuspendLayout();
gridQuote.Rows.Clear();
for (int i = 0; i < QuoteItems.Length; i++)
{
int idx = gridQuote.Rows.Add();
gridQuote.Rows[idx].Cells[QCOL_ITEM].Value = QuoteItems[i];
gridQuote.Rows[idx].Cells[QCOL_PRICE].Value = "";
gridQuote.Rows[idx].Cells[QCOL_QTY].Value = "0";
gridQuote.Rows[idx].Cells[QCOL_SUB].Value = "0";
}
gridQuote.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing;
gridQuote.ColumnHeadersHeight = 30;
gridQuote.AllowUserToResizeRows = false;
DisableAdgvFilterButtons(gridQuote);
gridQuote.ClearSelection();
gridQuote.ResumeLayout();
}
private void DisableAdgvFilterButtons(Smart.CustomComponents.EnhancedDataGridView grid)
{
// Smart EnhancedDataGridView 没有内置筛选按钮,无需禁用
}
private void InitDefaultValues()
{
double cabinetPrice = DefaultCabinetPrice;
double[] drawerPrices = (double[])DefaultDrawerPrices.Clone();
double[] saved = LoadSavedPrices();
if (saved != null && saved.Length >= 1 + DefaultDrawerPrices.Length)
{
cabinetPrice = saved[0];
for (int i = 0; i < DefaultDrawerPrices.Length; i++) drawerPrices[i] = saved[1 + i];
}
_isCalculating = true;
try
{
gridQuote.Rows[0].Cells[QCOL_PRICE].Value = cabinetPrice.ToString("0");
gridQuote.Rows[0].Cells[QCOL_QTY].Value = DefaultCabinetQty.ToString("0");
for (int i = 0; i < DefaultDrawerPrices.Length; i++)
{
gridQuote.Rows[1 + i].Cells[QCOL_PRICE].Value = drawerPrices[i].ToString("0");
gridQuote.Rows[1 + i].Cells[QCOL_QTY].Value = "0";
}
}
finally
{
_isCalculating = false;
}
}
private void WireEvents()
{
gridCurrents.CellValueChanged += gridCurrents_CellValueChanged;
gridCurrents.CurrentCellDirtyStateChanged += gridCurrents_CurrentCellDirtyStateChanged;
gridCurrents.CellValidating += gridCurrents_CellValidating;
gridQuote.CellValueChanged += gridQuote_CellValueChanged;
gridQuote.CurrentCellDirtyStateChanged += gridQuote_CurrentCellDirtyStateChanged;
checkBox1.CheckedChanged += checkBox1_CheckedChanged;
checkBox2.CheckedChanged += (s, e) => { if (!_isCalculating) RecalculateAll(); };
comboBox1.SelectedIndexChanged += comboBox1_SelectedIndexChanged;
btnClear.Click += btnClear_Click;
button1.Click += button1_Click;
button2.Click += button2_Click;
button3.Click += button3_Click;
this.SizeChanged += (s, e) => RelayoutBusbarColumns();
}
private void RelayoutBusbarColumns()
{
if (gridBusbar.Columns.Count < 2) return;
int totalW = gridBusbar.ClientSize.Width;
if (totalW <= 20) return;
gridBusbar.Columns[0].Width = totalW / 2;
gridBusbar.Columns[1].Width = totalW - totalW / 2;
}
private void gridCurrents_CurrentCellDirtyStateChanged(object sender, EventArgs e)
{
if (gridCurrents.IsCurrentCellDirty)
{
gridCurrents.CommitEdit(DataGridViewDataErrorContexts.Commit);
}
}
private void gridCurrents_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
if (e.RowIndex < 0 || e.RowIndex >= CircuitRows) return;
string txt = e.FormattedValue == null ? "" : e.FormattedValue.ToString().Trim();
if (txt.Length == 0) return;
if (!IsNonNegativeNumber(txt))
{
e.Cancel = true;
MessageBox.Show("请输入有效的电流数值 (≥0)。", "输入错误",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
private void gridCurrents_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if (_isCalculating) return;
if (e.RowIndex < 0 || e.RowIndex >= CircuitRows) return;
RecalculateAll();
}
private void gridQuote_CurrentCellDirtyStateChanged(object sender, EventArgs e)
{
if (gridQuote.IsCurrentCellDirty)
{
gridQuote.CommitEdit(DataGridViewDataErrorContexts.Commit);
}
}
private void gridQuote_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if (_isCalculating) return;
if (e.RowIndex < 0) return;
if (e.ColumnIndex != QCOL_PRICE && e.ColumnIndex != QCOL_QTY) return;
RecalculateAll();
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (_isCalculating) return;
RecalculateAll();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (_isCalculating) return;
RecalculateAll();
// ★不要在这里调 刷新推荐窗口数据()——下拉消息循环期间刷新推荐窗会吞掉
// 推荐窗按钮的 Click(2026-09-26 23:36 实测:MouseDown 到达但 Click 全灭)。
// 推荐窗在"打开时"和"点插入时"各按当前选定列取数一次(已验证可靠)。
}
private void RecalculateAll()
{
_isCalculating = true;
try
{
int sel = GetSelectedColumn();
RecalculateCurrents(sel);
AutoCalcDrawers();
RecalculateQuote();
UpdateBusbarRecommendation();
}
finally
{
_isCalculating = false;
}
}
private void RecalculateCurrents(int targetColumn = -1)
{
_maxLoadCurrent = 0;
for (int c = 0; c < ColumnCount; c++)
{
int circuitCount = 0;
double sum = 0;
for (int r = 0; r < CircuitRows; r++)
{
double v = GetCellDouble(gridCurrents.Rows[r].Cells[c].Value);
if (v > 0)
{
circuitCount++;
sum += v;
}
}
double ks = GetKsByCircuitCount(circuitCount);
double calcCurrent = sum * ks;
if (targetColumn < 0 || targetColumn == c)
{
if (calcCurrent > _maxLoadCurrent)
{
_maxLoadCurrent = calcCurrent;
}
}
for (int s = 0; s < SummaryRows; s++)
{
double val = sum * SummaryFactors[s];
var cell = gridCurrents.Rows[CircuitRows + s].Cells[c];
cell.Value = sum > 0 ? FormatCurrent(val) : "";
}
}
}
private double GetKsByCircuitCount(int n)
{
if (n <= 0) return 1.0;
if (n == 1) return 1.0;
if (n <= 3) return 0.9;
if (n <= 5) return 0.8;
if (n <= 9) return 0.7;
return 0.6;
}
private void AutoCalcDrawers()
{
int[] counts = new int[7];
bool useHalfDrawer = checkBox2 != null && checkBox2.Checked;
int colStart, colEnd;
int sel = GetSelectedColumn();
if (sel < 0) { colStart = 0; colEnd = ColumnCount - 1; }
else { colStart = sel; colEnd = sel; }
for (int r = 0; r < CircuitRows; r++)
{
for (int c = colStart; c <= colEnd; c++)
{
double v = GetCellDouble(gridCurrents.Rows[r].Cells[c].Value);
if (v <= 0) continue;
int idx = PickDrawerRow(v, useHalfDrawer);
if (idx >= 1 && idx <= 6)
counts[idx]++;
}
}
if (checkBox1 != null && checkBox1.Checked)
{
for (int i = 1; i <= 6; i++)
{
gridQuote.Rows[i].Cells[QCOL_QTY].Value = counts[i].ToString("0");
}
}
}
private int GetSelectedColumn()
{
try
{
if (comboBox1 == null || comboBox1.SelectedIndex <= 0) return -1;
return comboBox1.SelectedIndex - 1;
}
catch { return -1; }
}
private int PickDrawerRow(double current, bool useHalfDrawer)
{
if (current <= 0) return -1;
if (useHalfDrawer && current <= 63) return 1;
if (current <= 125) return 2;
if (current <= 250) return 3;
if (current <= 400) return 4;
if (current <= 630) return 5;
if (current <= 800) return 6;
return -1;
}
private void RecalculateQuote()
{
double total = 0;
for (int i = 0; i < gridQuote.Rows.Count; i++)
{
double price = GetCellDouble(gridQuote.Rows[i].Cells[QCOL_PRICE].Value);
double qty = GetCellDouble(gridQuote.Rows[i].Cells[QCOL_QTY].Value);
double sub = price * qty;
gridQuote.Rows[i].Cells[QCOL_SUB].Value = sub.ToString("0.##");
total += sub;
}
lblTotalPrice.Text = total.ToString("0.##");
}
private void UpdateBusbarRecommendation()
{
string recommend = PickBusbar(_maxLoadCurrent);
int recRowIdx = -1;
for (int i = 0; i < gridBusbar.Rows.Count; i++)
{
var row = gridBusbar.Rows[i];
bool isRec = recommend != null && BusbarSpecs[i] == recommend;
if (isRec) recRowIdx = i;
for (int c = 0; c < row.Cells.Count; c++)
{
row.Cells[c].Style.BackColor = isRec ? RecommendBackColor : Color.White;
row.Cells[c].Style.SelectionBackColor = isRec ? RecommendBackColor : Color.White;
row.Cells[c].Style.Font = isRec ? new Font("宋体", 9, FontStyle.Bold) : new Font("宋体", 9);
}
}
if (recRowIdx >= 0 && recRowIdx < gridBusbar.Rows.Count)
{
try
{
gridBusbar.FirstDisplayedScrollingRowIndex = recRowIdx;
gridBusbar.CurrentCell = gridBusbar.Rows[recRowIdx].Cells[0];
}
catch { }
}
int selCol = GetSelectedColumn();
string scope = selCol < 0 ? "全部" : ColumnHeaders[selCol];
if (_maxLoadCurrent > 0)
{
lblRecommend.Text = recommend == null
? "推荐铜排 [" + scope + "]: 计算电流 " + _maxLoadCurrent.ToString("0.#") + "A 超出最大规格!"
: "推荐铜排 [" + scope + "]: " + recommend + " (计算电流 " + _maxLoadCurrent.ToString("0.#") + "A)";
}
else
{
lblRecommend.Text = "推荐铜排: (请先在上方输入各回路电流)";
}
FitRecommendText();
}
private string PickBusbar(double needCurrent)
{
if (needCurrent <= 0) return null;
for (int i = 0; i < BusbarRatings.Length; i++)
{
if (BusbarRatings[i] >= needCurrent)
return BusbarSpecs[i];
}
return null;
}
private double GetCellDouble(object value)
{
if (value == null) return 0;
return GetTextDouble(value.ToString());
}
private double GetTextDouble(string s)
{
if (string.IsNullOrWhiteSpace(s)) return 0;
double v;
if (double.TryParse(s.Trim(), NumberStyles.Any, CultureInfo.InvariantCulture, out v))
return v;
if (double.TryParse(s.Trim(), NumberStyles.Any, CultureInfo.CurrentCulture, out v))
return v;
return 0;
}
private bool IsNonNegativeNumber(string s)
{
double v;
if (double.TryParse(s.Trim(), NumberStyles.Any, CultureInfo.InvariantCulture, out v))
return v >= 0;
return false;
}
private string FormatCurrent(double v)
{
if (v == 0) return "";
if (Math.Abs(v - Math.Round(v)) < 0.001)
return Math.Round(v).ToString("0");
return v.ToString("0.#");
}
private void btnClear_Click(object sender, EventArgs e)
{
if (MessageBox.Show("确定要清空所有电流输入和抽屉数量吗?\n(柜体数量保留,单价保留默认值)",
"确认清空", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) return;
for (int r = 0; r < CircuitRows; r++)
{
for (int c = 0; c < ColumnCount; c++)
{
gridCurrents.Rows[r].Cells[c].Value = "";
}
}
_isCalculating = true;
try
{
for (int i = 1; i < gridQuote.Rows.Count; i++)
{
gridQuote.Rows[i].Cells[QCOL_QTY].Value = "0";
}
}
finally { _isCalculating = false; }
RecalculateAll();
}
private string PricesFilePath
{
get
{
string dir = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"GCS铜排壳体计算");
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
return Path.Combine(dir, "单价.cfg");
}
}
private void button1_Click(object sender, EventArgs e)
{
try
{
var parts = new List<string>();
for (int i = 0; i < gridQuote.Rows.Count; i++)
{
object v = gridQuote.Rows[i].Cells[QCOL_PRICE].Value;
parts.Add(v == null ? "" : v.ToString().Trim());
}
File.WriteAllText(PricesFilePath, string.Join(",", parts),
System.Text.Encoding.UTF8);
MessageBox.Show("单价已保存,下次打开程序将自动使用这些单价。",
"保存成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show("保存单价失败: " + ex.Message, "错误",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private double[] LoadSavedPrices()
{
try
{
if (!File.Exists(PricesFilePath)) return null;
string content = File.ReadAllText(PricesFilePath, System.Text.Encoding.UTF8).Trim();
if (string.IsNullOrEmpty(content)) return null;
string[] parts = content.Split(',');
var result = new double[parts.Length];
for (int i = 0; i < parts.Length; i++)
{
if (!double.TryParse(parts[i].Trim(), NumberStyles.Any,
CultureInfo.InvariantCulture, out result[i])) return null;
}
return result;
}
catch
{
return null;
}
}
private void button2_Click(object sender, EventArgs e)
{
// 非模态打开推荐铜排窗口,打开时主窗口/GCS窗口仍可点击
if (_recommendForm != null && !_recommendForm.IsDisposed)
{
MainForm.写日志("[推荐铜排] button2:窗口已开,激活已有实例");
_recommendForm.Activate();
return;
}
int sel = GetSelectedColumn();
string scope = sel < 0 ? "全部" : ColumnHeaders[sel];
MainForm.写日志("[推荐铜排] button2:新建窗口(范围=" + scope + ", 电流 " + (GetAllCircuitCurrents(sel) == null ? 0 : GetAllCircuitCurrents(sel).Count) + " 个)");
_recommendForm = new GCS推荐铜排窗口();
_recommendForm.宿主 = this; // ★插入前实时重取回路电流用
_recommendForm.SetCircuitCurrents(GetAllCircuitCurrents(sel), scope);
_recommendForm.Show(this);
_recommendForm.BringToFront(); // ★确保不被主窗口压住(ShowInTaskbar=false 无任务栏按钮)
_recommendForm.FormClosed += (s2, e2) => { _recommendForm = null; };
}
/// <summary>★供推荐铜排窗口在点"插入"前实时重取回路电流(2026-09-26 用户报:
/// 先开推荐窗后回 GCS 窗输电流,推荐窗还是打开时的旧快照→回路数全 0→插入被"没有铜排"挡住)。
/// ★严格按 GCS 窗口当前下拉选定的列统计(用户 2026-09-26 确认:推荐窗必须匹配选择的列,
/// 选了 1#/2#/3# 就只算该列;下拉切列时推荐窗实时跟随)。</summary>
internal void 刷新推荐窗口数据()
{
if (_recommendForm == null || _recommendForm.IsDisposed) return;
int sel = GetSelectedColumn();
var currents = GetAllCircuitCurrents(sel);
string scope = sel < 0 ? "全部" : ColumnHeaders[sel];
MainForm.写日志("[推荐铜排] 刷新: 范围=" + scope + " 取到 " + (currents == null ? 0 : currents.Count) + " 个回路电流");
_recommendForm.SetCircuitCurrents(currents, scope);
}
/// <summary>在打开的窗体中查找主窗口(MyApp.MainForm)实例。</summary>
private MainForm FindMainForm()
{
foreach (Form f in Application.OpenForms)
{
if (f is MainForm) return (MainForm)f;
}
return null;
}
/// <summary>
/// "插入铜排"按钮(button3):把当前推荐的垂直母排规格插入主窗口元件表。
/// 规格取 lblRecommend 当前推荐结果(PickBusbar(_maxLoadCurrent)),数量默认 1 米,
/// 表价由主窗口按母排界面当前铜价自动计算。
/// </summary>
private void button3_Click(object sender, EventArgs e)
{
MainForm main = FindMainForm();
if (main == null)
{
MessageBox.Show("未找到MainForm,无法插入。", "提示",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (_maxLoadCurrent <= 0)
{
MainForm.写日志("[GCS窗口] 插入被防呆挡住: 未输入回路电流(_maxLoadCurrent=0)");
MessageBox.Show("请先在上方输入回路电流,计算出推荐铜排后再插入。", "提示",
MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
string recommend = PickBusbar(_maxLoadCurrent);
if (string.IsNullOrEmpty(recommend))
{
MessageBox.Show("计算电流超出最大铜排规格,无法选型。", "提示",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (main.InsertGcs母排(recommend, 1))
{
MessageBox.Show("已插入垂直母排「" + recommend + "」到报价元件表。", "插入完成",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
public List<double> GetAllCircuitCurrents(int targetColumn = -1)
{
var list = new List<double>();
int colStart, colEnd;
if (targetColumn < 0) { colStart = 0; colEnd = ColumnCount - 1; }
else { colStart = targetColumn; colEnd = targetColumn; }
for (int r = 0; r < CircuitRows; r++)
{
for (int c = colStart; c <= colEnd; c++)
{
double v = GetCellDouble(gridCurrents.Rows[r].Cells[c].Value);
if (v > 0) list.Add(v);
}
}
return list;
}
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>