Home > Net >  Turn to the great god, why couldn't run this code, can help to correct it for me? Urgent help
Turn to the great god, why couldn't run this code, can help to correct it for me? Urgent help

Time:09-17

I want to read the text on the coordinates of the points, and then in the form with the dot on the image display, as follows (this can copy directly debugging) :
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 (string path) defines a list of point method, this method can make the following behavior: read TXT in the coordinate data
{
//read text code coordinate, the streamread read flow
List Result=new List (a);//defines a about list An object of a class result

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 The
//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 The result of data
}

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:

reference 1/f, C:/Tclauncher. Exe response:
if this logic has serious errors.
While strline there

Put the string strline=sr. ReadLine (); Put the while inside try

Can't, that code doesn't inside, inside an error directly,

CodePudding user response:

refer to the second floor more measures and response:
Quote: reference 1/f, C:/Tclauncher. Exe response:
if this logic has serious errors.
While strline there

Put the string strline=sr. ReadLine (); Put the while inside try

Can't, that code doesn't inside, inside an error directly,

To what's wrong?
If put inside while also should have corresponding change?

CodePudding user response:

You make an error

CodePudding user response:

reference 4 floor Summer_djz response:
you make an error made by

Well, ok, the fault is "System. OutOfMemoryException" type of untreated abnormalities in mscorlib. DLL, appear in the result. The Add (pt); This code

CodePudding user response:

reference C: 3/f/Tclauncher. Exe response:
Quote: refer to the second floor more measures and response:
Quote: reference 1/f, C:/Tclauncher. Exe response:
if this logic has serious errors.
While strline there

Put the string strline=sr. ReadLine (); Put the while inside try

Can't, that code doesn't inside, inside an error directly,

To what's wrong?
If put inside while also should have corresponding change?

His fault is the result code. Add (pt); nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • C#
  • Related