public DwellTrialTrigger(IClock clock, SpellerController spellerController, GazePointHandler gazePointHandler, SpellerParadigm.Configuration.TestConfig testConfig) { _clock = clock; _spellerController = spellerController; _gazePointHandler = gazePointHandler; _cancellable = testConfig.TrialCancellable; _minTrialInterval = testConfig.Trial.Interval; _cursorMovementTolerance = testConfig.CursorMovementTolerance; _hoverToSelectDuration = testConfig.SelectionDelay; spellerController.Starting += (sender, e) => Start(); spellerController.Stopping += (sender, e) => Stop(); Reset(); }
public ButtonInsideTrialTrigger(IClock clock, SpellerController spellerController, GazePointHandler gazePointHandler, SpellerParadigm.Configuration.TestConfig testConfig, Func <Point, AbstractSpellerWindow.UIButton> findButtonFunc) { _clock = clock; _spellerController = spellerController; _gazePointHandler = gazePointHandler; _cancellable = testConfig.TrialCancellable; _minTrialInterval = testConfig.Trial.Interval; _hoverToSelectDuration = testConfig.SelectionDelay; _findButtonFunc = findButtonFunc; spellerController.Starting += (sender, e) => Start(); spellerController.Stopping += (sender, e) => Stop(); Reset(); }
protected AbstractSpellerWindow(Session session, SpellerController spellerController) { // ReSharper disable once LocalizableElement Text = "Speller"; SuspendLayout(); ControlBox = false; IsFullscreen = true; DoubleBuffered = false; FormBorderStyle = FormBorderStyle.None; WindowState = FormWindowState.Maximized; ResumeLayout(true); Load += Window_OnLoaded; KeyUp += Window_OnKeyUp; Resize += Window_OnResize; Session = session; SpellerController = spellerController; Paradigm = (SpellerParadigm)session.Paradigm; Markable = session.StreamerCollection.FindFirstOrDefault <IMarkable>(); LayoutSize = Paradigm.Config.Test.Layout.GetLayoutSize(Paradigm.Config.Gui.ColumnsOverridden); var maxButtonNum = LayoutSize[0] * LayoutSize[1]; Buttons = new UIButton[maxButtonNum]; var index = 0; var scaleFactor = (float)GraphicsUtils.Scale; foreach (var key in Paradigm.Config.Test.Layout.Keys) { if (index > maxButtonNum) { break; } var button = new UIButton(index, index / LayoutSize[1], index % LayoutSize[1], key, (float)Paradigm.Config.Gui.ButtonBorder.Width * scaleFactor, Paradigm.Config.Gui.ButtonFixationPoint.Size * scaleFactor, Paradigm.Config.Gui.ButtonFlashingMargins * (Paradigm.Config.Gui.ButtonFlashingMargins.Relative ? 1 : scaleFactor)) { State = -1 }; var size = Paradigm.Config.Gui.ButtonSize * scaleFactor; button.UpdateGeometries(new RawVector2(), new RawVector2(size, size)); Buttons[index++] = button; } ButtonMatrix = Buttons.Reshape(LayoutSize[0], LayoutSize[1], MatrixOrder.CRowMajor); ButtonCenterMatrix = new RawVector2[LayoutSize[0], LayoutSize[1]]; Char2ButtonDict = new Dictionary <char, UIButton>(); foreach (var button in Buttons) { if (button?.Key?.InputChar != null) { var ch = button.Key.InputChar.Value; if (Char2ButtonDict.ContainsKey(ch)) { throw new Exception($"duplicated char: '{ch}'"); } Char2ButtonDict[button.Key.InputChar.Value] = button; } } StageProgram = Paradigm.CreateStagedProgram(session, spellerController); StageProgram.StageChanged += (sender, e) => { if (e.IsEndReached) { this.ControlInvoke(self => Stop()); } else { OnNextStage(e); } }; GazePointHandler = new GazePointHandler(); if (session.StreamerCollection.TryFindFirst <GazePointStreamer>(out var gazePointStreamer)) { gazePointStreamer.AttachConsumer(GazePointHandler); // if (_paradigm.Config.Test.TrialCancellable) TODO: blink to cancel if (gazePointStreamer.EyeTracker.GetType() != typeof(CursorTracker)) { this.HideCursorInside(); } } else { throw new StateException("gaze point streamer not found for GazePointController"); } if (Paradigm.Config.Test.DynamicInterval) { if (Paradigm.Config.Test.ActivationMode == SpellerActivationMode.Single) { TrialTrigger = new ButtonInsideTrialTrigger(session.Clock, SpellerController, GazePointHandler, Paradigm.Config.Test, FindButtonAt); } else { TrialTrigger = new DwellTrialTrigger(session.Clock, SpellerController, GazePointHandler, Paradigm.Config.Test); } } HintText = Paradigm.Config.Test.HintText; /* Type conversion */ BackgroundColor = Paradigm.Config.Gui.BackgroundColor.ToSdColor().ToSdx(); ForegroundColor = Paradigm.Config.Gui.ForegroundColor.ToSdColor().ToSdx(); CorrectTextColor = Paradigm.Config.Gui.CorrectTextColor.ToSdColor().ToSdx(); WrongTextColor = Paradigm.Config.Gui.WrongTextColor.ToSdColor().ToSdx(); ButtonBorderColor = Paradigm.Config.Gui.ButtonBorder.Color.ToSdColor().ToSdx(); ButtonNormalColor = Paradigm.Config.Gui.ButtonNormalColor.ToSdColor().ToSdx(); ButtonFlashingColor = Paradigm.Config.Gui.ButtonFlashingColor.ToSdColor().ToSdx(); ButtonHintColor = Paradigm.Config.Gui.ButtonHintColor.ToSdColor().ToSdx(); ButtonFixationPointColor = Paradigm.Config.Gui.ButtonFixationPoint.Color.ToSdColor().ToSdx(); }