添加窗口

This commit is contained in:
2026-06-09 16:59:53 +08:00 Unverified
parent 518254d5ae
commit 1313ddafb0
15 changed files with 1232 additions and 77 deletions
-39
View File
@@ -1,39 +0,0 @@
namespace kcsj
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Text = "Form1";
}
#endregion
}
}
-10
View File
@@ -1,10 +0,0 @@
namespace kcsj
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
+71
View File
@@ -0,0 +1,71 @@
namespace kcsj.Forms
{
partial class DataInputForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
DataFromFiles = new Button();
button2 = new Button();
SuspendLayout();
//
// DataFromFiles
//
DataFromFiles.Location = new Point(57, 34);
DataFromFiles.Name = "DataFromFiles";
DataFromFiles.Size = new Size(165, 68);
DataFromFiles.TabIndex = 0;
DataFromFiles.Text = "从文件读取";
DataFromFiles.UseVisualStyleBackColor = true;
DataFromFiles.Click += DataFromFiles_Click;
//
// button2
//
button2.Location = new Point(57, 119);
button2.Name = "button2";
button2.Size = new Size(165, 74);
button2.TabIndex = 1;
button2.Text = "手动输入";
button2.UseVisualStyleBackColor = true;
//
// DataInputForm
//
AutoScaleDimensions = new SizeF(11F, 24F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(288, 218);
Controls.Add(button2);
Controls.Add(DataFromFiles);
Name = "DataInputForm";
Text = "数据输入";
ResumeLayout(false);
}
#endregion
private Button DataFromFiles;
private Button button2;
}
}
+27
View File
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace kcsj.Forms
{
public partial class DataInputForm : Form
{
public DataInputForm()
{
InitializeComponent();
}
private void DataFromFiles_Click(object sender, EventArgs e)
{
FileInputForm form = new FileInputForm();
form.ShowDialog();
}
}
}
+185
View File
@@ -0,0 +1,185 @@
namespace kcsj.Forms
{
partial class FileInputForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
KnownPointFile = new Label();
KonwnSFile = new Label();
btnSubmitData = new Button();
txtKnownPath = new TextBox();
txtObservationPath = new TextBox();
btnFileView1 = new Button();
btnFileView2 = new Button();
btnViewData = new Button();
dgvKnownPoints = new DataGridView();
dgvObservations = new DataGridView();
txtKnownPoints = new Label();
((System.ComponentModel.ISupportInitialize)dgvKnownPoints).BeginInit();
((System.ComponentModel.ISupportInitialize)dgvObservations).BeginInit();
SuspendLayout();
//
// KnownPointFile
//
KnownPointFile.AutoSize = true;
KnownPointFile.Location = new Point(37, 43);
KnownPointFile.Name = "KnownPointFile";
KnownPointFile.Size = new Size(136, 24);
KnownPointFile.TabIndex = 0;
KnownPointFile.Text = "已知点文件路径";
//
// KonwnSFile
//
KonwnSFile.AutoSize = true;
KonwnSFile.Location = new Point(37, 89);
KonwnSFile.Name = "KonwnSFile";
KonwnSFile.Size = new Size(136, 24);
KonwnSFile.TabIndex = 1;
KonwnSFile.Text = "观测值文件路径";
//
// btnSubmitData
//
btnSubmitData.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
btnSubmitData.Location = new Point(641, 38);
btnSubmitData.Name = "btnSubmitData";
btnSubmitData.Size = new Size(106, 83);
btnSubmitData.TabIndex = 2;
btnSubmitData.Text = "导入数据";
btnSubmitData.UseVisualStyleBackColor = true;
btnSubmitData.Click += btnSubmitData_Click;
//
// txtKnownPath
//
txtKnownPath.Location = new Point(190, 40);
txtKnownPath.Name = "txtKnownPath";
txtKnownPath.Size = new Size(194, 30);
txtKnownPath.TabIndex = 3;
//
// txtObservationPath
//
txtObservationPath.Location = new Point(190, 91);
txtObservationPath.Name = "txtObservationPath";
txtObservationPath.Size = new Size(194, 30);
txtObservationPath.TabIndex = 4;
//
// btnFileView1
//
btnFileView1.Location = new Point(390, 38);
btnFileView1.Name = "btnFileView1";
btnFileView1.Size = new Size(112, 34);
btnFileView1.TabIndex = 5;
btnFileView1.Text = "浏览";
btnFileView1.UseVisualStyleBackColor = true;
btnFileView1.Click += btnFileView1_Click;
//
// btnFileView2
//
btnFileView2.Location = new Point(390, 89);
btnFileView2.Name = "btnFileView2";
btnFileView2.Size = new Size(112, 34);
btnFileView2.TabIndex = 6;
btnFileView2.Text = "浏览";
btnFileView2.UseVisualStyleBackColor = true;
btnFileView2.Click += btnFileView2_Click;
//
// btnViewData
//
btnViewData.Location = new Point(529, 38);
btnViewData.Name = "btnViewData";
btnViewData.Size = new Size(106, 83);
btnViewData.TabIndex = 7;
btnViewData.Text = "预览数据";
btnViewData.UseVisualStyleBackColor = true;
btnViewData.Click += btnViewData_Click;
//
// dgvKnownPoints
//
dgvKnownPoints.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dgvKnownPoints.Location = new Point(31, 154);
dgvKnownPoints.Name = "dgvKnownPoints";
dgvKnownPoints.RowHeadersWidth = 62;
dgvKnownPoints.Size = new Size(710, 226);
dgvKnownPoints.TabIndex = 8;
//
// dgvObservations
//
dgvObservations.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dgvObservations.Location = new Point(31, 409);
dgvObservations.Name = "dgvObservations";
dgvObservations.RowHeadersWidth = 62;
dgvObservations.Size = new Size(710, 245);
dgvObservations.TabIndex = 9;
//
// txtKnownPoints
//
txtKnownPoints.AutoSize = true;
txtKnownPoints.Location = new Point(354, 127);
txtKnownPoints.Name = "txtKnownPoints";
txtKnownPoints.Size = new Size(64, 24);
txtKnownPoints.TabIndex = 10;
txtKnownPoints.Text = "已知点";
//
// FileInputForm
//
AutoScaleDimensions = new SizeF(11F, 24F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(769, 714);
Controls.Add(txtKnownPoints);
Controls.Add(dgvObservations);
Controls.Add(dgvKnownPoints);
Controls.Add(btnViewData);
Controls.Add(btnFileView2);
Controls.Add(btnFileView1);
Controls.Add(txtObservationPath);
Controls.Add(txtKnownPath);
Controls.Add(btnSubmitData);
Controls.Add(KonwnSFile);
Controls.Add(KnownPointFile);
MaximizeBox = false;
Name = "FileInputForm";
Text = "文件读取";
((System.ComponentModel.ISupportInitialize)dgvKnownPoints).EndInit();
((System.ComponentModel.ISupportInitialize)dgvObservations).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label KnownPointFile;
private Label KonwnSFile;
private Button btnSubmitData;
private TextBox txtKnownPath;
private TextBox txtObservationPath;
private Button btnFileView1;
private Button btnFileView2;
private Button btnViewData;
private DataGridView dgvKnownPoints;
private DataGridView dgvObservations;
private Label txtKnownPoints;
}
}
+299
View File
@@ -0,0 +1,299 @@
using kcsj.Models;
using kcsj.Services;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
namespace kcsj.Forms
{
public partial class FileInputForm : Form
{
// 保存解析后的已知点和观测值
private List<KnownPoint> knownPoints = new List<KnownPoint>();
private List<Observation> observations = new List<Observation>();
public List<KnownPoint> ImportedKnownPoints { get; private set; }
public List<Observation> ImportedObservations { get; private set; }
public FileInputForm()
{
InitializeComponent();
InitGridStyle();
}
// 初始化表格样式
private void InitGridStyle()
{
dgvKnownPoints.ReadOnly = true;
dgvKnownPoints.AllowUserToAddRows = false;
dgvKnownPoints.AllowUserToDeleteRows = false;
dgvKnownPoints.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dgvKnownPoints.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvObservations.ReadOnly = true;
dgvObservations.AllowUserToAddRows = false;
dgvObservations.AllowUserToDeleteRows = false;
dgvObservations.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dgvObservations.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
}
// 通用选择 TXT 文件函数
private string SelectTxtFile(string title)
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Title = title;
dialog.Filter = "文本文件 (*.txt)|*.txt|所有文件 (*.*)|*.*";
dialog.Multiselect = false;
if (dialog.ShowDialog() == DialogResult.OK)
{
return dialog.FileName;
}
return "";
}
// 浏览已知点文件
private void btnFileView1_Click(object sender, EventArgs e)
{
string path = SelectTxtFile("选择已知点高程文件");
if (path != "")
{
txtKnownPath.Text = path;
}
}
// 浏览观测值文件
private void btnFileView2_Click(object sender, EventArgs e)
{
string path = SelectTxtFile("选择观测值文件");
if (path != "")
{
txtObservationPath.Text = path;
}
}
// 按空格、Tab、英文逗号、中文逗号分割每一行
private string[] SplitLine(string line)
{
return line.Split(new char[] { ' ', '\t', ',', '' },
StringSplitOptions.RemoveEmptyEntries);
}
// 读取已知点 TXT
private List<KnownPoint> ReadKnownPoints(string filePath)
{
List<KnownPoint> result = new List<KnownPoint>();
HashSet<string> pointNames = new HashSet<string>();
string[] lines = File.ReadAllLines(filePath, Encoding.UTF8);
for (int i = 0; i < lines.Length; i++)
{
string line = lines[i].Trim();
if (string.IsNullOrWhiteSpace(line))
continue;
if (line.StartsWith("#") || line.StartsWith("//"))
continue;
string[] parts = SplitLine(line);
if (parts.Length != 2)
{
throw new Exception($"已知点文件第 {i + 1} 行格式错误,应为:点名 高程");
}
string name = parts[0];
if (!double.TryParse(parts[1], out double elevation))
{
throw new Exception($"已知点文件第 {i + 1} 行高程不是有效数字");
}
if (pointNames.Contains(name))
{
throw new Exception($"已知点文件第 {i + 1} 行点名重复:{name}");
}
pointNames.Add(name);
result.Add(new KnownPoint(name, elevation));
}
if (result.Count == 0)
{
throw new Exception("已知点文件为空或没有有效数据");
}
return result;
}
// 读取观测值 TXT
private List<Observation> ReadObservations(string filePath)
{
List<Observation> result = new List<Observation>();
string[] lines = File.ReadAllLines(filePath, Encoding.UTF8);
for (int i = 0; i < lines.Length; i++)
{
string line = lines[i].Trim();
if (string.IsNullOrWhiteSpace(line))
continue;
if (line.StartsWith("#") || line.StartsWith("//"))
continue;
string[] parts = SplitLine(line);
if (parts.Length != 4)
{
throw new Exception($"观测文件第 {i + 1} 行格式错误,应为:起点 终点 高差 距离");
}
string from = parts[0];
string to = parts[1];
if (from == to)
{
throw new Exception($"观测文件第 {i + 1} 行起点和终点不能相同");
}
if (!double.TryParse(parts[2], out double heightDiff))
{
throw new Exception($"观测文件第 {i + 1} 行高差不是有效数字");
}
if (!double.TryParse(parts[3], out double distance))
{
throw new Exception($"观测文件第 {i + 1} 行距离不是有效数字");
}
if (distance <= 0)
{
throw new Exception($"观测文件第 {i + 1} 行距离必须大于 0");
}
result.Add(new Observation(from, to, heightDiff, distance));
}
if (result.Count == 0)
{
throw new Exception("观测文件为空或没有有效数据");
}
return result;
}
// 设置表格中文表头
private void SetGridHeader()
{
if (dgvKnownPoints.Columns.Count > 0)
{
dgvKnownPoints.Columns["Name"].HeaderText = "点名";
dgvKnownPoints.Columns["Elevation"].HeaderText = "高程";
}
if (dgvObservations.Columns.Count > 0)
{
dgvObservations.Columns["FromPoint"].HeaderText = "起点";
dgvObservations.Columns["ToPoint"].HeaderText = "终点";
dgvObservations.Columns["HeightDiff"].HeaderText = "高差";
dgvObservations.Columns["Distance"].HeaderText = "距离";
}
}
// 点击“预览数据”
private void btnViewData_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(txtKnownPath.Text))
{
MessageBox.Show("请先选择已知点高程文件");
return;
}
if (string.IsNullOrWhiteSpace(txtObservationPath.Text))
{
MessageBox.Show("请先选择观测值文件");
return;
}
knownPoints = ReadKnownPoints(txtKnownPath.Text);
observations = ReadObservations(txtObservationPath.Text);
dgvKnownPoints.DataSource = null;
dgvKnownPoints.DataSource = knownPoints;
dgvObservations.DataSource = null;
dgvObservations.DataSource = observations;
SetGridHeader();
MessageBox.Show("数据预览成功!");
LogService.AddLog("数据预览成功!");
}
catch (Exception ex)
{
dgvKnownPoints.DataSource = null;
dgvObservations.DataSource = null;
MessageBox.Show($"数据预览失败:{ex.Message} ");
LogService.AddLog($"数据预览失败:{ex.Message} ");
}
}
private void btnSubmitData_Click(object sender, EventArgs e)
{
try
{
// 如果还没有点“预览数据”,这里自动读取一次
if (knownPoints == null || knownPoints.Count == 0 ||
observations == null || observations.Count == 0)
{
if (string.IsNullOrWhiteSpace(txtKnownPath.Text))
{
MessageBox.Show("请先选择已知点高程文件");
return;
}
if (string.IsNullOrWhiteSpace(txtObservationPath.Text))
{
MessageBox.Show("请先选择观测值文件");
return;
}
knownPoints = ReadKnownPoints(txtKnownPath.Text);
observations = ReadObservations(txtObservationPath.Text);
}
// 把数据交给主窗体
ImportedKnownPoints = knownPoints;
ImportedObservations = observations;
MessageBox.Show("数据导入成功!");
LogService.AddLog("数据导入成功!");
this.DialogResult = DialogResult.OK;
this.Close();
}
catch (Exception ex)
{
MessageBox.Show("导入失败:" + ex.Message);
LogService.AddLog("导入失败:" + ex.Message);
}
}
}
}
+120
View File
@@ -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>
+263
View File
@@ -0,0 +1,263 @@
namespace kcsj.Forms
{
partial class MainForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
MainTitle = new Label();
btnDataInput = new Button();
btnDataInspect = new Button();
btnStartAdjust = new Button();
button2 = new Button();
button3 = new Button();
LOG = new RichTextBox();
MainLog = new Label();
ClearLog = new Button();
menuStrip1 = new MenuStrip();
ToolStripMenuItem = new ToolStripMenuItem();
ToolStripMenuItem = new ToolStripMenuItem();
ToolStripMenuItem = new ToolStripMenuItem();
ToolStripMenuItem = new ToolStripMenuItem();
ToolStripMenuItem = new ToolStripMenuItem();
ToolStripMenuItem = new ToolStripMenuItem();
ToolStripMenuItem = new ToolStripMenuItem();
ToolStripMenuItem = new ToolStripMenuItem();
ToolStripMenuItem = new ToolStripMenuItem();
ToolStripMenuItem = new ToolStripMenuItem();
menuStrip1.SuspendLayout();
SuspendLayout();
//
// MainTitle
//
MainTitle.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
MainTitle.AutoSize = true;
MainTitle.Font = new Font("微软雅黑", 12F, FontStyle.Bold, GraphicsUnit.Point, 134);
MainTitle.Location = new Point(236, 55);
MainTitle.Name = "MainTitle";
MainTitle.Size = new Size(182, 31);
MainTitle.TabIndex = 0;
MainTitle.Text = "水准网平差程序";
MainTitle.TextAlign = ContentAlignment.TopCenter;
//
// btnDataInput
//
btnDataInput.Location = new Point(30, 94);
btnDataInput.Name = "btnDataInput";
btnDataInput.Size = new Size(202, 64);
btnDataInput.TabIndex = 1;
btnDataInput.Text = "数据输入";
btnDataInput.UseVisualStyleBackColor = true;
btnDataInput.Click += btnDataInput_Click;
//
// btnDataInspect
//
btnDataInspect.Location = new Point(30, 164);
btnDataInspect.Name = "btnDataInspect";
btnDataInspect.Size = new Size(202, 64);
btnDataInspect.TabIndex = 2;
btnDataInspect.Text = "数据检查";
btnDataInspect.UseVisualStyleBackColor = true;
//
// btnStartAdjust
//
btnStartAdjust.Location = new Point(30, 234);
btnStartAdjust.Name = "btnStartAdjust";
btnStartAdjust.Size = new Size(202, 64);
btnStartAdjust.TabIndex = 3;
btnStartAdjust.Text = "开始平差";
btnStartAdjust.UseVisualStyleBackColor = true;
//
// button2
//
button2.Location = new Point(30, 304);
button2.Name = "button2";
button2.Size = new Size(202, 64);
button2.TabIndex = 4;
button2.Text = "查看结果";
button2.UseVisualStyleBackColor = true;
//
// button3
//
button3.Location = new Point(30, 374);
button3.Name = "button3";
button3.Size = new Size(202, 64);
button3.TabIndex = 5;
button3.Text = "输出报告";
button3.UseVisualStyleBackColor = true;
//
// LOG
//
LOG.Location = new Point(275, 152);
LOG.Name = "LOG";
LOG.ReadOnly = true;
LOG.Size = new Size(356, 286);
LOG.TabIndex = 6;
LOG.Text = "";
//
// MainLog
//
MainLog.AutoSize = true;
MainLog.Font = new Font("微软雅黑", 10.5F, FontStyle.Bold, GraphicsUnit.Point, 134);
MainLog.Location = new Point(340, 101);
MainLog.Name = "MainLog";
MainLog.Size = new Size(96, 28);
MainLog.TabIndex = 7;
MainLog.Text = "运行日志";
//
// ClearLog
//
ClearLog.Location = new Point(456, 101);
ClearLog.Name = "ClearLog";
ClearLog.Size = new Size(112, 34);
ClearLog.TabIndex = 8;
ClearLog.Text = "清除日志";
ClearLog.UseVisualStyleBackColor = true;
ClearLog.Click += ClearLog_Click;
//
// menuStrip1
//
menuStrip1.ImageScalingSize = new Size(24, 24);
menuStrip1.Items.AddRange(new ToolStripItem[] { ToolStripMenuItem, ToolStripMenuItem, ToolStripMenuItem, ToolStripMenuItem, ToolStripMenuItem });
menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1";
menuStrip1.Size = new Size(644, 32);
menuStrip1.TabIndex = 9;
menuStrip1.Text = "menuStrip1";
//
// 数据ToolStripMenuItem
//
ToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ToolStripMenuItem, ToolStripMenuItem, ToolStripMenuItem });
ToolStripMenuItem.Name = "数据ToolStripMenuItem";
ToolStripMenuItem.Size = new Size(98, 28);
ToolStripMenuItem.Text = "数据管理";
//
// 数据输入ToolStripMenuItem
//
ToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ToolStripMenuItem, ToolStripMenuItem });
ToolStripMenuItem.Name = "数据输入ToolStripMenuItem";
ToolStripMenuItem.Size = new Size(270, 34);
ToolStripMenuItem.Text = "数据输入";
//
// 从文件ToolStripMenuItem
//
ToolStripMenuItem.Name = "从文件ToolStripMenuItem";
ToolStripMenuItem.Size = new Size(270, 34);
ToolStripMenuItem.Text = "从文件";
ToolStripMenuItem.Click += ToolStripMenuItem_Click;
//
// 手动输入ToolStripMenuItem
//
ToolStripMenuItem.Name = "手动输入ToolStripMenuItem";
ToolStripMenuItem.Size = new Size(270, 34);
ToolStripMenuItem.Text = "手动输入";
//
// 删除当前数据ToolStripMenuItem
//
ToolStripMenuItem.Name = "删除当前数据ToolStripMenuItem";
ToolStripMenuItem.Size = new Size(270, 34);
ToolStripMenuItem.Text = "删除当前数据";
//
// 数据检查ToolStripMenuItem
//
ToolStripMenuItem.Name = "数据检查ToolStripMenuItem";
ToolStripMenuItem.Size = new Size(270, 34);
ToolStripMenuItem.Text = "数据检查";
//
// 开始平差ToolStripMenuItem
//
ToolStripMenuItem.Name = "开始平差ToolStripMenuItem";
ToolStripMenuItem.Size = new Size(98, 28);
ToolStripMenuItem.Text = "开始平差";
//
// 查看结果ToolStripMenuItem
//
ToolStripMenuItem.Name = "查看结果ToolStripMenuItem";
ToolStripMenuItem.Size = new Size(98, 28);
ToolStripMenuItem.Text = "查看结果";
//
// 输出报告ToolStripMenuItem
//
ToolStripMenuItem.Name = "输出报告ToolStripMenuItem";
ToolStripMenuItem.Size = new Size(98, 28);
ToolStripMenuItem.Text = "输出报告";
//
// 关于ToolStripMenuItem
//
ToolStripMenuItem.Name = "关于ToolStripMenuItem";
ToolStripMenuItem.Size = new Size(62, 28);
ToolStripMenuItem.Text = "关于";
//
// MainForm
//
AutoScaleDimensions = new SizeF(11F, 24F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(644, 470);
Controls.Add(ClearLog);
Controls.Add(MainLog);
Controls.Add(LOG);
Controls.Add(button3);
Controls.Add(button2);
Controls.Add(btnStartAdjust);
Controls.Add(btnDataInspect);
Controls.Add(btnDataInput);
Controls.Add(MainTitle);
Controls.Add(menuStrip1);
MainMenuStrip = menuStrip1;
MaximizeBox = false;
Name = "MainForm";
Text = "水准网平差程序";
Load += MainForm_Load;
menuStrip1.ResumeLayout(false);
menuStrip1.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label MainTitle;
private Button btnDataInput;
private Button btnDataInspect;
private Button btnStartAdjust;
private Button button2;
private Button button3;
private RichTextBox LOG;
private Label MainLog;
private Button ClearLog;
private MenuStrip menuStrip1;
private ToolStripMenuItem ToolStripMenuItem;
private ToolStripMenuItem ToolStripMenuItem;
private ToolStripMenuItem ToolStripMenuItem;
private ToolStripMenuItem ToolStripMenuItem;
private ToolStripMenuItem ToolStripMenuItem;
private ToolStripMenuItem ToolStripMenuItem;
private ToolStripMenuItem ToolStripMenuItem;
private ToolStripMenuItem ToolStripMenuItem;
private ToolStripMenuItem ToolStripMenuItem;
private ToolStripMenuItem ToolStripMenuItem;
}
}
+51
View File
@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using kcsj.Services;
namespace kcsj.Forms
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private void btnDataInput_Click(object sender, EventArgs e)
{
DataInputForm form = new DataInputForm();
form.ShowDialog();
}
private void MainForm_Load(object sender, EventArgs e)
{
LogService.OnLog += ShowLog;
LogService.AddLog("程序启动成功。");
}
private void ShowLog(string message)
{
LOG.AppendText(message + "\r\n");
LOG.ScrollToCaret();
}
private void ClearLog_Click(object sender, EventArgs e)
{
LOG.Clear();
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
FileInputForm form = new FileInputForm();
form.ShowDialog();
}
}
}
+123
View File
@@ -0,0 +1,123 @@
<?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>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
+20
View File
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace kcsj.Models
{
public class KnownPoint
{
public string Name { get; set; }
public double Elevation { get; set; }
public KnownPoint(string name, double elevation)
{
Name = name;
Elevation = elevation;
}
}
}
+24
View File
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace kcsj.Models
{
public class Observation
{
public string FromPoint { get; set; }
public string ToPoint { get; set; }
public double HeightDiff { get; set; }
public double Distance { get; set; }
public Observation(string fromPoint, string toPoint, double heightDiff, double distance)
{
FromPoint = fromPoint;
ToPoint = toPoint;
HeightDiff = heightDiff;
Distance = distance;
}
}
}
+3 -1
View File
@@ -1,3 +1,5 @@
using kcsj.Forms;
namespace kcsj namespace kcsj
{ {
internal static class Program internal static class Program
@@ -11,7 +13,7 @@ namespace kcsj
// To customize application configuration such as set high DPI settings or default font, // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration. // see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
Application.Run(new Form1()); Application.Run(new Forms.MainForm());
} }
} }
} }
+19
View File
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace kcsj.Services
{
public static class LogService
{
public static event Action<string> OnLog;
public static void AddLog(string message)
{
string time = DateTime.Now.ToString("HH:mm:ss");
OnLog?.Invoke($"[{time}] {message}");
}
}
}