Public class customstylehelper
{
Public static void doserialize (string strfile, customstyle)
{
Using (filestream FS = new filestream (strfile, filemode. openorcreate ))
{
Xmlserializer formatter = new xmlserializer (typeof (customstyle ));
Formatter. serialize (FS, customstyle );
}
}
Public static customstyle deserialize (string strfile)
{
Customstyle;
Using (filestream FS = new filestream (strfile, filemode. Open ))
{
Xmlserializer formatter = new xmlserializer (typeof (customstyle ));
Customstyle = (customstyle) formatter. deserialize (FS );
}
Return customstyle;
}
// The XML serialization method Cannot serialize object type attributes (such as color), but can only serialize int string type attributes
// The binary serialization method can serialize object type attributes (such as color) or Int string type attributes.
// Zhangjun 2010.12.10
Public static void binarydoserialize (string strfile, customstyle)
{
Using (filestream FS = new filestream (strfile, filemode. openorcreate ))
{
Binaryformatter formatter = new binaryformatter ();
Formatter. serialize (FS, customstyle );
}
}< br> Public static customstyle binarydeserialize (string strfile)
{< br> customstyle;
using (filestream FS = new filestream (strfile, filemode. open)
{< br> binaryformatter formatter = new binaryformatter ();
customstyle = (customstyle) formatter. deserialize (FS);
}< br> return customstyle;
}
Public static irgbcolor color2rgbcolor (color)
{
Irgbcolor newcolor = new rgbcolor ();
Newcolor. Blue = color. B;
Newcolor. Red = color. R;
Newcolor. Green = color. g;
If (color. Name. toupper () = "Transparent ")
{
Newcolor. Transparency = 0;
}
Return newcolor;
}
}
[Serializable]
Public class customstyle
{
Private color scolor;
Public color scolor
{
Get {return scolor ;}
Set {scolor = value ;}
}
Private double swidth;
Public double swidth
{
Get {return swidth ;}
Set {swidth = value ;}
}
Private color dcolor;
Public color dcolor
{
Get {return dcolor ;}
Set {dcolor = value ;}
}
Private double dwidth;
Public double dwidth
{
Get {return dwidth ;}
Set {dwidth = value ;}
}
}