Ejemplo n.º 1
0
        /// <summary>
        /// Filter the properties displayed on the UI so that I can add in the enum property
        /// </summary>
        /// <param name="properties"></param>
        protected override void PreFilterProperties(IDictionary properties)
        {
            base.PreFilterProperties(properties);
#if DEBUG
            Type actType = this.Activity.GetType();

            PropertyInfo pi = actType.GetProperty("EnumType");

            if (null != pi)
            {
                Type enumType = pi.GetValue(this.Activity, null) as Type;

                if (null != enumType)
                {
                    MethodInfo mi = actType.GetMethod("GetEnumTypePropertyDescriptor", BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { typeof(IDictionary) }, null);

                    if (null != mi)
                    {
                        mi.Invoke(this.Activity, new object[] { properties });
                    }
                }
            }
#else
            FlagsActivity act = this.Activity as FlagsActivity;

            if ((null != act) && (null != act.EnumType))
            {
                act.GetEnumTypePropertyDescriptor(properties);
            }
#endif
        }
Ejemplo n.º 2
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 System.ComponentModel.IComponent[] CreateComponentsCore(System.ComponentModel.Design.IDesignerHost host)
        {
            CompositeActivity parent = new FlagsActivity();

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

            return(new IComponent[] { parent });
        }
Ejemplo n.º 3
0
            /// <summary>
            /// Set the value of the property
            /// </summary>
            /// <param name="component"></param>
            /// <param name="value"></param>
            public override void SetValue(object component, object value)
            {
                FlagsActivity act = component as FlagsActivity;

                if (null != act)
                {
                    act.BoundData.Data = value as ActivityBind;
                }
            }
Ejemplo n.º 4
0
            /// <summary>
            /// Reset the value to the default
            /// </summary>
            /// <param name="component"></param>
            public override void ResetValue(object component)
            {
                FlagsActivity act = component as FlagsActivity;

                if (null != act)
                {
                    act.BoundData.Data = null;
                }
            }
Ejemplo n.º 5
0
            /// <summary>
            /// Return true if the value should be serialized
            /// </summary>
            /// <param name="component"></param>
            /// <returns></returns>
            public override bool ShouldSerializeValue(object component)
            {
                bool shouldSerialize = false;

                FlagsActivity act = component as FlagsActivity;

                if (null != act)
                {
                    shouldSerialize = null != act.BoundData.Data;
                }

                return(shouldSerialize);
            }
Ejemplo n.º 6
0
            /// <summary>
            /// Get the value of the property
            /// </summary>
            /// <param name="component"></param>
            /// <returns></returns>
            public override object GetValue(object component)
            {
                object value = null;

                FlagsActivity act = component as FlagsActivity;

                if (null != act)
                {
                    value = act.BoundData.Data;
                }

                return(value);
            }
Ejemplo n.º 7
0
            /// <summary>
            /// Return true if the value can be reset
            /// </summary>
            /// <param name="component"></param>
            /// <returns></returns>
            public override bool CanResetValue(object component)
            {
                bool canReset = false;

                FlagsActivity act = component as FlagsActivity;

                if (null != act)
                {
                    canReset = null != act.BoundData.Data;
                }

                return(canReset);
            }
Ejemplo n.º 8
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");
            }

            FlagsActivity act = executionContext.Activity as FlagsActivity;

            if ((act.ExecutionStatus == ActivityExecutionStatus.Executing) && act.IsExecuting)
            {
                addedActivity.RegisterForStatusChange(Activity.ClosedEvent, this);
                executionContext.ExecuteActivity(addedActivity);
            }
        }
Ejemplo n.º 9
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");
            }

            FlagsActivity act = context.Activity as FlagsActivity;

            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();
            }
        }