using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

using DiagramUI;


namespace DataPerformerUI
{
    public partial class ColoredChooser : UserControl, IPointCollecionChooser
    {
        #region Fields
        private ComboBox[] boxes;

        public static readonly ColoredChooser Object = new ColoredChooser();

        #endregion

        #region Ctor

        internal ColoredChooser()
        {
            InitializeComponent();
            boxes = new ComboBox[] { comboBoxX, comboBoxY, comboBoxR, comboBoxG, comboBoxB, comboBoxS };
        }

        #endregion

        #region IPointCollecionChooser Members

        List<string> IPointCollecionChooser.Measurements
        {
            get
            {
                List<string> l = new List<string>();
                foreach (ComboBox box in boxes)
                {
                    string s = box.SelectedItem + "";
                    if (s.Length == 0)
                    {
                        throw new Exception("Undefined measure");
                    }
                    l.Add(s);
                }
                return l;
            }
            set
            {
                for (int i = 0; i < value.Count & i < boxes.Length; i++)
                {
                    DefaultForm.SelectCombo(boxes[i], value[i]);
                }
            }
        }

        DataPerformer.IDataConsumer IPointCollecionChooser.Consumer
        {
            set 
            {
                Double a = 0;
                List<string> mea = DataPerformer.DataConsumer.GetAllMeasurements(value, a);
                foreach (ComboBox box in boxes)
                {
                    DefaultForm.FillCombo(box, mea);
                }
            }
        }

        #endregion
    }
}
