public SeriesEditor(Series s)
        {
            InitializeComponent();
            this.series            = s;
            capture                = new CaptureManager(s);
            capture.OnErrorInit   += new CaptureManager.InitErrorEventHandler(capture_OnErrorInit);
            capture.OnFinishInit  += new CaptureManager.FinishInitEventHandler(capture_OnFinishInit);
            capture.OnImageQuery  += new CaptureManager.ImageEventHandler(capture_OnImageQuery);
            capture.OnStartInit   += new CaptureManager.StartInitEventHandler(capture_OnStartInit);
            capture.OnTimeChanged += new CaptureManager.CurrentTimeChangedEventHandler(capture_OnTimeChanged);
            capture.OnStimul      += new CaptureManager.StimulusEventHandler(capture_OnStimul);
            capture.CameraWidth    = 640;
            capture.CameraHeight   = 480;
            capture.Init();
            capture.StartCapture();

            slider.InitWithSeries(series);
            slider.ValueChanged += new controls.CaptureSlider.ValueChangedHandler(slider_ValueChanged);

            player          = new SeriesPlayer(series);
            player.OnStart += new SeriesPlayer.StartEventHandler(player_OnStart);
            player.Show();
        }
        public void InitWithSeries(ETS_Data.Series series)
        {
            this.series = series;
            if (series.Config.OrderTypeId == (long)Order.Fixed)
            {
                Minimum = 0;
                Maximum = (int)series.Length;
                Value   = 0;
                long interval = series.Config.MaxInt;

                for (int i = 0; i < series.Config.SelectedStimulusSet.Count; i++)
                {
                    Stimulus        s  = (Stimulus)series.Config.SelectedStimulusSet[i];
                    StimulusWrapper sw = new StimulusWrapper();
                    sw.Stimul       = s;
                    sw.TimePosition = (i + 1) * (int)interval;
                    cmbStimuluses.Items.Add(sw);
                }
            }
            else
            {
            }
        }
        public static void SaveSeria(ETS_Data.Series series, FileStream stream)
        {
            using (StreamWriter sr = new StreamWriter(stream))
            {
                //Name
                sr.WriteLine("Seria name;" + series.Name + ";");
                //Config
                SeriesConfig config = series.Config;
                sr.WriteLine("Config;");
                sr.WriteLine("Name;" + config.Name + ";");
                sr.WriteLine("Max interval;" + config.MaxInt + ";");
                sr.WriteLine("Min interval;" + config.MinInt + ";");
                sr.WriteLine("Order type;" + config.StringOrderType + ";");
                sr.WriteLine("Text before;" + config.TextBefore + ";");
                sr.WriteLine("Text after;" + config.TextAfter + ";");
                //Stimuluses
                sr.WriteLine("Stimuluses set;");
                sr.WriteLine("Name;Filename;Type;");
                foreach (Stimulus s in series.Config.StimulusSet)
                {
                    SerializeStimulus(s, sr);
                }
                //Templates
                for (int i = 0; i < series.Templates.Count; i++)
                {
                    Template t = (Template)series.Templates[i];
                    sr.WriteLine("Template;" + t.Name + ";");
                    ArrayList coords = (ArrayList)series.TemplateCoords[i];
                    sr.Write("Time;");
                    for (int j = 0; j < coords.Count; j++)
                    {
                        SeriesRecord r = (SeriesRecord)coords[j];
                        if (r != null)
                        {
                            sr.Write(Util.MsToStandardTimeRepresentation((int)r.Time) + ";");
                        }
                    }
                    sr.WriteLine();
                    sr.Write("X;");
                    for (int j = 0; j < coords.Count; j++)
                    {
                        SeriesRecord r = (SeriesRecord)coords[j];
                        if (r != null)
                        {
                            sr.Write(r.X + ";");
                        }
                    }
                    sr.WriteLine();
                    sr.Write("Y;");
                    for (int j = 0; j < coords.Count; j++)
                    {
                        SeriesRecord r = (SeriesRecord)coords[j];
                        if (r != null)
                        {
                            sr.Write(r.Y + ";");
                        }
                    }
                    sr.WriteLine();
                }
                if (series.TemplateCoords.Count > 0)
                {
                    ArrayList coords = (ArrayList)series.TemplateCoords[0];
                    if (coords.Count > 0)
                    {
                        sr.Write("Stimuluses;");

                        for (int j = 0; j < coords.Count; j++)
                        {
                            SeriesRecord r    = (SeriesRecord)coords[j];
                            int          time = (int)r.Time;
                            Stimulus     s    = series.GetStimulusForTime(time);
                            if (s == null)
                            {
                                sr.Write(";");
                            }
                            else
                            {
                                sr.Write(s.Name + ";");
                            }
                        }
                    }
                }
            }
            try
            {
                stream.Close();
            }
            catch (Exception e)
            {
            }
        }