Click here to Skip to main content
15,886,199 members
Home / Discussions / C#
   

C#

 
QuestionDatabase to xml Pin
pavya_Cool5-Aug-07 19:22
pavya_Cool5-Aug-07 19:22 
AnswerRe: Database to xml Pin
aamironline5-Aug-07 20:57
aamironline5-Aug-07 20:57 
GeneralRe: Database to xml Pin
pavya_Cool5-Aug-07 21:02
pavya_Cool5-Aug-07 21:02 
GeneralRe: Database to xml Pin
blackjack21505-Aug-07 21:45
blackjack21505-Aug-07 21:45 
GeneralRe: Database to xml Pin
T.EDY5-Aug-07 22:14
T.EDY5-Aug-07 22:14 
GeneralRe: Database to xml Pin
pavya_Cool5-Aug-07 22:32
pavya_Cool5-Aug-07 22:32 
Questionserialize a graphicspath? Pin
cyn85-Aug-07 18:59
cyn85-Aug-07 18:59 
AnswerRe: serialize a graphicspath? Pin
Hessam Jalali5-Aug-07 20:25
Hessam Jalali5-Aug-07 20:25 
everything is going to be serialized must have Serializable Attribute in .Net but GraphicsPath class does not have it so you can't direcly Serialize it however there are some ways to do that

I saw a constructor for GraphicsPath Takes 3 arguments (PointF[] points ,byte[] types ,FillMode fillMode)

and of course three Property from GraphicPath instance FillPoints:pointF[] ,PathTypes:byte[] ,FillMode:FillModeEnum

all of these three type are marked as serializable so you can serialize these data and then desrialize them and create a new GraphicsPath instance identical to the Serialized one.

Code some like this

<br />
<br />
    [Serializable]<br />
    class GraphicsPathData<br />
    {<br />
        byte[] types;<br />
        PointF[] points;<br />
        FillMode fillMode;<br />
<br />
        public GraphicsPathData(GraphicsPath gp)<br />
        {<br />
            this.types = gp.PathTypes;<br />
            this.points = gp.PathPoints;<br />
            this.fillMode = gp.FillMode;<br />
        }<br />
<br />
        public static System.IO.Stream Serialize(GraphicsPathData gpd)<br />
        {<br />
            System.IO.MemoryStream ms=new System.IO.MemoryStream();<br />
<br />
            System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();<br />
<br />
            bf.Serialize(ms, gpd);<br />
            ms.Flush();<br />
            return ms;<br />
        }<br />
<br />
        public static GraphicsPathData Deserialize(System.IO.Stream stream)<br />
        {<br />
            System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();<br />
<br />
            object obj=bf.Deserialize(stream);<br />
            GraphicsPathData gpd =obj  as GraphicsPathData;<br />
            return gpd;<br />
        }<br />
<br />
        public static GraphicsPath GetGraphicsPath(GraphicsPathData gpd)<br />
        {<br />
            return new GraphicsPath(gpd.points, gpd.types, gpd.fillMode);<br />
        }<br />
<br />
        public static GraphicsPath GetGraphicsPath(System.IO.Stream gpdStream)<br />
        {<br />
            return GetGraphicsPath(Deserialize(gpdStream));<br />
        }<br />
    }<br />
<br />


and I tested that like

<br />
<br />
GraphicsPath gp = new GraphicsPath();<br />
gp.AddEllipse(10, 10, 100, 100);<br />
<br />
GraphicsPathData gpd = new GraphicsPathData(gp);<br />
System.IO.Stream gpdStream = GraphicsPathData.Serialize(gpd);<br />
<br />
//Just create a new stream for showing exchange of data!!!<br />
<br />
System.IO.Stream newStream = new System.IO.MemoryStream(((System.IO.MemoryStream)gpdStream).ToArray());<br />
<br />
GraphicsPath gpDeserialized = GraphicsPathData.GetGraphicsPath(newStream);<br />
<br />


Good Luck
GeneralRe: serialize a graphicspath? Pin
cyn86-Aug-07 19:29
cyn86-Aug-07 19:29 
GeneralRe: serialize a graphicspath? Pin
Hessam Jalali6-Aug-07 21:16
Hessam Jalali6-Aug-07 21:16 
QuestionUnable to find entry point in DLL Pin
dashprasannajit5-Aug-07 18:30
dashprasannajit5-Aug-07 18:30 
Questiondatagridvew Pin
Sonia Gupta5-Aug-07 18:18
Sonia Gupta5-Aug-07 18:18 
QuestionRe: datagridvew Pin
T.EDY5-Aug-07 18:31
T.EDY5-Aug-07 18:31 
AnswerRe: datagridvew Pin
Sonia Gupta5-Aug-07 18:47
Sonia Gupta5-Aug-07 18:47 
AnswerRe: datagridvew Pin
Brady Kelly5-Aug-07 23:25
Brady Kelly5-Aug-07 23:25 
Questionregistering COM component as Out proc sever Pin
KrunalC5-Aug-07 17:44
KrunalC5-Aug-07 17:44 
AnswerRe: registering COM component as Out proc sever Pin
KrunalC5-Aug-07 19:50
KrunalC5-Aug-07 19:50 
GeneralRe: registering COM component as Out proc sever Pin
Dave Kreskowiak6-Aug-07 4:12
mveDave Kreskowiak6-Aug-07 4:12 
QuestionChecking last index of the array giving me a problem. VS2005 C# Pin
foolios5-Aug-07 16:47
foolios5-Aug-07 16:47 
AnswerRe: Checking last index of the array giving me a problem. VS2005 C# Pin
Hessam Jalali5-Aug-07 19:25
Hessam Jalali5-Aug-07 19:25 
Questionpassing parameter from one windows form to another one Pin
dinakatina5-Aug-07 14:47
dinakatina5-Aug-07 14:47 
AnswerRe: passing parameter from one windows form to another one Pin
Christian Graus5-Aug-07 14:55
protectorChristian Graus5-Aug-07 14:55 
QuestionThreading passing parameters to thread Pin
Muhammad Nauman Yousuf5-Aug-07 12:29
Muhammad Nauman Yousuf5-Aug-07 12:29 
AnswerRe: Threading passing parameters to thread Pin
Luc Pattyn5-Aug-07 13:15
sitebuilderLuc Pattyn5-Aug-07 13:15 
GeneralRe: Threading passing parameters to thread Pin
Muhammad Nauman Yousuf6-Aug-07 8:10
Muhammad Nauman Yousuf6-Aug-07 8:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.