Example #1
0
 /// <summary>
 /// Initializes a new instance of the BrowserTreeNode class
 /// by cloneing the given <see cref="BrowserTreeNode"/>
 /// </summary>
 /// <param name="browserTreeNode">A <see cref="BrowserTreeNode"/> to be cloned.</param>
 public BrowserTreeNode(BrowserTreeNode browserTreeNode)
 {
     this.Name        = browserTreeNode.Name;
     this.Category    = browserTreeNode.Category;
     this.Text        = browserTreeNode.Text;
     this.BrowseDepth = browserTreeNode.BrowseDepth;
     this.ImageKey    = browserTreeNode.ImageKey;
     this.UrlToID     = browserTreeNode.UrlToID;
     foreach (SlideshowTreeNode node in browserTreeNode.Nodes)
     {
         this.Nodes.Add((SlideshowTreeNode)node.Clone());
     }
 }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the BrowserTreeNode class 
 /// by cloneing the given <see cref="BrowserTreeNode"/>
 /// </summary>
 /// <param name="browserTreeNode">A <see cref="BrowserTreeNode"/> to be cloned.</param>
 public BrowserTreeNode(BrowserTreeNode browserTreeNode)
 {
   this.Name = browserTreeNode.Name;
   this.Category = browserTreeNode.Category;
   this.Text = browserTreeNode.Text;
   this.BrowseDepth = browserTreeNode.BrowseDepth;
   this.ImageKey = browserTreeNode.ImageKey;
   this.UrlToID = browserTreeNode.UrlToID;
   foreach (SlideshowTreeNode node in browserTreeNode.Nodes)
   {
     this.Nodes.Add((SlideshowTreeNode)node.Clone());
   }
 }
Example #3
0
        /// <summary>
        /// This method creates a <see cref="Slide"/> containing the<see cref="VGBrowser"/>
        /// that can be used to display the website described in the
        /// given <see cref="BrowserTreeNode"/>
        /// </summary>
        /// <param name="browserSlide">The <see cref="BrowserTreeNode"/> to be converted into a
        /// presentation slide.</param>
        /// <returns>A <see cref="Slide"/> containing the <see cref="VGBrowser"/>
        /// that displays the web site.</returns>
        private Slide CreateBrowserSlide(BrowserTreeNode browserSlide)
        {
            Slide slide = (Slide)browserSlide.Slide.Clone();

            VGBrowser browser = new VGBrowser(
                ShapeDrawAction.None,
                browserSlide.OriginURL,
                browserSlide.BrowseDepth,
                Pens.Black,
                Brushes.Black,
                SystemFonts.DefaultFont,
                Color.Black,
                PointF.Empty,
                Document.ActiveDocument.PresentationSize,
                VGStyleGroup.ACTIVEX,
                browserSlide.Name,
                string.Empty);

            slide.ActiveXStimuli.Add(browser);
            return(slide);
        }
Example #4
0
        /// <summary>
        /// This method is a custom deserialization with an <see cref="XmlSerializer"/>
        /// to read the contents of the <see cref="Slideshow"/> that
        /// are exposed in this override. It deserializes recursively.
        /// </summary>
        /// <param name="reader">The <see cref="XmlReader"/> to use.</param>
        /// <param name="node">The <see cref="SlideshowTreeNode"/> to deserialize.</param>
        public override void DeserializeNode(XmlReader reader, SlideshowTreeNode node)
        {
            var shuffleSerializer = new XmlSerializer(typeof(CustomShuffling));

            // Check for Versions < Ogama 4.3
            if (reader.Name == "SlideshowTreeNode")
            {
                base.DeserializeNode(reader, node);
                return;
            }

            reader.ReadStartElement("IsModified");
            this.IsModified = reader.ReadContentAsBoolean();
            reader.ReadEndElement();

            if (reader.Name == "CustomShuffling")
            {
                this.shuffling = (CustomShuffling)shuffleSerializer.Deserialize(reader);
            }


            while ((reader.Name == "SlideshowTreeNode" && reader.NodeType == XmlNodeType.Element) ||
                   (reader.Name == "BrowserTreeNode" && reader.NodeType == XmlNodeType.Element))
            {
                if (reader.Name == "SlideshowTreeNode")
                {
                    var newNode = new SlideshowTreeNode();
                    newNode.DeserializeNode(reader, newNode);
                    this.SetTreeNodeImageKey(newNode);
                    node.Nodes.Add(newNode);
                }
                else if (reader.Name == "BrowserTreeNode")
                {
                    var newNode = new BrowserTreeNode();
                    newNode.DeserializeNode(reader, newNode);
                    this.SetTreeNodeImageKey(newNode);
                    node.Nodes.Add(newNode);
                }
            }
        }
