Very serious serializing problem !

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
glikoz
Newbie
Newbie
Posts: 50
Joined: Fri Oct 07, 2005 4:00 am

Very serious serializing problem !

Post by glikoz » Tue Jun 27, 2006 11:53 am

I have custom classes that inherited from Steema classes ..
And also some of my classes has instance of Steema's classes and all of my classes integrated with Steema's ..

Code: Select all

Class RChart:TChart
{
    List<RFunction> listRF;
    List<RAxis> listRA; 
}
class RFunction
{
      Chart c;
}
class RAxis:Axis
class RCustomPoint
{
    CustomPoint CP;
}
What must i do for clear serialization , I will use serialization for Saving and Loading data...
Should i implement Steema.TeeChart.Export.TemplateExport.ICustomSerialization to my classes ?
Should i imitate DeserializeFrom and SerializeObject method ..

Thx for advice ...

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Jun 29, 2006 1:58 pm

Hi glikoz,

This is how your classes should look like:

Code: Select all

public class MyChart : TChart
{
  public MyChart()
  {
    Text = "MyChart";
  }
}

public class MyLine : Line, Steema.TeeChart.Export.TemplateExport.ICustomSerialization
{
  public MyLine(Chart c) : base(c)
  {
    myBooleanProperty = true;
  }

  public MyLine() : this((Chart)null) { }

  public override string Description
  {
    get { return "My vastly superior line"; }
  }

  private bool myBooleanProperty;

  [DefaultValue(true)]
  public bool MyBooleanPropery
  {
    get { return myBooleanProperty; }
    set { myBooleanProperty = value; }
  }


  #region ICustomSerialization Members

  public void Serialize(System.Runtime.Serialization.SerializationInfo info)
  {
    info.AddValue("MyBooleanPropery", MyBooleanPropery);
  }

  public void DeSerialize(System.Runtime.Serialization.SerializationInfo info)
  {
    MyBooleanPropery = info.GetBoolean("MyBooleanPropery");
  }

  #endregion
}
And this is how they should be used in a form:

Code: Select all

public partial class Form1 : Form
{
  public Form1()
  {
    InitializeComponent();
    InitializeChart();
  }


  private void InitializeChart()
  {
    MyLine myline = new MyLine(myChart1.Chart);
    myline.FillSampleValues();
    myline.MyBooleanPropery = false;
  }

  private void button1_Click(object sender, EventArgs e)
  {
    MemoryStream ms = new MemoryStream();
    myChart1.Export.Template.Save(ms);
    ms.Position = 0;
    myChart2.Import.Template.Load(ms);
    MyLine line = myChart2.Series[0] as MyLine;
    MessageBox.Show(line.MyBooleanPropery.ToString());
  }
}
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply