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. Graphics
  4. saving my drawing as atext file...!!

saving my drawing as atext file...!!

Scheduled Pinned Locked Moved Graphics
graphicshelp
5 Posts 3 Posters 3 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

    hello guys..my program is about drawing some shapes like (lines ,polygons..etc)my nightmare is after drawing the shapes i wanna to save them as atext file which contains the (start point , end point , color ,..etc) iam using V.S 2003...i will apprecaite any help . Regards:sigh:;

    P C 2 Replies Last reply
    0
    • M mr jets

      hello guys..my program is about drawing some shapes like (lines ,polygons..etc)my nightmare is after drawing the shapes i wanna to save them as atext file which contains the (start point , end point , color ,..etc) iam using V.S 2003...i will apprecaite any help . Regards:sigh:;

      P Offline
      P Offline
      PandemoniumPasha
      wrote on last edited by
      #2

      hi, i would recommend that you create a separate class to hold all the fields that you need such as points and colors etc. and every time you draw any shape, you would need to save the things you need in memory. then when you click save(or whatever) you can write the contents of the array to the file. you can use an arraylist to store the objects that you create, or any array structure that you are comfortable with. hope this helps. regards

      M 1 Reply Last reply
      0
      • P PandemoniumPasha

        hi, i would recommend that you create a separate class to hold all the fields that you need such as points and colors etc. and every time you draw any shape, you would need to save the things you need in memory. then when you click save(or whatever) you can write the contents of the array to the file. you can use an arraylist to store the objects that you create, or any array structure that you are comfortable with. hope this helps. regards

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

        yah thats cool my bro..i have already used an arraylist and thats was my best : // 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

        P 1 Reply Last reply
        0
        • M mr jets

          yah thats cool my bro..i have already used an arraylist and thats was my best : // 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

          P Offline
          P Offline
          PandemoniumPasha
          wrote on last edited by
          #4

          hi, from the code above i see that you are storing the points in the array list, but this is not a good way to store data because you don't know that kind of shape it is i.e. is it a line, a circle, a rectangle... what? therefore, i recommmend you to store objects of the shape class that you can create for each shape you draw and store that object in the arraylist. if you do this, you can set the type of shape that it represents just by setting a simple flag - some enum value. so, when you save the data, you will be saving the class objects and not points. when you retrieve the data, you will retrieve the class objects. this will enable you to distinguish what type of shape it is and enable you to draw accordingly. hope this helps. regards

          1 Reply Last reply
          0
          • M mr jets

            hello guys..my program is about drawing some shapes like (lines ,polygons..etc)my nightmare is after drawing the shapes i wanna to save them as atext file which contains the (start point , end point , color ,..etc) iam using V.S 2003...i will apprecaite any help . Regards:sigh:;

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

            You have been asking the same questions for some time now. Realistically, the best way to do this is to create a class for each shape you want to draw, with a common base class, and make a list of that base class. Then you can make the class know how to build itself from the string you store in your file, and to generate a string which identifies the shape type and the details of that shape. I'd go for something less verbose, you really only need to store numbers, just assign each shape type a number.

            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