Example #5
0
    /// <summary>
    /// This method initializes the next slide in the given
    ///   <see cref="SlidePresentationContainer"/>.
    ///   That is setting a time stop condition timer,
    ///   setup audio replay, and load flash objects.
    ///   Because this can last a significant amount of time
    ///   it should be done in a background thread.
    /// </summary>
    /// <param name="slideContainer">
    /// The <see cref="SlidePresentationContainer"/>
    ///   that should be initialized.
    /// </param>
    private void InitializeNextSlide(SlidePresentationContainer slideContainer)
    {
      try
      {
        // Reset Timer to 1ms period indicating that it should not be used during
        // call to PlaySlideContainer
        slideContainer.Timer.Period = 1;

        // Reset the timer according to stop condition if applicable.
        foreach (StopCondition condition in slideContainer.Slide.StopConditions)
        {
          if (condition is TimeStopCondition)
          {
            var timeCondition = (TimeStopCondition)condition;
            slideContainer.Timer.Period = timeCondition.Duration;
            break;
          }
        }

        // Search for audio files
        this.ParseElementsForAudio(slideContainer);

        // Load background sound
        if (slideContainer.Slide.BackgroundSound != null)
        {
          if (slideContainer.Slide.BackgroundSound.ShouldPlay)
          {
            slideContainer.AudioPlayer.AddAudioChannel(slideContainer.Slide.BackgroundSound.FullFilename);
          }
        }

        // Check for flash stimuli and load them into the
        // flashObject activeX control.
        foreach (VGElement element in slideContainer.Slide.ActiveXStimuli)
        {
          if (element is VGFlash)
          {
            var flash = element as VGFlash;
            flash.InitializeOnControl(slideContainer.ContainerControl, true, new System.Drawing.Drawing2D.Matrix());
          }
          else if (element is VGBrowser)
          {
            var browser = element as VGBrowser;
            this.currentVgBrowser = browser;
            browser.InitializeOnControl(slideContainer.ContainerControl, true);
            browser.WebBrowser.NewWindow += this.WebBrowser_NewWindow;
            browser.WebBrowser.DocumentCompleted += this.WebBrowserDocumentCompleted;
            browser.WebBrowser.Navigating += this.WebBrowserNavigating;

            // if (browser.WebBrowser.Url != null && browser.WebBrowser.Document != null)
            // {
            // // Attach Scroll events in document completed handler
            // browser.WebBrowser.Document.MouseDown += this.WebBrowserMouseDown;
            // }
            browser.WebBrowser.Navigate(browser.BrowserURL);
            this.numberOfTimesNavigated = 0;
            this.maxBrowseDepth = browser.BrowseDepth;
            this.currentBrowserTreeNode =
              (BrowserTreeNode)Document.ActiveDocument.ExperimentSettings.SlideShow.GetNodeByID(slideContainer.Trial.ID);
          }
        }
      }
      catch (Exception ex)
      {
        ExceptionMethods.HandleExceptionSilent(ex);
      }
    }
