using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
Using System. The Threading. The Tasks;
using System.Windows.Forms;
Using System. IO;
The namespace and coordinates to read the text and figure display point
{
Public partial class Form1: Form
{
Public _click ()
{
InitializeComponent();
}
Public class point//define a class, and have the x, y attributes of the
{
Public string name {get; set; }
Public double x {get; set; }
Public double y {get; set; }
Public point ()//define a no arguments constructor
{
}
Public point (string name, double x, double y)//define a constructor, used to store the name of the incoming, the value of x, y
{
this.name=name;
this.x=x;
this.y=y;
}
Public static List
{
//read text code coordinate, the streamread read flow
List
FileStream fs=new FileStream (path, FileMode. Open, FileAccess. Read, FileShare. ReadWrite);
Using (StreamReader sr=new StreamReader (fs))//the path of the file read
{
int i=0;//define an I to control data into list
//read line by line, use the while loop operation on
String strline=sr. ReadLine ();
While (strline!=null)
{
String [] line=strline. Split (', ');//define a line array, each line separated by a comma, and the line of each different indexes for different x, y
Point pt=new point ((+ + I). The ToString (), double the Parse (line [0]), double the Parse (line [1]));//instantiate the point of an object to represent the pt, will read the data in the constructor of the
Result. The Add (pt); Data from the pt//in the result
}
}
return result;//return had saved good list
}
Public static object List {get; set; }
}
Private void button1_Click (object sender, EventArgs e)
{
////point. Read (@ "E: \ \ c # new text documents. TXT");//call the read method of point class
}
Bitmap BMP.
Private void Form1_Load (object sender, EventArgs e)
{
BMP=new Bitmap (enclosing ClientRectangle. Width, enclosing ClientRectangle, Height);
Graphics g=Graphics. FromImage (BMP);
Point. Read (@ "E: \ \ c # new text documents. TXT");//call the read method of point class
Point p=new point ();
Int I, j;
Int w=BMP. Width;
Int h=BMP. Height;
Int interval=5;//every 5 pixels setting to generate a black color picture
For (I=0; I & lt; w; I +=interval)
{
For (j=0; J & lt; h; J +=interval)
{
BMP. SetPixel (Convert. ToInt32 (p.x), Convert the ToInt32 (p.y), Color, Black);
}
}
}
Private void button1_Paint (object sender, PaintEventArgs e)
{
//point. Read (@ "E: \ \ c # new text documents. TXT");//call the read method of point class
//point p=new point ();
//int I, j;
//int w=BMP. Width;
//int h=BMP. Height;
//int interval=5;//every 5 pixels setting to generate a black color picture
//for (I=0; I & lt; w; I +=interval)
//{
//for (j=0; J & lt; h; J +=interval)
//{
//BMP. SetPixel (Convert. ToInt32 (p.x), Convert the ToInt32 (p.y), Color, Black);
//}
//}
Graphics gg=um participant raphics;
Gg. DrawImage (BMP, new Rectangle (0, 0, enclosing ClientRectangle. Width, enclosing ClientRectangle, Height));
}
}
}
CodePudding user response:
This logic if has serious errors.While strline there
Put the string strline=sr. ReadLine (); Put the while inside try
CodePudding user response: