using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using System.Xml.Schema;
using System.Xml.Serialization;

namespace QC.CTDS.DM.DataStructures.FormatDescriptorStructure;

[Serializable]
public class LineOutputCommonBinResults : DiscriminatorElement
{
	private ObservableCollection<ResultDataSet> resultSets = new ObservableCollection<ResultDataSet>();

	private bool _sort;

	[XmlElement("Result", Form = XmlSchemaForm.Unqualified)]
	public ObservableCollection<ResultDataSet> Result
	{
		get
		{
			return resultSets;
		}
		set
		{
			if (resultSets != value)
			{
				resultSets = value;
				OnPropertyChanged("Result");
			}
		}
	}

	[XmlIgnore]
	public string BinName { get; set; }

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

	public LineOutputCommonBinResults()
	{
		Result.CollectionChanged += EstablishParentChildRelationOnCollectionChanged;
		Result.CollectionChanged += Result_CollectionChanged;
	}

	private void Result_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
	{
		base.OnPropertyChanged("Result");
	}

	public void AddNewResultSet()
	{
		ResultDataSet resultDataSet = new ResultDataSet();
		Result.Add(resultDataSet);
		resultDataSet.testID = "Test1";
		resultDataSet.resID = "Parameter";
		resultDataSet.ChartSeriesType = "Default";
		resultDataSet.IsSelected = true;
	}

	public IEnumerable<string> GetTestNames()
	{
		return Result.Select((ResultDataSet res) => res.testID);
	}
}
