コード例 #1
0
ファイル: SlidePicture.cs プロジェクト: zhjh-stack/ogama
        ///////////////////////////////////////////////////////////////////////////////
        // Inherited methods                                                         //
        ///////////////////////////////////////////////////////////////////////////////
        #region OVERRIDES

        /// <summary>
        /// Overridden. This custom on paste invokes a dialog that switches
        /// between target and default stimulus element insertion.
        /// </summary>
        public override void OnPaste()
        {
            // Retrieves the data from the clipboard.
            object test = Clipboard.GetData(DataFormats.StringFormat);

            if (test == null)
            {
                return;
            }

            VGElement t = VGElement.Deserialize(test.ToString());

            // Determines whether the data is in a format you can use.
            if (t != null)
            {
                VGElement elementToAdd = t;
                this.ResetSelectedElement();

                PasteAsDialog dialog = new PasteAsDialog();
                dialog.ElementToPaste = elementToAdd;

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    if (!this.Elements.Contains(elementToAdd))
                    {
                        if (dialog.IsTarget)
                        {
                            int count = this.GetNextTargetNumber();
                            elementToAdd.Name          = "Target" + count.ToString();
                            elementToAdd.StyleGroup    = VGStyleGroup.AOI_TARGET;
                            elementToAdd.Pen           = this.TargetPen;
                            elementToAdd.Font          = this.TargetFont;
                            elementToAdd.FontColor     = this.TargetFontColor;
                            elementToAdd.TextAlignment = this.TargetTextAlignment;
                        }
                        else
                        {
                            elementToAdd.StyleGroup = VGStyleGroup.None;
                        }
                    }

                    this.Elements.Add(elementToAdd);
                    this.SelectedElement = elementToAdd;

                    // New Graphic element created, so notify listeners.
                    this.OnShapeAdded(new ShapeEventArgs(elementToAdd));
                    this.DrawForeground(false);
                }
            }
        }
コード例 #2
0
ファイル: SlidePicture.cs プロジェクト: DeSciL/Ogama
    ///////////////////////////////////////////////////////////////////////////////
    // Inherited methods                                                         //
    ///////////////////////////////////////////////////////////////////////////////
    #region OVERRIDES

    /// <summary>
    /// Overridden. This custom on paste invokes a dialog that switches
    /// between target and default stimulus element insertion.
    /// </summary>
    public override void OnPaste()
    {
      // Retrieves the data from the clipboard.
      object test = Clipboard.GetData(DataFormats.StringFormat);
      if (test == null)
      {
        return;
      }

      VGElement t = VGElement.Deserialize(test.ToString());

      // Determines whether the data is in a format you can use.
      if (t != null)
      {
        VGElement elementToAdd = t;
        this.ResetSelectedElement();

        PasteAsDialog dialog = new PasteAsDialog();
        dialog.ElementToPaste = elementToAdd;

        if (dialog.ShowDialog() == DialogResult.OK)
        {
          if (!this.Elements.Contains(elementToAdd))
          {
            if (dialog.IsTarget)
            {
              int count = this.GetNextTargetNumber();
              elementToAdd.Name = "Target" + count.ToString();
              elementToAdd.StyleGroup = VGStyleGroup.AOI_TARGET;
              elementToAdd.Pen = this.TargetPen;
              elementToAdd.Font = this.TargetFont;
              elementToAdd.FontColor = this.TargetFontColor;
              elementToAdd.TextAlignment = this.TargetTextAlignment;
            }
            else
            {
              elementToAdd.StyleGroup = VGStyleGroup.None;
            }
          }

          this.Elements.Add(elementToAdd);
          this.SelectedElement = elementToAdd;

          // New Graphic element created, so notify listeners.
          this.OnShapeAdded(new ShapeEventArgs(elementToAdd));
          this.DrawForeground(false);
        }
      }
    }