示例#1
0
    /// <summary>
    /// Overridden <see cref="PictureModifiable.ShapeAdded"/> event handler.
    ///   Adds a shape name user dialog to the shape creation process.
    /// </summary>
    /// <param name="e">
    /// The <see cref="ShapeEventArgs"/> with the new shape.
    /// </param>
    protected override void OnShapeAdded(ShapeEventArgs e)
    {
      // Show NameDialog if name is empty
      if (e.Shape.Name == string.Empty)
      {
        var newDlg = new NameShapeDlg(Document.ActiveDocument.SelectionState.TrialID);
        if (newDlg.ShowDialog() == DialogResult.OK)
        {
          // Set new shapes name
          e.Shape.Name = newDlg.ShapeName;

          // Save to aoi collection
          this.AoiCollection.Add(e.Shape);

          // Raise event
          base.OnShapeAdded(e);
        }
        else
        {
          this.Elements.Remove(e.Shape);
          this.DrawForeground(false);
        }
      }
      else
      {
        // Raise event
        base.OnShapeAdded(e);

        // Save to aoi collection
        this.AoiCollection.Add(e.Shape);
      }
    }
示例#2
0
 /// <summary>
 /// The <see cref="OgamaControls.Dialogs.PenStyleDlg.PenChanged"/> 
 /// event handler for the <see cref="OgamaControls.Dialogs.PenStyleDlg"/>.
 /// Updates picture by invoking the pictures pen changed event handler.
 /// </summary>
 /// <param name="sender">Source of the event</param>
 /// <param name="e">A <see cref="PenChangedEventArgs"/> with group and pen to switch.</param>
 private void dlgMouseCursorTyp_ShapeChanged(object sender, ShapeEventArgs e)
 {
   e.Shape.StyleGroup = VGStyleGroup.RPL_PEN_MOUSE_CURSOR;
   this.replayPicture.DrawingCursorChanged(sender, e);
 }
示例#3
0
    /// <summary>
    /// <see cref="DrawingCursorChanged"/> event handler. 
    /// Is Raised when the cursor element has changed.
    /// Updates all graphic elements from the given group
    /// with the new cursor shape.
    /// </summary>
    /// <param name="sender">
    /// Source of the event.
    /// </param>
    /// <param name="e">
    /// A <see cref="ShapeEventArgs"/> with the new cursor shape.
    /// </param>
    public void DrawingCursorChanged(object sender, ShapeEventArgs e)
    {
      switch (e.Shape.StyleGroup)
      {
        case VGStyleGroup.RPL_PEN_GAZE_CURSOR:
          e.Shape.Pen = this.penGazeCursor;
          this.gazeCursor = (VGCursor)e.Shape;
          break;
        case VGStyleGroup.RPL_PEN_MOUSE_CURSOR:
          e.Shape.Pen = this.penMouseCursor;
          this.mouseCursor = (VGCursor)e.Shape;
          break;
      }

      var sublist = this.Elements.FindAllGroupMembers(e.Shape.StyleGroup);
      if (sublist.Count == 1)
      {
        var storeCenter = sublist[0].Center;
        this.Elements.Remove(sublist[0]);
        e.Shape.Center = storeCenter;
        this.Elements.Add(e.Shape);
      }

      this.DrawForeground(true);
    }
示例#4
0
    /// <summary>
    /// <see cref="VectorGraphics.Canvas.PictureModifiable.ShapeDoubleClick"/> event handler of the
    ///   <see cref="VectorGraphics.Canvas.PictureModifiable"/> <see cref="designPicture"/>.
    ///   Calls the detailed stimuli dialogs for the clicked element.
    /// </summary>
    /// <param name="sender">
    /// Source of the event.
    /// </param>
    /// <param name="e">
    /// A <see cref="ShapeEventArgs"/> with the selected shape.
    /// </param>
    private void PicPreviewShapeDoubleClick(object sender, ShapeEventArgs e)
    {
      if (e.Shape is VGText)
      {
        var text = (VGText)e.Shape;
        var dlg = new TextDialog { NewText = text };
        if (dlg.ShowDialog() == DialogResult.OK)
        {
          VGText modifiedText = dlg.NewText;
          ((VGText)this.designPicture.SelectedElement).StringToDraw = modifiedText.StringToDraw;
          ((VGText)this.designPicture.SelectedElement).Alignment = modifiedText.Alignment;
          ((VGText)this.designPicture.SelectedElement).TextFont = modifiedText.TextFont;
          ((VGText)this.designPicture.SelectedElement).TextFontColor = modifiedText.TextFontColor;
          ((VGText)this.designPicture.SelectedElement).LineSpacing = modifiedText.LineSpacing;
          this.UpdateSelectedElementAndPropertyControl(modifiedText);
        }
      }
      else if (e.Shape is VGRichText)
      {
        var text = (VGRichText)e.Shape;
        var dlg = new RichTextDialog();
        dlg.NewRichText = text;
        if (dlg.ShowDialog() == DialogResult.OK)
        {
          VGRichText modifiedText = dlg.NewRichText;
          ((VGRichText)this.designPicture.SelectedElement).RtfToDraw = modifiedText.RtfToDraw;
          this.UpdateSelectedElementAndPropertyControl(modifiedText);
        }
      }
      else if (e.Shape is VGImage)
      {
        var image = (VGImage)e.Shape;
        var dlg = new ImageDialog();
        dlg.NewImage = image;
        if (dlg.ShowDialog() == DialogResult.OK)
        {
          VGImage modifiedImage = dlg.NewImage;
          ((VGImage)this.designPicture.SelectedElement).Filename = modifiedImage.Filename;
          ((VGImage)this.designPicture.SelectedElement).Filepath = modifiedImage.Filepath;
          ((VGImage)this.designPicture.SelectedElement).Layout = modifiedImage.Layout;
          ((VGImage)this.designPicture.SelectedElement).CreateInternalImage();
          this.UpdateSelectedElementAndPropertyControl(modifiedImage);
        }
      }
      else if (e.Shape.StyleGroup != VGStyleGroup.AOI_TARGET)
      {
        var dlg = new ShapeDialog();
        dlg.NewShape = e.Shape;
        if (dlg.ShowDialog() == DialogResult.OK)
        {
          this.UpdateSelectedElementAndPropertyControl(dlg.NewShape);
        }
      }
      else if (e.Shape.StyleGroup == VGStyleGroup.AOI_TARGET)
      {
        this.tctStandards.SelectedTab = this.tbpTargets;
      }

      this.designPicture.Invalidate();
    }
示例#5
0
 /// <summary>
 /// The <see cref="Control.Click"/> event handler for the
 /// <see cref="Button"/> <see cref="btnMouseCursorTyp"/>.
 /// Shows mouse cursor selection dialog.
 /// </summary>
 /// <param name="sender">Source of the event.</param>
 /// <param name="e">An empty <see cref="EventArgs"/></param>
 private void btnMouseCursorTyp_Click(object sender, EventArgs e)
 {
   VGCursor backupShape = this.replayPicture.MouseCursor;
   CursorStyleDlg dlgMouseCursorTyp = new CursorStyleDlg();
   dlgMouseCursorTyp.CursorStyleChanged += new EventHandler<ShapeEventArgs>(this.dlgMouseCursorTyp_ShapeChanged);
   dlgMouseCursorTyp.Text = "Set mouse cursor shape...";
   dlgMouseCursorTyp.DrawingCursor = this.replayPicture.MouseCursor;
   dlgMouseCursorTyp.Icon = Properties.Resources.RPLCursorTypIcon;
   if (dlgMouseCursorTyp.ShowDialog() == DialogResult.Cancel)
   {
     ShapeEventArgs ea = new ShapeEventArgs(backupShape);
     ea.Shape.StyleGroup = VGStyleGroup.RPL_PEN_MOUSE_CURSOR;
     this.replayPicture.DrawingCursorChanged(this, ea);
   }
 }
