57 lines
1.9 KiB
C#
57 lines
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace DTS.SensorDB.TDCINI
|
|
{
|
|
/// <summary>
|
|
/// helper class for ViewerROI section of ROI
|
|
/// </summary>
|
|
public class INIViewerROI
|
|
{
|
|
/// <summary>
|
|
/// x Min value
|
|
/// </summary>
|
|
public double XMin { get; set; }
|
|
/// <summary>
|
|
/// x Max value
|
|
/// </summary>
|
|
public double XMax { get; set; }
|
|
|
|
/// <summary>
|
|
/// reads section from a line
|
|
/// returns false if failed to read section, true if section was read.
|
|
/// </summary>
|
|
/// <param name="line"></param>
|
|
/// <param name="curLine"></param>
|
|
/// <param name="errors"></param>
|
|
/// <returns></returns>
|
|
public bool ReadFrom(string line, int curLine, ref List<TDCINIError> errors)
|
|
{
|
|
string[] tokens = line.Split(new char[] { ',' });
|
|
if (2 != tokens.Length)
|
|
{
|
|
errors.Add(new TDCINIError(TDCINIError.INIErrors.INI_ViewerROI_INVALID, line, curLine));
|
|
return false;
|
|
}
|
|
|
|
double d;
|
|
if (!double.TryParse(tokens[0], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out d))
|
|
{
|
|
errors.Add(new TDCINIError(TDCINIError.INIErrors.INI_ViewerROI_INVALID, tokens[0], curLine));
|
|
return false;
|
|
}
|
|
else { XMin = d; }
|
|
|
|
if (!double.TryParse(tokens[1], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out d))
|
|
{
|
|
errors.Add(new TDCINIError(TDCINIError.INIErrors.INI_ViewerROI_INVALID, tokens[1], curLine));
|
|
return false;
|
|
}
|
|
else { XMax = d; }
|
|
return true;
|
|
}
|
|
}
|
|
}
|