Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Graphics ..with c #

Graphics ..with c #

Scheduled Pinned Locked Moved C#
graphicsquestiondockerjsonhelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mr jets
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • M mr jets

      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

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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 )

      M 1 Reply Last reply
      0
      • C Christian Graus

        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 )

        M Offline
        M Offline
        mr jets
        wrote on last edited by
        #3

        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

        C 1 Reply Last reply
        0
        • M mr jets

          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

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          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 )

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups