Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Read Icons back from XML (Read 2395 times)
moelski
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 50
Joined: Feb 28th, 2011
Read Icons back from XML
Dec 21st, 2011 at 10:12am
Print Post  
Hi !

I use this code to save my node:
Code
Select All
	  protected override void SaveToXml(System.Xml.XmlElement xmlElement, XmlPersistContext context)
	  {
		base.SaveToXml(xmlElement, context);

		context.WriteString(this.headText, "HeadText", xmlElement);
		context.WriteString(this.hintText, "HintText", xmlElement);
		context.WriteImage(this.icon, "Icon", xmlElement);
	  } 



And this to Load it back:
Code
Select All
	  protected override void LoadFromXml(System.Xml.XmlElement xmlElement, XmlPersistContext context)
	  {
		base.LoadFromXml(xmlElement, context);

		this.HeadText = context.ReadString("HeadText", xmlElement);
		this.HintText = context.ReadString("HintText", xmlElement);
		this.Icon = context.ReadImage("Icon", xmlElement);
	  } 



It works perfect for the strings but the Icon is only a black box  ???

Greetz
   Dominik
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Read Icons back from XML
Reply #1 - Dec 21st, 2011 at 6:20pm
Print Post  
Hi,

Check if it's not the same problem as here:
http://mindfusion.eu/Forum/YaBB.pl?board=fcnet_disc;action=display;num=120110289...

If you are loading this.icon from a stream, keep that stream open or otherwise you'll loose the transparency.

Stoyan
  
Back to top
 
IP Logged
 
moelski
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 50
Joined: Feb 28th, 2011
Re: Read Icons back from XML
Reply #2 - Dec 21st, 2011 at 7:30pm
Print Post  
Hi Stoyan,

I canīt see any stream involved in loading the icon.

I load the XML from a file with this code:
Code
Select All
		diagram1.ClearAll();
		diagram1.LoadFromXml("test.xml");
		diagramView1.Refresh(); 



And LoadFromXml calls the MyNode.LoadFromXml at some point:
Code
Select All
	  protected override void LoadFromXml(System.Xml.XmlElement xmlElement, XmlPersistContext context)
	  {
		base.LoadFromXml(xmlElement, context);

		this.HeadText = context.ReadString("HeadText", xmlElement);
		this.HintText = context.ReadString("HintText", xmlElement);
		this.maxInputs = (byte)context.ReadInt("maxInputs", xmlElement);
		this.maxOutputs = (byte)context.ReadInt("maxOutputs", xmlElement);
		this.Icon = context.ReadImage("Icon", xmlElement);
	  } 



Must I load the Image to a stream first?

Greetz
     Dominik
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Read Icons back from XML
Reply #3 - Dec 22nd, 2011 at 7:15am
Print Post  
But where are you getting the initial image from, when creating a new node and not loading the diagram from a file?
  
Back to top
 
IP Logged
 
moelski
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 50
Joined: Feb 28th, 2011
Re: Read Icons back from XML
Reply #4 - Dec 22nd, 2011 at 7:32am
Print Post  
Hi Stoyan,

I figured out that it is a problem of the created Icon from your IconNode demo.
When I use an icon from a file or resource all is fine.

So I think this problem is gone ...  Smiley

btw.
I first draw the Icon with graphics.DrawImage ...
But this methode scales the image. So I found graphics.DrawImageUnscaled.

But DrawImageUnscaled seems to use the Resolution of the image file. I had a file with 197DPI and so the Image gets streched.
Now I have an Image with 96DPI and all works as expected.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint