public ActivityEditor(List<IActivityComponent> sources, IActivityComponent outboundActivity)
     : this(outboundActivity)
 {
     foreach (IActivityComponent source in sources)
     {
         //We first add an reference to collection belonging to this class
         this.AddSource(source);
     }
 }
        public void AddOutboundActivity(IActivityComponent item)
        {
            #region Validation 

            if (item == null)
                throw new ArgumentNullException
                    ("Null is not permitted.");

            #endregion
            
            this.SPMainActivity.Children.Add
                                (CreateOutboundParamComp(item));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="main">The object that we want to scan its siblings for menu</param>
        private ActivityEditor RetrieveSiblingsEditorMenu(IActivityComponent main)
        {
            if (main is ForLoopComponent)
                return null; //Not supported for now

            else 
                {
                    foreach (ActivityConnection conn in main.InputConn)
                        if (conn._editorMenu != null)
                            return conn._editorMenu;
                }

            return null;
        }
        public void RemoveSourceActivity(IActivityComponent item)
        {
            if (item == null)
                throw new ArgumentNullException("source cannot be null.");
            else if ((item as UIElement) == null)
                throw new ArgumentException("You can only remove an UIElement object.");


            if (myDictionary.ContainsKey(item))
            {
                (item as UIElement).Visibility = System.Windows.Visibility.Collapsed;
                SPSourceActivity.Children.Remove(myDictionary[item]);
                myDictionary[item].DestroyOutputLine(); //destroy its output line (if any exist)
                myDictionary.Remove(item);
            }
            
        }
        public void ValidateActivities
            (List<IActivityComponent> outboundComp, IActivityComponent inboundComp)
        {
            ActivityModel inboundModel = (inboundComp.DataContext as ActivityModel);

            foreach (ParamInputModel input in inboundModel.InputParam)
            {
                if (input.IsMandatory)
                {
                    if (input.ValueStr == null)
                        throw new NullValueForMandatoryParam
                                    ("The parameter " + input.Name + " from activity "
                                        + input.ParentName + " is mandatory but no data value " +
                                        "was found.");
                    //else
                    //  if (input.ValueStr == null)
                    //    throw new ArgumentNullException
                    //          ("input is mandatory!");

                    else
                        if (input.ValueStr.Length < 1)
                            throw new NullValueForMandatoryParam("The length of string value for paramter " + input.Name + " was less than 1.");

                        else if (input.ValueStr.Contains(":\\"))
                        {
                            throw new ArgumentException
                                ("Parameter " + input.Name + " of activity " + input.ParentName +
                                " has invalid data input. File reading from local machine is not supported for this application, " +
                                    "try parsing the entire file using the file content reader.");
                        }
                        else if ((input.DataType.ToLower() == "system.boolean")
                               && (input.ValueStr.ToLower() != "true" || input.ValueStr.ToLower() != "false"))
                            throw new ArgumentException("The Parameter " + input.Name + " for activity " + input.ParentName +
                                "is boolean type and thus it only can accept either true or false as its data value.");
                }
            }
        }
 public ActivityConnection(IActivityComponent input, Point startPtr)
     : base(startPtr)
 {
     Source = input;
     Loaded += new RoutedEventHandler(Line_Loaded);
 }
 private void UpdateParamEditorMenu(IActivityComponent deleter)
 {
     //Basically if a menu already exist, obviously something has to do something about it.
     if (_editorMenu != null)
     {
         _editorMenu.RemoveSource(deleter);
     }
 }
        public void DeleteLine(IActivityComponent deleter)
        {
            base.DeleteLine();
            //First thing to do is update the parameter menu to reflect this change.
            UpdateParamEditorMenu(deleter);

            OnConnRemove(new ConnectionEventArgs(InputSource.Name, OutputSource.Name, false));

            //In the line's perspective point of view the input source would be the output component.
            if (deleter.Equals(InputSource)) //if this line is an outgoing line for the deleter
            {
                Target.InputConn.Remove(this);
                

                #region Then remove all inputs related to this source on its target source

                ActivityModel model = OutputSource.DataContext as ActivityModel;

                if (model != null)
                {
                    foreach (ParamInputModel input in model.InputParam)
                    {
                        if (input.Value != null) //remove all the bindings
                        {
                            input.Value = null;
                            input.ValueStr = null;
                            (OutputSource as ActivityComponent).InputGate.GateStatus
                                                = IOGateComponent.Status.NeedsConfiguration;
                        }
                    }
                }

                #endregion
            }
        }
 public ActivityEditor(IActivityComponent source, IActivityComponent outboundActivity)
     : this(outboundActivity)
 {
     this.AddSource(source);
 }
 public ActivityEditor(IActivityComponent outboundActivity)
     : this()
 {
     Outbound = outboundActivity;
     ParamEditorCanvas.AddOutboundActivity(outboundActivity);
 }
 public void AddSource(IActivityComponent source)
 {
     _sources.Add(source);
     ParamEditorCanvas.AddSourceActivity(source);
 }
        public bool RemoveSource(IActivityComponent source)
        {
            if (_sources.Contains(source))
            {
                _sources.Remove(source);
                ParamEditorCanvas.RemoveSourceActivity(source);
                return true;
            }

            return false;
        }
 public ActivityEditor(List<IActivityComponent> sources, IActivityComponent outboundActivity, IActivityComponent[] nestedComps)
     : this(sources, outboundActivity)
 {
     foreach (IActivityComponent component in nestedComps)
     {
         //We first add an reference to collection belonging to this class
         ParamEditorCanvas.AddOutboundActivity(component);
     }
 }
 private void AddReferenceToDictionary(IActivityComponent activity, ParamOutboundComp paramModel)
 {
     this.myDictionary.Add(activity, paramModel);
 }
        private ParamOutboundComp CreateParamComponent
                                   (IActivityComponent activity)
        {
            ParamOutboundComp component = new ParamOutboundComp(this)
            {
                Name = activity.Name,
                DataContext = activity.DataContext
            };

            component.ParamValueChanged += new ParamOutboundComp.OnParamValueChangedEventHandler(component_ParamValueChanged);
            AddReferenceToDictionary(activity, component);

            return component;
        }
        private ParamInboundComp CreateOutboundParamComp
                           (IActivityComponent activity)
        {

            ParamInboundComp component = new ParamInboundComp(this)
            {
                Name = activity.Name,
                DataContext = activity.DataContext
            };
            component.ParamValueChanged += new ParamInboundComp.OnParamValueChangedEventHandler(component_ParamValueChanged);

            return component;
            /*return new ParamInboundComp(this)
            {
                Name = activity.Name,
                DataContext = activity.DataContext
            };*/
        }