public FlowComponentXML(FlowComponent fc)
 {
     this.left = (fc as Control).Left;
     this.top  = (fc as Control).Top;
     this.data = (ExecutionUnitDataBinding)fc.GetDataBinding();
     if (fc is FlowStart)
     {
         this.type = 1;
     }
     if (fc is FlowStop)
     {
         this.type = 2;
     }
     if (fc is FlowProcessing)
     {
         this.type = 3;
     }
     if (fc is FlowDecision)
     {
         this.type = 4;
     }
     if (this.type == 4)
     {
         //avem doi copii
         if (fc.GetDefaultNextControl() != null)
         {
             next1 = new FlowComponentXML(fc.GetDefaultNextControl());
         }
         if ((fc as FlowDecision).GetNegationNextControl() != null)
         {
             next2 = new FlowComponentXML((fc as FlowDecision).GetNegationNextControl() as FlowComponent);
         }
     }
     else
     {
         //avem un singur copil
         if (fc.GetDefaultNextControl() != null)
         {
             next1 = new FlowComponentXML(fc.GetDefaultNextControl());
         }
     }
 }
        public bool Execute()
        {
            if (BaseApplication.MainInstance == null)
            {
                //ramane apoi sa le numaram sa fie ok
                BaseApplication.MainInstance = new BaseApplication(1000);
            }
            FlowComponent       current = StartNode.GetDefaultNextControl();
            ExecutionUnitOutput eo      = null;
            Object dataToken            = null;

            while ((current != null) && (!(current is FlowStop)))
            {
                //trecem la urmatorul nod si executam tot ce se poate:d
                //procesam datele
                if (current is FlowProcessing)
                {
                    //eo=(current as ProcessingBlock).ProcessData(dataToken, BaseApplication.MainInstance);
                    //dataToken = (current as ProcessingBlock).ProcessData(dataToken, BaseApplication.MainInstance);
                    //if (dataToken == null) return false;
                    eo        = (current as FlowProcessing).ExecutionUnit.Execute(dataToken);
                    dataToken = eo.ObjectOutput;
                    if (dataToken == null)
                    {
                        return(false);
                    }

                    current = current.GetDefaultNextControl();
                }
                else if (current is FlowDecision)
                {
                    eo        = (current as FlowDecision).ExecutionUnit.Execute(dataToken);
                    dataToken = eo.ObjectOutput;
                    bool cond = eo.DecisionOutput;
                    //bool cond = (current as DecisionBlock).EvaluateCondition(dataToken, BaseApplication.MainInstance);
                    //dataToken = (current as DecisionBlock).GetData(dataToken, BaseApplication.MainInstance);
                    if (dataToken == null)
                    {
                        return(false);
                    }
                    if (cond)
                    {
                        current = (current as FlowDecision).GetDefaultNextControl();
                    }
                    else
                    {
                        current = ((current as FlowDecision).GetNegationNextControl() as FlowComponent);
                    }
                }
            }
            return(true);
        }