﻿//version:1.0
//published by:Microsoft
//company:http://www.microsoft.com
//description:OOB IfElseBranch Activity
//assembly:System.Workflow.Activities.dll

function IfElseBranchActivity(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
	this.noToolboxIcon = true
}

IfElseBranchActivity.GetToolboxIcon = function()
{
    return null;
}

IfElseBranchActivity.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 += "<IfElseBranchActivity x:Name=\""+this.Properties["Name"]+"\">\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 += "</IfElseBranchActivity>\n"
        return result
    }    
  /*  
    Resize : function(event)
    {
	    var factory = Quanticks.activityFactory()
	    var resizedActivity  = factory.getActivity(this)
	    if (resizedActivity.noResizeFlag)
	    {
	        resizedActivity.noResizeFlag = false
	    }
	    else
	    {
	        resizedActivity.noResizeFlag = true
			
	        var maxWidth = resizedActivity.ActWidth
	        for(jj=0;jj<this.children.length;jj++)
	        {
	            var childActicity = factory.getActivity(this.children[jj])
	            if (childActicity!=null)
	            {
	                if (childActicity.ActWidth > maxWidth)
	                    maxWidth = childActicity.ActWidth
	            }
	        }
	        resizedActivity.ActWidth = maxWidth + 12
	        this.style.width = maxWidth + 12
	    }
    }*/

}

