• 大小: 5KB
    文件类型: .cs
    金币: 1
    下载: 0 次
    发布日期: 2021-06-04
  • 语言: C#
  • 标签:

资源简介

C#,包括四参数计算和平面二维坐标之间的转换、简洁易懂,过程清晰

资源截图

代码片段和文件信息

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();
        }
        //导入
        private void OnInput(object sender EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();
            open.title = “请选择数据文件“;
            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();
  

评论

共有 条评论

相关资源