Example #1
0
 /// <summary>
 /// Initializes a new instance of the VGRectangle class.
 /// Clone Constructor. Creates new rectangle that is
 /// identical to the given <see cref="VGRectangle"/>
 /// </summary>
 /// <param name="newBounds">Rectangle to clone</param>
 private VGRectangle(VGRectangle newBounds)
     : base(
         newBounds.ShapeDrawAction,
         newBounds.Pen,
         newBounds.Brush,
         newBounds.Font,
         newBounds.FontColor,
         newBounds.Bounds,
         newBounds.StyleGroup,
         newBounds.Name,
         newBounds.ElementGroup,
         newBounds.Sound)
 {
 }
Example #2
0
    /// <summary>
    /// Loads the shapes that are listed in the given database table
    ///   and creates corresponding graphic elements.
    /// </summary>
    /// <param name="areaOfInterestTableRows">
    /// Areas of interest table as
    ///   a <see cref="DataGridViewRowCollection"/>
    /// </param>
    public void LoadShapesFromDataGridView(DataGridViewRowCollection areaOfInterestTableRows)
    {
      try
      {
        // Create aoi elements from data view
        this.AoiCollection = new VGElementCollection();

        foreach (DataGridViewRow row in areaOfInterestTableRows)
        {
          if (!row.IsNewRow)
          {
            // retrieve shape parameters from cell values.
            var shapeName = row.Cells["colShapeName"].Value.ToString();
            var strPtList = row.Cells["colShapePts"].Value.ToString();
            Pen usedPen;
            Font usedFont;
            Color usedFontColor;
            VGAlignment usedAlignment;
            VGStyleGroup usedStyleGroup;
            var pointList = ObjectStringConverter.StringToPointFList(strPtList);
            var usedElementGroup = row.Cells["colShapeGroup"].Value.ToString();
            switch (usedElementGroup)
            {
              case "Target":
                usedPen = this.TargetPen;
                usedFont = this.TargetFont;
                usedFontColor = this.TargetFontColor;
                usedStyleGroup = VGStyleGroup.AOI_TARGET;
                usedAlignment = this.TargetTextAlignment;
                break;
              case "SearchRect":
                usedPen = this.SearchRectPen;
                usedFont = this.SearchRectFont;
                usedFontColor = this.SearchRectFontColor;
                usedStyleGroup = VGStyleGroup.AOI_SEARCHRECT;
                usedAlignment = this.SearchRectTextAlignment;
                break;
              default:
                usedPen = this.DefaultPen;
                usedFont = this.DefaultFonts;
                usedFontColor = this.DefaultFontColor;
                usedStyleGroup = VGStyleGroup.AOI_NORMAL;
                usedAlignment = this.DefaultTextAlignment;
                break;
            }

            // Create the shape depending on ShapeType
            var boundingRect = new RectangleF();
            switch (row.Cells["colShapeType"].Value.ToString())
            {
              case "Rectangle":
                boundingRect.Location = pointList[0];
                boundingRect.Width = pointList[2].X - pointList[0].X;
                boundingRect.Height = pointList[2].Y - pointList[0].Y;

                // Create Rect with defined stroke
                var newRect =
                  new VGRectangle(
                    this.hideAOIDescription ? ShapeDrawAction.Edge : ShapeDrawAction.NameAndEdge, 
                    usedPen, 
                    usedFont, 
                    usedFontColor, 
                    boundingRect, 
                    usedStyleGroup, 
                    shapeName, 
                    usedElementGroup);
                newRect.TextAlignment = usedAlignment;
                this.AoiCollection.Add(newRect);
                break;
              case "Ellipse":
                boundingRect.Location = pointList[0];
                boundingRect.Width = pointList[2].X - pointList[0].X;
                boundingRect.Height = pointList[2].Y - pointList[0].Y;

                // Create Rect with defined stroke
                var newEllipse =
                  new VGEllipse(
                    this.hideAOIDescription ? ShapeDrawAction.Edge : ShapeDrawAction.NameAndEdge, 
                    usedPen, 
                    usedFont, 
                    usedFontColor, 
                    boundingRect, 
                    usedStyleGroup, 
                    shapeName, 
                    usedElementGroup);
                newEllipse.TextAlignment = usedAlignment;
                this.AoiCollection.Add(newEllipse);
                break;
              case "Polyline":

                // Create Polyline with defined stroke
                var newPolyline =
                  new VGPolyline(
                    this.hideAOIDescription ? ShapeDrawAction.Edge : ShapeDrawAction.NameAndEdge, 
                    usedPen, 
                    usedFont, 
                    usedFontColor, 
                    usedStyleGroup, 
                    shapeName, 
                    usedElementGroup);
                newPolyline.TextAlignment = usedAlignment;
                foreach (var point in pointList)
                {
                  newPolyline.AddPt(point);
                }

                newPolyline.ClosePolyline();
                this.AoiCollection.Add(newPolyline);
                break;
            }
          }
        }

        // Reset Elements (deselect and clear all)
        this.ResetPicture();

        this.Elements.AddRange(this.AoiCollection);

        // If there were a selected element before updating, try
        // to select it again.
        if (this.SelectedElement != null)
        {
          foreach (VGElement element in this.Elements)
          {
            if (VGPolyline.Distance(element.Location, this.SelectedElement.Location) < 1)
            {
              this.SelectedElement = element;
              element.IsInEditMode = true;
            }
          }
        }

        this.DrawForeground(true);
      }
      catch (Exception ex)
      {
        ExceptionMethods.HandleException(ex);
      }
    }
Example #3
0
    /// <summary>
    /// This method creates a rectangular grid of AOI named from
    ///   A-Z or Aa to Zz depending on grid size.
    ///   The given <see cref="DataGridView"/> supplies the names
    ///   and the number of rows and columns.
    /// </summary>
    /// <param name="dataGridView">
    /// A <see cref="DataGridView"/>
    ///   with the named rows and columns for the new rectangular AOI grid.
    /// </param>
    public void CreateAOIGrid(DataGridView dataGridView)
    {
      try
      {
        // Calculate grid sizes
        var numRows = dataGridView.Rows.Count;
        var numColumns = dataGridView.Columns.Count;
        var cellHeight = (float)Document.ActiveDocument.PresentationSize.Height / numRows;
        var cellWidth = (float)Document.ActiveDocument.PresentationSize.Width / numColumns;

        // Iterate through data grid view and creat for each cell a rectangular AOI
        for (var i = 0; i < numRows; i++)
        {
          for (var j = 0; j < numColumns; j++)
          {
            // Calculate grid cell bounds.
            var boundingRect = new RectangleF();
            boundingRect.Y = i * cellHeight;
            boundingRect.X = j * cellWidth;
            boundingRect.Width = cellWidth;
            boundingRect.Height = cellHeight;

            // Create Rect with default stroke
            var newRect = new VGRectangle(
              this.hideAOIDescription ? ShapeDrawAction.Edge : ShapeDrawAction.NameAndEdge, 
              this.DefaultPen, 
              this.DefaultFonts, 
              this.DefaultFontColor, 
              boundingRect, 
              VGStyleGroup.AOI_NORMAL, 
              dataGridView.Rows[i].Cells[j].Value.ToString(), 
              string.Empty);
            newRect.TextAlignment = this.DefaultTextAlignment;
            this.AoiCollection.Add(newRect);

            // Raise event
            base.OnShapeAdded(new ShapeEventArgs(newRect));
          }
        }

        this.DrawForeground(true);
      }
      catch (Exception ex)
      {
        ExceptionMethods.HandleException(ex);
      }
    }
Example #4
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;
    }
