資源簡介
C#,包括四參數(shù)計(jì)算和平面二維坐標(biāo)之間的轉(zhuǎn)換、簡潔易懂,過程清晰
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?System.IO;
namespace?CoordinateTransformation
{
????public?partial?class?Four_parameterCalculation?:?Form
????{
????????public?Four_parameterCalculation()
????????{
????????????InitializeComponent();
????????}
????????//初始化
????????private?void?onload(object?sender?EventArgs?e)
????????{
????????????dataGridView1.AutoGenerateColumns?=?false;
????????????dataGridView1.GridColor?=?System.Drawing.Color.Chocolate;
????????????dataGridView1.SelectionMode?=?DataGridViewSelectionMode.RowHeaderSelect;
????????}
????????//添加
????????private?void?OnAdd(object?sender?EventArgs?e)
????????{
????????????int?rowNo?=?dataGridView1.Rows.Add();
????????????dataGridView1.Rows[rowNo].Cells[“ColPoint“].Value?=?txbPoint.Text.Trim();
????????????dataGridView1.Rows[rowNo].Cells[“ColOldX“].Value?=?txbOX.Text.Trim();
????????????dataGridView1.Rows[rowNo].Cells[“ColOldY“].Value?=?txbOY.Text.Trim();
????????????dataGridView1.Rows[rowNo].Cells[“ColNewX“].Value?=?txbNX.Text.Trim();
????????????dataGridView1.Rows[rowNo].Cells[“ColNewY“].Value?=?txbNY.Text.Trim();
????????}
????????//導(dǎo)入
????????private?void?OnInput(object?sender?EventArgs?e)
????????{
????????????OpenFileDialog?open?=?new?OpenFileDialog();
????????????open.title?=?“請選擇數(shù)據(jù)文件“;
????????????open.InitialDirectory?=?“D:\\“;
????????????open.Filter?=?“文本文件(*.txt)|*.txt“;
????????????open.RestoreDirectory?=?true;
????????????if?(open.ShowDialog()?==?DialogResult.OK)
????????????{
????????????????FileStream?fs?=?new?FileStream(open.FileName?FileMode.Open);
????????????????StreamReader?sr?=?new?StreamReader(fs);
????????????????while?(!sr.EndOfStream)
????????????????{
????????????????????string?strLine?=?sr.ReadLine();
????????????????????if?(string.IsNullOrEmpty(strLine))
????????????????????{
????????????????????????continue;
????????????????????}
????????????????????string[]?arr?=?strLine.Split(new?string[]?{?“\r\n“?“?“?}?StringSplitOptions.RemoveEmptyEntries);
????????????????????dataGridView1.Rows.Add(arr);
????????????????}
????????????????sr.Close();
??
評論
共有 條評論