예제 #1
0
        public MavepTestWindow(Session session)
        {
            // ReSharper disable once LocalizableElement
            Text = "VEP";
            SuspendLayout();
            ControlBox      = false;
            IsFullscreen    = true;
            DoubleBuffered  = false;
            FormBorderStyle = FormBorderStyle.None;
            WindowState     = FormWindowState.Maximized;
            ResumeLayout(true);

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

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

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

            _stimulusPoints = new D2D1.Ellipse[_experiment.Config.Gui.Stimulus.Count];

            /* Type conversion */
            _backgroundColor = _experiment.Config.Gui.BackgroundColor.ToSdColor().ToSdx();
            _fontColor       = _experiment.Config.Gui.BackgroundColor.ToSdColor().Inverted().ToSdx();
            _fixationColor   = _experiment.Config.Gui.FixationPoint.Color.ToSdColor().ToSdx();
        }
예제 #2
0
        public MidasTouchWindow(Session session)
        {
            // ReSharper disable once LocalizableElement
            Text = "Midas Touch";
            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;
            _paradigm = (MidasTouchParadigm)session.Paradigm;
            _markable = session.StreamerCollection.FindFirstOrDefault <IMarkable>();

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

            /* Type conversion */
            _backgroundColor  = _paradigm.Config.Gui.ColorScheme[ColorKeys.Background].ToSdColor().ToSdx();
            _foregroundColor  = _paradigm.Config.Gui.ColorScheme[ColorKeys.Foreground].ToSdColor().ToSdx();
            _blockBorderColor = _paradigm.Config.Gui.ButtonBorder.Color.ToSdColor().ToSdx();
            _blockNormalColor = _paradigm.Config.Gui.ButtonNormalColor.ToSdColor().ToSdx();
        }
예제 #3
0
 public static void Mark(this IMarkable markable)
 {
     if (markable.IsMarked == true)
     {
         throw new Exception("markable object must not be marked twice.");
     }
     markable.IsMarked = true;
 }
예제 #4
0
        public static Option <Marker> FindLabelMarker(this IMarkable markable)
        {
            Ensure.That(markable, nameof(markable)).IsNotNull();

            Debug.Assert(markable.Markers != null, "markable.Markers != null");

            return(markable.Markers.Find(LabelMarker));
        }
예제 #5
0
        public IEnumerable <Mark> GetMarks(IMarkable markable)
        {
            var marks = from mrk in _markList
                        where mrk.Parent == markable
                        select mrk;

            return(marks);
        }
예제 #6
0
        public static Marker GetLabelMarker([NotNull] this IMarkable markable)
        {
            Ensure.Any.IsNotNull(markable, nameof(markable));

            markable.Markers.TryGetValue(LabelMarker, out var marker);

            return(marker);
        }
        void OnListLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            ListBox   parent = sender as ListBox;
            IMarkable data   = GetObjectDataFromPoint(parent, e.GetPosition(parent)) as IMarkable;

            if (data != null)
            {
                DragDrop.DoDragDrop(parent, data, DragDropEffects.Move);
            }
        }
예제 #8
0
 void SetMarkableMark(IMarkable[]  targetMarkArr, IMarkable exceptMark, bool isMarked)
 {
     for (int i = 0; i < targetMarkArr.Length; i++)
     {
         if (targetMarkArr [i] == exceptMark)
         {
             continue;
         }
         targetMarkArr [i].SetMark(isMarked);
     }
 }
예제 #9
0
        public ToggleButton GetMarkingButton(IMarkable markable)
        {
            ToggleButton button = new ToggleButton();

            button.Content = markable.Symbol;
            button.Background = markable.ColorBrush;
            button.Margin = new Thickness(0, 0, 10, 0);
            button.Padding = new Thickness(5, 0, 5, 0);

            return button;
        }
        void OnListItemDrop(object sender, DragEventArgs e)
        {
            ListBox   parent = sender as ListBox;
            IMarkable data   = e.Data.GetData(typeof(IMarkable)) as IMarkable;
            IMarkable objectToPlaceBefore = GetObjectDataFromPoint(parent, e.GetPosition(parent)) as IMarkable;

            if (data != null && objectToPlaceBefore != null)
            {
                var managar = ModelsComposite.ItemModelManager;
                managar.SwapItem(data, objectToPlaceBefore);
            }
        }
예제 #11
0
        public TestWindow(Session session, DemoExperiment experiment)
        {
            InitializeComponent();

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

            /* Set experiment parameters to this window. */
            CueTextBlock.Text       = experiment.Text;
            CueTextBlock.Foreground = new SolidColorBrush(experiment.BackgroundColor.ToSwmColor());
            Background = new SolidColorBrush(experiment.BackgroundColor.ToSwmColor());
        }
예제 #12
0
        public ToggleButton GetMarkingButton(IMarkable markable)
        {
            ToggleButton button = new ToggleButton();

            button.Content    = markable.Symbol;
            button.Background = markable.ColorBrush;
            button.Margin     = new Thickness(0, 0, 10, 0);
            button.Padding    = new Thickness(5, 0, 5, 0);


            return(button);
        }
예제 #13
0
        public void RemoveModel(IMarkable markable)
        {
            var marks = ModelsComposite.MarkManager.GetMarks(markable);

            var RemoveMarks = marks.ToArray();

            foreach (var mark in RemoveMarks)
            {
                ModelsComposite.MarkManager.DeleteMark(mark);
            }

            _modelDictionary.Remove(markable.Id);
            ModelCollection.Remove(markable);
        }
예제 #14
0
        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();
        }
예제 #15
0
        public P300ExperimentWindow(Session session)
        {
            // ReSharper disable once LocalizableElement
            Text = "P300";
            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;
            _paradigm = (P300Paradigm)session.Paradigm;
            _markable = session.StreamerCollection.FindFirstOrDefault <IMarkable>();
            _result   = new P300Paradigm.Result {
                Trials = new LinkedList <P300Paradigm.Result.Trial>()
            };

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

            /* Initialize blocks */
            _blocks = new Block[(int)_paradigm.Config.Test.Layout];
            for (var i = 0; i < _blocks.Length; i++)
            {
                var block = new Block
                {
                    Target = _blocks.Length / 2 == i,
                    Random = _paradigm.Config.Test.TargetRate
                             .CreateRandomBoolSequence((int)(DateTimeUtils.CurrentTimeTicks << 1 + i)),
                    Size        = new RawVector2(_paradigm.Config.Gui.BlockLayout.Width, _paradigm.Config.Gui.BlockLayout.Height),
                    BorderWidth = (float)_paradigm.Config.Gui.BlockBorder.Width
                };
                block.UpdateGeometries();
                _blocks[i] = block;
            }

            /* Type conversion */
            _backgroundColor   = _paradigm.Config.Gui.BackgroundColor.ToSdColor().ToSdx();
            _fontColor         = _paradigm.Config.Gui.BackgroundColor.ToSdColor().Inverted().ToSdx();
            _blockBorderColor  = _paradigm.Config.Gui.BlockBorder.Color.ToSdColor().ToSdx();
            _blockNormalColor  = _paradigm.Config.Gui.BlockNormalColor.ToSdColor().ToSdx();
            _blockActivedColor = _paradigm.Config.Gui.BlockActivedColor.ToSdColor().ToSdx();
        }
예제 #16
0
        public static bool AddMark(string text, int index, IMarkable targetMark)
        {
            if (targetMark.GetType() == typeof(CharacterModel))
            {
                CharacterMarkManagementStrategy.AddMark(text, index, targetMark);
                return(true);
            }
            else if (targetMark.GetType() == typeof(StoryFrameModel))
            {
                StoryFrameMarkManagementStrategy.AddMark(text, index, targetMark);
                return(true);
            }

            return(false);
        }
예제 #17
0
        public static bool AddMark(string text, int index, IMarkable targetMark)
        {
            if (targetMark.GetType() == typeof(CharacterModel))
            {
                CharacterMarkManagementStrategy.AddMark(text, index, targetMark);
                return true;
            }
            else if (targetMark.GetType() == typeof(StoryFrameModel))
            {
                StoryFrameMarkManagementStrategy.AddMark(text, index, targetMark);
                return true;
            }

            return false;
        }
예제 #18
0
        public TestWindow(Session session)
        {
            InitializeComponent();

            _session  = session;
            _markable = session.StreamerCollection.FindFirstOrDefault <IMarkable>();
            this.HideCursorInside();

            var experiment = (CountdownExperiment)session.Experiment;

            Background         = new SolidColorBrush(experiment.Config.Gui.BackgroundColor.ToSwmColor());
            CueText.Foreground = new SolidColorBrush(experiment.Config.Gui.ForegroundColor.ToSwmColor());
            CueText.FontSize   = experiment.Config.Gui.FontSize;

            _stageProgram = experiment.CreateStagedProgram(session);
            _stageProgram.StageChanged += StageProgram_StageChanged;
        }
예제 #19
0
        public void RemoveModel(IMarkable markable)
        {
            var marks = ModelsComposite.MarkManager.GetMarks(markable);

            var RemoveMarks = marks.ToArray();

            foreach (var mark in RemoveMarks)
            {
                ModelsComposite.MarkManager.DeleteMark(mark);
            }

            _modelDictionary.Remove(markable.Id);
            ModelCollection.Remove(markable);

            EventAggregator.OnModelDataChanged(this, new ModelValueChangedEventArgs());
            EventAggregator.OnDeleteIMarkable(this, new DeleteIMarkableModelEventArgs(markable));
        }
예제 #20
0
        public TextDisplayExperimentWindow(Session session)
        {
            InitializeComponent();

            _session  = session;
            _markable = session.StreamerCollection.FindFirstOrDefault <IMarkable>();
            this.HideCursorInside();

            var paradigm = (TextDisplayParadigm)session.Paradigm;

            Background         = new SolidColorBrush(paradigm.Config.Gui.BackgroundColor.ToSwmColor());
            CueText.Foreground = new SolidColorBrush(paradigm.Config.Gui.ForegroundColor.ToSwmColor());
            CueText.FontSize   = paradigm.Config.Gui.FontSize;

            _stageProgram = paradigm.CreateStagedProgram(session);
            _stageProgram.StageChanged += StageProgram_StageChanged;
        }
예제 #21
0
        public TestWindow(Session session)
        {
            InitializeComponent();
            _session    = session;
            _experiment = (MrcpExperiment)session.Experiment;
            _markable   = session.StreamerCollection.FindFirstOrDefault <IMarkable>();

            this.HideCursorInside();

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

            _defaultLineStyle     = (Style)FindResource("DefaultLineStyle");
            _highlightedLineStyle = (Style)FindResource("HighlightedLineStyle");

            _relaxCueImage = (BitmapImage)FindResource("RelaxCueImage");
            _liftCueImage  = (BitmapImage)FindResource("LiftCueImage");
        }
예제 #22
0
        public void SwapItem(IMarkable insertItem, IMarkable targetItem)
        {
            int removedIdx = ModelCollection.IndexOf(insertItem);
            int targetIdx  = ModelCollection.IndexOf(targetItem);

            if (removedIdx < targetIdx)
            {
                ModelCollection.Insert(targetIdx + 1, targetItem);
                ModelCollection.RemoveAt(removedIdx);
            }
            else
            {
                int remIdx = removedIdx + 1;
                if (ModelCollection.Count + 1 > remIdx)
                {
                    ModelCollection.Insert(targetIdx, targetItem);
                    ModelCollection.RemoveAt(remIdx);
                }
            }

            EventAggregator.OnModelDataChanged(this, new ModelValueChangedEventArgs());
        }
        /// <summary>
        /// X,Y座標にMarkを追加する
        /// </summary>
        /// <param name="pos">X,Y座標</param>
        /// <returns>処理の正否</returns>
        public bool AddMarkAt(Point pos)
        {
            // 現在選択中のマーカーを取得する
            IMarkable mark = MarkerModel.GetSelectingMark();

            if (mark == null)
            {
                return(false);
            }
            int selectingIndex = GetIndexFromPosition(pos);

            if (selectingIndex == -1)
            {
                return(false);
            }

            if (GetMarkFromIndex(selectingIndex) != null)
            {
                return(false);
            }

            return(MarkFactory.AddMark(_writersBFView.Editor.GetText(), GetIndexFromPosition(pos), mark));
        }
