public MultiDataTriggerItem(MultiDataTrigger trigger, FrameworkElement source, TriggerSource triggerSource)
     : base(source, TriggerType.MultiDataTrigger, triggerSource)
 {
     _trigger = trigger;
     _source = source;
 }
 public static TriggerItemBase GetTriggerItem(TriggerBase trigger, FrameworkElement source, TriggerSource triggerSource)
 {
     TriggerItemBase triggerItem;
     if (trigger is Trigger)
     {
         triggerItem = new TriggerItem((Trigger)trigger, source, triggerSource);
     }
     else if (trigger is DataTrigger)
     {
         triggerItem = new DataTriggerItem((DataTrigger)trigger, source, triggerSource);
     }
     else if (trigger is MultiTrigger)
     {
         triggerItem = new MultiTriggerItem((MultiTrigger)trigger, source, triggerSource);
     }
     else if (trigger is MultiDataTrigger)
     {
         triggerItem = new MultiDataTriggerItem((MultiDataTrigger)trigger, source, triggerSource);
     }
     else
     {
         return null;
     }
     triggerItem.Initialize();
     return triggerItem;
 }
        private AdaptiveCostEffect(AdaptiveCostEffect prototype, IPlayable owner)
        {
            if (!(owner is Playable p))
            {
                throw new Exception($"Can't activate {this} to non-playable {owner}");
            }

            _owner = p;

            if (prototype._triggerType != TriggerType.NONE)
            {
                _value             = prototype._value;
                _triggerType       = prototype._triggerType;
                _triggerSource     = prototype._triggerSource;
                _condition         = prototype._condition;
                _updateHandler     = Trigger;
                _removedHandler    = RemoveAtEnd;
                _isTriggered       = prototype._isTriggered;
                _isAppliedThisTurn = prototype._isAppliedThisTurn;
            }
            else
            {
                _costFunction = prototype._costFunction;
            }
        }
        /// <summary>
        /// 定义将TriggerSource枚举类型变量转变为字符类型的函数
        /// </summary>
        /// <param name="source_1"></param>
        /// <returns></returns>
        private string TriggerSoureSwitch(TriggerSource source_1)
        {
            string str = "Channel1";

            //str = source_1.ToString();
            switch (source_1)
            {
            case TriggerSource.Channel1:
                str = "CHANnel1";
                break;

            case TriggerSource.Channel2:
                str = "CHANnel2";
                break;

            case TriggerSource.Channel3:
                str = "CHANnel3";
                break;

            case TriggerSource.Channel4:
                str = "CHANnel4";
                break;

            case TriggerSource.Aux:
                str = "AUX";
                break;

            default:
                str = "LINE";
                break;
            }
            return(str);
        }
        private AdaptiveCostEffectObsolete(AdaptiveCostEffectObsolete prototype, IPlayable owner)
        {
            if (!(owner is Playable p))
            {
                throw new Exception($"Can't activate {this} to non-playable {owner}");
            }

            _owner = p;

            _costFunction      = prototype._costFunction;
            _value             = prototype._value;
            _triggerType       = prototype._triggerType;
            _triggerSource     = prototype._triggerSource;
            _condition         = prototype._condition;
            _updateHandler     = Trigger;
            _removedHandler    = RemoveAtEnd;
            _isTriggered       = prototype._isTriggered;
            _isAppliedThisTurn = prototype._isAppliedThisTurn;

            if (prototype._initialisationFunction != null)
            {
                _initialisationFunction = prototype._initialisationFunction;
                _cachedValue            = prototype._initialisationFunction.Invoke(p);
            }
        }
        public static void Handle(TriggerSourceHandlerHelperContext context, TriggerSource triggerSource, int?moduleID = null)
        {
            var trigger = triggerSource.Trigger;

            var triggerSourceHandler = context.TriggerSourceHandlers[triggerSource.Type];
            var method = context.TriggerDelegates[triggerSource.TriggerID];

            var properties = new Dictionary <string, object>();

            foreach (var triggerDependency in trigger.TriggerDependencies)
            {
                var triggerDependencyHandler = context.TriggerDependencyHandlers.GetValueOrDefault(triggerDependency.Type);
                if (triggerDependencyHandler == null)
                {
                    continue;
                }

                if (triggerDependencyHandler.IsModuleIdentityRequired && !moduleID.HasValue)
                {
                    continue;
                }

                properties.Add(triggerDependencyHandler.Handle(context.DatabaseContext, moduleID));
            }

            var methodContext = new TriggerDelegateContext(context.TriggerDateTime, properties);

            method(methodContext);

            triggerSourceHandler?.Handle(context, triggerSource);
        }
 /// <summary>
 /// Creates an Adaptive Cost Effect that sets cost of the owner to a specific value
 /// until the end of the turn when the given criterion is satisfied. (e.g. Happy Ghoul, Arcane Tyrant)
 /// </summary>
 /// <param name="value">The value to set.</param>
 /// <param name="trigger">The type of trigger this effect should check.</param>
 /// <param name="triggerSource">The specific type of source entities that can invoke the trigger.</param>
 /// <param name="triggerCondition">Condition to be applied to the source of the trigger.</param>
 public AdaptiveCostEffect(int value, TriggerType trigger,
                           TriggerSource triggerSource = TriggerSource.ALL, SelfCondition triggerCondition = null)
 {
     _value         = value;
     _triggerType   = trigger;
     _triggerSource = triggerSource;
     _condition     = triggerCondition;
 }
示例#8
0
 public AdaptiveCostEffect(Func <Playable, int> initialisationFunction, Func <IPlayable, int> triggerValueFunction, TriggerType trigger,
                           TriggerSource triggerSource = TriggerSource.ALL, SelfCondition triggerCondition = null)
 {
     _initialisationFunction = initialisationFunction;
     _costFunction           = triggerValueFunction;
     _triggerType            = trigger;
     _triggerSource          = triggerSource;
     _condition = triggerCondition;
 }
 /// <summary>
 /// Creates an Adaptive Cost Effect that sets cost of the owner to a specific value
 /// until the end of the turn when the given criterion is satisfied. (e.g. Happy Ghoul, Arcane Tyrant)
 /// </summary>
 /// <param name="value">The value to set.</param>
 /// <param name="trigger">The type of trigger this effect should check.</param>
 /// <param name="triggerSource">The specific type of source entities that can invoke the trigger.</param>
 /// <param name="triggerCondition">Condition to be applied to the source of the trigger.</param>
 public AdaptiveCostEffectObsolete(int value, TriggerType trigger,
                                   TriggerSource triggerSource = TriggerSource.ALL, SelfCondition triggerCondition = null)
 {
     Contract.Requires(trigger != TriggerType.NONE);
     _value         = value;
     _triggerType   = trigger;
     _triggerSource = triggerSource;
     _condition     = triggerCondition;
 }
 public AdaptiveCostEffectObsolete(Func <Playable, int> initialisationFunction, Func <IPlayable, int> triggerValueFunction, TriggerType trigger,
                                   TriggerSource triggerSource = TriggerSource.ALL, SelfCondition triggerCondition = null)
 {
     Contract.Requires(trigger != TriggerType.NONE);
     _initialisationFunction = initialisationFunction;
     _costFunction           = triggerValueFunction;
     _triggerType            = trigger;
     _triggerSource          = triggerSource;
     _condition = triggerCondition;
 }
示例#11
0
 public TriggerValue(TriggerValue t) : this()
 {
     mode          = t.mode;
     source        = t.source;
     channel       = t.channel;
     Digital       = new Dictionary <DigitalChannel, DigitalTriggerValue>(t.Digital);
     edge          = t.edge;
     level         = t.level;
     pulseWidthMax = t.pulseWidthMax;
     pulseWidthMin = t.pulseWidthMin;
 }
示例#12
0
        public void Handle(TriggerSourceHandlerContext triggerSourceHandlerContext, TriggerSource source)
        {
            // ReSharper disable once PossibleInvalidOperationException
            source.NextAbsoluteTimeExecution = DateTime.Now.AddDays(1).ReplaceTime(source.AbsoluteTime.Value);

            triggerSourceHandlerContext.DatabaseContext.EnqueueUpdate <TriggerSource>(
                i => i.ID == source.ID,
                i => i.NextAbsoluteTimeExecution == source.NextAbsoluteTimeExecution);

            triggerSourceHandlerContext.DatabaseContext.SaveChanges();
        }
示例#13
0
 protected Trigger(Trigger prototype, IEntity owner)
 {
     Game                 = owner.Game;
     _sourceId            = owner.Id;
     _owner               = (IPlayable)owner;
     _triggerType         = prototype._triggerType;
     _sequenceType        = prototype._sequenceType;
     TriggerSource        = prototype.TriggerSource;
     Condition            = prototype.Condition;
     SingleTask           = prototype.SingleTask;
     EitherTurn           = prototype.EitherTurn;
     FastExecution        = prototype.FastExecution;
     RemoveAfterTriggered = prototype.RemoveAfterTriggered;
     _isSecret            = prototype.Game == null ? owner.Card.IsSecret : prototype._isSecret;
     IsAncillaryTrigger   = prototype.IsAncillaryTrigger;
 }
示例#14
0
 private Trigger(Trigger prototype, IEntity owner)
 {
     Game                 = owner.Game;
     _sourceId            = owner.Id;
     _owner               = (IPlayable)owner;
     _controllerId        = owner.Controller?.Id ?? prototype._controllerId;
     _triggerType         = prototype._triggerType;
     _sequenceType        = prototype._sequenceType;
     TriggerSource        = prototype.TriggerSource;
     Condition            = prototype.Condition;
     SingleTask           = prototype.SingleTask;
     EitherTurn           = prototype.EitherTurn;
     FastExecution        = prototype.FastExecution;
     RemoveAfterTriggered = prototype.RemoveAfterTriggered;
     _isSecret            = prototype.Game == null ? owner.Card[GameTag.SECRET] == 1 : prototype._isSecret;
     IsAncillaryTrigger   = prototype.IsAncillaryTrigger;
 }
            protected virtual void SetTriggerSource(TriggerSource triggerSource)
            {
                _triggerSource = triggerSource;
                switch (triggerSource)
                {
                case TriggerSource.Bus:
                    WriteString("TRIGger:SOURce BUS");
                    break;

                case TriggerSource.Immediate:
                    WriteString("TRIGger:SOURce IMMediate");
                    break;

                case TriggerSource.External:
                    WriteString("TRIGger:SOURce EXTernal");
                    break;
                }
            }
示例#16
0
        public bool SetTriggerSource(TriggerSource triggerSource)
        {
            try
            {
                if (triggerSource == TriggerSource.Software)
                {
                    if (mDevice.RemoteNodeList["TriggerSource"].EnumNodeList.GetNodePresent("SoftwareTrigger"))
                    {
                        mDevice.RemoteNodeList["TriggerSource"].Value = "SoftwareTrigger";
                    }
                    else
                    {
                        mDevice.RemoteNodeList["TriggerSource"].Value = "Software";
                    }
                    return(true);
                }
                else if (triggerSource == TriggerSource.Hardware)
                {
                    mDevice.RemoteNodeList["TriggerSource"].Value = "Line0";
                }
                else if (triggerSource == TriggerSource.All)
                {
                    mDevice.RemoteNodeList["TriggerSource"].Value = "All";
                }
                else
                {
                    mDevice.RemoteNodeList["TriggerSource"].Value = "Off";
                }

                //mDataStream.StartAcquisition();
                //mDevice.RemoteNodeList["AcquisitionStart"].Execute();
                return(true);
            }

            catch (BGAPI2.Exceptions.IException ex)
            {
                string str;
                str = string.Format("ExceptionType:{0}! ErrorDescription:{1} in function:{2}", ex.GetType(), ex.GetErrorDescription(), ex.GetFunctionName());
                MessageBox.Show(str);

                return(false);
            }
        }
示例#17
0
        private AdaptiveCostEffect(AdaptiveCostEffect prototype, IPlayable owner)
        {
            if (!(owner is Playable p))
            {
                throw new Exception($"Can't activate {this} to non-playable {owner}");
            }

            _owner = p;
            _type  = prototype._type;
            switch (_type)
            {
            case Type.Variable:
                _costFunction = prototype._costFunction;
                _operator     = prototype._operator;
                _condition    = prototype._condition;
                return;

            case Type.Triggered:
                _value         = prototype._value;
                _triggerType   = prototype._triggerType;
                _triggerSource = prototype._triggerSource;
                _condition     = prototype._condition;
                break;

            case Type.TriggeredWithInitialisation:
                _initialisationFunction = prototype._initialisationFunction;
                _cachedValue            = _initialisationFunction(p);
                _costFunction           = prototype._costFunction;
                _triggerType            = prototype._triggerType;
                _triggerSource          = prototype._triggerSource;
                _condition = prototype._condition;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            _updateHandler     = Trigger;
            _removedHandler    = RemoveAtEnd;
            _isTriggered       = prototype._isTriggered;
            _isAppliedThisTurn = prototype._isAppliedThisTurn;
        }
示例#18
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="MultiTriggerItem" /> class.
 /// </summary>
 public MultiTriggerItem(MultiTrigger trigger, DependencyObject source, TriggerSource triggerSource)
     : base(trigger, source, TriggerType.MultiTrigger, triggerSource)
 {
     this.trigger = trigger;
     this.source  = source;
 }
示例#19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataTriggerItem"/> class.
 /// </summary>
 public DataTriggerItem(DataTrigger trigger, FrameworkElement source, TriggerSource triggerSource)
     : base(source, TriggerType.DataTrigger, triggerSource)
 {
     _dataTrigger = trigger;
     _source = source;
 }
示例#20
0
        public static TriggerActionItem GetTriggerActionItem(TriggerAction triggerAction, DependencyObject source, TriggerSource triggerSource)
        {
            TriggerActionItem triggerActionItem;

            triggerActionItem = new TriggerActionItem(triggerAction, source);

            triggerActionItem.Initialize();

            return(triggerActionItem);
        }
示例#21
0
 public void SetTriggerSource(IAWG awg, TriggerSource setValue)
 {
     awg.SetTriggerSource(TranslateTriggerSource(setValue));
 }
示例#22
0
 public void TriggerSourceShouldBe(IAWG awg, TriggerSource expectedValue)
 {
     Assert.AreEqual(TranslateTriggerSource(expectedValue), awg.TriggerSource);
 }
示例#23
0
 public void SetTriggerSource(TriggerSource triggerSource)
 {
     m_pMyCamera.MV_CC_SetEnumValue_NET("TriggerSource", (uint)triggerSource);
 }
示例#24
0
 public TriggerBuilder SetSource(TriggerSource source)
 {
     _trigger.TriggerSource = source;
     return(this);
 }
示例#25
0
 public TriggerItem(Trigger trigger, FrameworkElement source, TriggerSource triggerSource)
     : base(source, TriggerType.Trigger, triggerSource)
 {
     _trigger = trigger;
     _source  = source;
 }
示例#26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataTriggerItem"/> class.
 /// </summary>
 public DataTriggerItem(DataTrigger trigger, FrameworkElement source, TriggerSource triggerSource)
     : base(source, TriggerType.DataTrigger, triggerSource)
 {
     _dataTrigger = trigger;
     _source      = source;
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="TriggerItemBase" /> class.
 /// </summary>
 protected TriggerItemBase(TriggerBase trigger, DependencyObject instance, TriggerType triggerType, TriggerSource triggerSource)
 {
     this.trigger       = trigger;
     this.Instance      = instance;
     this.TriggerType   = triggerType;
     this.TriggerSource = triggerSource;
 }
示例#28
0
 private string TranslateTriggerSource(TriggerSource valueToTranslate)
 {
     return((valueToTranslate == TriggerSource.Internal) ? "INT" : "EXT");
 }
示例#29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TriggerItemBase"/> class.
 /// </summary>
 protected TriggerItemBase(object instance, TriggerType triggerType, TriggerSource triggerSource)
 {
     Instance = instance;
     TriggerType = triggerType;
     TriggerSource = triggerSource;
 }
 public MultiDataTriggerItem(MultiDataTrigger trigger, FrameworkElement source, TriggerSource triggerSource)
     : base(source, TriggerType.MultiDataTrigger, triggerSource)
 {
     _trigger = trigger;
     _source  = source;
 }
示例#31
0
        public static TriggerItemBase?GetTriggerItem(TriggerBase trigger, DependencyObject source, TriggerSource triggerSource)
        {
            TriggerItemBase triggerItem;

            if (trigger is Trigger)
            {
                triggerItem = new TriggerItem((Trigger)trigger, source, triggerSource);
            }
            else if (trigger is DataTrigger)
            {
                triggerItem = new DataTriggerItem((DataTrigger)trigger, source, triggerSource);
            }
            else if (trigger is MultiTrigger)
            {
                triggerItem = new MultiTriggerItem((MultiTrigger)trigger, source, triggerSource);
            }
            else if (trigger is MultiDataTrigger)
            {
                triggerItem = new MultiDataTriggerItem((MultiDataTrigger)trigger, source, triggerSource);
            }
            else if (trigger is EventTrigger)
            {
                triggerItem = new EventTriggerItem((EventTrigger)trigger, source, triggerSource);
            }
            else
            {
                return(null);
            }

            triggerItem.Initialize();
            return(triggerItem);
        }
示例#32
0
 public TriggerItem(Trigger trigger, FrameworkElement source, TriggerSource triggerSource)
     : base(trigger, source, TriggerType.Trigger, triggerSource)
 {
     this.trigger = trigger;
     this.source  = source;
 }
示例#33
0
 private void AddTriggers(FrameworkElement instance, IEnumerable <TriggerBase> triggers, TriggerSource source)
 {
     foreach (TriggerBase trigger in triggers)
     {
         var triggerItem = TriggerItemFactory.GetTriggerItem(trigger, instance, source);
         if (triggerItem != null)
         {
             _triggers.Add(triggerItem);
         }
     }
 }
示例#34
0
 public TriggerItem(Trigger trigger, FrameworkElement source, TriggerSource triggerSource)
     : base(source, TriggerType.Trigger, triggerSource)
 {
     _trigger = trigger;
     _source = source;
 }
示例#35
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TriggerItemBase"/> class.
 /// </summary>
 protected TriggerItemBase(object instance, TriggerType triggerType, TriggerSource triggerSource)
 {
     Instance      = instance;
     TriggerType   = triggerType;
     TriggerSource = triggerSource;
 }
示例#36
0
 private void AddTriggers(FrameworkElement instance, IEnumerable<TriggerBase> triggers, TriggerSource source)
 {
     foreach (TriggerBase trigger in triggers)
     {
         var triggerItem = TriggerItemFactory.GetTriggerItem(trigger, instance, source);
         if (triggerItem != null)
         {
             _triggers.Add(triggerItem);
         }
     }
 }