Exemplo n.º 1
0
 /// <summary>
 /// Class for a block creation ev.
 /// </summary>
 /// <param name="block">The created block.  Null for a blank ev.</param>
 public Create(Block block)
     : base(block, Events.CREATE)
 {
     if (block == null)
     {
         return;                      // Blank ev to be populated by fromJson.
     }
     xml = Xml.blockToDomWithXY(block);
     ids = Events.getDescendantIds_(block);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Encode a block tree as XML.
        /// </summary>
        /// <param name="workspace">workspace The workspace containing blocks.</param>
        /// <param name="opt_noId">True if the encoder should skip the block ids.</param>
        /// <returns>XML document.</returns>
        public static Element workspaceToDom(Workspace workspace, bool opt_noId = false)
        {
            var xml    = goog.dom.createDom("xml");
            var blocks = workspace.getTopBlocks(true);

            foreach (var block in blocks)
            {
                xml.AppendChild(Xml.blockToDomWithXY(block, opt_noId));
            }
            return(xml);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Class for a block deletion ev.
 /// </summary>
 /// <param name="block">The deleted block.  Null for a blank ev.</param>
 public Delete(Block block)
     : base(block, Events.DELETE)
 {
     if (block == null)
     {
         return;                      // Blank ev to be populated by fromJson.
     }
     if (block.getParent() != null)
     {
         throw new Exception("Connected blocks cannot be deleted.");
     }
     oldXml = Xml.blockToDomWithXY(block);
     ids    = Events.getDescendantIds_(block);
 }