예제 #24
0
        /*
         * void ISortAlgorithm.Sort(IMarkable[] elements)
         * {
         *      while (((ISortAlgorithm)this).SortStep (elements)) {
         *
         *      }
         * }
         */
        private void Merge(IMarkable[] array, int start, int middle, int end)
        {
            IMarkable[] merge = new IMarkable[end - start];
            int         l = 0, r = 0, i = 0;

            while (l < middle - start && r < end - middle)
            {
                if (i < merge.Length &&
                    middle + r < array.Length &&
                    start + l < array.Length)
                {
                    merge [i++] = array [start + l].CompareTo(array [middle + r]) < 0
                                        ? array [start + l++]
                                        : array [middle + r++];
                }
                else
                {
                    break;
                }
            }

            while (r < end - middle &&
                   i < merge.Length &&
                   middle + r < array.Length)
            {
                merge[i++] = array[middle + r++];
            }

            while (l < middle - start &&
                   i < merge.Length &&
                   start + l < array.Length)
            {
                merge[i++] = array[start + l++];
            }

            Array.Copy(merge, 0, array, start, Math.Min(merge.Length, array.Length - start));
        }
 public static bool AddMark(string text, int index, IMarkable targetMark)
 {
     AddStoryFrameMark(text, index, targetMark as StoryFrameModel);
     return true;
 }
 public AddIMarkableModelEventArgs(IMarkable markable)
 {
     Markable = markable;
 }
예제 #27
0
        public SsvepExperimentWindow(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;
            this.HideCursorInside();

            _session         = session;
            _paradigm        = (SsvepParadigm)session.Paradigm;
            _trialStartEvent = _paradigm.Config.Test.PressKeyToStartBlock.HasValue ? new AutoResetEvent(false) : null;
            _markable        = session.StreamerCollection.FindFirstOrDefault <IMarkable>();

            _stageProgram = _paradigm.CreateStagedProgram(session, _trialStartEvent);
            _stageProgram.StageChanged += StageProgram_StageChanged;

            _blocks = new Block[(int)_paradigm.Config.Gui.BlockLayout.Volume];
            for (var i = 0; i < _blocks.Length; i++)
            {
                var block = _blocks[i] = new Block();
                block.Size    = new RawVector2(_paradigm.Config.Gui.BlockSize.Width, _paradigm.Config.Gui.BlockSize.Height);
                block.Pattern = _paradigm.Config.Test.Patterns[i];
                block.Text    = _paradigm.Config.Gui.GetBlockText(i);
            }

            /* Type conversion */
            _backgroundColor         = _paradigm.Config.Gui.BackgroundColor.ToSdColor().ToSdx();
            _fontColor               = _paradigm.Config.Gui.BackgroundColor.ToSdColor().Inverted().ToSdx();
            _blockBorderColor        = _paradigm.Config.Gui.BlockBorder.Color.ToSdColor().ToSdx();
            _blockNormalColor        = _paradigm.Config.Gui.BlockColors[0].ToSdColor().ToSdx();
            _blockFlashingColor      = _paradigm.Config.Gui.BlockColors[1].ToSdColor().ToSdx();
            _blockFontColor          = _paradigm.Config.Gui.BlockFontColor.ToSdColor().ToSdx();
            _blockFixationPointColor = _paradigm.Config.Gui.BlockFixationPoint.Color.ToSdColor().ToSdx();

            /* Initialize presenter */
            switch (_paradigm.Config.Test.StimulationType)
            {
            case SsvepStimulationType.Square01:
                _presenter = new Square01StimulationPresenter(_blockNormalColor, _blockFlashingColor);
                break;

            case SsvepStimulationType.SineGradient:
                _presenter = new SineGradientStimulationPresenter(_blockNormalColor, _blockFlashingColor);
                break;

            case SsvepStimulationType.SquareCheckerboard:
                _presenter = new SquareCheckerboardStimulationPresenter(_blockNormalColor, _blockFlashingColor);
                break;

            case SsvepStimulationType.SquareCheckerboardRadical:
                _presenter = new SquareCheckerboardRadicalStimulationPresenter(_blockNormalColor, _blockFlashingColor);
                break;

            default:
                throw new NotSupportedException(_paradigm.Config.Test.StimulationType.ToString());
            }
        }
