Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the Slide class.
 /// </summary>
 /// <param name="newName">A <see cref="string"/> with the unique name of this Slide</param>
 /// <param name="newBackgroundColor">A <see cref="Color"/> with the background color for this slide</param>
 /// <param name="newBackgroundImage">A <see cref="Image"/> with the background image for this slide</param>
 /// <param name="newStopConditions">A <see cref="StopConditionCollection"/> list
 /// of responses for which the slide presentation should stop.</param>
 /// <param name="newResponses">An optional <see cref="StopConditionCollection"/> with responses
 /// that indicate correct answers.</param>
 /// <param name="newCategory">A <see cref="string"/> with an optional category 
 /// that gives an additional slide distinction.</param>
 /// <param name="newPresentationSize">A <see cref="Size"/> with the original 
 /// presentation size of this slide.</param>
 public Slide(
   string newName,
   Color newBackgroundColor,
   Image newBackgroundImage,
   StopConditionCollection newStopConditions,
   StopConditionCollection newResponses,
   string newCategory,
   Size newPresentationSize)
 {
   this.stimuli = new VGElementCollection();
   this.activeXElements = new VGElementCollection();
   this.targets = new VGElementCollection();
   this.links = new StopConditionCollection();
   this.stopConditions = newStopConditions;
   this.BackgroundColor = newBackgroundColor;
   this.BackgroundImage = newBackgroundImage;
   this.name = newName;
   this.correctResponses = newResponses;
   this.category = newCategory;
   this.PresentationSize = newPresentationSize;
   this.IdOfPreSlideFixationTrial = -1;
 }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the Slide class.
 /// </summary>
 public Slide()
 {
   this.stimuli = new VGElementCollection();
   this.activeXElements = new VGElementCollection();
   this.targets = new VGElementCollection();
   this.correctResponses = new StopConditionCollection();
   this.links = new StopConditionCollection();
   this.stopConditions = new StopConditionCollection();
   this.category = string.Empty;
   this.TriggerSignal = new Trigger(TriggerSignaling.None, TriggerOutputDevices.LPT, 40, 255, 0x0378);
   this.IdOfPreSlideFixationTrial = -1;
 }
Esempio n. 3
0
    /// <summary>
    /// Initializes a new instance of the Slide class as a clone of 
    /// the given slide.
    /// </summary>
    /// <param name="slide">The <see cref="Slide"/> to clone.</param>
    public Slide(Slide slide)
    {
      // Clone stimuli
      this.stimuli = new VGElementCollection();
      foreach (VGElement element in slide.VGStimuli)
      {
        this.stimuli.Add((VGElement)element.Clone());
      }

      // Clone activeXElements
      this.activeXElements = new VGElementCollection();
      foreach (VGElement element in slide.ActiveXStimuli)
      {
        this.activeXElements.Add((VGElement)element.Clone());
      }

      // Clone stop conditions
      this.stopConditions = new StopConditionCollection();
      foreach (StopCondition condition in slide.StopConditions)
      {
        this.stopConditions.Add((StopCondition)condition.Clone());
      }

      // Clone background properties
      this.BackgroundColor = slide.BackgroundColor;
      if (slide.BackgroundImage != null)
      {
        this.BackgroundImage = (Image)slide.BackgroundImage.Clone();
      }

      if (slide.BackgroundSound != null)
      {
        this.BackgroundSound = (AudioFile)slide.BackgroundSound.Clone();
      }

      // Clone trigger
      this.TriggerSignal = slide.TriggerSignal;

      this.IsDesktopSlide = slide.IsDesktopSlide;
      this.IdOfPreSlideFixationTrial = slide.IdOfPreSlideFixationTrial;
      this.IsDisabled = slide.IsDisabled;

      // Clone correct responses
      this.correctResponses = new StopConditionCollection();
      foreach (StopCondition condition in slide.CorrectResponses)
      {
        this.correctResponses.Add((StopCondition)condition.Clone());
      }

      // Clone links
      this.links = new StopConditionCollection();
      foreach (StopCondition condition in slide.Links)
      {
        this.links.Add((StopCondition)condition.Clone());
      }

      // Clone description
      this.name = slide.Name;
      this.category = slide.Category;

      // Clone target areas
      this.targets = new VGElementCollection();
      foreach (VGElement target in slide.TargetShapes)
      {
        this.targets.Add((VGElement)target.Clone());
      }

      // Clone mouse properties
      this.MouseInitialPosition = slide.MouseInitialPosition;
      this.MouseCursorVisible = slide.MouseCursorVisible;
      this.ForceMousePositionChange = slide.ForceMousePositionChange;

      this.PresentationSize = slide.PresentationSize;
      this.Modified = slide.Modified;
    }
Esempio n. 4
0
    /// <summary>
    ///   This method creates the initialization trial.
    /// </summary>
    private void InitializeFirstTrial()
    {
      var coll = new StopConditionCollection();
      var stc = new TimeStopCondition(5000);
      coll.Add(stc);

      this.preparedSlideOne.Slide = new Slide(
        "OgamaDummyStartTrial6gsj2",
        Color.Gray,
        Images.CreateRecordInstructionImage(
          Document.ActiveDocument.ExperimentSettings.WidthStimulusScreen,
          Document.ActiveDocument.ExperimentSettings.HeightStimulusScreen),
        coll,
        new StopConditionCollection(),
        string.Empty,
        Document.ActiveDocument.PresentationSize);
      var wait = new VGText(
        ShapeDrawAction.None,
        "Initializing ...",
        new Font("Verdana", 40f),
        Color.WhiteSmoke,
        HorizontalAlignment.Center,
        1,
        6,
        Pens.Red,
        Brushes.Red,
        SystemFonts.MenuFont,
        Color.Black,
        new RectangleF(100, 100, 400, 200),
        VGStyleGroup.None,
        "Text",
        string.Empty,
        null);
      this.preparedSlideOne.Slide.VGStimuli.Add(wait);

      // Reset the cursor position to initial location if applicable
      var newPoint = new Point(
        this.presentationBounds.Left + this.presentationBounds.Width / 2,
        this.presentationBounds.Top + this.presentationBounds.Height / 2);
      Cursor.Position = newPoint;

      Cursor.Hide();
      this.hiddenCursor = true;

      // Prepare preparation slide 
      this.preparedSlideOne.Trial = new Trial("DummyTrial", -1);
      this.preparedSlideOne.Trial.Add(this.preparedSlideOne.Slide);
      this.preparedSlideOne.Timer.Period = 2000;
      this.preparedSlideOne.Timer.Mode = TimerMode.OneShot;
      this.preparedSlideOne.Timer.SynchronizingObject = this;
      this.preparedSlideOne.Timer.Tick += this.TimerTick;

      this.DrawToBuffer(this.preparedSlideOne);
      this.PresentPreparedSlide();

      // Prepare first slide of trial list
      this.preparedSlideTwo.Trial = this.trials[0];
      this.preparedSlideTwo.Slide = this.trials[0][0];
      this.preparedSlideTwo.Timer.Period = 200;
      this.preparedSlideTwo.Timer.Mode = TimerMode.OneShot;
      this.preparedSlideTwo.Timer.SynchronizingObject = this;
      this.preparedSlideTwo.Timer.Tick += this.TimerTick;
      this.InitializeNextSlide(this.preparedSlideTwo);
      this.DrawToBuffer(this.preparedSlideTwo);
      this.PrepareScreenCapture(-1);
    }
Esempio n. 5
0
    /// <summary>
    /// Removes all <see cref="StopCondition"/>s with a target condition
    ///   of the given <see cref="ListBox"/>
    /// </summary>
    /// <param name="box">
    /// A <see cref="ListBox"/> which should be checked for
    ///   target conditions.
    /// </param>
    private void RemoveTargetConditions(ListBox box)
    {
      // Get conditions to remove
      var itemsToRemove = new StopConditionCollection();
      foreach (StopCondition stc in box.Items)
      {
        if (stc is MouseStopCondition)
        {
          if (((MouseStopCondition)stc).Target != string.Empty)
          {
            itemsToRemove.Add(stc);
          }
        }
      }

      // Remove them from the ListBox
      foreach (StopCondition removeStc in itemsToRemove)
      {
        box.Items.Remove(removeStc);
      }
    }
Esempio n. 6
0
    /// <summary>
    /// This static method creates a slide with a sized image
    ///   for each trial and adds it to the slideshow.
    /// </summary>
    /// <param name="detectonSettings">
    /// The <see cref="DetectionSettings"/>
    ///   used in this import.
    /// </param>
    /// <param name="mainWindow">
    /// The <see cref="MainForm"/> to get access to the status label.
    /// </param>
    public static void GenerateOgamaSlideshowTrials(DetectionSettings detectonSettings, MainForm mainWindow)
    {
      // Stores found stimuli files
      List<string> trialNames = Document.ActiveDocument.ExperimentSettings.SlideShow.GetTrialNames();

      foreach (KeyValuePair<int, int> kvp in detectonSettings.TrialSequenceToTrialIDAssignments)
      {
        int trialID = kvp.Value;
        string file = string.Empty;
        if (detectonSettings.TrialIDToImageAssignments.ContainsKey(trialID))
        {
          file = detectonSettings.TrialIDToImageAssignments[trialID];
        }

        string filename = Path.GetFileNameWithoutExtension(file);

        // Create slide
        var stopConditions = new StopConditionCollection
                               {
                                 new MouseStopCondition(
                                   MouseButtons.Left, 
                                   true, 
                                   string.Empty, 
                                   null, 
                                   Point.Empty)
                               };

        VGImage stimulusImage = null;

        if (file != string.Empty)
        {
          stimulusImage = new VGImage(
            ShapeDrawAction.None,
            Pens.Black,
            Brushes.Black,
            SystemFonts.MenuFont,
            Color.White,
            Path.GetFileName(file),
            Document.ActiveDocument.ExperimentSettings.SlideResourcesPath,
            ImageLayout.Zoom,
            1f,
            Document.ActiveDocument.PresentationSize,
            VGStyleGroup.None,
            filename,
            string.Empty,
            true)
            {
              Size = Document.ActiveDocument.PresentationSize
            };
        }

        var newSlide = new Slide(
          filename,
          Color.White,
          null,
          stopConditions,
          null,
          string.Empty,
          Document.ActiveDocument.PresentationSize) { Modified = true, MouseCursorVisible = true };

        // Only add stimulus if an image exists
        if (file != string.Empty)
        {
          newSlide.VGStimuli.Add(stimulusImage);
        }
        else
        {
          newSlide.Name = "No stimulus detected";
        }

        // Create trial
        if (Document.ActiveDocument.ExperimentSettings.SlideShow.GetNodeByID(trialID) != null)
        {
          // trialID = int.Parse(Document.ActiveDocument.ExperimentSettings.SlideShow.GetUnusedNodeID());
          // var message = string.Format("The trial with the ID:{0} exists already in the slideshow so it will not be created."
          // + Environment.NewLine + "Delete the trial with this ID in the slideshow design module if you want it to be newly created by the importer, or assign a new ID to the imported data.", trialID);
          // ExceptionMethods.ProcessMessage("This trial exists already", message);
          continue;
        }

        var newTrial = new Trial(filename, trialID) { Name = filename };

        newTrial.Add(newSlide);

        if (trialNames.Contains(filename) || (filename == string.Empty && trialNames.Contains("No stimulus detected")))
        {
          // Trial already exists
          continue;
        }

        trialNames.Add(filename);

        // Create slide node
        var slideNode = new SlideshowTreeNode(newSlide.Name)
                          {
                            Name = trialID.ToString(CultureInfo.InvariantCulture),
                            Slide = newSlide
                          };

        // Add slide node to slideshow
        Document.ActiveDocument.ExperimentSettings.SlideShow.Nodes.Add(slideNode);
        Document.ActiveDocument.Modified = true;
      }

      mainWindow.StatusLabel.Text = "Saving slideshow to file ...";
      if (!Document.ActiveDocument.SaveSettingsToFile(Document.ActiveDocument.ExperimentSettings.DocumentFilename))
      {
        ExceptionMethods.ProcessErrorMessage("Couldn't save slideshow to experiment settings.");
      }

      mainWindow.StatusLabel.Text = "Refreshing context panel ...";
      mainWindow.RefreshContextPanelImageTabs();
      mainWindow.StatusLabel.Text = "Ready ...";
      mainWindow.StatusProgressbar.Value = 0;
    }
        ///////////////////////////////////////////////////////////////////////////////
        // Construction and Initializing methods                                     //
        ///////////////////////////////////////////////////////////////////////////////
        #region CONSTRUCTION

        /// <summary>
        /// Initializes a new instance of the StopConditionCollectionPropertyDescriptor class.
        /// </summary>
        /// <param name="collection">The <see cref="StopConditionCollection"/>
        /// for this <see cref="PropertyDescriptor"/></param>
        /// <param name="index">The index to use.</param>
        public StopConditionCollectionPropertyDescriptor(StopConditionCollection collection, int index)
            : base("#" + index.ToString(), null)
        {
            this.collection = collection;
            this.index      = index;
        }
    ///////////////////////////////////////////////////////////////////////////////
    // Construction and Initializing methods                                     //
    ///////////////////////////////////////////////////////////////////////////////
    #region CONSTRUCTION

    /// <summary>
    /// Initializes a new instance of the StopConditionCollectionPropertyDescriptor class.
    /// </summary>
    /// <param name="collection">The <see cref="StopConditionCollection"/>
    /// for this <see cref="PropertyDescriptor"/></param>
    /// <param name="index">The index to use.</param>
    public StopConditionCollectionPropertyDescriptor(StopConditionCollection collection, int index)
      : base("#" + index.ToString(), null)
    {
      this.collection = collection;
      this.index = index;
    }