• 大小: 1.37MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-11-05
  • 语言: C#
  • 标签: TIN  

资源简介

C#可视化界面开发 效率很高 读文件绘制

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace tin
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        Stream myStream = null;
        StreamReader read_txt;
        int num;  //存储点数
        double xmax xmin ymax ymin; //存储点数据中xy的最大值及最小值
        public class points   //存储点数据
        {
            public static int[] ID;
            public static double[] x;
            public static double[] y;
        }
        public class orderedpoint  //存储第L号三角形三个顶点的编号
        {
            public static int[] IB1;
            public static int[] IB2;
            public static int[] IB3;
        }
        private int L K;
        private void 打开OToolStripMenuItem_Click(object sender EventArgs e)
        {
            // 打开文本文件
            openFileDialog1.Filter = “txt files(*.txt)|*.txt|All files(*.*)|*.*“;
            openFileDialog1.FilterIndex = 1;
            // 如果打开成功的话,则执行读文件函数
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if ((myStream = openFileDialog1.OpenFile()) != null)
                    {
                        using (myStream)
                        {
                            read_txt = new StreamReader(myStream);
                            //读文件函数
                            ReadFile(read_txt);
                            myStream.Close();
                        }
                        MessageBox.Show(“成功打开文件“);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show(“can‘t open file!“);

                }
            }
        }
        void ReadFile(StreamReader read_txt)
        {
            //读取前12行数据
            int count = 0;
            string[] header = new string[12]; //存储头文件
            string readline;
            while (count < 12)
            {
                readline = read_txt.ReadLine();  //一次读取一行
                header[count++] = readline;
                // 读取到第五行的时候,取出此行所包含的点个数数据
                if (count == 5)
                {
                    string readdata;
                    readdata = header[count - 1].Remove(0 2);//删除这一行开头的两个字符,即“N=“
                    num = Convert.ToInt32(readdata);  //将此行最后一个字符取出并转化为整型
                }
            }
            points.ID = new int[num+1];  // 开辟存储空间
            points.x = new double[num+1];
            points.y = new double[num+1];
            readline = read_txt.ReadLine();
            string[] substr = readline.Split(‘\t‘);  //以一个tab制表位作为分隔符将所读到一行的数据转化成几个字符
            if (substr.Length == 3)  // 如果一行数据是以tab作为分隔符,此处为真,继续读取;
            {
                points.ID[1] = Convert.ToInt32(sub

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        117  2011-05-24 13:15  tin\tin\app.config

     文件     328192  2011-05-24 13:16  tin\tin\bin\Debug\tin.exe

     文件        117  2011-05-24 13:15  tin\tin\bin\Debug\tin.exe.config

     文件      38400  2011-05-24 13:16  tin\tin\bin\Debug\tin.pdb

     文件      11608  2011-05-24 13:17  tin\tin\bin\Debug\tin.vshost.exe

     文件        117  2011-05-24 13:15  tin\tin\bin\Debug\tin.vshost.exe.config

     文件        490  2010-03-17 22:39  tin\tin\bin\Debug\tin.vshost.exe.manifest

     文件      15044  2011-05-24 13:16  tin\tin\Form1.cs

     文件       6861  2011-05-23 20:24  tin\tin\Form1.Designer.cs

     文件       6219  2011-05-23 20:24  tin\tin\Form1.resx

     文件       5598  2011-05-24 13:16  tin\tin\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       1506  2011-05-24 13:16  tin\tin\obj\x86\Debug\GenerateResource-ResGen.read.1.tlog

     文件          2  2011-05-24 13:16  tin\tin\obj\x86\Debug\GenerateResource-ResGen.read.6.tlog

     文件       1114  2011-05-24 13:16  tin\tin\obj\x86\Debug\GenerateResource-ResGen.write.1.tlog

     文件          2  2011-05-24 13:16  tin\tin\obj\x86\Debug\GenerateResource-ResGen.write.6.tlog

     文件       4608  2011-05-24 13:16  tin\tin\obj\x86\Debug\TempPE\Properties.Resources.Designer.cs.dll

     文件       2080  2011-05-24 13:17  tin\tin\obj\x86\Debug\tin.csproj.FileListAbsolute.txt

     文件     328192  2011-05-24 13:16  tin\tin\obj\x86\Debug\tin.exe

     文件        180  2011-05-24 13:16  tin\tin\obj\x86\Debug\tin.Form1.resources

     文件      38400  2011-05-24 13:16  tin\tin\obj\x86\Debug\tin.pdb

     文件     312179  2011-05-24 13:16  tin\tin\obj\x86\Debug\tin.Properties.Resources.resources

     文件        464  2011-05-24 13:16  tin\tin\Program.cs

     文件       1338  2011-05-03 15:55  tin\tin\Properties\AssemblyInfo.cs

     文件       3348  2011-05-24 13:15  tin\tin\Properties\Resources.Designer.cs

     文件       6583  2011-05-23 20:22  tin\tin\Properties\Resources.resx

     文件       1101  2011-05-24 13:15  tin\tin\Properties\Settings.Designer.cs

     文件        249  2011-05-03 15:55  tin\tin\Properties\Settings.settings

     文件      36934  2011-05-23 20:22  tin\tin\Resources\悠哉3.jpg

     文件     299958  2011-05-23 20:22  tin\tin\Resources\童心.jpg

     文件       3670  2011-05-24 13:16  tin\tin\tin.csproj

............此处省略19个文件信息

评论

共有 条评论