예제 #28
0
 public void AddModel(IMarkable markable)
 {
     ModelCollection.Add(markable);
 }
예제 #29
0
 private void Select(IMarkable markable)
 {
     markable?.MarkAsSelected();
 }
예제 #30
0
 public static long Mark(this IMarkable markable, int code) => markable.Mark(null, code);
예제 #31
0
 private void Deselect(IMarkable markable)
 {
     markable?.MarkAsDeselected();
 }
예제 #32
0
        public void SwapItem(IMarkable insertItem, IMarkable targetItem)
        {
            int removedIdx = ModelCollection.IndexOf(insertItem);
            int targetIdx = ModelCollection.IndexOf(targetItem);

            if (removedIdx < targetIdx)
            {
                ModelCollection.Insert(targetIdx + 1, targetItem);
                ModelCollection.RemoveAt(removedIdx);
            }
            else
            {
                int remIdx = removedIdx + 1;
                if (ModelCollection.Count + 1 > remIdx)
                {
                    ModelCollection.Insert(targetIdx, targetItem);
                    ModelCollection.RemoveAt(remIdx);
                }
            }

            EventAggregator.OnModelDataChanged(this, new ModelValueChangedEventArgs());
        }
예제 #33
0
 public static bool AddMark(string text, int index, IMarkable targetMark)
 {
     AddCharacterMark(text, index, targetMark as CharacterModel);
     return(true);
 }
예제 #34
0
 public static void Unmark(this IMarkable markable)
 {
     markable.IsMarked = false;
 }
 public DeleteIMarkableModelEventArgs(IMarkable markable)
 {
     Markable = markable;
 }
 public static bool AddMark(string text, int index, IMarkable targetMark)
 {
     AddCharacterMark(text, index, targetMark as CharacterModel);
     return true;
 }
예제 #37
0
 public DeleteIMarkableModelEventArgs(IMarkable markable)
 {
     Markable = markable;
 }
예제 #38
0
 static void ApplyMarkers(XmlReader re, IMarkable m)
 {
     re.MoveToContent();
     for (int i = 0; i < re.AttributeCount; i++)
     {
         try
         {
             re.MoveToAttribute(i);
             if (re.LocalName == STARTMARKER_ATTR)
                 m.StartMarker = (DMarker)Enum.Parse(typeof(DMarker), re.Value, true);
             else if (re.LocalName == ENDMARKER_ATTR)
                 m.EndMarker = (DMarker)Enum.Parse(typeof(DMarker), re.Value, true);
         }
         catch { }
     }
 }
예제 #39
0
 public AddIMarkableModelEventArgs(IMarkable markable)
 {
     Markable = markable;
 }
예제 #40
0
        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();
        }
예제 #41
0
        public IEnumerable<Mark> GetMarks(IMarkable markable)
        {
            var marks = from mrk in _markList
                        where mrk.Parent == markable
                        select mrk;

            return marks;
        }