Problems to open a Gauge (csharp .net)

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Msi
Newbie
Newbie
Posts: 8
Joined: Fri Sep 14, 2018 12:00 am

Problems to open a Gauge (csharp .net)

Post by Msi » Tue Nov 06, 2018 8:35 am

Hello,

My name is Tony. I hope somebody can help me. Many thanks in advance!

I have a Project (Visual Studio 2012) with TChart v.2018. When I try to serialize and deserialize a Gauge to save it and open I receive an error.

This is the way I'm doing it:

- To save:
public void nativeSerialize(Steema.TeeChart.TChart chart, bool includeData)
{
// Guardar archivo a carpeta temporal
string path = System.IO.Path.GetTempPath() + @"\temp" + System.DateTime.Now.Millisecond.ToString() + ".ten";
chart.Export.Template.IncludeData = includeData;
chart.Export.Template.Save(path);
byte[] buff = null;
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader stream = new BinaryReader(fs);
int LengthOfBuffer = (int)fs.Length;
// the buffer for contents of the file
buff = new byte[LengthOfBuffer];
// read the file into the buffer
for (int i = 0; i < LengthOfBuffer; i++)
buff = stream.ReadByte();
// close the file
stream.Close();
fs.Close();

this.native = Convert.ToBase64String(buff);
File.Delete(path);

}

- To open:

public void nativeDeSerialize(Steema.TeeChart.TChart chart)
{
byte[] buff2 = Convert.FromBase64String(this.native);

string path = System.IO.Path.GetTempPath() + @"\temp" + System.DateTime.Now.Millisecond.ToString() + ".ten";


FileStream fsOut = new FileStream(path, FileMode.Create, FileAccess.Write);

BinaryWriter streamOut = new BinaryWriter(fsOut);

streamOut.Write(buff2);
streamOut.Close();
fsOut.Close();

chart.Import.Template.Load(path);  << here I get the error (*)

File.Delete(path);
}

(*) Error: {"Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index"}

This way is the same I do with another types of Graphs (histogram, for example) and I have no problems. And also, I don't receive any error if I use an older versión of TChart (2014)

If you need any more details or information, please tell me.

Thanks,

Tony

Christopher
Guru
Posts: 1195
Joined: Fri Nov 15, 2002 12:00 am

Re: Problems to open a Gauge (csharp .net)

Post by Christopher » Wed Nov 07, 2018 8:06 am

Hello Tony,

using the following code and the latest TeeChart.NET Pro assembly available from Nuget here (v.4.2018.10.27), CircularGauge template exportation and importation work as expected:

Code: Select all

    public Form1()
    {
      InitializeComponent();

      tChart1.Series.Add(typeof(CircularGauge)).FillSampleValues();
    }

    private void button1_Click(object sender, EventArgs e)
    {
      MemoryStream ms = new MemoryStream();
      tChart1.Export.Template.IncludeData = true;
      tChart1.Export.Template.Save(ms);

      ms.Position = 0;

      tChart2.Import.Template.Load(ms);
    }
Could you please retouch the above example so I can reproduce your issue here?
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Msi
Newbie
Newbie
Posts: 8
Joined: Fri Sep 14, 2018 12:00 am

Re: Problems to open a Gauge (csharp .net)

Post by Msi » Wed Nov 07, 2018 9:54 am

Hello,

And many thanks.

I have downloaded the nuget package and now is running. But, now a watermark is showing in my charts "This is an EVALUATION versión...."

I have tried to activate the license following the steps in Steema web, but I am afraid I am doing something wrong because it doesnt work


Last thing I have done is to search for the "Steema_License.zip" file, but I cant find it anywhere in my PC. Where is it supposed to be?


Thanks again. Best regards,

Tony

Christopher
Guru
Posts: 1195
Joined: Fri Nov 15, 2002 12:00 am

Re: Problems to open a Gauge (csharp .net)

Post by Christopher » Wed Nov 07, 2018 10:21 am

Hello Tony,

if you have a valid license for TeeChart.NET Pro then you can write to sales@steema.com and they will be happy to give you the necessary Steema_License.zip. If you don't have a valid license then they will be happy to provide you with one!
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Msi
Newbie
Newbie
Posts: 8
Joined: Fri Sep 14, 2018 12:00 am

Re: Problems to open a Gauge (csharp .net)

Post by Msi » Wed Nov 07, 2018 4:54 pm

Thank you very much!!

It is working now...

Best regards,

Tony

Post Reply