Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic ShapeTemplate after loading from file (Read 1403 times)
Alex
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Nov 21st, 2006
ShapeTemplate after loading from file
May 7th, 2007 at 11:22am
Print Post  
Hello,

currently I have the following problem:

I implemented my own ShapeTemplate which holds additional information (like a second Box in a class called Textlabel).

When I paint a diagram, all information is displayed correctly and everything works well. After saving and loading the diagramm, the following occurs:

The ShapeTemplate is in memory (displayed correctly and everything), but the additional information holds no information anymore.

Here is my code, first the shapeTemplate:
Code
Select All
    [Serializable()]
    class Shapes3682 : ShapeTemplate
    {
        public Color bgColor;
        public static FillMode fillMode = FillMode.Winding;
        public TextLabel label;

        public Shapes3682(ElementTemplate[] elements, String shortName)
            : base(elements, fillMode, shortName)
        {
        }

        public void createTextLabel(Box icon, String text, int textPosition)
        {
            label = new TextLabel(icon, text, textPosition);
        }
    }
 



and the code for the Textlabel:

Code
Select All
    [Serializable()]
    class TextLabel
    {
        private int iTextPosition;
        private Box label;

        public TextLabel(Box icon, String text, int TextPosition)
        {
            iTextPosition = TextPosition;
            label = new Box(icon.Parent);
            label.Text = text;
            label.BoundingRect = new RectangleF(PointF.Empty,
              icon.Parent.MeasureString(label.Text, label.Font, int.MaxValue, label.TextFormat));
            label.Transparent = true;
            label.Locked = true;
            label.PolyTextLayout = true;
            label.FitSizeToText(FitSize.KeepRatio);

            icon.Parent.Add(label);
            //// attach the label to the icon
            RectangleF rc1 = icon.BoundingRect;
            RectangleF rc2 = label.BoundingRect;
            label.BoundingRect = getBoundingRect(ref rc1, ref rc2);
            label.AttachTo(icon, AttachToNode.BottomCenter);
            icon.SubordinateGroup.AutoDeleteItems = true;
        }
}
 



After reloading the diagram, the label from the ShapeTemplate class is set to null Sad.

I can't figure out why the information is not stored.

Can anyone help?

Best regards,

Alex
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ShapeTemplate after loading from file
Reply #1 - May 7th, 2007 at 12:04pm
Print Post  
Hello,

When saving a box' shape, Flowchart.NET saves just the ShapeTemplate identifier (shortName in your case). There isn't any shape data saved apart from that id. That is true for both the binary and XML formats.

When you load the diagram later, the control will read the shape id and assign the ShapeTemplate with that id to the Box.Shape. Since the extra information does not exist in the saved files, it cannot be loaded. You could store the additional properties in the Box.Tag, instead in custom ShapeTemplates.

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


I love YaBB 1G - SP1!

Posts: 60
Joined: Nov 21st, 2006
Re: ShapeTemplate after loading from file
Reply #2 - May 7th, 2007 at 12:21pm
Print Post  
Ok, thank you for the fast response. Something else is already saved in the Box. Tag so I'll have to figure out a different way.

Thank you very much for saving me a lot of trouble shooting Smiley

Alex
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint