Beispiel #1
0
 /// <summary>
 /// Initializes a new instance of the VGLine class.
 /// Clone Constructor. Creates new line that is
 /// identical to the given line.
 /// </summary>
 /// <param name="line">Line to clone</param>
 private VGLine(VGLine line)
     : base(
         line.ShapeDrawAction,
         line.Pen,
         line.Brush,
         line.Font,
         line.FontColor,
         line.Bounds,
         line.StyleGroup,
         line.Name,
         line.ElementGroup,
         line.Sound)
 {
     this.firstPoint   = line.firstPoint;
     this.secondPoint  = line.secondPoint;
     this.pointsAreSet = true;
 }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the VGLine class.
 /// Clone Constructor. Creates new line that is
 /// identical to the given line.
 /// </summary>
 /// <param name="line">Line to clone</param>
 private VGLine(VGLine line)
   : base(
   line.ShapeDrawAction,
   line.Pen,
   line.Brush,
   line.Font,
   line.FontColor,
   line.Bounds,
   line.StyleGroup,
   line.Name,
   line.ElementGroup,
   line.Sound)
 {
   this.firstPoint = line.firstPoint;
   this.secondPoint = line.secondPoint;
   this.pointsAreSet = true;
 }
Beispiel #3
0
    ///////////////////////////////////////////////////////////////////////////////
    // Eventhandler for Custom Defined Events                                    //
    ///////////////////////////////////////////////////////////////////////////////
    #region CUSTOMEVENTHANDLER
    #endregion //CUSTOMEVENTHANDLER

    #endregion //EVENTS

    ///////////////////////////////////////////////////////////////////////////////
    // Methods and Eventhandling for Background tasks                            //
    ///////////////////////////////////////////////////////////////////////////////
    #region BACKGROUNDWORKER
    #endregion //BACKGROUNDWORKER

    ///////////////////////////////////////////////////////////////////////////////
    // Inherited methods                                                         //
    ///////////////////////////////////////////////////////////////////////////////
    #region OVERRIDES
    #endregion //OVERRIDES

    ///////////////////////////////////////////////////////////////////////////////
    // Methods for doing main class job                                          //
    ///////////////////////////////////////////////////////////////////////////////
    #region METHODS

    /// <summary>
    /// This method creates the shape that is defined in this dialog to be added to a slide.
    /// </summary>
    /// <returns>The ready to use <see cref="VGElement"/>.</returns>
    private VGElement GenerateNewShape()
    {
      VGElement element = null;
      if (this.rdbRectangle.Checked)
      {
        element = new VGRectangle(
          this.pbcStyle.DrawAction,
          this.pbcStyle.NewPen,
          this.pbcStyle.NewBrush,
          this.pbcStyle.NewFont, 
          this.pbcStyle.NewFontColor,
          new RectangleF(0, 0, 100, 100), 
          VGStyleGroup.None,
          this.pbcStyle.NewName,
          string.Empty);
      }
      else if (this.rdbEllipse.Checked)
      {
        element = new VGEllipse(
          this.pbcStyle.DrawAction,
          this.pbcStyle.NewPen,
          this.pbcStyle.NewBrush, 
          this.pbcStyle.NewFont, 
          this.pbcStyle.NewFontColor,
          new RectangleF(0, 0, 100, 100),
          VGStyleGroup.None, 
          this.pbcStyle.NewName,
          string.Empty);
      }
      else if (this.rdbPolyline.Checked)
      {
        element = new VGPolyline(
          this.pbcStyle.DrawAction,
          this.pbcStyle.NewPen,
          this.pbcStyle.NewBrush,
          this.pbcStyle.NewFont,
          this.pbcStyle.NewFontColor, 
          VGStyleGroup.None,
          this.pbcStyle.NewName,
          string.Empty);
      }
      else if (this.rdbSharp.Checked)
      {
        element = new VGSharp(
          this.pbcStyle.DrawAction,
          this.pbcStyle.NewPen, 
          this.pbcStyle.NewFont, 
          this.pbcStyle.NewFontColor,
          new RectangleF(0, 0, 100, 100), 
          VGStyleGroup.None,
          this.pbcStyle.NewName,
          string.Empty);
      }
      else if (this.rdbLine.Checked)
      {
        element = new VGLine(
          this.pbcStyle.DrawAction,
          this.pbcStyle.NewPen, 
          this.pbcStyle.NewFont, 
          this.pbcStyle.NewFontColor,
          VGStyleGroup.None, 
          this.pbcStyle.NewName,
          string.Empty);
      }

      element.Sound = this.audioControl.Sound;

      return element;
    }
Beispiel #4
0
 /// <summary>
 /// Moves coordinates of last point in line to new position.
 /// If this line has no first point, first add this.
 /// </summary>
 /// <param name="line">
 /// A <see cref="VGLine"/> to modify
 /// </param>
 /// <param name="currPt">
 /// The <see cref="PointF"/> with the new last point.
 /// </param>
 /// <param name="time">
 /// The <see cref="Int64"/> with the points time.
 /// </param>
 private void UpdateLastPtInLine(VGLine line, PointF currPt, long time)
 {
   if (line.FirstPoint.IsEmpty)
   {
     line.FirstPoint = currPt;
     line.OnsetTime = time;
   }
   else
   {
     line.SecondPoint = currPt;
     line.EndTime = time;
   }
 }
Beispiel #5
0
    ///////////////////////////////////////////////////////////////////////////////
    // Small helping Methods                                                     //
    ///////////////////////////////////////////////////////////////////////////////
    #region HELPER

    /// <summary>
    /// This method changes the first point of the <see cref="VGLine"/>
    /// object that holds the current moving point.
    /// </summary>
    /// <param name="line">
    /// The <see cref="VGLine"/> with the line to modify
    /// </param>
    /// <param name="currPt">
    /// The <see cref="PointF"/> with the new first point.
    /// </param>
    /// <param name="time">
    /// The <see cref="Int64"/> with the points time.
    /// </param>
    private void UpdateFirstPtInLine(VGLine line, PointF currPt, long time)
    {
      line.FirstPoint = currPt;
      line.OnsetTime = time;
    }
Beispiel #6
0
    /// <summary>
    /// Draws fixations and fixation connections.
    /// Updates fixation objects and calculates fixation parameters.
    /// </summary>
    /// <param name="pointTime">
    /// The time estimation of the new point.
    /// </param>
    /// <param name="newPt">
    /// A <see cref="PointF"/> with the new sampling data.
    /// </param>
    /// <param name="toDraw">
    /// The <see cref="SampleType"/> to draw.
    /// </param>
    /// <param name="lastPointInSampleRange">
    /// A <see cref="Boolean"/>
    /// indicating whether this sample is the last one in the range of
    /// the current update, so this is to update the current fixations diameter.
    /// </param>
    private void DrawFixations(
      long pointTime, 
      PointF newPt, 
      SampleType toDraw, 
      bool lastPointInSampleRange)
    {
      bool point_found_delayed;
      float x_delayed;
      float y_delayed;
      float deviation_delayed;
      float x_fix_delayed;
      float y_fix_delayed;
      int saccade_duration_delayed;
      long fix_start_time;
      int fix_duration_delayed_samples;
      long fix_duration_delayed_milliseconds;

      VGPolyline usedPolyline;
      VGLine usedLine;
      VGEllipse usedEllipse;
      Pen usedFixationPen;
      PointF usedFixCenterPt;
      var usedBoundingRect = new RectangleF();
      VGStyleGroup usedGroup;
      EyeMotionState currentState;
      float divisor;
      switch (toDraw)
      {
        case SampleType.Gaze:
        default:
          currentState = this.objFixGazeDetection.DetectFixation(
            newPt.IsEmpty ? false : true, 
            pointTime, 
            newPt.X, 
            newPt.Y, 
             this.gazeMaxDistance, 
             this.gazeMinSamples, 
            out point_found_delayed, 
            out x_delayed, 
            out y_delayed, 
            out deviation_delayed, 
            out x_fix_delayed, 
            out y_fix_delayed, 
            out saccade_duration_delayed, 
            out fix_start_time, 
            out fix_duration_delayed_milliseconds, 
            out fix_duration_delayed_samples);
          usedPolyline = this.gazeFixConPolyline;
          usedLine = this.gazeFixConLine;
          usedEllipse = this.gazeFixEllipse;
          usedFixationPen = this.penGazeFixation;
          usedFixCenterPt = this.currentLoopState.GazeLastFixCenter;
          usedGroup = VGStyleGroup.RPL_PEN_GAZE_FIX;
          divisor = this.gazeFixDiameterDiv;
          break;
        case SampleType.Mouse:
          currentState = this.objFixMouseDetection.DetectFixation(
            newPt.IsEmpty ? false : true, 
            pointTime, 
            newPt.X, 
            newPt.Y, 
             this.mouseMaxDistance, 
             this.mouseMinSamples, 
            out point_found_delayed, 
            out x_delayed, 
            out y_delayed, 
            out deviation_delayed, 
            out x_fix_delayed, 
            out y_fix_delayed, 
            out saccade_duration_delayed, 
            out fix_start_time, 
            out fix_duration_delayed_milliseconds, 
            out fix_duration_delayed_samples);
          usedPolyline = this.mouseFixConPolyline;
          usedLine = this.mouseFixConLine;
          usedEllipse = this.mouseFixEllipse;
          usedFixationPen = this.penMouseFixation;
          usedFixCenterPt = this.currentLoopState.MouseLastFixCenter;
          usedGroup = VGStyleGroup.RPL_PEN_MOUSE_FIX;
          divisor = this.mouseFixDiameterDiv;
          break;
      }

      // Calculate Bounding Rectangle
      var fixationDiameter = Convert.ToSingle(fix_duration_delayed_samples) / divisor;
      usedBoundingRect.X = x_fix_delayed - fixationDiameter;
      usedBoundingRect.Y = y_fix_delayed - fixationDiameter;
      usedBoundingRect.Width = fixationDiameter * 2;
      usedBoundingRect.Height = fixationDiameter * 2;

      var fixationCenter = new PointF(x_fix_delayed, y_fix_delayed);

      switch (currentState)
      {
        case EyeMotionState.MOVING:
          if (!Queries.OutOfScreen(newPt, this.StimulusSize))
          {
            if (lastPointInSampleRange)
            {
              this.UpdateLastPtInLine(usedLine, newPt, pointTime);
            }
          }
          else
          {
            this.currentLoopState.IsOutOfMonitor = true;
          }

          this.onsetTime = pointTime;
          break;

        case EyeMotionState.FIXATING:
          if (lastPointInSampleRange)
          {
            usedEllipse.Bounds = usedBoundingRect;
            this.UpdateLastPtInLine(usedLine, fixationCenter, pointTime);
          }

          break;

        case EyeMotionState.FIXATION_COMPLETED:
          if (!Queries.OutOfScreen(fixationCenter, this.StimulusSize))
          {
            if (this.currentLoopState.IsOutOfMonitor)
            {
              this.currentLoopState.IsOutOfMonitor = false;
              var dottedLine = new VGLine(ShapeDrawAction.Edge, this.penGazeNoData, VGStyleGroup.RPL_PEN_GAZE_NODATA, string.Empty, string.Empty);
              dottedLine.FirstPoint = usedFixCenterPt;
              dottedLine.SecondPoint = fixationCenter;
              dottedLine.OnsetTime = pointTime;
              dottedLine.EndTime = pointTime;
              switch (toDraw)
              {
                case SampleType.Gaze:
                  if (((this.gazeDrawingMode & ReplayDrawingModes.FixationConnections) == ReplayDrawingModes.FixationConnections) &&
                      (!this.isGazeDiscreteLength))
                  {
                    this.Elements.Add(dottedLine);
                  }

                  break;
                case SampleType.Mouse:
                  if (((this.mouseDrawingMode & ReplayDrawingModes.FixationConnections) == ReplayDrawingModes.FixationConnections) &&
                      (!this.isMouseDiscreteLength))
                  {
                    this.Elements.Add(dottedLine);
                  }

                  break;
              }
            }

            var ellipse2 = new VGEllipse(
              ShapeDrawAction.Edge, 
              usedFixationPen, 
              usedBoundingRect, 
              usedGroup, 
              string.Empty, 
              string.Empty);
            ellipse2.OnsetTime = this.onsetTime;
            ellipse2.EndTime = pointTime;

            switch (toDraw)
            {
              default:
              case SampleType.Gaze:
                this.UpdateFirstPtInLine(usedLine, fixationCenter, pointTime);
                this.AddPtToPolyline(usedPolyline, fixationCenter, this.isGazeDiscreteLength, pointTime);
                this.currentLoopState.GazeLastFixCenter = fixationCenter;

                this.gazeFixations.Add(ellipse2);

                // Switch to fixed length if choosen
                if (this.isGazeDiscreteLength && (this.gazeFixations.Count >= this.numFixToShow))
                {
                  this.Elements.Remove(this.gazeFixations[0]);
                  this.gazeFixations.RemoveAt(0);
                  while (usedPolyline.GetPointCount() >= this.numFixToShow)
                  {
                    usedPolyline.RemoveFirstPt();
                  }
                }

                if ((this.gazeDrawingMode & ReplayDrawingModes.Fixations) == ReplayDrawingModes.Fixations)
                {
                  Elements.Add(ellipse2);
                }

                break;
              case SampleType.Mouse:
                this.UpdateFirstPtInLine(usedLine, fixationCenter, pointTime);
                this.AddPtToPolyline(usedPolyline, fixationCenter, this.isMouseDiscreteLength, pointTime);
                this.currentLoopState.MouseLastFixCenter = fixationCenter;
                this.mouseFixations.Add(ellipse2);

                // Switch to fixed length if choosen
                if (this.isMouseDiscreteLength && (this.mouseFixations.Count >= this.numFixToShow))
                {
                  this.Elements.Remove(this.mouseFixations[0]);
                  this.mouseFixations.RemoveAt(0);
                  while (usedPolyline.GetPointCount() >= this.numFixToShow)
                  {
                    usedPolyline.RemoveFirstPt();
                  }
                }

                if ((this.mouseDrawingMode & ReplayDrawingModes.Fixations) == ReplayDrawingModes.Fixations)
                {
                  this.Elements.Add(ellipse2);
                }

                break;
            }
          }
          else
          {
            this.currentLoopState.IsOutOfMonitor = true;
          }

          break;
        case EyeMotionState.ERROR:
          break;
        default:
          break;
      }
    }
Beispiel #7
0
    /// <summary>
    /// Initializes standard values of drawing elements
    /// </summary>
    private void InitializeElements()
    {
      try
      {
        this.penGazeCursor = new Pen(Properties.Settings.Default.GazeCursorColor, Properties.Settings.Default.GazeCursorWidth);
        this.penGazeCursor.DashStyle = Properties.Settings.Default.GazeCursorStyle;

        this.penGazePath = new Pen(Properties.Settings.Default.GazePathColor, Properties.Settings.Default.GazePathWidth);
        this.penGazePath.DashStyle = Properties.Settings.Default.GazePathStyle;
        this.penGazePath.LineJoin = LineJoin.Round;

        this.penGazeFixation = new Pen(Properties.Settings.Default.GazeFixationsPenColor, Properties.Settings.Default.GazeFixationsPenWidth);
        this.penGazeFixation.DashStyle = Properties.Settings.Default.GazeFixationsPenStyle;

        this.penGazeFixationConnection = new Pen(Properties.Settings.Default.GazeFixationConnectionsPenColor, Properties.Settings.Default.GazeFixationConnectionsPenWidth);
        this.penGazeFixation.DashStyle = Properties.Settings.Default.GazeFixationConnectionsPenStyle;

        this.penGazeNoData = new Pen(Properties.Settings.Default.GazeNoDataColor, Properties.Settings.Default.GazeNoDataWidth);
        this.penGazeNoData.DashStyle = Properties.Settings.Default.GazeNoDataStyle;

        this.penMouseCursor = new Pen(Properties.Settings.Default.MouseCursorColor, Properties.Settings.Default.MouseCursorWidth);
        this.penMouseCursor.DashStyle = Properties.Settings.Default.MouseCursorStyle;

        this.penMousePath = new Pen(Properties.Settings.Default.MousePathColor, Properties.Settings.Default.MousePathWidth);
        this.penMousePath.DashStyle = Properties.Settings.Default.MousePathStyle;
        this.penMousePath.LineJoin = LineJoin.Round;

        this.penMouseFixation = new Pen(Properties.Settings.Default.MouseFixationsPenColor, Properties.Settings.Default.MouseFixationsPenWidth);
        this.penMouseFixation.DashStyle = Properties.Settings.Default.MouseFixationsPenStyle;

        this.penMouseFixationConnection = new Pen(Properties.Settings.Default.MouseFixationConnectionsPenColor, Properties.Settings.Default.MouseFixationConnectionsPenWidth);
        this.penMouseFixationConnection.DashStyle = Properties.Settings.Default.MouseFixationConnectionsPenStyle;

        this.gazePicEllipse = new VGEllipse(ShapeDrawAction.Fill, this.GrayBrush);
        this.gazePicEllipse.Inverted = true;
        this.gazePicEllipse.ElementGroup = "Default";
        this.mousePicEllipse = new VGEllipse(ShapeDrawAction.Fill, this.GrayBrush);
        this.mousePicEllipse.Inverted = true;
        this.mousePicEllipse.ElementGroup = "Default";

        this.gazeRawPolyline = new VGPolyline(ShapeDrawAction.Edge, this.penGazePath, VGStyleGroup.RPL_PEN_GAZE_PATH, string.Empty, string.Empty);
        this.gazeRawPolyline.ElementGroup = "Default";
        this.mouseRawPolyline = new VGPolyline(ShapeDrawAction.Edge, this.penMousePath, VGStyleGroup.RPL_PEN_MOUSE_PATH, string.Empty, string.Empty);
        this.mouseRawPolyline.ElementGroup = "Default";
        this.gazeFixEllipse = new VGEllipse(ShapeDrawAction.Edge, this.penGazeFixation, VGStyleGroup.RPL_PEN_GAZE_FIX, string.Empty, string.Empty);
        this.gazeFixEllipse.ElementGroup = "Default";
        this.mouseFixEllipse = new VGEllipse(ShapeDrawAction.Edge, this.penMouseFixation, VGStyleGroup.RPL_PEN_MOUSE_FIX, string.Empty, string.Empty);
        this.mouseFixEllipse.ElementGroup = "Default";
        this.gazeFixConPolyline = new VGPolyline(ShapeDrawAction.Edge, this.penGazeFixationConnection, VGStyleGroup.RPL_PEN_GAZE_FIXCON, string.Empty, string.Empty);
        this.gazeFixConPolyline.ElementGroup = "Default";
        this.mouseFixConPolyline = new VGPolyline(ShapeDrawAction.Edge, this.penMouseFixationConnection, VGStyleGroup.RPL_PEN_MOUSE_FIXCON, string.Empty, string.Empty);
        this.mouseFixConPolyline.ElementGroup = "Default";
        this.gazeFixConLine = new VGLine(ShapeDrawAction.Edge, this.penGazeFixationConnection, VGStyleGroup.RPL_PEN_GAZE_FIXCON, string.Empty, string.Empty);
        this.gazeFixConLine.ElementGroup = "Default";
        this.mouseFixConLine = new VGLine(ShapeDrawAction.Edge, this.penMouseFixationConnection, VGStyleGroup.RPL_PEN_MOUSE_FIXCON, string.Empty, string.Empty);
        this.mouseFixConLine.ElementGroup = "Default";

        var gazeCursorSize = (float)Properties.Settings.Default.GazeCursorSize;
        var gazeCursorType = (VGCursor.DrawingCursors)Enum.Parse(
          typeof(VGCursor.DrawingCursors), Properties.Settings.Default.GazeCursorType);
        this.gazeCursor = new VGCursor(this.penGazeCursor, gazeCursorType, gazeCursorSize, VGStyleGroup.RPL_PEN_GAZE_CURSOR);
        this.gazeCursor.ElementGroup = "Default";

        var mouseCursorSize = (float)Properties.Settings.Default.MouseCursorSize;
        var mouseCursorType = (VGCursor.DrawingCursors)Enum.Parse(
          typeof(VGCursor.DrawingCursors), Properties.Settings.Default.MouseCursorType);
        this.mouseCursor = new VGCursor(this.penMouseCursor, mouseCursorType, mouseCursorSize, VGStyleGroup.RPL_PEN_MOUSE_CURSOR);
        this.mouseCursor.ElementGroup = "Default";

        if (Document.ActiveDocument != null)
        {
          this.visiblePartOfScreen = new VGRectangle(
            ShapeDrawAction.Edge, 
            Pens.Red, 
            Document.ActiveDocument.PresentationSizeRectangle);
          this.visiblePartOfScreen.Visible = false;
        }
      }
      catch (Exception ex)
      {
        ExceptionMethods.HandleException(ex);
      }
    }
Beispiel #8
0
    /// <summary>
    /// Draw fixation circles over original image with line connections in between.
    /// </summary>
    /// <param name="sampleType">The <see cref="SampleType"/> to draw. Can be gaze or mouse.</param>
    private void DrawSamples(SampleType sampleType)
    {
      try
      {
        DataView usedFixationTable = null;
        VGStyleGroup usedGroup = VGStyleGroup.None;
        Pen usedPen = null;
        Font usedFont = null;
        Color usedFontColor = Color.Empty;
        VGLine usedConnectionLine = new VGLine(ShapeDrawAction.Edge, Pens.Red);
        FixationDrawingMode usedFixationDrawingMode = FixationDrawingMode.None;

        // Initialize variables
        bool drawLine = false;
        bool drawNumber = false;
        int eyeMonX = this.StimulusSize.Width;
        int eyeMonY = this.StimulusSize.Height;

        // Set used variables
        switch (sampleType)
        {
          case SampleType.Gaze:
            usedFixationTable = this.gazeFixationsView;
            usedGroup = VGStyleGroup.FIX_GAZE_ELEMENT;
            usedPen = this.gazeFixationsPen;
            usedFont = this.gazeFixationsFont;
            usedFontColor = this.gazeFixationsFontColor;
            usedConnectionLine.Pen = this.gazeFixationConnectionsPen;
            usedFixationDrawingMode = this.gazeDrawingMode;
            if (this.gazeConnections)
            {
              drawLine = true;
            }

            if (this.gazeNumbers)
            {
              drawNumber = true;
            }

            break;
          case SampleType.Mouse:
            usedFixationTable = this.mouseFixationsView;
            usedGroup = VGStyleGroup.FIX_MOUSE_ELEMENT;
            usedPen = this.mouseFixationsPen;
            usedFont = this.mouseFixationsFont;
            usedFontColor = this.mouseFixationsFontColor;
            usedConnectionLine.Pen = this.mouseFixationConnectionsPen;
            usedFixationDrawingMode = this.mouseDrawingMode;
            if (this.mouseConnections)
            {
              drawLine = true;
            }

            if (this.mouseNumbers)
            {
              drawNumber = true;
            }

            break;
        }

        // TextureBrush bkgBrush = null;
        // if (usedFixationDrawingMode == FixationDrawingMode.Circles)
        // {
        //  Bitmap bkg = new Bitmap(eyeMonX, eyeMonY);
        //  Bitmap transparentBkg = new Bitmap(eyeMonX, eyeMonY);
        //  using (Graphics graphics = Graphics.FromImage(bkg))
        //  {
        //    ColorMatrix colorMatrix = new ColorMatrix();
        //    colorMatrix.Matrix33 = 0.7f;
        //    ImageAttributes attributes = new ImageAttributes();
        //    attributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
        //    if (this.BGSlide != null)
        //    {
        //      Slide.DrawSlideAsync(this.BGSlide, graphics);
        //    }
        //    using (Graphics transGraphics = Graphics.FromImage(transparentBkg))
        //    {
        //      transGraphics.DrawImage(bkg, new Rectangle(0, 0, bkg.Width, bkg.Height), 0, 0, bkg.Width, bkg.Height, GraphicsUnit.Pixel, attributes);
        //      bkgBrush = new TextureBrush(transparentBkg);
        //    }
        //  }
        //  bkg.Dispose();
        //  transparentBkg.Dispose();
        // }

        // Loop Fixations and draw each one
        for (int i = 0; i < usedFixationTable.Count; i++)
        {
          DataRow row = usedFixationTable[i].Row;

          // Skip samples that are out of timing section bounds
          long fixationStartTime = row.IsNull("StartTime") ? 0 : Convert.ToInt64(row["StartTime"]);

          if (fixationStartTime < this.SectionStartTime)
          {
            continue;
          }

          if (fixationStartTime > this.SectionEndTime)
          {
            break;
          }

          float x = !row.IsNull("PosX") ? Convert.ToSingle(row["PosX"]) : 0;
          float y = !row.IsNull("PosY") ? Convert.ToSingle(row["PosY"]) : 0;
          PointF newFixationLocation = new PointF(x, y);
          float factor = (int)row["Length"];

          if (drawLine && this.foregoingFixationLocation != PointF.Empty)
          {
            // Add Point to connectionline
            usedConnectionLine.FirstPoint = this.foregoingFixationLocation;
            usedConnectionLine.SecondPoint = newFixationLocation;
            this.Elements.Add((VGElement)usedConnectionLine.Clone());
          }

          this.foregoingFixationLocation = newFixationLocation;

          // Create fixation description if applicable
          string name = string.Empty;
          if (drawNumber)
          {
            name = row["CountInTrial"].ToString();
          }

          switch (usedFixationDrawingMode)
          {
            case FixationDrawingMode.None:
              if (drawNumber)
              {
                // Create Ellipse with DOTSIZEd bounding rect
                int placeHolderSize = (int)(usedFont.Size * DOTSIZE);
                RectangleF numberBoundingRect = new RectangleF(
                  x - placeHolderSize / 2,
                  y - placeHolderSize / 2,
                  placeHolderSize,
                  placeHolderSize);

                // Draw Ellipse
                VGEllipse newNameEllipse = new VGEllipse(
                  ShapeDrawAction.Name,
                  (Pen)usedPen.Clone(),
                  new SolidBrush(usedPen.Color),
                  (Font)usedFont.Clone(),
                  usedFontColor,
                  numberBoundingRect,
                  usedGroup,
                  name,
                  string.Empty);

                this.Elements.Add(newNameEllipse);
              }

              break;
            case FixationDrawingMode.Dots:
              // Create Ellipse with DOTSIZEd bounding rect
              RectangleF dotBoundingRect = new RectangleF(
                x - DOTSIZE / 2,
                y - DOTSIZE / 2,
                DOTSIZE,
                DOTSIZE);

              Font ont = (Font)usedFont.Clone();

              // Draw Ellipse
              VGEllipse newEllipse = new VGEllipse(
                ShapeDrawAction.NameAndFill,
                (Pen)usedPen.Clone(),
                new SolidBrush(usedPen.Color),
                (Font)usedFont.Clone(),
                usedFontColor,
                dotBoundingRect,
                usedGroup,
                name,
                string.Empty);

              this.Elements.Add(newEllipse);
              break;
            case FixationDrawingMode.Circles:
              RectangleF fixBoundingRect = this.GetBoundingRectFromRow(sampleType, row);
              newEllipse = new VGEllipse(
                ShapeDrawAction.NameAndEdge,
                (Pen)usedPen.Clone(),
                null,                // (TextureBrush)bkgBrush.Clone(),
                (Font)usedFont.Clone(),
                usedFontColor,
                fixBoundingRect,
                usedGroup,
                name,
                string.Empty);

              this.Elements.Add(newEllipse);
              break;
            case FixationDrawingMode.Spotlight:
              if (drawNumber)
              {
                dotBoundingRect = new RectangleF(x - DOTSIZE / 2, y - DOTSIZE / 2, DOTSIZE, DOTSIZE);
                newEllipse = new VGEllipse(
                  ShapeDrawAction.Name,
                  (Pen)usedPen.Clone(),
                  new SolidBrush(usedPen.Color),
                  (Font)usedFont.Clone(),
                  usedFontColor,
                  dotBoundingRect,
                  usedGroup,
                  name,
                  string.Empty);

                this.Elements.Add(newEllipse);
              }

              fixBoundingRect = this.GetBoundingRectFromRow(sampleType, row);
              this.spotlightRegion.AddEllipse(fixBoundingRect);
              break;
            case FixationDrawingMode.AttentionMap:
              if (drawNumber)
              {
                dotBoundingRect = new RectangleF(x - DOTSIZE / 2, y - DOTSIZE / 2, DOTSIZE, DOTSIZE);
                newEllipse = new VGEllipse(
                  ShapeDrawAction.Name,
                  (Pen)usedPen.Clone(),
                  new SolidBrush(usedPen.Color),
                  (Font)usedFont.Clone(),
                  usedFontColor,
                  dotBoundingRect,
                  usedGroup,
                  name,
                  string.Empty);

                this.Elements.Add(newEllipse);
              }

              float[,] kernelMultiplied = AttentionMaps.MultiplyKernel(factor, AttentionMaps.KernelSize);
              AttentionMaps.AddKernelToArray(
                this.distributionArray,
                (int)x,
                (int)y,
                eyeMonX,
                eyeMonY,
                AttentionMaps.KernelSize,
                kernelMultiplied);

              break;
          }
        }

        // if (bkgBrush != null)
        // {
        //  bkgBrush.Dispose();
        // }
      }
      catch (Exception ex)
      {
        ExceptionMethods.HandleException(ex);
      }
    }
Beispiel #9
0
    /// <summary>
    /// Starts new shape by setting the <see cref="VGElement"/>
    /// in the <see cref="newShape"/> field.
    /// Then calls <see cref="StartCreation(Cursor)"/>.
    /// </summary>
    /// <param name="element">The <see cref="VGElement"/> to be added to the <see cref="Picture"/></param>
    public void NewShapeStart(VGElement element)
    {
      this.newShape = element;

      if (this.newShape is VGRectangle)
      {
        this.StartCreation(CustomCursors.Rectangle);
      }
      else if (this.newShape is VGEllipse)
      {
        this.StartCreation(CustomCursors.Ellipse);
      }
      else if (this.newShape is VGPolyline)
      {
        this.currentLine = new VGLine(ShapeDrawAction.Edge, this.newShape.Pen);
        this.StartCreation(CustomCursors.Polyline);
      }
      else if (this.newShape is VGLine)
      {
        this.StartCreation(CustomCursors.Line);
      }
      else if (this.newShape is VGSound)
      {
        this.StartCreation(CustomCursors.Sound);
      }
      else if (this.newShape is VGSharp)
      {
        this.StartCreation(CustomCursors.Sharp);
      }
    }
Beispiel #10
0
    /// <summary>
    /// Starts new polylineal shape by creating a <see cref="VGPolyline"/>
    /// in the <see cref="newShape"/> field.
    /// Then calls <see cref="StartCreation(Cursor)"/>.
    /// </summary>
    /// <param name="newShapeDrawAction">The <see cref="ShapeDrawAction"/> for the
    /// new shape.</param>
    /// <param name="pen">The <see cref="Pen"/> for the new shape.</param>
    /// <param name="brush">The <see cref="Brush"/> for the new shape.</param>
    /// <param name="font">The <see cref="Font"/> for the new shape.</param>
    /// <param name="fontColor">The <see cref="Color"/> for the font of the new shape.</param>
    /// <param name="group">The <see cref="VGStyleGroup"/> for the new shape.</param>
    /// <param name="name">The optional name for the new shape.</param>
    public void NewPolylineStart(
      ShapeDrawAction newShapeDrawAction,
      Pen pen,
      Brush brush,
      Font font,
      Color fontColor,
      VGStyleGroup group,
      string name)
    {
      if (pen != null)
      {
        this.defaultPen = pen;
      }

      if (brush != null)
      {
        this.defaultBrush = brush;
      }

      if (font != null)
      {
        this.defaultFont = font;
      }

      if (fontColor != Color.Empty)
      {
        this.defaultFontColor = fontColor;
      }

      this.newShape = new VGPolyline(
        newShapeDrawAction,
        this.defaultPen,
        this.defaultBrush,
       this.defaultFont,
       this.defaultFontColor,
       group,
       name,
       string.Empty);

      this.currentLine = new VGLine(ShapeDrawAction.Edge, this.defaultPen);
      this.StartCreation(CustomCursors.Polyline);
    }