Example #5
0
    /// <summary>
    /// Drawing initialization. Add elements referring to current drawing modes.
    /// </summary>
    /// <returns><strong>True</strong> if mouse or gaze data is available.</returns>
    public bool InitDrawingElements()
    {
      if (this.replayTable != null && this.replayTable.Rows.Count > 0)
      {
        // Determine StartTime to Initialize Progress detection
        var firstRow = this.replayTable.Rows[0];
        var trialStartTimeInMS = !firstRow.IsNull(3) ? Convert.ToInt64(firstRow[3]) : 0;
        var processBeginningTime = DateTime.Now;

        var gazeDataAvailable = false;
        var mouseDataAvailable = false;

        // Check for first valid eye and mouse sample
        PointF? test;
        for (var i = 0; i < this.replayTable.Rows.Count; i++)
        {
          if (!gazeDataAvailable)
          {
            if (this.CheckSamples(this.replayTable.Rows[i], SampleType.Gaze, out test))
            {
              gazeDataAvailable = true;
              if (mouseDataAvailable)
              {
                break;
              }
            }
          }

          if (!mouseDataAvailable)
          {
            if (this.CheckSamples(this.replayTable.Rows[i], SampleType.Mouse, out test))
            {
              mouseDataAvailable = true;
              if (gazeDataAvailable)
              {
                break;
              }
            }
          }
        }

        var parent = (FormWithPicture)this.OwningForm;
        if (parent.MdiParent != null)
        {
          if (!gazeDataAvailable && !mouseDataAvailable)
          {
            ((MainForm)parent.MdiParent).StatusRightLabel.Text = "No gaze or mouse data available for this trial.";
            return false;
          }
          else if (!gazeDataAvailable)
          {
            ((MainForm)parent.MdiParent).StatusRightLabel.Text = "No gaze data available for this trial.";
          }
          else if (!mouseDataAvailable)
          {
            ((MainForm)parent.MdiParent).StatusRightLabel.Text = "No mouse data available for this trial.";
          }
        }

        // Init currentLoopState
        this.currentLoopState.IsBlink = false;
        this.currentLoopState.GazeLastFixCenter.X = 0;
        this.currentLoopState.GazeLastFixCenter.Y = 0;
        this.currentLoopState.MouseLastFixCenter.X = 0;
        this.currentLoopState.MouseLastFixCenter.Y = 0;
        this.currentLoopState.IsOutOfMonitor = false;
        this.currentLoopState.RowCounter = 0;
        this.currentLoopState.TrialStartTimeInMS = trialStartTimeInMS;
        this.currentLoopState.ProcessBeginningTime = processBeginningTime;

        // Reset Cursor and Spotlight positions
        this.gazeCursor.Center = new PointF(-500, 0);
        this.gazePicEllipse.Center = new PointF(-500, 0);
        this.gazeFixEllipse.Center = new PointF(-500, 0);
        this.mouseCursor.Center = new PointF(-500, 0);
        this.mousePicEllipse.Center = new PointF(-500, 0);
        this.mouseFixEllipse.Center = new PointF(-500, 0);

        // Remove all old elements from drawing list.
        this.Elements.Clear();

        // At first ad Spotlights, because they have to be at top of background
        // and lines and circles on top of them.
        if (gazeDataAvailable && (this.gazeDrawingMode & ReplayDrawingModes.Spotlight) == ReplayDrawingModes.Spotlight)
        {
          // Add Spotlight Element: Ellipse with OriginalImageBrush
          this.Elements.Add(this.gazePicEllipse);
        }

        if (mouseDataAvailable && (this.mouseDrawingMode & ReplayDrawingModes.Spotlight) == ReplayDrawingModes.Spotlight)
        {
          // Add Spotlight Element: Ellipse with OriginalImageBrush
          this.Elements.Add(this.mousePicEllipse);
        }

        if (gazeDataAvailable && (this.gazeDrawingMode & ReplayDrawingModes.Path) == ReplayDrawingModes.Path)
        {
          // Add GazePolyline Element
          this.Elements.Add(this.gazeRawPolyline);
        }

        if (mouseDataAvailable && (this.mouseDrawingMode & ReplayDrawingModes.Path) == ReplayDrawingModes.Path)
        {
          // Add GazePolyline Element
          this.Elements.Add(this.mouseRawPolyline);
        }

        if (gazeDataAvailable && (this.gazeDrawingMode & ReplayDrawingModes.FixationConnections) == ReplayDrawingModes.FixationConnections)
        {
          this.objFixGazeDetection.InitFixation(this.gazeMinSamples);

          // Add FixGazePolyline Element
          this.Elements.Add(this.gazeFixConPolyline);
          this.Elements.Add(this.gazeFixConLine);
        }

        if (mouseDataAvailable && (this.mouseDrawingMode & ReplayDrawingModes.FixationConnections) == ReplayDrawingModes.FixationConnections)
        {
          this.objFixMouseDetection.InitFixation(this.mouseMinSamples);

          // Add FixGazePolyline Element
          this.Elements.Add(this.mouseFixConPolyline);
          this.Elements.Add(this.mouseFixConLine);
        }

        if (gazeDataAvailable && (this.gazeDrawingMode & ReplayDrawingModes.Fixations) == ReplayDrawingModes.Fixations)
        {
          this.objFixGazeDetection.InitFixation(this.gazeMinSamples);

          // Add FixationEllipse Element
          this.Elements.Add(this.gazeFixEllipse);
        }

        if (mouseDataAvailable && (this.mouseDrawingMode & ReplayDrawingModes.Fixations) == ReplayDrawingModes.Fixations)
        {
          this.objFixMouseDetection.InitFixation(this.mouseMinSamples);

          // Add FixationEllipse Element
          this.Elements.Add(this.mouseFixEllipse);
        }

        if (gazeDataAvailable && (this.gazeDrawingMode & ReplayDrawingModes.Cursor) == ReplayDrawingModes.Cursor)
        {
          // Add FixationEllipse Element
          this.Elements.Add(this.gazeCursor);
        }

        if (mouseDataAvailable && (this.mouseDrawingMode & ReplayDrawingModes.Cursor) == ReplayDrawingModes.Cursor)
        {
          // Add FixationEllipse Element
          this.Elements.Add(this.mouseCursor);
        }

        // Init VG Elements referring to DrawingModes
        var customColor = Color.FromArgb(200, Color.Black);
        var shadowBrush = new SolidBrush(customColor);
        this.rectBlink = new VGRectangle(
          ShapeDrawAction.Fill, 
          shadowBrush, 
          new RectangleF(0, 0, Document.ActiveDocument.ExperimentSettings.WidthStimulusScreen, Document.ActiveDocument.ExperimentSettings.HeightStimulusScreen));
        this.rectBlink.Visible = false;

        this.Elements.Add(this.rectBlink);

        // Readd the visible bounds rectangle
        this.Elements.Add(this.visiblePartOfScreen);

        this.DrawForeground(true);

        return true;
      }
      else
      {
        InformationDialog.Show(
          "Please note", 
          "No gaze or mouse data available for these settings", 
          false, 
          MessageBoxIcon.Warning);
        return false;
      }
    }
Example #6
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);
      }
    }
Example #7
0
    /// <summary>
    /// This method returns an default colored <see cref="VGElement"/>
    /// that represents the object in the database described by the three parameters
    /// </summary>
    /// <param name="shapeType">A <see cref="String"/> with the shape type Rectangle, Ellipse or Polyline</param>
    /// <param name="shapeName">A <see cref="String"/> with the shape name</param>
    /// <param name="shapeGroup">A <see cref="String"/> with the shapes group</param>
    /// <param name="strPtList">A <see cref="String"/> with the list of points to be converted
    /// with <see cref="ObjectStringConverter.StringToPointFList(String)"/></param>
    /// <returns>A <see cref="VGElement"/> that represents the object in the database described by the three parameters.</returns>
    public static VGElement GetVGElementFromDatabase(
      string shapeType,
      string shapeName,
      string shapeGroup,
      string strPtList)
    {
      // Create the shape depending on ShapeType
      RectangleF boundingRect = new RectangleF();
      List<PointF> pointList = ObjectStringConverter.StringToPointFList(strPtList);

      switch (shapeType)
      {
        case "Rectangle":
          boundingRect.Location = pointList[0];
          boundingRect.Width = pointList[2].X - pointList[0].X;
          boundingRect.Height = pointList[2].Y - pointList[0].Y;

          // Create Rect with defined stroke
          VGRectangle newRect = new VGRectangle(
            ShapeDrawAction.NameAndEdge,
            Pens.Red,
            SystemFonts.MenuFont,
            Color.Black,
            boundingRect,
            VGStyleGroup.None,
            shapeName,
            shapeGroup);
          newRect.TextAlignment = VGAlignment.Center;
          return newRect;
        case "Ellipse":
          boundingRect.Location = pointList[0];
          boundingRect.Width = pointList[2].X - pointList[0].X;
          boundingRect.Height = pointList[2].Y - pointList[0].Y;

          // Create Rect with defined stroke
          VGEllipse newEllipse = new VGEllipse(
            ShapeDrawAction.NameAndEdge,
            Pens.Red,
            SystemFonts.MenuFont,
            Color.Black,
            boundingRect,
            VGStyleGroup.None,
            shapeName,
            shapeGroup);
          newEllipse.TextAlignment = VGAlignment.Center;
          return newEllipse;
        case "Polyline":
          // Create Polyline with defined stroke
          VGPolyline newPolyline = new VGPolyline(
            ShapeDrawAction.NameAndEdge,
            Pens.Red,
            SystemFonts.MenuFont,
            Color.Black,
            VGStyleGroup.None,
            shapeName,
            shapeGroup);
          newPolyline.TextAlignment = VGAlignment.Center;
          foreach (PointF point in pointList)
          {
            newPolyline.AddPt(point);
          }

          newPolyline.ClosePolyline();
          boundingRect = newPolyline.Bounds;
          return newPolyline;
      }

      return null;
    }
Example #8
0
    /// <summary>
    /// This method converts the AOI table with areas of interest from the database
    /// into a list of <see cref="VGElement"/>s.
    /// </summary>
    /// <param name="aoiTable">The <see cref="DataTable"/> with the AOIs.</param>
    /// <returns>A <see cref="List{VGElement}"/> with the shapes.</returns>
    protected virtual VGElementCollection GetAOIElements(DataTable aoiTable)
    {
      Pen defaultPen = new Pen(Properties.Settings.Default.AOIStandardColor, Properties.Settings.Default.AOIStandardWidth);
      Pen targetPen = new Pen(Properties.Settings.Default.AOITargetColor, Properties.Settings.Default.AOITargetWidth);
      Pen searchRectPen = new Pen(Properties.Settings.Default.AOISearchRectColor, Properties.Settings.Default.AOISearchRectWidth);
      Font defaultFont = (Font)Properties.Settings.Default.AOIStandardFont.Clone();
      Font targetFont = (Font)Properties.Settings.Default.AOITargetFont.Clone();
      Font searchRectFont = (Font)Properties.Settings.Default.AOISearchRectFont.Clone();
      Color defaultFontColor = Properties.Settings.Default.AOIStandardFontColor;
      Color targetFontColor = Properties.Settings.Default.AOITargetFontColor;
      Color searchRectFontColor = Properties.Settings.Default.AOISearchRectFontColor;

      VGElementCollection aoiList = new VGElementCollection();
      int counter = 0;

      try
      {
        foreach (DataRow row in aoiTable.Rows)
        {
          string strPtList = row["ShapePts"].ToString();
          string shapeName = row["ShapeName"].ToString();
          Pen usedPen = defaultPen;
          Font usedFont = defaultFont;
          Color usedFontColor = defaultFontColor;
          VGStyleGroup usedStyleGroup = VGStyleGroup.AOI_NORMAL;
          List<PointF> pointList = ObjectStringConverter.StringToPointFList(strPtList);
          string usedElementGroup = row["ShapeGroup"].ToString();
          switch (usedElementGroup)
          {
            case "Target":
              usedPen = targetPen;
              usedFont = targetFont;
              usedFontColor = targetFontColor;
              usedStyleGroup = VGStyleGroup.SCA_GRID_AOI;
              break;
            case "SearchRect":
              usedPen = searchRectPen;
              usedFont = searchRectFont;
              usedFontColor = searchRectFontColor;
              usedStyleGroup = VGStyleGroup.SCA_GRID_AOI;
              break;
            default:
              usedPen = defaultPen;
              usedFont = defaultFont;
              usedFontColor = defaultFontColor;
              usedStyleGroup = VGStyleGroup.SCA_GRID_AOI;
              break;
          }

          // Create the shape depending on ShapeType
          RectangleF boundingRect = new RectangleF();
          switch (row["ShapeType"].ToString())
          {
            case "Rectangle":
              boundingRect.Location = pointList[0];
              boundingRect.Width = pointList[2].X - pointList[0].X;
              boundingRect.Height = pointList[2].Y - pointList[0].Y;

              // Create Rect with defined stroke
              VGRectangle newRect = new VGRectangle(
                ShapeDrawAction.NameAndEdge,
                usedPen,
                usedFont,
                usedFontColor,
                boundingRect,
                usedStyleGroup,
                shapeName,
                usedElementGroup);

              aoiList.Add(newRect);
              break;
            case "Ellipse":
              boundingRect.Location = pointList[0];
              boundingRect.Width = pointList[2].X - pointList[0].X;
              boundingRect.Height = pointList[2].Y - pointList[0].Y;

              // Create Rect with defined stroke
              VGEllipse newEllipse = new VGEllipse(
                ShapeDrawAction.NameAndEdge,
                usedPen,
                usedFont,
                usedFontColor,
                boundingRect,
                usedStyleGroup,
                shapeName,
                usedElementGroup);

              aoiList.Add(newEllipse);
              break;
            case "Polyline":
              // Create Polyline with defined stroke
              VGPolyline newPolyline = new VGPolyline(
                ShapeDrawAction.NameAndEdge,
                usedPen,
                usedFont,
                usedFontColor,
                usedStyleGroup,
                shapeName,
                usedElementGroup);

              foreach (PointF point in pointList)
              {
                newPolyline.AddPt(point);
              }

              newPolyline.ClosePolyline();
              aoiList.Add(newPolyline);
              boundingRect = newPolyline.Bounds;
              break;
          }

          counter++;
        }
      }
      catch (Exception ex)
      {
        ExceptionMethods.HandleException(ex);
      }

      return aoiList;
    }