示例#6
0
    /// <summary>
    /// <see cref="VectorGraphics.Canvas.PictureModifiable.ShapeDeleted"/> event handler of the
    ///   <see cref="VectorGraphics.Canvas.PictureModifiable"/> <see cref="designPicture"/>.
    ///   Removes the selected shape from the target list.
    /// </summary>
    /// <param name="sender">
    /// Source of the event.
    /// </param>
    /// <param name="e">
    /// A <see cref="ShapeEventArgs"/> with the deleted shape.
    /// </param>
    private void picPreview_ShapeDeleted(object sender, ShapeEventArgs e)
    {
      if (e.Shape.StyleGroup == VGStyleGroup.AOI_TARGET)
      {
        this.lsbTargets.Items.Remove(e.Shape.Name);
        this.cbbTestingTargets.Items.Remove(e.Shape.Name);
        this.cbbLinksTargets.Items.Remove(e.Shape.Name);
        if (this.lsbTargets.Items.Count == 0)
        {
          this.chbOnlyWhenInTarget.Visible = false;

          // Remove StopConditions with target entries.
          this.RemoveTargetConditions(this.lsbStopConditions);

          // Remove CorrectResponses with target entries.
          this.RemoveTargetConditions(this.lsbCorrectResponses);

          // Remove Links with target entries.
          this.RemoveTargetConditions(this.lsbLinks);
        }
      }
    }
示例#7
0
    /// <summary>
    /// <see cref="VectorGraphics.Canvas.PictureModifiable.ShapeSelected"/> event handler of the
    ///   <see cref="VectorGraphics.Canvas.PictureModifiable"/> <see cref="designPicture"/>.
    ///   Raises the appropriate design tab page and fills the
    ///   desing fields.
    /// </summary>
    /// <remarks>
    /// For setting the <see cref="RichTextBox.ZoomFactor"/>  property
    ///   see http://www.vbforums.com/showthread.php?t=410548
    /// </remarks>
    /// <param name="sender">
    /// Source of the event.
    /// </param>
    /// <param name="e">
    /// A <see cref="ShapeEventArgs"/> with the new shape.
    /// </param>
    private void picPreview_ShapeSelected(object sender, ShapeEventArgs e)
    {
      if (e.Shape != null)
      {
        this.isInitializingSelectedShape = true;

        // Check for target shapes which should not be modifiable
        if (e.Shape.StyleGroup == VGStyleGroup.AOI_TARGET)
        {
          this.tctStandards.SelectedTab = this.tbpTargets;
          if (e.Shape is VGPolyline)
          {
            var poly = (VGPolyline)e.Shape;
            poly.RecalculateBounds();
          }
        }
        else
        {
          this.tacProperties.Visible = true;
          this.pbcElements.SetFillVisibility(true);
          if (e.Shape is VGPolyline)
          {
            var poly = (VGPolyline)e.Shape;
            poly.RecalculateBounds();
          }
          else if (e.Shape is VGLine)
          {
            var line = (VGLine)e.Shape;
            line.RecalculateBounds();
            this.pbcElements.SetFillVisibility(false);
          }

          // Update preview style areas
          string backupName = e.Shape.Name;
          Font backupFont = e.Shape.Font;
          Color backupColor = e.Shape.FontColor;
          this.pbcElements.NewPen = e.Shape.Pen;
          this.pbcElements.NewBrush = e.Shape.Brush;
          this.pbcElements.DrawAction = e.Shape.ShapeDrawAction;
          e.Shape.Name = backupName;
          this.pbcElements.NewName = e.Shape.Name;
          e.Shape.Font = backupFont;
          this.pbcElements.NewFont = e.Shape.Font;
          e.Shape.FontColor = backupColor;
          this.pbcElements.NewFontColor = e.Shape.FontColor;
          this.pbcElements.Refresh();
          this.audioControl.Sound = e.Shape.Sound;

          this.nudLayoutHeight.Enabled = true;

          if (e.Shape.Location.X > Document.ActiveDocument.PresentationSize.Width
              || e.Shape.Location.Y > Document.ActiveDocument.PresentationSize.Height)
          {
            e.Shape.Location = PointF.Empty;
          }

          if (e.Shape.Width > Document.ActiveDocument.PresentationSize.Width
              || e.Shape.Height > Document.ActiveDocument.PresentationSize.Height)
          {
            e.Shape.Size = Document.ActiveDocument.PresentationSize;
          }

          this.UpdateShapePositionAndSizeNumerics(e.Shape);

          if (e.Shape is VGRichText)
          {
            var text = (VGRichText)e.Shape;
            this.rtbInstructions.RichTextBox.ZoomFactor = 1f;
            this.rtbInstructions.RichTextBox.Rtf = text.RtfToDraw;
            if (!this.tctStimuli.TabPages.Contains(this.tbpRtfInstructions))
            {
              this.tctStimuli.TabPages.Add(this.tbpRtfInstructions);
            }

            this.tctStimuli.SelectedTab = this.tbpRtfInstructions;
            this.rtbInstructions.RichTextBox.ZoomFactor = 0.5f;
            this.nudLayoutHeight.Enabled = false;
          }
          else if (e.Shape is VGText)
          {
            var text = (VGText)e.Shape;
            this.txbInstructions.Text = text.StringToDraw;
            this.txbInstructions.TextAlign = text.Alignment;
            if (!this.tctStimuli.TabPages.Contains(this.tbpInstructions))
            {
              this.tctStimuli.TabPages.Add(this.tbpInstructions);
            }

            this.tctStimuli.SelectedTab = this.tbpInstructions;
            this.nudLayoutHeight.Enabled = false;
          }
          else if (e.Shape is VGImage)
          {
            var image = (VGImage)e.Shape;
            this.txbImageFilename.Text = image.Filename;

            this.toolTip.SetToolTip(
              this.txbImageFilename, 
              Path.Combine(
                image.Filepath == string.Empty
                  ? Document.ActiveDocument.ExperimentSettings.SlideResourcesPath
                  : image.Filepath, 
                image.Filename));

            this.cbbImageLayout.SelectedItem = image.Layout.ToString();
            if (!this.tctStimuli.TabPages.Contains(this.tbpImages))
            {
              this.tctStimuli.TabPages.Add(this.tbpImages);
            }

            this.tctStimuli.SelectedTab = this.tbpImages;
          }
          else if (e.Shape is VGFlash)
          {
            var flash = (VGFlash)e.Shape;
            this.txbFlashFilename.Text = flash.Filename;

            this.toolTip.SetToolTip(
              this.txbFlashFilename, 
              Path.Combine(
                flash.Filepath == string.Empty
                  ? Document.ActiveDocument.ExperimentSettings.SlideResourcesPath
                  : flash.Filepath, 
                flash.Filename));

            if (!this.tctStimuli.TabPages.Contains(this.tbpFlashMovies))
            {
              this.tctStimuli.TabPages.Add(this.tbpFlashMovies);
            }

            this.tctStimuli.SelectedTab = this.tbpFlashMovies;
          }
        }

        this.isInitializingSelectedShape = false;
      }
    }
示例#8
0
 /// <summary>
 /// <see cref="VectorGraphics.Canvas.PictureModifiable.ShapeChanged"/> event handler of the
 ///   <see cref="VectorGraphics.Canvas.PictureModifiable"/> <see cref="designPicture"/>.
 ///   Updates the shapes position and soze properties.
 /// </summary>
 /// <param name="sender">
 /// Source of the event.
 /// </param>
 /// <param name="e">
 /// A <see cref="ShapeEventArgs"/> with the new shape.
 /// </param>
 private void DesignPictureShapeChanged(object sender, ShapeEventArgs e)
 {
   this.UpdateShapePositionAndSizeNumerics(e.Shape);
 }
示例#9
0
    /// <summary>
    /// <see cref="VectorGraphics.Canvas.PictureModifiable.ShapeAdded"/> event handler of the
    ///   <see cref="VectorGraphics.Canvas.PictureModifiable"/> <see cref="designPicture"/>.
    ///   Updates the <see cref="Slide"/>s TargetShapes
    ///   property.
    /// </summary>
    /// <param name="sender">
    /// Source of the event.
    /// </param>
    /// <param name="e">
    /// A <see cref="ShapeEventArgs"/> with the new shape.
    /// </param>
    private void picPreview_ShapeAdded(object sender, ShapeEventArgs e)
    {
      if (e.Shape.StyleGroup == VGStyleGroup.AOI_TARGET)
      {
        this.lsbTargets.Items.Add(e.Shape.Name);
        this.chbOnlyWhenInTarget.Visible = true;
        this.cbbTestingTargets.Items.Add(e.Shape.Name);
        this.cbbLinksTargets.Items.Add(e.Shape.Name);
      }

      this.UpdateShapePositionAndSizeNumerics(e.Shape);

      this.Cursor = Cursors.Default;
    }
示例#10
0
    ///////////////////////////////////////////////////////////////////////////////
    // Eventhandler                                                              //
    ///////////////////////////////////////////////////////////////////////////////
    #region EVENTS

    ///////////////////////////////////////////////////////////////////////////////
    // Eventhandler for UI, Menu, Buttons, Toolbars etc.                         //
    ///////////////////////////////////////////////////////////////////////////////
    #region WINDOWSEVENTHANDLER
    #endregion //WINDOWSEVENTHANDLER

    ///////////////////////////////////////////////////////////////////////////////
    // Eventhandler for Custom Defined Events                                    //
    ///////////////////////////////////////////////////////////////////////////////
    #region CUSTOMEVENTHANDLER

    /// <summary>
    /// Raises the <see cref="CursorStyleChanged"/> event by invoking the delegates.
    /// </summary>
    /// <param name="e"><see cref="ShapeEventArgs"/> event arguments</param>.
    public void OnCursorStyleChanged(ShapeEventArgs e)
    {
      if (this.CursorStyleChanged != null)
      {
        this.CursorStyleChanged(this, e);
      }
    }
示例#11
0
 /// <summary>
 /// Wires the event from the underlying control to the listeners.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">A <see cref="ShapeEventArgs"/> with the new cursor.</param>
 private void cursorSelectControl_CursorStyleChanged(object sender, ShapeEventArgs e)
 {
   OnCursorStyleChanged(e);
 }
示例#12
0
文件: AOIModule.cs 项目: DeSciL/Ogama
    /// <summary>
    /// The <see cref="VectorGraphics.Canvas.PictureModifiable.ShapeDeleted"/> event handler for the
    ///   <see cref="VectorGraphics.Canvas.PictureModifiable"/> <see cref="aoiPicture"/>.
    ///   Removes the corresponding row from the data grid view.
    /// </summary>
    /// <param name="sender">
    /// Source of the event.
    /// </param>
    /// <param name="e">
    /// A <see cref="ShapeEventArgs"/> with the event data.
    /// </param>
    private void AOIPictureShapeDeleted(object sender, ShapeEventArgs e)
    {
      try
      {
        string shapeName = e.Shape.Name;

        foreach (DataGridViewRow row in this.dgvAOIs.Rows)
        {
          if (row.Cells["colShapeName"].Value.ToString() == shapeName)
          {
            this.dgvAOIs.Rows.Remove(row);
            break;
          }
        }
      }
      catch (Exception ex)
      {
        ExceptionMethods.HandleException(ex);
      }
    }
