Graphics ..with c #
-
good evning every one..i really need ur help guys ..my program like that one in Paint ..finally i can save the file as text in C DRIVE but while opening it can read the data from text but cant display it ( draw the lines..)..note it can save & open the lines only. ---> my question : how can i make the program display the file. this apart of my code guys : using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Drawing.Drawing2D; using System.Data; using System.IO; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Serialization; namespace graphics_practis { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { Point center,radius,v,start,end,a,b; ArrayList arraypoint=new ArrayList(); ArrayList arraylist_points=new ArrayList(); private System.Windows.Forms.Panel panel1; private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.Button line; private System.Windows.Forms.Button square; private System.Windows.Forms.Button circle; private System.Windows.Forms.Button ellipse; private System.Windows.Forms.Button polygon; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.Button ok; private System.Windows.Forms.MainMenu mainMenu1; private System.Windows.Forms.MenuItem menuItem1; private System.Windows.Forms.MenuItem menuItem2; private System.Windows.Forms.MenuItem menuItem3; private System.Windows.Forms.MenuItem menuItem4; private System.Windows.Forms.MenuItem menuItem5; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private System.Windows.Forms.OpenFileDialog openFileDialog1; private System.Windows.Forms.SaveFileDialog saveFileDialog1; private BinaryFormatter formtter = new BinaryFormatter(); /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // dr = new draw(this.pictureBox1); } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.D
-
good evning every one..i really need ur help guys ..my program like that one in Paint ..finally i can save the file as text in C DRIVE but while opening it can read the data from text but cant display it ( draw the lines..)..note it can save & open the lines only. ---> my question : how can i make the program display the file. this apart of my code guys : using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Drawing.Drawing2D; using System.Data; using System.IO; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Serialization; namespace graphics_practis { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { Point center,radius,v,start,end,a,b; ArrayList arraypoint=new ArrayList(); ArrayList arraylist_points=new ArrayList(); private System.Windows.Forms.Panel panel1; private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.Button line; private System.Windows.Forms.Button square; private System.Windows.Forms.Button circle; private System.Windows.Forms.Button ellipse; private System.Windows.Forms.Button polygon; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.Button ok; private System.Windows.Forms.MainMenu mainMenu1; private System.Windows.Forms.MenuItem menuItem1; private System.Windows.Forms.MenuItem menuItem2; private System.Windows.Forms.MenuItem menuItem3; private System.Windows.Forms.MenuItem menuItem4; private System.Windows.Forms.MenuItem menuItem5; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private System.Windows.Forms.OpenFileDialog openFileDialog1; private System.Windows.Forms.SaveFileDialog saveFileDialog1; private BinaryFormatter formtter = new BinaryFormatter(); /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // dr = new draw(this.pictureBox1); } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.D
No-one is going to read all of this.
mr jets wrote:
private void menuItem3_Click(object sender, System.EventArgs e) { //open the file string str_reader; if(openFileDialog1.ShowDialog()==DialogResult.OK) { StreamReader streamReader=new StreamReader(openFileDialog1.FileName); str_reader=streamReader.ReadToEnd(); MessageBox.Show(str_reader); streamReader.Close(); }
This code assigns your file contents to a string, which you then discard ( it's a local variable, so it disappears after the function ends ). By what process did you expect your program to do anything with this data ?
mr jets wrote:
for(int j=0;j { streamWriter.WriteLine("Line"); start=(Point)arraylist_points[j]; end=(Point)arraylist_points[j+1]; str_Line=start.ToString()+end.ToString(); streamWriter.WriteLine(str_Line); j++; } streamWriter.Flush(); streamWriter.Close(); fs.Close();
You need to reverse this process and fill your array of points with the data you've read in. Your program is not like Paint. Paint deals in raster info, you're doing a drawing package. You shouldn't use a picture box, that's a waste of time, write your own handler for the paint message.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
No-one is going to read all of this.
mr jets wrote:
private void menuItem3_Click(object sender, System.EventArgs e) { //open the file string str_reader; if(openFileDialog1.ShowDialog()==DialogResult.OK) { StreamReader streamReader=new StreamReader(openFileDialog1.FileName); str_reader=streamReader.ReadToEnd(); MessageBox.Show(str_reader); streamReader.Close(); }
This code assigns your file contents to a string, which you then discard ( it's a local variable, so it disappears after the function ends ). By what process did you expect your program to do anything with this data ?
mr jets wrote:
for(int j=0;j { streamWriter.WriteLine("Line"); start=(Point)arraylist_points[j]; end=(Point)arraylist_points[j+1]; str_Line=start.ToString()+end.ToString(); streamWriter.WriteLine(str_Line); j++; } streamWriter.Flush(); streamWriter.Close(); fs.Close();
You need to reverse this process and fill your array of points with the data you've read in. Your program is not like Paint. Paint deals in raster info, you're doing a drawing package. You shouldn't use a picture box, that's a waste of time, write your own handler for the paint message.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
heloo christian ..u are my hero man ..there was awrong with my save code..: // save the file string str_Line; System.IO.FileStream fs = new System.IO.FileStream("c:\\graphics.txt", System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite); StreamWriter streamWriter=new StreamWriter(fs); if(drawwhat==1) { for(int j=0;j
-
heloo christian ..u are my hero man ..there was awrong with my save code..: // save the file string str_Line; System.IO.FileStream fs = new System.IO.FileStream("c:\\graphics.txt", System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite); StreamWriter streamWriter=new StreamWriter(fs); if(drawwhat==1) { for(int j=0;j
mr jets wrote:
about my open code what should i do to make the program display the file after reading the data from the text..?
Like I said, you need to parse the text and use it to fill your array of points. It really seems to me like you probably need an array of instances of a struct that contains all the data you need to draw different items, I thought I saw you drawing polygons, etc ? But, either way, what ever you store in your array, you need to repopulate. Your drawing code draws based on that array, right ? So how can it draw if you don't populate that array with the data ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )