public SsvepTestWindow(Session session)
        {
            // ReSharper disable once LocalizableElement
            Text = "SSVEP";
            SuspendLayout();
            ControlBox      = false;
            IsFullscreen    = true;
            DoubleBuffered  = false;
            FormBorderStyle = FormBorderStyle.None;
            WindowState     = FormWindowState.Maximized;
            ResumeLayout(true);

            Load   += Window_OnLoaded;
            KeyUp  += Window_OnKeyUp;
            Resize += Window_OnResize;
            this.HideCursorInside();

            _session    = session;
            _experiment = (SsvepExperiment)session.Experiment;
            _markable   = session.StreamerCollection.FindFirstOrDefault <IMarkable>();

            _paradigm = _experiment.Config.Test.Paradigm;
            _blocks   = new Block[(int)_experiment.Config.Gui.BlockLayout.Volume];
            var patternMultiplier = _paradigm.GetParadigmPatternMultiplier();

            for (var i = 0; i < _blocks.Length; i++)
            {
                _blocks[i].Size              = new RawVector2(_experiment.Config.Gui.BlockSize.Width, _experiment.Config.Gui.BlockSize.Height);
                _blocks[i].BorderWidth       = (float)_experiment.Config.Gui.BlockBorder.Width * (float)GraphicsUtils.Scale;
                _blocks[i].FixationPointSize = _experiment.Config.Gui.BlockFixationPoint.Size * (float)GraphicsUtils.Scale;
                var patterns = new ITemporalPattern[patternMultiplier];
                for (var j = 0; j < patternMultiplier; j++)
                {
                    patterns[j] = _experiment.Config.Test.Patterns[i * patternMultiplier + j];
                }
                _blocks[i].Patterns = patterns.All(Functions.IsNull) ? null : patterns;
                _blocks[i].UpdateGeometries();
            }

            _stageProgram = _experiment.CreateStagedProgram(session);
            _stageProgram.StageChanged += StageProgram_StageChanged;

            /* Type conversion */
            _backgroundColor         = _experiment.Config.Gui.BackgroundColor.ToSdColor().ToSdx();
            _fontColor               = _experiment.Config.Gui.BackgroundColor.ToSdColor().Inverted().ToSdx();
            _blockBorderColor        = _experiment.Config.Gui.BlockBorder.Color.ToSdColor().ToSdx();
            _blockNormalColor        = _experiment.Config.Gui.BlockColors[0].ToSdColor().ToSdx();
            _blockFlashingColor      = _experiment.Config.Gui.BlockColors[1].ToSdColor().ToSdx();
            _blockFixationPointColor = _experiment.Config.Gui.BlockFixationPoint.Color.ToSdColor().ToSdx();
        }
Beispiel #2
0
        public static int GetParadigmPatternMultiplier(this SsvepExperiment.Configuration.TestConfig.StimulationParadigm paradigm)
        {
            switch (paradigm)
            {
            case SsvepExperiment.Configuration.TestConfig.StimulationParadigm.Flicker:
                return(1);

            case SsvepExperiment.Configuration.TestConfig.StimulationParadigm.DualFlickers:
                return(2);

            default:
                throw new NotSupportedException();
            }
        }