using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Xml.Serialization;

namespace QC.CTDS.DM.DataStructures.FormatDescriptorStructure;

[Serializable]
public class ResultDataSet : DiscriminatorElement, IDataErrorInfo
{
	private string groupName;

	private string _resID;

	private string _testID;

	private string _testName;

	private string _name;

	private string _chartSeriesType = "Default";

	private string _format = "0.00";

	private string _baseIndicator;

	private int _axisIndex = 1;

	private double _sigmaTol = -1.0;

	private bool isSelected;

	private ObservableCollection<string> chartSeriesType = new ObservableCollection<string>();

	private bool _sort;

	[XmlIgnore]
	public string GroupName
	{
		get
		{
			return groupName;
		}
		set
		{
			groupName = value;
		}
	}

	[XmlAttribute]
	public string resID
	{
		get
		{
			return _resID;
		}
		set
		{
			if (!(_resID == value))
			{
				_resID = value.Trim();
				base.OnPropertyChanged("resID");
				base.OnPropertyChanged("ResultDisplayName");
			}
		}
	}

	[XmlAttribute]
	public string testID
	{
		get
		{
			return _testID;
		}
		set
		{
			if (!(_testID == value))
			{
				_testID = value.Trim();
				base.OnPropertyChanged("testID");
				base.OnPropertyChanged("ResultDisplayName");
			}
		}
	}

	[XmlAttribute]
	[DefaultValue("")]
	public string testName
	{
		get
		{
			return _testName;
		}
		set
		{
			if (!(_testName == value))
			{
				_testName = value;
				base.OnPropertyChanged("testName");
				base.OnPropertyChanged("ResultDisplayName");
			}
		}
	}

	[XmlAttribute]
	[DefaultValue("")]
	public string name
	{
		get
		{
			return _name;
		}
		set
		{
			if (!(_name == value))
			{
				_name = value;
				base.OnPropertyChanged("name");
				base.OnPropertyChanged("ResultDisplayName");
			}
		}
	}

	[XmlAttribute]
	[DefaultValue("Default")]
	public string ChartSeriesType
	{
		get
		{
			return _chartSeriesType;
		}
		set
		{
			if (!(_chartSeriesType == value))
			{
				_chartSeriesType = value;
				base.OnPropertyChanged("ChartSeriesType");
				base.OnPropertyChanged("ResultDisplayName");
			}
		}
	}

	[DefaultValue("0.00")]
	[XmlAttribute]
	public string format
	{
		get
		{
			return _format;
		}
		set
		{
			if (!(_format == value))
			{
				_format = value;
				base.OnPropertyChanged("format");
			}
		}
	}

	[XmlAttribute(AttributeName = "base")]
	public string BaseIndicator
	{
		get
		{
			return _baseIndicator;
		}
		set
		{
			if (!(_baseIndicator == value))
			{
				_baseIndicator = value;
				base.OnPropertyChanged("_baseIndicator");
			}
		}
	}

	[DefaultValue(1)]
	[XmlAttribute]
	public int axisIndex
	{
		get
		{
			return _axisIndex;
		}
		set
		{
			if (_axisIndex != value)
			{
				_axisIndex = value;
				base.OnPropertyChanged("axisIndex");
			}
		}
	}

	[XmlAttribute]
	[DefaultValue(-1.0)]
	public double sigmaTol
	{
		get
		{
			return _sigmaTol;
		}
		set
		{
			if (_sigmaTol != value)
			{
				_sigmaTol = value;
				base.OnPropertyChanged("sigmaTol");
			}
		}
	}

	[XmlIgnore]
	public string ResultDisplayName
	{
		get
		{
			if (string.IsNullOrEmpty(name) && string.IsNullOrEmpty(testName))
			{
				return testID + ", " + resID;
			}
			if (string.IsNullOrEmpty(testName))
			{
				return name;
			}
			return testName;
		}
	}

	[XmlIgnore]
	public bool IsSelected
	{
		get
		{
			return isSelected;
		}
		set
		{
			if (isSelected != value)
			{
				isSelected = value;
				OnPropertyChanged("IsSelected");
			}
		}
	}

	public string Error
	{
		get
		{
			throw new NotImplementedException();
		}
	}

	public string this[string columnName]
	{
		get
		{
			string result = null;
			if (columnName == "testID" && string.IsNullOrEmpty(testID))
			{
				result = "Please enter a valid Test Name";
			}
			if (columnName == "resID" && string.IsNullOrEmpty(resID))
			{
				result = "Please enter a valid Parameter Name";
			}
			return result;
		}
	}

	[XmlIgnore]
	public ObservableCollection<string> ChartSeriesTypes
	{
		get
		{
			if (chartSeriesType == null || chartSeriesType.Count <= 0)
			{
				CreatePreDefinedChartTypeList();
			}
			return chartSeriesType;
		}
		set
		{
			chartSeriesType = value;
			OnPropertyChanged("ChartSeriesTypes");
		}
	}

	[DefaultValue(false)]
	[XmlAttribute]
	public bool sort
	{
		get
		{
			return _sort;
		}
		set
		{
			if (_sort != value)
			{
				_sort = value;
				base.OnPropertyChanged("sort");
			}
		}
	}

	public ResultDataSet()
	{
	}

	public ResultDataSet(ResultDataSet resultSet)
		: base(resultSet)
	{
		groupName = resultSet.groupName;
		_axisIndex = resultSet._axisIndex;
		_format = resultSet._format;
		isSelected = resultSet.isSelected;
		_name = resultSet._name;
		_resID = resultSet._resID;
		_sigmaTol = resultSet._sigmaTol;
		_sort = resultSet._sort;
		_testID = resultSet._testID;
		_testName = resultSet._testName;
		_chartSeriesType = resultSet._chartSeriesType;
	}

	public override void Changed(string changedFieldName)
	{
		if (changedFieldName == "IsSelected")
		{
			if (base.Parent != null)
			{
				base.Parent.Changed(changedFieldName);
			}
		}
		else
		{
			base.Changed(changedFieldName);
		}
	}

	private void CreatePreDefinedChartTypeList()
	{
		chartSeriesType.Add("Default");
		chartSeriesType.Add("ClusteredColumn");
	}
}
