public override bool CanBeParentedTo(CompositeActivityDesigner parentActivityDesigner)
 {
     if (parentActivityDesigner == null)
     {
         throw new ArgumentNullException("parentActivityDesigner");
     }
     return ((parentActivityDesigner.Activity is StateActivity) && base.CanBeParentedTo(parentActivityDesigner));
 }
 public ConnectorHitTestInfo(CompositeActivityDesigner compositeActivityDesigner, HitTestLocations flags, int connector) : base(compositeActivityDesigner, flags)
 {
     if (this.connector < 0)
     {
         throw new ArgumentException(SR.GetString("Error_InvalidConnectorValue"), "connector");
     }
     this.connector = connector;
 }
        public override bool CanBeParentedTo(CompositeActivityDesigner parentActivityDesigner)
        {
            if (parentActivityDesigner == null)
                throw new ArgumentNullException("parentActivityDesigner");

            if (!(parentActivityDesigner.Activity is StateActivity))
                return false;

            return base.CanBeParentedTo(parentActivityDesigner);
        }
 public override bool CanBeParentedTo(CompositeActivityDesigner parentActivityDesigner)
 {
     for (Activity activity = parentActivityDesigner.Activity; activity != null; activity = activity.Parent)
     {
         if (((activity is CancellationHandlerActivity) || (activity is CompensationHandlerActivity)) || (activity is FaultHandlerActivity))
         {
             return true;
         }
     }
     return false;
 }
 public override bool CanBeParentedTo(CompositeActivityDesigner parentActivityDesigner)
 {
     if (parentActivityDesigner == null)
     {
         throw new ArgumentNullException("parentActivity");
     }
     if ((!Type.GetType("System.Workflow.Activities.ListenActivity,System.Workflow.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35").IsAssignableFrom(parentActivityDesigner.Activity.GetType()) && !(parentActivityDesigner.Activity is EventHandlersActivity)) && !Type.GetType("System.Workflow.Activities.StateActivity,System.Workflow.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35").IsAssignableFrom(parentActivityDesigner.Activity.GetType()))
     {
         return false;
     }
     return base.CanBeParentedTo(parentActivityDesigner);
 }
 public override bool CanBeParentedTo(CompositeActivityDesigner parentActivityDesigner)
 {
     if (parentActivityDesigner == null)
     {
         throw new ArgumentNullException("parentActivity");
     }
     if ((parentActivityDesigner.Activity != null) && !(parentActivityDesigner.Activity is EventHandlingScopeActivity))
     {
         return false;
     }
     return base.CanBeParentedTo(parentActivityDesigner);
 }
        public override bool CanBeParentedTo(CompositeActivityDesigner parentActivityDesigner)
        {
            if (parentActivityDesigner == null)
                throw new ArgumentNullException("parentActivity");

            if (!(Type.GetType("System.Workflow.Activities.ListenActivity," + AssemblyRef.ActivitiesAssemblyRef).IsAssignableFrom(parentActivityDesigner.Activity.GetType())) &&
                !(parentActivityDesigner.Activity is EventHandlersActivity) &&
                !(Type.GetType("System.Workflow.Activities.StateActivity," + AssemblyRef.ActivitiesAssemblyRef).IsAssignableFrom(parentActivityDesigner.Activity.GetType())))
                return false;

            return base.CanBeParentedTo(parentActivityDesigner);
        }
        public override bool CanBeParentedTo(CompositeActivityDesigner parentActivityDesigner)
        {
            Activity parentActivity = parentActivityDesigner.Activity;
            while (parentActivity != null)
            {
                if (parentActivity is CancellationHandlerActivity || parentActivity is CompensationHandlerActivity || parentActivity is FaultHandlerActivity)
                    return true;

                parentActivity = parentActivity.Parent;
            }

            return false;
        }
 public override bool CanBeParentedTo(CompositeActivityDesigner parentActivityDesigner)
 {
     if (parentActivityDesigner == null)
     {
         throw new ArgumentNullException("parentActivityDesigner");
     }
     CompositeActivity parentActivity = parentActivityDesigner.Activity as CompositeActivity;
     if (parentActivity == null)
     {
         return false;
     }
     if (!ValidateParent(parentActivity))
     {
         return false;
     }
     return base.CanBeParentedTo(parentActivityDesigner);
 }
 private void SetAutoExpandableDesigner(CompositeActivityDesigner value)
 {
     if (this.autoExpandableDesigner != value)
     {
         if (((value == null) || value.Expanded) || !value.CanExpandCollapse)
         {
             this.autoExpandableDesigner = null;
             if (this.autoExpandEventHandler != null)
             {
                 WorkflowTimer.Default.Unsubscribe(this.autoExpandEventHandler);
                 this.autoExpandEventHandler = null;
             }
         }
         else
         {
             this.autoExpandableDesigner = value;
             if (this.autoExpandEventHandler == null)
             {
                 this.autoExpandEventHandler = new EventHandler(this.OnAutoExpand);
                 WorkflowTimer.Default.Subscribe(500, this.autoExpandEventHandler);
             }
         }
     }
 }
        /// <summary>
        /// Returns if a CompositeActivity can be set as parent of activity associated with designer.
        /// This method is called in case of insertion operation such as Drag-Drop or Paste.
        /// </summary>
        /// <param name="parentActivity">CompositeActivity which can be potentially set as parent.</param>
        /// <returns>True if the CompositeActivity can be set as parent of activity associated with designer, false otherwise.</returns>
        public virtual bool CanBeParentedTo(CompositeActivityDesigner parentActivityDesigner)
        {
            if (parentActivityDesigner == null)
                throw new ArgumentNullException("parentActivityDesigner");

            return true;
        }
 public override bool CanBeParentedTo(CompositeActivityDesigner parentActivityDesigner)
 {
     return false;
 }
        private void SetAutoExpandableDesigner(CompositeActivityDesigner value)
        {
            if (this.autoExpandableDesigner == value)
                return;

            //We always remove this so that the timer counter gets reset
            if (value == null || value.Expanded || !value.CanExpandCollapse)
            {
                this.autoExpandableDesigner = null;
                if (this.autoExpandEventHandler != null)
                {
                    WorkflowTimer.Default.Unsubscribe(this.autoExpandEventHandler);
                    this.autoExpandEventHandler = null;
                }
            }
            else
            {
                //User has to hover for 2 seconds
                this.autoExpandableDesigner = value;
                if (this.autoExpandEventHandler == null)
                {
                    this.autoExpandEventHandler = new EventHandler(OnAutoExpand);
                    WorkflowTimer.Default.Subscribe(500, this.autoExpandEventHandler);
                }
            }
        }
 public CompositeDesignerAccessibleObject(CompositeActivityDesigner activityDesigner) : base(activityDesigner)
 {
 }
 public static void InsertActivities(CompositeActivityDesigner compositeActivityDesigner, System.Workflow.ComponentModel.Design.HitTestInfo insertLocation, ReadOnlyCollection<Activity> activitiesToInsert, string undoTransactionDescription)
 {
     if (compositeActivityDesigner == null)
     {
         throw new ArgumentNullException("compositeActivityDesigner");
     }
     if (((compositeActivityDesigner.Activity == null) || (compositeActivityDesigner.Activity.Site == null)) || !(compositeActivityDesigner.Activity is CompositeActivity))
     {
         throw new ArgumentException("compositeActivityDesigner");
     }
     if (insertLocation == null)
     {
         throw new ArgumentNullException("insertLocation");
     }
     if (activitiesToInsert == null)
     {
         throw new ArgumentNullException("activitiesToInsert");
     }
     IDesignerHost service = compositeActivityDesigner.Activity.Site.GetService(typeof(IDesignerHost)) as IDesignerHost;
     DesignerTransaction transaction = null;
     if ((service != null) && !string.IsNullOrEmpty(undoTransactionDescription))
     {
         transaction = service.CreateTransaction(undoTransactionDescription);
     }
     bool flag = false;
     try
     {
         foreach (Activity activity in activitiesToInsert)
         {
             if (activity == null)
             {
                 throw new ArgumentException("activitiesToInsert", SR.GetString("Error_CollectionHasNullEntry"));
             }
             flag = activity.Site != null;
             break;
         }
         if (flag)
         {
             compositeActivityDesigner.MoveActivities(insertLocation, activitiesToInsert);
         }
         else
         {
             compositeActivityDesigner.InsertActivities(insertLocation, activitiesToInsert);
         }
         if (transaction != null)
         {
             transaction.Commit();
         }
     }
     catch (Exception exception)
     {
         if (transaction != null)
         {
             transaction.Cancel();
         }
         throw exception;
     }
     if (!flag)
     {
         ArrayList list = new ArrayList();
         foreach (Activity activity2 in activitiesToInsert)
         {
             list.Add(activity2);
             if (activity2 is CompositeActivity)
             {
                 list.AddRange(Helpers.GetNestedActivities((CompositeActivity) activity2));
             }
         }
     }
 }
        public override bool CanBeParentedTo(CompositeActivityDesigner parentActivityDesigner)
        {
            if (parentActivityDesigner == null)
                throw new ArgumentNullException("parentActivityDesigner");

            CompositeActivity parentActivity = parentActivityDesigner.Activity as CompositeActivity;
            if (parentActivity == null)
                return false;

            bool result = ValidateParent(parentActivity);
            if (!result)
                return false;

            return base.CanBeParentedTo(parentActivityDesigner);
        }
        /// <summary>
        /// Inserts activities in specified composite activity designer by creating transaction
        /// </summary>
        /// <param name="compositeActivityDesigner">Designer in which to insert the activities</param>
        /// <param name="insertLocation">Insertion location</param>
        /// <param name="activitiesToInsert">Array of activities to insert</param>
        /// <param name="undoTransactionDescription">Text for the designer transaction which will be created</param>
        public static void InsertActivities(CompositeActivityDesigner compositeActivityDesigner, HitTestInfo insertLocation, ReadOnlyCollection<Activity> activitiesToInsert, string undoTransactionDescription)
        {
            if (compositeActivityDesigner == null)
                throw new ArgumentNullException("compositeActivityDesigner");

            if (compositeActivityDesigner.Activity == null ||
                compositeActivityDesigner.Activity.Site == null ||
                !(compositeActivityDesigner.Activity is CompositeActivity))
                throw new ArgumentException("compositeActivityDesigner");

            if (insertLocation == null)
                throw new ArgumentNullException("insertLocation");

            if (activitiesToInsert == null)
                throw new ArgumentNullException("activitiesToInsert");

            ISite site = compositeActivityDesigner.Activity.Site;

            // now insert the actual activities
            IDesignerHost designerHost = site.GetService(typeof(IDesignerHost)) as IDesignerHost;
            DesignerTransaction trans = null;
            if (designerHost != null && !string.IsNullOrEmpty(undoTransactionDescription))
                trans = designerHost.CreateTransaction(undoTransactionDescription);

            bool moveCase = false;
            try
            {
                //Detect if the activities are being moved or inserted
                foreach (Activity activity in activitiesToInsert)
                {
                    if (activity == null)
                        throw new ArgumentException("activitiesToInsert", SR.GetString(SR.Error_CollectionHasNullEntry));

                    moveCase = ((IComponent)activity).Site != null;
                    break;
                }

                //We purposely create a new instance of activities list so that we do not modify the original one
                if (moveCase)
                    compositeActivityDesigner.MoveActivities(insertLocation, activitiesToInsert);
                else
                    compositeActivityDesigner.InsertActivities(insertLocation, activitiesToInsert);

                if (trans != null)
                    trans.Commit();
            }
            catch (Exception e)
            {
                if (trans != null)
                    trans.Cancel();

                throw e;
            }

            //If we are just moving the activities then we do not need to emit the class
            //for scopes; only when we are adding the activities the class needs to be emitted for
            //scope in code beside file
            if (!moveCase)
            {
                // if everything was successful then generate classes correposnding to new scopes
                // get all the activities underneath the child activities
                ArrayList allActivities = new ArrayList();
                foreach (Activity activity in activitiesToInsert)
                {
                    allActivities.Add(activity);
                    if (activity is CompositeActivity)
                        allActivities.AddRange(Helpers.GetNestedActivities((CompositeActivity)activity));
                }
            }
        }
            internal ContainedDesignSurface(IServiceProvider parentServiceProvider, CompositeActivityDesigner parentDesigner)
                : base(parentServiceProvider)
            {
                this.parentDesigner = parentDesigner;

                if (ServiceContainer != null)
                    ServiceContainer.RemoveService(typeof(ISelectionService));
            }