﻿//version:1.0
//published by:Microsoft
//company:http://www.microsoft.com
//description:OOB Sequence Activity
//assembly:System.Workflow.Activities.dll

function SequenceActivity(element) {
	this.element = element	
	this.innerBar=document.createElement("DIV")
	this.innerBar.className="bar"
	this.innerBar.style["width"]=100+"%"
	this.innerBar.style["heigth"]=28+"px"
    this.innerBar.innerHTML = "<DIV id='"+element.id+"_id' class='idlabel'>"+element.id+"</DIV>"
    element.appendChild(this.innerBar)
    this.group = Quanticks.drag().createSimpleActivity(element, this.innerBar)
    this.Properties = new Array()
	this.RegisteredProperties = new Array()
	this.RegisteredProperties[0] = "Name"
	this.RegisteredProperties[1] = "Description"
	this.RegisteredProperties[2] = "Enabled"	
    //composite resize handling
	this.element.onresize=CompositeResize
	this.ActWidth = 160
	this.BlockWidth = 160
	this.noResizeFlag = false
}

SequenceActivity.GetToolboxIcon = function()
{
    return "http://netfxlive.com/images/activity.GIF";
}

SequenceActivity.prototype = {
    Initialize : function()
    {
		var innerConnector=document.createElement("DIV")
	    innerConnector.className="connector"
	    var innerImg=document.createElement("IMG")
	    innerImg.src="http://netfxlive.com/images/connector.gif"
        innerConnector.appendChild(innerImg);
	    connectors[connectors.length] = innerConnector
	    this.element.appendChild(innerConnector)
    },
    
    Serialize : function()
    {
        var activityFactory = Quanticks.activityFactory()
        var result = "";
        result += "<SequenceActivity "
        for (var propi = 0;propi<this.RegisteredProperties.length;propi++)
        {
            if (this.RegisteredProperties[propi]=="Name")
                result += "x:";
            if (typeof this.Properties[this.RegisteredProperties[propi]] != "undefined" && this.Properties[this.RegisteredProperties[propi]]!="")
                result += this.RegisteredProperties[propi]+"=\""+this.Properties[this.RegisteredProperties[propi]]+"\" ";
        }
        result += ">\n"   
        for(var ch=0;ch<this.element.children.length;ch++)
        {
            var childActivity = activityFactory.getActivity(this.element.children[ch])
            if (childActivity!=null)
            {
                result += childActivity.Serialize()
            }
        }
        result += "</SequenceActivity>\n"
        return result
    }
}