Example #6
0
        /// <summary>
        /// This method is a custom deserialization with an <see cref="XmlSerializer"/>
        /// to read the contents of the <see cref="SlideshowTreeNode"/> that
        /// are exposed in this override.
        /// It deserializes recursively.
        /// </summary>
        /// <param name="reader">The <see cref="XmlReader"/> to use.</param>
        /// <param name="node">The <see cref="SlideshowTreeNode"/> to deserialize.</param>
        public virtual void DeserializeNode(XmlReader reader, SlideshowTreeNode node)
        {
            var slideSerializer = new XmlSerializer(typeof(Slide));

            // Check for older versions of Ogama 1.X
            if (reader.Name == "Slides")
            {
                // A List<Slide> instead of SlideshowTreeNodes
                // in the slideshow node
                reader.ReadStartElement("Slides");
                this.ParseOgamaV1Slideshow(reader, slideSerializer);
                reader.ReadEndElement();
            }
            else if (reader.Name == "Slide")
            {
                // Directly the slides in the slideshow node
                this.ParseOgamaV1Slideshow(reader, slideSerializer);
            }
            else
            {
                // Ogama V2 format
                reader.ReadStartElement("SlideshowTreeNode");
                reader.ReadStartElement("Name");
                node.Name = reader.ReadString();
                reader.ReadEndElement();
                reader.ReadStartElement("Randomize");
                node.Randomize = reader.ReadContentAsBoolean();
                reader.ReadEndElement();
                reader.ReadStartElement("NumberOfItemsToUse");
                node.NumberOfItemsToUse = reader.ReadContentAsInt();
                reader.ReadEndElement();

                if (reader.Name == "Slide")
                {
                    node.Slide = (Slide)slideSerializer.Deserialize(reader);
                }

                reader.ReadStartElement("Tag");
                if (reader.Value != string.Empty)
                {
                    node.Tag = reader.ReadContentAsString();
                    reader.ReadEndElement();
                }

                reader.ReadStartElement("Text");
                node.Text = reader.ReadContentAsString();
                reader.ReadEndElement();
                while ((reader.Name == "SlideshowTreeNode" && reader.NodeType == XmlNodeType.Element) ||
                       (reader.Name == "BrowserTreeNode" && reader.NodeType == XmlNodeType.Element))
                {
                    if (reader.Name == "SlideshowTreeNode")
                    {
                        var newNode = new SlideshowTreeNode();
                        newNode.DeserializeNode(reader, newNode);
                        this.SetTreeNodeImageKey(newNode);
                        node.Nodes.Add(newNode);
                    }
                    else if (reader.Name == "BrowserTreeNode")
                    {
                        var newNode = new BrowserTreeNode();
                        newNode.DeserializeNode(reader, newNode);
                        this.SetTreeNodeImageKey(newNode);
                        node.Nodes.Add(newNode);
                    }
                }

                reader.ReadEndElement();

                reader.MoveToContent();
            }
        }
Example #7
0
    /// <summary>
    /// This method creates a <see cref="Slide"/> containing the<see cref="VGBrowser"/>
    /// that can be used to display the website described in the 
    /// given <see cref="BrowserTreeNode"/>
    /// </summary>
    /// <param name="browserSlide">The <see cref="BrowserTreeNode"/> to be converted into a 
    /// presentation slide.</param>
    /// <returns>A <see cref="Slide"/> containing the <see cref="VGBrowser"/>
    /// that displays the web site.</returns>
    private Slide CreateBrowserSlide(BrowserTreeNode browserSlide)
    {
      Slide slide = (Slide)browserSlide.Slide.Clone();

      VGBrowser browser = new VGBrowser(
        ShapeDrawAction.None,
        browserSlide.OriginURL,
        browserSlide.BrowseDepth,
        Pens.Black,
        Brushes.Black,
        SystemFonts.DefaultFont,
        Color.Black,
        PointF.Empty,
        Document.ActiveDocument.PresentationSize,
        VGStyleGroup.ACTIVEX,
        browserSlide.Name,
        string.Empty);
      slide.ActiveXStimuli.Add(browser);
      return slide;
    }
Example #8
0
    /// <summary>
    /// This method is a custom deserialization with an <see cref="XmlSerializer"/>
    /// to read the contents of the <see cref="Slideshow"/> that 
    /// are exposed in this override. It deserializes recursively.
    /// </summary>
    /// <param name="reader">The <see cref="XmlReader"/> to use.</param>
    /// <param name="node">The <see cref="SlideshowTreeNode"/> to deserialize.</param>
    public override void DeserializeNode(XmlReader reader, SlideshowTreeNode node)
    {
      var shuffleSerializer = new XmlSerializer(typeof(CustomShuffling));

      // Check for Versions < Ogama 4.3
      if (reader.Name == "SlideshowTreeNode")
      {
        base.DeserializeNode(reader, node);
        return;
      }

      reader.ReadStartElement("IsModified");
      this.IsModified = reader.ReadContentAsBoolean();
      reader.ReadEndElement();

      if (reader.Name == "CustomShuffling")
      {
        this.shuffling = (CustomShuffling)shuffleSerializer.Deserialize(reader);
      }


      while ((reader.Name == "SlideshowTreeNode" && reader.NodeType == XmlNodeType.Element) ||
        (reader.Name == "BrowserTreeNode" && reader.NodeType == XmlNodeType.Element))
      {
        if (reader.Name == "SlideshowTreeNode")
        {
          var newNode = new SlideshowTreeNode();
          newNode.DeserializeNode(reader, newNode);
          this.SetTreeNodeImageKey(newNode);
          node.Nodes.Add(newNode);
        }
        else if (reader.Name == "BrowserTreeNode")
        {
          var newNode = new BrowserTreeNode();
          newNode.DeserializeNode(reader, newNode);
          this.SetTreeNodeImageKey(newNode);
          node.Nodes.Add(newNode);
        }
      }
    }
Example #9
0
    /// <summary>
    /// Creates a new <see cref="Slide"/> with the
    /// properties defined on this dialog and creates a thumb for it.
    /// </summary>
    /// <returns>The new <see cref="Slide"/> to be added to the slideshow.</returns>
    private BrowserTreeNode GetBrowserSlide()
    {
      if (this.browserTreeNode == null)
      {
        this.browserTreeNode = new BrowserTreeNode();
      }

      // Store category and name.
      this.browserTreeNode.Category = this.cbbCategory.Text;
      this.browserTreeNode.Text = this.txbName.Text;
      this.browserTreeNode.OriginURL = this.txbURL.Text;
      this.browserTreeNode.BrowseDepth = (int)this.nudBrowseDepth.Value;

      // Add standard stop condition if none is specified.
      if (this.lsbStopConditions.Items.Count == 0)
      {
        this.lsbStopConditions.Items.Add(new TimeStopCondition(SlideDesignModule.SLIDEDURATIONINS * 1000));
      }

      Slide baseURLSlide = new Slide();
      baseURLSlide.Category = this.cbbCategory.Text;
      baseURLSlide.Modified = true;
      baseURLSlide.Name = this.txbName.Text;
      baseURLSlide.PresentationSize = Document.ActiveDocument.PresentationSize;
      baseURLSlide.MouseCursorVisible = true;

      // Store Stop conditions
      foreach (StopCondition cond in this.lsbStopConditions.Items)
      {
        baseURLSlide.StopConditions.Add(cond);
      }

      Bitmap screenshot = WebsiteThumbnailGenerator.GetWebSiteScreenshot(
        this.txbURL.Text,
        Document.ActiveDocument.PresentationSize);
      string screenshotFilename = GetFilenameFromUrl(new Uri(this.txbURL.Text));
      var filename = Path.Combine(Document.ActiveDocument.ExperimentSettings.SlideResourcesPath, screenshotFilename);
      screenshot.Save(filename, System.Drawing.Imaging.ImageFormat.Png);

      VGScrollImage baseURLScreenshot = new VGScrollImage(
        ShapeDrawAction.None,
        Pens.Transparent,
        Brushes.Black,
        SystemFonts.DefaultFont,
        Color.Black,
        Path.GetFileName(screenshotFilename),
        Document.ActiveDocument.ExperimentSettings.SlideResourcesPath,
        ImageLayout.None,
        1f,
        Document.ActiveDocument.PresentationSize,
        VGStyleGroup.None,
        baseURLSlide.Name,
        string.Empty);

      baseURLSlide.VGStimuli.Add(baseURLScreenshot);
      this.browserTreeNode.Slide = baseURLSlide;

      // HtmlElementCollection es = webBrowser1.Document.GetElementsByTagName("a");
      // if (es != null && es.Count != 0)
      // {
      //  HtmlElement ele = es[0];
      //  //This line is optional, it only visually scolls the first link element into view
      //  ele.ScrollIntoView(true);
      //  ele.Focus();
      // SendKeys.Send("{ENTER}");
      // }
      return this.browserTreeNode;
    }
Example #10
0
    ///////////////////////////////////////////////////////////////////////////////
    // Methods and Eventhandling for Background tasks                            //
    ///////////////////////////////////////////////////////////////////////////////
    #region THREAD
    #endregion //THREAD

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

    /// <summary>
    /// Update the dialog forms fields with the content from the given <see cref="BrowserTreeNode"/>.
    /// </summary>
    /// <param name="browserTreeNode">The <see cref="BrowserTreeNode"/> whichs content should
    /// be shown in the dialog.</param>
    private void PopulateDialogWithBrowserTreeNode(BrowserTreeNode browserTreeNode)
    {
      this.browserTreeNode = browserTreeNode;

      // Common properties
      this.txbName.Text = browserTreeNode.Text;
      this.cbbCategory.Text = browserTreeNode.Category;
      this.txbURL.Text = browserTreeNode.OriginURL;
      this.nudBrowseDepth.Value = browserTreeNode.BrowseDepth;

      // Tab Timing
      foreach (StopCondition condition in browserTreeNode.Slide.StopConditions)
      {
        this.lsbStopConditions.Items.Add(condition);
      }
    }
Example #11
0
    /// <summary>
    /// This method is a custom deserialization with an <see cref="XmlSerializer"/>
    /// to read the contents of the <see cref="SlideshowTreeNode"/> that 
    /// are exposed in this override.
    /// It deserializes recursively.
    /// </summary>
    /// <param name="reader">The <see cref="XmlReader"/> to use.</param>
    /// <param name="node">The <see cref="SlideshowTreeNode"/> to deserialize.</param>
    public virtual void DeserializeNode(XmlReader reader, SlideshowTreeNode node)
    {
      var slideSerializer = new XmlSerializer(typeof(Slide));

      // Check for older versions of Ogama 1.X 
      if (reader.Name == "Slides")
      {
        // A List<Slide> instead of SlideshowTreeNodes
        // in the slideshow node
        reader.ReadStartElement("Slides");
        this.ParseOgamaV1Slideshow(reader, slideSerializer);
        reader.ReadEndElement();
      }
      else if (reader.Name == "Slide")
      {
        // Directly the slides in the slideshow node
        this.ParseOgamaV1Slideshow(reader, slideSerializer);
      }
      else
      {
        // Ogama V2 format
        reader.ReadStartElement("SlideshowTreeNode");
        reader.ReadStartElement("Name");
        node.Name = reader.ReadString();
        reader.ReadEndElement();
        reader.ReadStartElement("Randomize");
        node.Randomize = reader.ReadContentAsBoolean();
        reader.ReadEndElement();
        reader.ReadStartElement("NumberOfItemsToUse");
        node.NumberOfItemsToUse = reader.ReadContentAsInt();
        reader.ReadEndElement();

        if (reader.Name == "Slide")
        {
          node.Slide = (Slide)slideSerializer.Deserialize(reader);
        }

        reader.ReadStartElement("Tag");
        if (reader.Value != string.Empty)
        {
          node.Tag = reader.ReadContentAsString();
          reader.ReadEndElement();
        }

        reader.ReadStartElement("Text");
        node.Text = reader.ReadContentAsString();
        reader.ReadEndElement();
        while ((reader.Name == "SlideshowTreeNode" && reader.NodeType == XmlNodeType.Element) ||
          (reader.Name == "BrowserTreeNode" && reader.NodeType == XmlNodeType.Element))
        {
          if (reader.Name == "SlideshowTreeNode")
          {
            var newNode = new SlideshowTreeNode();
            newNode.DeserializeNode(reader, newNode);
            this.SetTreeNodeImageKey(newNode);
            node.Nodes.Add(newNode);
          }
          else if (reader.Name == "BrowserTreeNode")
          {
            var newNode = new BrowserTreeNode();
            newNode.DeserializeNode(reader, newNode);
            this.SetTreeNodeImageKey(newNode);
            node.Nodes.Add(newNode);
          }
        }

        reader.ReadEndElement();

        reader.MoveToContent();
      }
    }
