Пример #1
0
        /// <summary>
        /// Called when the activity is dragged onto the design surface
        /// </summary>
        /// <remarks>
        /// Here I construct two child activities as well as the FlagsActivity.
        /// </remarks>
        /// <param name="host"></param>
        /// <returns></returns>
        protected override IComponent[] CreateComponentsCore(IDesignerHost host)
        {
            CompositeActivity parent = new DaysOfWeekActivity();

            parent.Activities.Add(new SequenceActivity());
            parent.Activities.Add(new SequenceActivity());

            return(new IComponent[] { parent });
        }
Пример #2
0
        public void SetWeekday(Activity activity, WeekdayEnum weekday)
        {
            Activity parent = activity.Parent;

            if ((null != parent) && (parent is DaysOfWeekActivity))
            {
                DaysOfWeekActivity.SetWeekday(activity, weekday);
            }
        }
Пример #3
0
        public WeekdayEnum GetWeekday(Activity activity)
        {
            WeekdayEnum weekday = WeekdayEnum.None;

            Activity parent = activity.Parent;

            if ((null != parent) && (parent is DaysOfWeekActivity))
            {
                weekday = (WeekdayEnum)DaysOfWeekActivity.GetWeekday(activity);
            }

            return(weekday);
        }
Пример #4
0
        /// <summary>
        /// An activity has been added - hookup to that activites Closed event
        /// </summary>
        /// <param name="executionContext"></param>
        /// <param name="addedActivity"></param>
        protected override void OnActivityChangeAdd(ActivityExecutionContext executionContext, Activity addedActivity)
        {
            if (null == executionContext)
            {
                throw new ArgumentNullException("executionContext");
            }
            if (null == addedActivity)
            {
                throw new ArgumentNullException("addedActivity");
            }

            DaysOfWeekActivity act = executionContext.Activity as DaysOfWeekActivity;

            if ((act.ExecutionStatus == ActivityExecutionStatus.Executing) && act.IsExecuting)
            {
                addedActivity.RegisterForStatusChange(Activity.ClosedEvent, this);
                executionContext.ExecuteActivity(addedActivity);
            }
        }
Пример #5
0
        /// <summary>
        /// Respond to status changes on child activities
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void IActivityEventListener <ActivityExecutionStatusChangedEventArgs> .OnEvent(object sender, ActivityExecutionStatusChangedEventArgs e)
        {
            if (null == sender)
            {
                throw new ArgumentNullException("sender");
            }
            if (null == e)
            {
                throw new ArgumentNullException("e");
            }

            ActivityExecutionContext context = sender as ActivityExecutionContext;

            if (null == context)
            {
                throw new ArgumentException("No execution context is available");
            }

            DaysOfWeekActivity act = context.Activity as DaysOfWeekActivity;

            e.Activity.UnregisterForStatusChange(Activity.ClosedEvent, this);
            bool canClose = true;

            for (int pos = 0; pos < act.EnabledActivities.Count; pos++)
            {
                Activity childAct = act.EnabledActivities[pos];
                if ((childAct.ExecutionStatus != ActivityExecutionStatus.Initialized) && (childAct.ExecutionStatus != ActivityExecutionStatus.Closed))
                {
                    canClose = false;
                    break;
                }
            }
            if (canClose)
            {
                context.CloseActivity();
            }
        }