public ConditionManager(Condition condition, IMastAdapter mastInterface)
        {
            if (condition == null)
            {
                throw new NullReferenceException("Condition must not be null");
            }
            if (mastInterface == null)
            {
                throw new NullReferenceException("IMastAdapter must not be null.");
            }

            Condition     = condition;
            MastInterface = mastInterface;

            if (condition.type == ConditionType.@event)
            {
                eventHandler = ReflectionHelper.AttachEvent(MastInterface, condition.name, this, "OnEventFired");
            }

            //Wire up our child conditions.  Note - only top level conditions can be based on events, or things would get weird.
            foreach (Condition c in Condition.condition)
            {
                if (c.type == ConditionType.@event)
                {
                    throw new Exception("Event classed conditions can not be children");
                }
                ConditionManager cm = new ConditionManager(c, MastInterface)
                {
                    ParentCondition = this
                };
                Children.Add(cm);
            }
        }
        public ConditionManager(Condition condition, IMastAdapter mastInterface)
        {
            if (condition == null)
            {
                throw new NullReferenceException("Condition must not be null");
            }
            if (mastInterface == null)
            {
                throw new NullReferenceException("IMastAdapter must not be null.");
            }

            Condition = condition;
            MastInterface = mastInterface;

            if (condition.type == ConditionType.@event)
            {
                eventHandler = ReflectionHelper.AttachEvent(MastInterface, condition.name, this, "OnEventFired");
            }

            //Wire up our child conditions.  Note - only top level conditions can be based on events, or things would get weird.
            foreach (Condition c in Condition.condition)
            {
                if (c.type == ConditionType.@event)
                {
                    throw new Exception("Event classed conditions can not be children");
                }
                ConditionManager cm = new ConditionManager(c, MastInterface) { ParentCondition = this };
                Children.Add(cm);
            }
        }
        public Mainsail(IMastAdapter MastInterface)
        {
            UseDispatcherThread = true;
            UseTimelineChanged  = true;

            mastInterface = MastInterface;
            mastInterface.TimelineChanged += mastInterface_TimelineChanged;
            PollingFrequency = TimeSpan.FromMilliseconds(500);
        }
        //private bool spent = false;

        internal TriggerManager(Trigger trigger, IMastAdapter mastInterface)
        {
            if (trigger == null)
            {
                throw new NullReferenceException("Trigger must not be null.");
            }
            if (mastInterface == null)
            {
                throw new NullReferenceException("IMastAdapter must not be null.");
            }

            Trigger       = trigger;
            MastInterface = mastInterface;

            foreach (Condition c in trigger.startConditions)
            {
                ConditionManager cm = new ConditionManager(c, MastInterface);
                //We need to wire up events, for event type conditions, and this is also used for some property calculations around time
                //if (c.type == ConditionType.@event) {
                cm.EventFired += new EventHandler(OnConditionEventFired);
                //}
                StartConditions.Add(cm);
            }

            foreach (Condition c in trigger.endConditions)
            {
                ConditionManager cm = new ConditionManager(c, MastInterface)
                {
                    IsEndCondition = true
                };
                //if (c.type == ConditionType.@event) {
                cm.EventFired += new EventHandler(OnConditionEventFired);
                //}
                EndConditions.Add(cm);
            }

            //we just need this for 'per clip' events, to reset the flag
            //ReflectionHelper.AttachEvent(MastInterface, "OnItemEnd", this, "OnItemEnd");
        }
        //private bool spent = false;

        internal TriggerManager(Trigger trigger, IMastAdapter mastInterface)
        {
            if (trigger == null)
            {
                throw new NullReferenceException("Trigger must not be null.");
            }
            if (mastInterface == null)
            {
                throw new NullReferenceException("IMastAdapter must not be null.");
            }

            Trigger = trigger;
            MastInterface = mastInterface;

            foreach (Condition c in trigger.StartConditions)
            {
                ConditionManager cm = new ConditionManager(c, MastInterface);
                //We need to wire up events, for event type conditions, and this is also used for some property calculations around time
                //if (c.type == ConditionType.@event) {
                cm.EventFired += OnConditionEventFired;
                //}
                StartConditions.Add(cm);
            }

            foreach (Condition c in trigger.EndConditions)
            {
                ConditionManager cm = new ConditionManager(c, MastInterface) { IsEndCondition = true };
                //if (c.type == ConditionType.@event) {
                cm.EventFired += OnConditionEventFired;
                //}
                EndConditions.Add(cm);
            }

            //we just need this for 'per clip' events, to reset the flag
            //ReflectionHelper.AttachEvent(MastInterface, "OnItemEnd", this, "OnItemEnd");
        }
Exemple #6
0
 public Mainsail(IMastAdapter mastInterface)
 {
     MastInterface = mastInterface;
 }
        public Mainsail(IMastAdapter MastInterface)
        {
            UseDispatcherThread = true;
            UseTimelineChanged = true;

            mastInterface = MastInterface;
            mastInterface.TimelineChanged += mastInterface_TimelineChanged;
            PollingFrequency = TimeSpan.FromMilliseconds(500);
        }
Exemple #8
0
        public ConditionManager(Condition condition, IMastAdapter mastInterface)
        {
            if (condition == null)
            {
                throw new NullReferenceException("Condition must not be null");
            }
            if (mastInterface == null)
            {
                throw new NullReferenceException("IMastAdapter must not be null.");
            }

            Condition     = condition;
            MastInterface = mastInterface;

            if (condition.Type == ConditionType.Event)
            {
#if SILVERLIGHT
                var eventHandler = ReflectionHelper.AttachEvent(MastInterface, condition.Name, this, "OnEventFired");
                eventUnhookAction = () => ReflectionHelper.DetachEvent(MastInterface, eventHandler);
#else
                switch (condition.Name)
                {
                case "OnPlay":
                    MastInterface.OnPlay += OnEventFired;
                    eventUnhookAction     = () => MastInterface.OnPlay -= OnEventFired;
                    break;

                case "OnStop":
                    MastInterface.OnStop += OnEventFired;
                    eventUnhookAction     = () => MastInterface.OnStop -= OnEventFired;
                    break;

                case "OnPause":
                    MastInterface.OnPause += OnEventFired;
                    eventUnhookAction      = () => MastInterface.OnPause -= OnEventFired;
                    break;

                case "OnMute":
                    MastInterface.OnMute += OnEventFired;
                    eventUnhookAction     = () => MastInterface.OnMute -= OnEventFired;
                    break;

                case "OnVolumeChange":
                    MastInterface.OnVolumeChange += OnEventFired;
                    eventUnhookAction             = () => MastInterface.OnVolumeChange -= OnEventFired;
                    break;

                case "OnEnd":
                    MastInterface.OnEnd += OnEventFired;
                    eventUnhookAction    = () => MastInterface.OnEnd -= OnEventFired;
                    break;

                case "OnSeek":
                    MastInterface.OnSeek += OnEventFired;
                    eventUnhookAction     = () => MastInterface.OnSeek -= OnEventFired;
                    break;

                case "OnItemStart":
                    MastInterface.OnItemStart += OnEventFired;
                    eventUnhookAction          = () => MastInterface.OnItemStart -= OnEventFired;
                    break;

                case "OnItemEnd":
                    MastInterface.OnItemEnd += OnEventFired;
                    eventUnhookAction        = () => MastInterface.OnItemEnd -= OnEventFired;
                    break;

                case "OnFullScreenChange":
                    MastInterface.OnFullScreenChange += OnEventFired;
                    eventUnhookAction = () => MastInterface.OnFullScreenChange -= OnEventFired;
                    break;

                case "OnPlayerSizeChanged":
                    MastInterface.OnPlayerSizeChanged += OnEventFired;
                    eventUnhookAction = () => MastInterface.OnPlayerSizeChanged -= OnEventFired;
                    break;

                case "OnError":
                    MastInterface.OnError += OnEventFired;
                    eventUnhookAction      = () => MastInterface.OnError -= OnEventFired;
                    break;

                case "OnMouseOver":
                    MastInterface.OnMouseOver += OnEventFired;
                    eventUnhookAction          = () => MastInterface.OnMouseOver -= OnEventFired;
                    break;
                }

                //ReflectionHelper.AttachEvent(MastInterface, condition.Name, new EventHandler(OnEventFired));
#endif
            }

            //Wire up our child conditions.  Note - only top level conditions can be based on events, or things would get weird.
            foreach (Condition c in Condition.Conditions)
            {
                if (c.Type == ConditionType.Event)
                {
                    throw new Exception("Event classed conditions can not be children");
                }
                ConditionManager cm = new ConditionManager(c, MastInterface)
                {
                    ParentCondition = this
                };
                Children.Add(cm);
            }
        }
        public ConditionManager(Condition condition, IMastAdapter mastInterface)
        {
            if (condition == null)
            {
                throw new NullReferenceException("Condition must not be null");
            }
            if (mastInterface == null)
            {
                throw new NullReferenceException("IMastAdapter must not be null.");
            }

            Condition = condition;
            MastInterface = mastInterface;

            if (condition.Type == ConditionType.Event)
            {
#if SILVERLIGHT
                var eventHandler = ReflectionHelper.AttachEvent(MastInterface, condition.Name, this, "OnEventFired");
                eventUnhookAction = () => ReflectionHelper.DetachEvent(MastInterface, eventHandler);
#else

                switch (condition.Name)
                { 
                    case "OnPlay":
                        MastInterface.OnPlay += OnEventFired;
                        eventUnhookAction = () => MastInterface.OnPlay -= OnEventFired;
                        break;
                    case "OnStop":
                        MastInterface.OnStop += OnEventFired;
                        eventUnhookAction = () => MastInterface.OnStop -= OnEventFired;
                        break;
                    case "OnPause":
                        MastInterface.OnPause += OnEventFired;
                        eventUnhookAction = () => MastInterface.OnPause -= OnEventFired;
                        break;
                    case "OnMute":
                        MastInterface.OnMute += OnEventFired;
                        eventUnhookAction = () => MastInterface.OnMute -= OnEventFired;
                        break;
                    case "OnVolumeChange":
                        MastInterface.OnVolumeChange += OnEventFired;
                        eventUnhookAction = () => MastInterface.OnVolumeChange -= OnEventFired;
                        break;
                    case "OnEnd":
                        MastInterface.OnEnd += OnEventFired;
                        eventUnhookAction = () => MastInterface.OnEnd -= OnEventFired;
                        break;
                    case "OnSeek":
                        MastInterface.OnSeek += OnEventFired;
                        eventUnhookAction = () => MastInterface.OnSeek -= OnEventFired;
                        break;
                    case "OnItemStart":
                        MastInterface.OnItemStart += OnEventFired;
                        eventUnhookAction = () => MastInterface.OnItemStart -= OnEventFired;
                        break;
                    case "OnItemEnd":
                        MastInterface.OnItemEnd += OnEventFired;
                        eventUnhookAction = () => MastInterface.OnItemEnd -= OnEventFired;
                        break;
                    case "OnFullScreenChange":
                        MastInterface.OnFullScreenChange += OnEventFired;
                        eventUnhookAction = () => MastInterface.OnFullScreenChange -= OnEventFired;
                        break;
                    case "OnPlayerSizeChanged":
                        MastInterface.OnPlayerSizeChanged += OnEventFired;
                        eventUnhookAction = () => MastInterface.OnPlayerSizeChanged -= OnEventFired;
                        break;
                    case "OnError":
                        MastInterface.OnError += OnEventFired;
                        eventUnhookAction = () => MastInterface.OnError -= OnEventFired;
                        break;
                    case "OnMouseOver":
                        MastInterface.OnMouseOver += OnEventFired;
                        eventUnhookAction = () => MastInterface.OnMouseOver -= OnEventFired;
                        break;
                }

                //ReflectionHelper.AttachEvent(MastInterface, condition.Name, new EventHandler(OnEventFired));
#endif
            }

            //Wire up our child conditions.  Note - only top level conditions can be based on events, or things would get weird.
            foreach (Condition c in Condition.Conditions)
            {
                if (c.Type == ConditionType.Event)
                {
                    throw new Exception("Event classed conditions can not be children");
                }
                ConditionManager cm = new ConditionManager(c, MastInterface) { ParentCondition = this };
                Children.Add(cm);
            }
        }