Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for PP3 v326 #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions LapseStudio/Timelapse_API/Programs/RT/PP3.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Globalization;

namespace Timelapse_API
{
Expand Down Expand Up @@ -112,6 +113,9 @@ public void Write(string Path)
case 321:
Write321(Writer);
break;
case 326:
Write326(Writer);
break;

default:
throw new NotSupportedException("This fileversion is not supported!");
Expand All @@ -134,6 +138,46 @@ public PP3 Copy()
return output;
}

private void Add(PP3entry val)
{
Values.Add(val.Name, val);
}

private void Write(StreamWriter writer, string header, string name)
{
CultureInfo culture = new CultureInfo("en-US");
string digits = "0.################"; // up to 16 digits

PP3entry entry = Values[header + "." + name];
object val = entry.Value;
string valstring;
if (val is bool)
{
valstring = val.ToString().ToLower();

}
else if (val is double)
{
valstring = ((double)val).ToString(digits, culture);
}
else if (val is int)
{
valstring = val.ToString();
}
else if (val is string)
{
valstring = val.ToString();
}
else if (val is PP3Curve)
{
valstring = ((PP3Curve)val).ToString();
}
else
{
throw new InvalidOperationException("Value " + header + "." + name + " has unknown type: " + val);
}
writer.WriteLine(name + "=" + valstring);
}

private string GetValue(string line)
{
Expand Down Expand Up @@ -186,6 +230,9 @@ private void Read()
case 321:
Read321(lines);
break;
case 326:
Read326(lines);
break;

default:
throw new NotSupportedException("This fileversion is not supported!");
Expand Down
Loading