Example #9
0
    /// <summary>
    /// This method draws a rectangular grid with gridFactor divided length.
    /// </summary>
    private void DrawRectangularGrid()
    {
      int widthData = Document.ActiveDocument.ExperimentSettings.WidthStimulusScreen;
      int heightData = Document.ActiveDocument.ExperimentSettings.HeightStimulusScreen;

      float xDistance = (widthData - 2) / (float)this.gridFactor;
      float yDistance = (heightData - 2) / (float)this.gridFactor;

      // For each row
      for (int i = 0; i < this.gridFactor; i++)
      {
        // For each column
        for (int j = 0; j < this.gridFactor; j++)
        {
          // Create a rectangle with a new string index
          RectangleF bounds = new RectangleF(j * xDistance, i * yDistance, xDistance, yDistance);
          VGRectangle rect = new VGRectangle(
            ShapeDrawAction.NameAndEdge,
            new Pen(Color.Gray, 1.0f),
            new Font(VGRectangle.DefaultFont.FontFamily, 14.0f),
            Color.Gray,
            bounds,
            VGStyleGroup.SCA_GRID_RECTANGLE,
            currentIdentifierList[i * this.gridFactor + j],
            string.Empty);

          this.Elements.Add(rect);
        }
      }
    }
Example #10
0
 /// <summary>
 /// Initializes a new instance of the VGRectangle class.
 /// Clone Constructor. Creates new rectangle that is
 /// identical to the given <see cref="VGRectangle"/>
 /// </summary>
 /// <param name="newBounds">Rectangle to clone</param>
 private VGRectangle(VGRectangle newBounds)
   : base(
   newBounds.ShapeDrawAction,
   newBounds.Pen,
   newBounds.Brush,
   newBounds.Font,
   newBounds.FontColor,
   newBounds.Bounds,
   newBounds.StyleGroup,
   newBounds.Name,
   newBounds.ElementGroup,
   newBounds.Sound)
 {
 }