示例#13
0
文件: AOIModule.cs 项目: DeSciL/Ogama
    /// <summary>
    /// The event handler for the
    ///   <see cref="VectorGraphics.Canvas.PictureModifiable.ShapeChanged"/> event from the
    ///   <see cref="VectorGraphics.Canvas.PictureModifiable"/> <see cref="aoiPicture"/>.
    ///   Updates database with modified areas of interest shape given in the event arguments
    /// </summary>
    /// <param name="sender">
    /// Source of the event.
    /// </param>
    /// <param name="e">
    /// A <see cref="ShapeEventArgs"/> with the event data.
    /// </param>
    private void AOIPictureShapeChanged(object sender, ShapeEventArgs e)
    {
      // Skip if no data available
      if (this.cbbTrial.SelectedItem == null)
      {
        return;
      }

      string shapeName = e.Shape.Name;
      int shapePointCount = e.Shape.GetPointCount();
      string shapeType = e.Shape.GetType().ToString().Replace("VectorGraphics.Elements.VG", string.Empty);
      string strShapePoints = ObjectStringConverter.PointFListToString(e.Shape.GetPoints());
      int trialID = ((Trial)this.cbbTrial.SelectedItem).ID;

      try
      {
        // Presuming the DataTable has a column named ShapeName.
        string expression = "ShapeName = '" + shapeName + "' AND TrialID = '" + trialID + "'";

        // Use the Select method to find all rows matching the filter.
        DataRow[] foundRows = Document.ActiveDocument.DocDataSet.AOIs.Select(expression);
        if (foundRows.Length > 0)
        {
          foreach (DataRow row in foundRows)
          {
            row["ShapeType"] = shapeType;
            row["ShapeNumPts"] = shapePointCount;
            row["ShapePts"] = strShapePoints;
          }
        }
      }
      catch (Exception ex)
      {
        ExceptionMethods.HandleException(ex);
      }

      this.ResetButtons();
    }
示例#14
0
文件: AOIModule.cs 项目: DeSciL/Ogama
    /// <summary>
    /// The event handler for the
    ///   <see cref="VectorGraphics.Canvas.PictureModifiable.ShapeAdded"/> event from the
    ///   <see cref="VectorGraphics.Canvas.PictureModifiable"/> <see cref="aoiPicture"/>.
    ///   Updates database with new areas of interest shape given in the event arguments
    /// </summary>
    /// <param name="sender">
    /// Source of the event.
    /// </param>
    /// <param name="e">
    /// A <see cref="ShapeEventArgs"/> with the event data.
    /// </param>
    private void AOIPictureShapeAdded(object sender, ShapeEventArgs e)
    {
      // Skip if no data available
      if (this.cbbTrial.SelectedItem == null)
      {
        return;
      }

      string shapeName = e.Shape.Name;
      int shapePointCount = e.Shape.GetPointCount();
      string shapeType = e.Shape.GetType().ToString().Replace("VectorGraphics.Elements.VG", string.Empty);
      string strShapePoints = ObjectStringConverter.PointFListToString(e.Shape.GetPoints());
      int trialID = ((Trial)this.cbbTrial.SelectedItem).ID;

      // Add new Element to AOITable
      var aoi = new AOIData();
      aoi.ShapeName = shapeName;
      aoi.ShapeNumPts = shapePointCount;
      aoi.ShapePts = strShapePoints;
      aoi.ShapeType = (VGShapeType)Enum.Parse(typeof(VGShapeType), shapeType);
      aoi.TrialID = trialID;
      aoi.SlideNr = this.trialTimeLine.HighlightedSlideIndex;

      if (!Queries.WriteAOIDataToDataSet(aoi, null))
      {
        this.aoiPicture.DeleteShape(e.Shape);
      }

      this.ResetButtons();
    }
示例#15
0
 /// <summary>
 /// The protected OnShapeDoubleClick method raises the <see cref="ShapeChanged"/>  
 /// event by invoking the delegates.
 /// </summary>
 /// <param name="e">The <see cref="ShapeEventArgs"/> with the event data.</param>
 protected virtual void OnShapeDoubleClick(ShapeEventArgs e)
 {
   if (this.ShapeDoubleClick != null)
   {
     // Invokes the delegates. 
     this.ShapeDoubleClick(this, e);
   }
 }
示例#16
0
 /// <summary>
 /// The protected OnShapeChanged method raises the <see cref="ShapeChanged"/>  
 /// event by invoking the delegates.
 /// </summary>
 /// <param name="e">The <see cref="ShapeEventArgs"/> with the event data.</param>
 protected virtual void OnShapeChanged(ShapeEventArgs e)
 {
   if (this.ShapeChanged != null)
   {
     // Invokes the delegates. 
     this.ShapeChanged(this, e);
   }
 }