hi,
I have same problem and i had more difficult to got info about Objet
serialization such as font,graphicspath,pen, ecc ...
I solved this problem with a "manually" serialization ,I dont't think that
is a right solution but that is an only way that I find for serialize some
graphics object such as Font
void Grafica::SerializeFont(Font* xFont,SerializationInfo *info,String* ID)
{
info->AddValue(String::Concat(ID,"N"),xFont->FontFamily->Name);
info->AddValue(String::Concat(ID,"H"),xFont->Height);
info->AddValue(String::Concat(ID,"S"),__box(xFont->Style),__typeof(FontStyle));
info->AddValue(String::Concat(ID,"U"),__box(xFont->Unit),__typeof(GraphicsUnit));
info->AddValue(String::Concat(ID,"C"),xFont->GdiCharSet);
info->AddValue(String::Concat(ID,"V"),xFont->GdiVerticalFont);
}
and relative deserialization
Font* Grafica::DeSerializeFont(SerializationInfo *info,String *ID)
{
String* familyname = info->GetString(String::Concat(ID,"N"));
float emsize = info->GetSingle(String::Concat(ID,"H"));
FontStyle stile = *dynamic_cast<FontStyle __box*>
(info->GetValue(String::Concat(ID,"S"),__typeof(System::Object)));
GraphicsUnit unit = *dynamic_cast<GraphicsUnit
__box*>(info->GetValue(String::Concat(ID,"U"),__typeof(System::Object)));
System::Byte gdcharset = info->GetByte(String::Concat(ID,"C"));
bool gdiverticalfont = info->GetBoolean(String::Concat(ID,"V"));
return new Font(familyname,emsize,stile,unit,gdcharset,gdiverticalfont);
}
I enjoy if anyone has a better solution.
hi,
I Apologize for my english.
"SharpCoderMP" <csharp_mp@interia.pl.NFSPM> ha scritto nel messaggio
news:um3BUvGtFHA.304@TK2MSFTNGP11.phx.gbl...
[quoted text, click to view] > hi,
> i posted this erlier to the other group but got no response :(
> so i'm trying now this one...
>
> according to the documentation System.Drawing.Font is serializable, well
> at least it should be because it implements ISerializable. but when i try
> to serialize it with XmlSerializer i get exception saying that this object
> cannot be serialized because it hasn't got defined default public
> constructor (or something like that - this is translation from other
> language, so it may sound wired).
>
> so how can i serialize Font object? is it serializable or this is another
> documentation bug?