saving my drawing as atext file...!!
-
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:;
-
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:;
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
-
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
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
-
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
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
-
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:;
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 )