Click here to Skip to main content
15,901,122 members
Home / Discussions / C#
   

C#

 
GeneralRe: internal and internal protected Pin
originSH6-Aug-07 4:03
originSH6-Aug-07 4:03 
QuestionTake over a GUI of running program Pin
Morad Kobi5-Aug-07 22:21
Morad Kobi5-Aug-07 22:21 
AnswerRe: Take over a GUI of running program Pin
Hessam Jalali6-Aug-07 23:17
Hessam Jalali6-Aug-07 23:17 
Questionregarding xml's property dynamically Pin
praveenkumar palla5-Aug-07 21:51
praveenkumar palla5-Aug-07 21:51 
QuestionDataAdapter.Fill() Pin
blackjack21505-Aug-07 21:43
blackjack21505-Aug-07 21:43 
AnswerRe: DataAdapter.Fill() Pin
Marek Grzenkowicz5-Aug-07 22:04
Marek Grzenkowicz5-Aug-07 22:04 
AnswerRe: DataAdapter.Fill() Pin
N a v a n e e t h5-Aug-07 22:49
N a v a n e e t h5-Aug-07 22:49 
AnswerRe: DataAdapter.Fill() Pin
Nouman Bhatti6-Aug-07 2:12
Nouman Bhatti6-Aug-07 2:12 
QuestionFind Out the executed page??? Pin
mimimimilaw5-Aug-07 21:08
mimimimilaw5-Aug-07 21:08 
QuestionCalling unmanaged DLL-methodes (winmm.dll) Pin
J. Holzer5-Aug-07 20:32
J. Holzer5-Aug-07 20:32 
AnswerRe: Calling unmanaged DLL-methodes (winmm.dll) Pin
m@u5-Aug-07 21:29
m@u5-Aug-07 21:29 
AnswerRe: Calling unmanaged DLL-methodes (winmm.dll) Pin
originSH5-Aug-07 21:57
originSH5-Aug-07 21:57 
QuestionODBC how to connect reomte SQL Server Pin
jason_mf5-Aug-07 20:16
jason_mf5-Aug-07 20:16 
AnswerRe: ODBC how to connect reomte SQL Server Pin
Guffa5-Aug-07 20:29
Guffa5-Aug-07 20:29 
QuestionCrystal Report working with generic collections Pin
Developer6115-Aug-07 20:01
Developer6115-Aug-07 20:01 
Question.NET dll and VB 6 ocx Pin
MozhdehQeraati5-Aug-07 19:34
MozhdehQeraati5-Aug-07 19:34 
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 

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.