Exemplo n.º 1
0
        /// <summary>
        ///   Handles the Paste event by pasting an <see cref="VGElement" /> from the
        ///   clipboard into the picture.
        /// </summary>
        public override void OnPaste()
        {
            // Retrieves the data from the clipboard.
            var test = Clipboard.GetData(DataFormats.StringFormat);

            if (test == null)
            {
                return;
            }

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

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

                if (!this.Elements.Contains(elementToAdd))
                {
                    // New Graphic element created, so notify listeners.
                    this.OnShapeAdded(new ShapeEventArgs(elementToAdd));
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Adds an object to the end of the collection.
 /// </summary>
 /// <param name="element">The <see cref="VGElement"/> to be
 /// added to the end of the collection.</param>
 public void Add(VGElement element)
 {
     if (element != null)
     {
         this.List.Add(element);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Removes the first occurrence of a specific
 /// <see cref="VGElement"/> from the collection.
 /// </summary>
 /// <param name="element">The <see cref="VGElement"/>
 /// to remove from the collection.</param>
 public void Remove(VGElement element)
 {
     if (element != null)
     {
         if (this.List.Contains(element))
         {
             this.List.Remove(element);
         }
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// The <see cref="Control.Click"/> event handler for the
        /// <see cref="Button"/> <see cref="btnShapes"/>.
        /// Shows a <see cref="ShapeDialog"/> to define a shape
        /// element that is added to all imported slides.
        /// </summary>
        /// <param name="sender">Source of the event.</param>
        /// <param name="e">An empty <see cref="EventArgs"/></param>
        private void btnShapes_Click(object sender, EventArgs e)
        {
            ShapeDialog dlg = new ShapeDialog();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                VGElement shape = dlg.NewShape;
                this.cbbDesignedItem.Items.Add(shape);
                this.cbbDesignedItem.SelectedItem = shape;
            }
        }
Exemplo n.º 5
0
        ///////////////////////////////////////////////////////////////////////////////
        // Public methods                                                            //
        ///////////////////////////////////////////////////////////////////////////////
        #region PUBLICMETHODS

        /// <summary>
        /// Moves gives object to the end of the collection.
        /// </summary>
        /// <param name="element">The <see cref="VGElement"/> to be
        /// moved to the end of the collection.</param>
        public void ToTail(VGElement element)
        {
            if (element != null)
            {
                if (this.List.Contains(element))
                {
                    this.List.Remove(element);
                }

                this.List.Add(element);
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// The <see cref="Control.Click"/> event handler for the
 /// <see cref="Button"/> <see cref="btnAddItem"/>.
 /// Adds the selected item in the <see cref="ComboBox"/> of designed items
 /// to the list of items to be added to the slide.
 /// </summary>
 /// <param name="sender">Source of the event.</param>
 /// <param name="e">An empty <see cref="EventArgs"/></param>
 private void btnAddItem_Click(object sender, EventArgs e)
 {
     if (this.cbbDesignedItem.SelectedItem != null &&
         this.cbbDesignedItem.SelectedItem is VGElement)
     {
         VGElement itemToAdd = (VGElement)this.cbbDesignedItem.SelectedItem;
         itemToAdd.Center = this.psbItems.CurrentPosition;
         itemToAdd.Size   = new SizeF((float)this.nudWidth.Value, (float)this.nudHeight.Value);
         this.lsbStandardItems.Items.Add(itemToAdd);
         this.cbbDesignedItem.Items.Remove(itemToAdd);
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Moves gives object to the beginning of the collection.
        /// </summary>
        /// <param name="element">The <see cref="VGElement"/> to be
        /// moved to the beginning of the collection.</param>
        public void ToHead(VGElement element)
        {
            if (element != null)
            {
                if (this.List.Contains(element))
                {
                    this.List.Remove(element);
                }

                this.List.Insert(0, element);
            }
        }
Exemplo n.º 8
0
        ///////////////////////////////////////////////////////////////////////////////
        // Eventhandler                                                              //
        ///////////////////////////////////////////////////////////////////////////////
        #region EVENTS

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

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

        #endregion //EVENTS

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

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

        /// <summary>
        /// This method updates the given element with the new resources path
        /// </summary>
        /// <param name="newResourcesPath">The new resource path</param>
        /// <param name="element">The <see cref="VGElement"/> to update.</param>
        private static void UpdateElement(string newResourcesPath, VGElement element)
        {
            // check all element for sounds
            if (element.Sound == null)
            {
                element.Sound = new AudioFile();
            }

            if (element.Sound.Filename != null)
            {
                if (element.Sound.Filename.Contains(@"\"))
                {
                    element.Sound.Filename = System.IO.Path.GetFileName(element.Sound.Filename);
                }

                element.Sound.Filepath = newResourcesPath;
            }

            // check file based elements
            if (element is VGScrollImage)
            {
                var scrollImage = (VGScrollImage)element;
                if (scrollImage.Filepath != newResourcesPath)
                {
                    scrollImage.Filename = System.IO.Path.GetFileName(scrollImage.Filename);
                    scrollImage.Filepath = newResourcesPath;
                    scrollImage.Canvas   = Document.ActiveDocument.PresentationSize;
                }

                scrollImage.CreateInternalImage();
            }
            else if (element is VGImage)
            {
                VGImage image = (VGImage)element;
                if (image.Filepath != newResourcesPath)
                {
                    image.Filename = System.IO.Path.GetFileName(image.Filename);
                    image.Filepath = newResourcesPath;
                    image.Canvas   = Document.ActiveDocument.PresentationSize;
                    image.CreateInternalImage();
                }
            }
            else if (element is VGFlash)
            {
                VGFlash flash = (VGFlash)element;
                if (flash.Filepath != newResourcesPath)
                {
                    flash.Filename = System.IO.Path.GetFileName(flash.Filename);
                    flash.Filepath = newResourcesPath;
                }
            }
        }
Exemplo n.º 9
0
        ///////////////////////////////////////////////////////////////////////////////
        // 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);
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// The delete shape.
        /// </summary>
        /// <param name="vGElement">
        /// The v g element.
        /// </param>
        internal void DeleteShape(VGElement vGElement)
        {
            if (this.AoiCollection.Contains(vGElement))
            {
                this.AoiCollection.Remove(vGElement);
            }

            if (this.Elements.Contains(vGElement))
            {
                this.Elements.Remove(vGElement);
            }

            this.DrawForeground(true);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Overridden <see cref="TypeConverter.ConvertTo(ITypeDescriptorContext,CultureInfo,object,Type)"/>
        /// </summary>
        /// <remarks>This value is the description at the right side of the row
        /// at the property grid.</remarks>
        /// <param name="context">An <see cref="ITypeDescriptorContext"/> that
        /// provides a format context.</param>
        /// <param name="culture">A <see cref="CultureInfo"/>. If a null reference
        /// is passed, the current culture is assumed.</param>
        /// <param name="value">The <see cref="Object"/> to convert.</param>
        /// <param name="destinationType">The <see cref="Type"/> to convert the
        /// <strong>value</strong> parameter to.</param>
        /// <returns>An <strong>Object</strong> that represents the converted value.</returns>
        public override object ConvertTo(
            ITypeDescriptorContext context,
            CultureInfo culture,
            object value,
            Type destinationType)
        {
            if (destinationType == typeof(string) && value is VGElement)
            {
                VGElement element = (VGElement)value;
                return(element.ToShortString());
            }

            return(base.ConvertTo(context, culture, value, destinationType));
        }
Exemplo n.º 12
0
 /// <summary>
 /// Moves gives object one step in direction beginning of the collection.
 /// </summary>
 /// <param name="element">The <see cref="VGElement"/> to be
 /// moved in direction beginning of the collection.</param>
 public void MoveDown(VGElement element)
 {
     if (element != null)
     {
         if (this.List.Contains(element))
         {
             int index = this.List.IndexOf(element);
             if (index > 0)
             {
                 this.List.Remove(element);
                 this.List.Insert(index - 1, element);
             }
         }
     }
 }
Exemplo n.º 13
0
 /// <summary>
 /// Moves gives object one step in direction end of the collection.
 /// </summary>
 /// <param name="element">The <see cref="VGElement"/> to be
 /// moved in direction end of the collection.</param>
 public void MoveUp(VGElement element)
 {
     if (element != null)
     {
         if (this.List.Contains(element))
         {
             int index = this.List.IndexOf(element);
             if (index < this.List.Count - 1)
             {
                 this.List.Remove(element);
                 this.List.Insert(index + 1, element);
             }
         }
     }
 }
Exemplo n.º 14
0
        /// <summary>
        /// Overridden. Does the same as the base method,
        /// but renames all AOIs with an increasing number.
        /// </summary>
        /// <param name="aoiTable">The <see cref="DataTable"/> with the AOIs.</param>
        /// <returns>A <see cref="List{VGElement}"/> with the renamed shapes.</returns>
        protected override VGElementCollection GetAOIElements(DataTable aoiTable)
        {
            VGElementCollection aoiElements = base.GetAOIElements(aoiTable);

            for (int i = 0; i < aoiElements.Count; i++)
            {
                VGElement element = aoiElements[i];

                // Modify shape names to fit Levenshtein settings.
                string shapeName = currentIdentifierList[i];
                element.Name   = shapeName;
                aoiElements[i] = element;
            }

            return(aoiElements);
        }
Exemplo n.º 15
0
    /// <summary>
    /// Moves gives object to the beginning of the collection.
    /// </summary>
    /// <param name="element">The <see cref="VGElement"/> to be 
    /// moved to the beginning of the collection.</param>
    public void ToHead(VGElement element)
    {
      if (element != null)
      {
        if (this.List.Contains(element))
        {
          this.List.Remove(element);
        }

        this.List.Insert(0, element);
      }
    }
Exemplo n.º 16
0
        ///////////////////////////////////////////////////////////////////////////////
        // Construction and Initializing methods                                     //
        ///////////////////////////////////////////////////////////////////////////////
        #region CONSTRUCTION

        /// <summary>
        /// Initializes a new instance of the ShapeEventArgs class.
        /// </summary>
        /// <param name="shape">The <see cref="VGElement"/> to store.</param>
        public ShapeEventArgs(VGElement shape)
        {
            this.shape = shape;
        }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
0
    ///////////////////////////////////////////////////////////////////////////////
    // Public methods                                                            //
    ///////////////////////////////////////////////////////////////////////////////
    #region PUBLICMETHODS

    /// <summary>
    /// Moves gives object to the end of the collection.
    /// </summary>
    /// <param name="element">The <see cref="VGElement"/> to be 
    /// moved to the end of the collection.</param>
    public void ToTail(VGElement element)
    {
      if (element != null)
      {
        if (this.List.Contains(element))
        {
          this.List.Remove(element);
        }

        this.List.Add(element);
      }
    }
Exemplo n.º 19
0
 /// <summary>
 /// Removes the first occurrence of a specific
 /// <see cref="VGElement"/> from the collection. 
 /// </summary>
 /// <param name="element">The <see cref="VGElement"/>
 /// to remove from the collection.</param>
 public void Remove(VGElement element)
 {
   if (element != null)
   {
     if (this.List.Contains(element))
     {
       this.List.Remove(element);
     }
   }
 }
Exemplo n.º 20
0
 /// <summary>
 /// Determines whether the collection contains a specific element.
 /// </summary>
 /// <param name="element">The Object to locate in the collection.</param>
 /// <returns><strong>True</strong> if the collection
 /// contains the specified value; otherwise, <strong>false</strong>.</returns>
 public bool Contains(VGElement element)
 {
   return this.List.Contains(element);
 }
Exemplo n.º 21
0
 /// <summary>
 /// Adds an object to the end of the collection.
 /// </summary>
 /// <param name="element">The <see cref="VGElement"/> to be 
 /// added to the end of the collection.</param>
 public void Add(VGElement element)
 {
   if (element != null)
   {
     this.List.Add(element);
   }
 }
Exemplo n.º 22
0
 /// <summary>
 /// Moves gives object one step in direction end of the collection.
 /// </summary>
 /// <param name="element">The <see cref="VGElement"/> to be 
 /// moved in direction end of the collection.</param>
 public void MoveUp(VGElement element)
 {
   if (element != null)
   {
     if (this.List.Contains(element))
     {
       int index = this.List.IndexOf(element);
       if (index < this.List.Count - 1)
       {
         this.List.Remove(element);
         this.List.Insert(index + 1, element);
       }
     }
   }
 }
Exemplo n.º 23
0
 /// <summary>
 /// Moves gives object one step in direction beginning of the collection.
 /// </summary>
 /// <param name="element">The <see cref="VGElement"/> to be 
 /// moved in direction beginning of the collection.</param>
 public void MoveDown(VGElement element)
 {
   if (element != null)
   {
     if (this.List.Contains(element))
     {
       int index = this.List.IndexOf(element);
       if (index > 0)
       {
         this.List.Remove(element);
         this.List.Insert(index - 1, element);
       }
     }
   }
 }
Exemplo n.º 24
0
 /// <summary>
 /// Determines whether the collection contains a specific element.
 /// </summary>
 /// <param name="element">The Object to locate in the collection.</param>
 /// <returns><strong>True</strong> if the collection
 /// contains the specified value; otherwise, <strong>false</strong>.</returns>
 public bool Contains(VGElement element)
 {
     return(this.List.Contains(element));
 }