Example #12
0
    /// <summary>
    /// Opens a <see cref="BrowserDialog"/> form, waits for successful
    /// design and updates slideshow with the designed <see cref="BrowserTreeNode"/>.
    /// </summary>
    /// <param name="node">Contains the node that is 
    /// modified or null if this should be a new slide.</param>
    private void OpenBrowserDesignerForm(BrowserTreeNode node)
    {
      BrowserDialog dlg = new BrowserDialog();
      if (node != null)
      {
        dlg.BrowserNode = node;
      }

      if (dlg.ShowDialog() == DialogResult.OK)
      {
        BrowserTreeNode newNode = dlg.BrowserNode;
        if (node != null)
        {
          newNode.UrlToID.Clear();
          newNode.UrlToID.Add(newNode.OriginURL, Convert.ToInt32(node.Name));
          node = newNode;
        }
        else
        {
          this.AddBrowserSlide(newNode);
        }

        this.SlideShowModified();
      }
    }
Example #13
0
    /// <summary>
    /// This method adds the given <see cref="BrowserTreeNode"/> at the
    /// current treeview position.
    /// </summary>
    /// <param name="newBrowserSlideNode">The new <see cref="BrowserTreeNode"/> to be added to the slideshow.</param>
    private void AddBrowserSlide(BrowserTreeNode newBrowserSlideNode)
    {
      // Add node
      string newID = this.slideshow.GetUnusedNodeID();
      newBrowserSlideNode.Name = newID;
      newBrowserSlideNode.UrlToID.Add(newBrowserSlideNode.OriginURL, Convert.ToInt32(newID));

      // Get root node for insertion
      SlideshowTreeNode firstNode = this.trvSlideshow.Nodes[0] as SlideshowTreeNode;

      // If there is a selected node use this instead
      NodesCollection selectedNodes = this.trvSlideshow.SelectedNodes;
      if (selectedNodes.Count > 0)
      {
        firstNode = selectedNodes[0] as SlideshowTreeNode;
        this.trvSlideshow.SelectedNodes.Clear();
      }

      // Add to node, if it is a slide node add to parent instead
      if (firstNode.Slide != null)
      {
        firstNode.Parent.Nodes.Add(newBrowserSlideNode);
      }
      else
      {
        firstNode.Nodes.Add(newBrowserSlideNode);
      }

      // Select added node.
      this.trvSlideshow.SelectedNodes.Add(newBrowserSlideNode);

      this.UpdateListView(this.trvSlideshow.SelectedNodes);
    }