示例#1
0
 public virtual void Update(GameTime gameTime)
 {
     present = gameTime;
     if (gameTime.TotalGameTime > BeginTime.TotalGameTime)
     {
         if ((gameTime.TotalGameTime < (BeginTime.TotalGameTime + Duration)) && !Finished)
         {
             isRunning = true;
             var presentvalue = (int)(BeginValue + (EasingFunction.EasingCurve(Progress, PlayBack) * (EndValue - BeginValue)));
             TargetProperty.SetValue(TargetSprite, presentvalue, null);
         }
         else
         {
             isRunning = false;
             Finished  = true;
         }
     }
     if ((LoopCount > 1 || LoopMode == LoopMode.Forever) && Finished && (LoopMode != LoopMode.Once))
     {
         LoopCount--;
         BeginTime = new GameTime(gameTime.TotalGameTime, gameTime.ElapsedGameTime);
         BeginTime.TotalGameTime += LoopDelay;
         if (ReturnToBeginning)
         {
             TargetProperty.SetValue(TargetSprite, (int)BeginValue, null);
         }
         isRunning = true;
         Finished  = false;
         return;
     }
 }
示例#2
0
        private static TargetProperty GetTargetProperty(object source, string propertyName)
        {
            if (!propertyName.Contains("."))
            {
                return new TargetProperty {
                           Target = source, Property = source.GetType().GetProperty(propertyName)
                }
            }
            ;

            string[] propertyPath = propertyName.Split('.');

            var targetProperty = new TargetProperty();

            targetProperty.Target   = source;
            targetProperty.Property = source.GetType().GetProperty(propertyPath[0]);

            for (int propertyIndex = 1; propertyIndex < propertyPath.Length; propertyIndex++)
            {
                propertyName = propertyPath[propertyIndex];
                if (!string.IsNullOrEmpty(propertyName))
                {
                    targetProperty.Target   = targetProperty.Property.GetValue(targetProperty.Target, null);
                    targetProperty.Property = targetProperty.Target.GetType().GetProperty(propertyName);
                }
            }

            return(targetProperty);
        }
示例#3
0
        public void SimplePathTargetResolutionTest()
        {
            string      rawPath = "tb1.Text";
            BindingPath path    = new BindingPath(rawPath);

            TextBox tb = new TextBox();

            tb.ID   = "tb1";
            tb.Text = "hello";

            //tell the control service to return our control when asked
            controlService.Expect(cs => cs.FindControlUnique(null, null)).IgnoreArguments()
            .Do(new Func <IBindingTarget, string, IBindingTarget>((s, e) => new WebformControl(tb)));

            //and unwrap
            controlService.Expect(cs => cs.Unwrap(null)).IgnoreArguments().Do(new Func <IBindingTarget, object>(b => tb));

            TargetProperty targetProperty = path.ResolveAsTarget(new WebformControl(tb), this.controlService);

            Assert.IsNotNull(targetProperty);
            Assert.IsNotNull(targetProperty.Descriptor);
            Assert.IsNotNull(targetProperty.OwningControlRaw);
            Assert.IsNotNull(targetProperty.Value);

            Assert.AreEqual("hello", targetProperty.Value);
            Assert.AreEqual("Text", targetProperty.Descriptor.Name);
            Assert.AreEqual(tb, targetProperty.OwningControlRaw);
        }
示例#4
0
        public bool Eval(SongViewModel song)
        {
            T targetValue = DebugHelper.CastAndAssert <T>(TargetProperty.GetValue(song));

            switch (EvalType)
            {
            case NumericEvalType.StrictLess:
                return(targetValue.CompareTo(Target) < 0);

            case NumericEvalType.Less:
                return(targetValue.CompareTo(Target) <= 0);

            case NumericEvalType.Equal:
                return(targetValue.CompareTo(Target) == 0);

            case NumericEvalType.More:
                return(targetValue.CompareTo(Target) >= 0);

            case NumericEvalType.StrictMore:
                return(targetValue.CompareTo(Target) > 0);

            default:
                DebugHelper.Alert(new CallerInfo(), "Unexpected NumericEvalType: {0}", EvalType);
                return(false);
            }
        }
示例#5
0
        public object ConvertValue(object value)
        {
            object convertedValue = value;

            var memberType = TargetProperty.GetMemberType();

            if (Binding.Converter != null)
            {
//				try
                {
                    object parameter = Element;
                    if (Binding.ConverterParameter != null)
                    {
                        parameter = Binding.ConverterParameter;
                    }

                    convertedValue = Binding.Converter.Convert(value, memberType, parameter, CultureInfo.CurrentUICulture);
                }
//				catch (InvalidCastException) {}
//				catch (NotSupportedException) {}
//				catch (NotImplementedException) {}
            }

            var typeCode = Convert.GetTypeCode(convertedValue);

            if (typeCode != TypeCode.Object && typeCode != TypeCode.Empty)
            {
                convertedValue = Convert.ChangeType(convertedValue, memberType);
            }

            return(convertedValue);
        }
 public static bool IsTheGreaterTheBetter(this TargetProperty property)
 {
     if (property == TargetProperty.AttackCooldown)
     {
         return(false);
     }
     return(true);
 }
示例#7
0
        public override void OnDrawOutport(int outportIndex, OutportContainer outportContainer)
        {
            base.OnDrawOutport(outportIndex, outportContainer);

            SerializedProperty setterValueProp = TargetProperty.FindPropertyRelative(BlackboardSetter.SetterValueVarName);

            outportContainer.OutportBody.Add(new Label(BlackboardSetter.GetOutportLabel(setterValueProp)));
        }
示例#8
0
        /// <summary>
        /// 添加标的信息
        /// </summary>
        /// <param name="typeId"></param>
        /// <returns></returns>
        private bool AddAction(int typeId)
        {
            TargetProperty        targetModel = new TargetProperty();
            TargetPropertyManager targetBLL   = new TargetPropertyManager();

            TargetEnum        enumModel = new TargetEnum();
            TargetEnumManager enumBLL   = new TargetEnumManager();

            if (HidMainFlag.Value == string.Empty)
            {
                targetModel.MainFlag = null;
            }
            else
            {
                targetModel.MainFlag = HidMainFlag.Value == "chkMain_0" ? true : false; //判断是否是主标
            }

            targetModel.IsRequired = this.isrequired.Checked;                      //判断是否必填

            targetModel.PropertyName = txtName.Text;                               //标的描述
            targetModel.PropertyType = Convert.ToInt32(rdoDataType.SelectedValue); //数据类型
            try
            {
                targetModel.PropertyId = targetBLL.GetMaxID(typeId) + 1;//自动生成
            }
            catch (Exception)
            {
                targetModel.PropertyId = 0;
            }
            targetModel.EnumTypeId   = 0;                    //属性数据关联id
            targetModel.PropertyNO   = txtNum.Text;          //标的编号
            targetModel.TargetTypeId = typeId;               //标的种类关联id

            if (rdoDataType.Items.FindByValue("9").Selected) //数据类型为多选一
            {
                targetModel.EnumTypeId = enumBLL.GetMaxId() + 1;

                enumModel.EnumTypeId = enumBLL.GetMaxId() + 1;

                string temp = HidItem.Value;
                if (temp.EndsWith("$¥$"))
                {
                    temp = temp.TrimEnd("$¥$".ToCharArray());
                }
                temp = temp.Replace("$¥$", "$");
                string[] enumValues = temp.Split('$');

                for (int i = 0; i < enumValues.Count(); i++)
                {
                    enumModel.EnumId    = i + 1;
                    enumModel.EnumValue = enumValues[i];
                    enumBLL.Add(enumModel);
                }
            }

            return(targetBLL.Add(targetModel));
        }
 /// <inheritdoc />
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (TargetProperty != null ? TargetProperty.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ TargetPropertyIndex;
         return(hashCode);
     }
 }
 public virtual void Dispose()
 {
     if (TargetProperty != VisualProperty.None)
     {
         TargetVisual?.StopAnimation(TargetProperty.ToString());
     }
     CompositionAnimation?.Dispose();
     CompositionAnimation = null;
 }
示例#11
0
        public void Add(TargetProperty property, Operation operation, float value)
        {
            var modifier = new ModifierDescriptor();

            modifier.TargetProperty = property;
            modifier.Operation      = operation;
            modifier.Value          = value;
            Modifiers.Add(modifier);
        }
示例#12
0
        protected override void DoInit()
        {
            GetMethod = () => (bool)TargetProperty.GetValue(null, null);
            SetMethod = newQuantity => TargetProperty.SetValue(null, newQuantity, null);

            text.text = Attribute.displayName;
            toggle.onValueChanged.AddListener(OnToggled);

            UpdateToggle();
        }
示例#13
0
        public void For(TargetProperty property, Action <ModifierDescriptor> modifierAction)
        {
            var modifier = Modifiers.Where(x => x.TargetProperty == property).FirstOrDefault();

            if (modifier == null)
            {
                return;
            }
            modifierAction(modifier);
        }
        protected override void DoInit()
        {
            GetQuantityMethod = () => (string)TargetProperty.GetValue(null, null);
            SetQuantityMethod = newQuantity => TargetProperty.SetValue(null, newQuantity, null);

            titleText.text = Attribute.displayName;

            inputField.onEndEdit.AddListener(OnInputEntered);

            UpdateQuantity();
        }
        /// <summary>
        /// Invoked by an <see cref="Spring.Objects.Factory.IObjectFactory"/>
        /// after it has set all object properties supplied
        /// (and satisfied <see cref="Spring.Objects.Factory.IObjectFactoryAware"/>
        /// and ApplicationContextAware).
        /// </summary>
        /// <exception cref="System.Exception">
        /// In the event of misconfiguration (such as failure to set an essential
        /// property) or if initialization fails.
        /// </exception>
        public override void AfterPropertiesSet()
        {
            if (TargetType == null &&
                TargetObject == null)
            {
                throw new ArgumentException("One of the TargetType or TargetObject properties must be set.");
            }
            if (TargetProperty == null)
            {
                throw new ArgumentException("The TargetProperty property is required.");
            }
            Type         targetType    = null;
            BindingFlags propertyFlags = BindingFlags.Public | BindingFlags.IgnoreCase;

            if (TargetObject == null)
            {
                // a static property...
                propertyFlags |= BindingFlags.Static;
                targetType     = TargetType;
                if (TargetProperty.IndexOf(".") == -1)
                {
                    Property = targetType.GetProperty(TargetProperty, propertyFlags);
                }
                else
                {
                    // $?#@! a nested static property... recurse to the end property
                    string property      = TargetProperty;
                    int    propertyIndex = property.IndexOf(".");
                    string startProperty = property.Substring(0, propertyIndex);
                    Property       = targetType.GetProperty(startProperty, propertyFlags);
                    TargetObject   = Property.GetValue(null, new object[] {});
                    TargetProperty = property.Substring(propertyIndex + 1);
                    AfterPropertiesSet();
                }
            }
            else
            {
                // an instance property...
                propertyFlags |= BindingFlags.Instance;
                targetType     = TargetObject.GetType();

                // using the object wrapper does nested property lookup
                Property = _targetObjectWrapper.GetPropertyInfo(TargetProperty);
            }
            if (Property == null)
            {
                throw new InvalidPropertyException(targetType, TargetProperty);
            }
            if (!Property.CanRead)
            {
                throw new NotWritablePropertyException(TargetProperty, targetType);
            }
            base.AfterPropertiesSet();
        }
        public override void OnDrawPrimaryBody(VisualElement primaryBodyContainer)
        {
            base.OnDrawPrimaryBody(primaryBodyContainer);
            string            blackboardEleId   = TargetProperty.FindPropertyRelative(BlackboardConditional.BlackboardElementIdVarName).stringValue;
            BlackboardElement blackboardElement = NodeGraph.BlackboardProperties.GetElementById(blackboardEleId);
            Label             selectedEleLabel  = new Label(blackboardElement == null ? "None" : blackboardElement.Name);

            selectedEleLabel.style.unityTextAlign = TextAnchor.MiddleCenter;
            selectedEleLabel.style.fontSize       = 18;
            primaryBodyContainer.Add(selectedEleLabel);
        }
        public override void OnDrawOutport(int outportIndex, OutportContainer outportContainer)
        {
            base.OnDrawOutport(outportIndex, outportContainer);

            SerializedProperty conditionalProp = TargetProperty
                                                 .FindPropertyRelative(BlackboardConditional.ConditionalsVarName)
                                                 .GetArrayElementAtIndex(outportIndex);


            outportContainer.OutportBody.Add(new Label(BlackboardConditional.GetOutportLabel(conditionalProp)));
        }
示例#18
0
        internal override bool Update()
        {
            lock (Locker)
            {
                var delta = (float)GetDelta();

                TargetProperty.Set(TargetElement, Mathf.Lerp(_from, _to, delta));

                return(delta < 1);
            }
        }
 /// <summary>
 /// Update value of CLR Property
 /// </summary>
 /// <param name="newValue"></param>
 private void UpdateTarget()
 {
     if (TargetProperty?.CanWrite == true)
     {
         // Update the target property if the owner hasn't already been GC'ed
         if (BindingTarget.IsAlive)
         {
             TargetProperty.SetValue(BindingTarget.Target, Property.GetValue());
         }
     }
 }
示例#20
0
        protected override void DoInit()
        {
            GetQuantityMethod = () => (float)TargetProperty.GetValue(null, null);
            SetQuantityMethod = newQuantity => TargetProperty.SetValue(null, newQuantity, null);

            titleText.text = Attribute.displayName;

            slider.minValue = Attribute.min;
            slider.maxValue = Attribute.max;
            slider.onValueChanged.AddListener(delegate { OnQuantityFieldUpdated(slider.value); });
            UpdateQuantity();
        }
示例#21
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = OnCompleted != null?OnCompleted.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ (АnimationInitializer != null ? АnimationInitializer.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (TargetProperty != null ? TargetProperty.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0);
                return(hashCode);
            }
        }
示例#22
0
 public override void Map(object source, object target)
 {
     try
     {
         var sourceValue = _sourceProperty.GetValue(source);
         var targetValue = _map.Map(sourceValue);
         TargetProperty.SetValue(target, targetValue);
     }
     catch (Exception ex)
     {
         throw new MappingException(string.Format("Could not map {0}.{1} to {2}.{3}", source.GetType(), _sourceProperty.Name, target, TargetProperty.Name), ex);
     }
 }
示例#23
0
        protected override void DoInit()
        {
            GetQuantityMethod = () => (int)TargetProperty.GetValue(null, null);
            SetQuantityMethod = newQuantity => TargetProperty.SetValue(null, newQuantity, null);

            titleText.text = Attribute.displayName;

            inputField.characterValidation = InputField.CharacterValidation.Integer;
            inputField.onEndEdit.AddListener(OnInputEntered);

            _allowNegative = Attribute.allowNegative;

            UpdateQuantity();
        }
示例#24
0
文件: Binding.cs 项目: mlivensp/csla
        /// <summary>
        /// Updates the target with the current value in the source object.  Uses the Convert function to convert the data if available.
        /// </summary>
        public void UpdateTarget()
        {
            var value = SourceProperty.GetValue(Source, null);

            if (Convert != null)
            {
                value = Convert(value);
            }
            var converted = Utilities.CoerceValue(
                TargetProperty.PropertyType, SourceProperty.PropertyType, null, value);

            TargetProperty.SetValue(Target,
                                    converted,
                                    null);
        }
示例#25
0
文件: Binding.cs 项目: mlivensp/csla
        /// <summary>
        /// Updates the source with the current value in the target object.  Uses the ConvertBack function to convert the data if available.
        /// </summary>
        public void UpdateSource()
        {
            var value = TargetProperty.GetValue(Target, null);

            if (ConvertBack != null)
            {
                value = ConvertBack(value);
            }
            var converted = Utilities.CoerceValue(
                SourceProperty.PropertyType, TargetProperty.PropertyType, null, value);

            SourceProperty.SetValue(Source,
                                    converted,
                                    null);
        }
示例#26
0
        public bool Eval(SongViewModel song)
        {
            DateTime targetValue = DebugHelper.CastAndAssert <DateTime>(TargetProperty.GetValue(song));

            switch (EvalType)
            {
            case RangeEvalType.Days:
                DateTime target = DateTime.Now - TimeSpan.FromDays(Target);

                return(target < targetValue);

            default:
                DebugHelper.Alert(new CallerInfo(), "Unexpected MemberEvalType: {0}", EvalType);
                return(false);
            }
        }
示例#27
0
        internal override bool Update()
        {
            lock (Locker)
            {
                var delta = (float)GetDelta();

                var scaleX = Mathf.Lerp(_from.Scale.x, _to.Scale.x, delta);
                var scaleY = Mathf.Lerp(_from.Scale.y, _to.Scale.y, delta);
                var absX   = Mathf.Lerp(_from.Absolute.x, _to.Absolute.x, delta);
                var absY   = Mathf.Lerp(_from.Absolute.y, _to.Absolute.y, delta);

                TargetProperty.Set(TargetElement, new UDim2(scaleX, absX, scaleY, absY));

                return(delta < 1);
            }
        }
示例#28
0
        private bool UpdateAction(int typeId, int targetId)
        {
            TargetProperty        targetModel = new TargetProperty();
            TargetPropertyManager targetBLL   = new TargetPropertyManager();

            targetModel = targetBLL.GetModel(typeId, targetId);
            if (HidMainFlag.Value == string.Empty)
            {
                targetModel.MainFlag = null;
            }
            else
            {
                targetModel.MainFlag = HidMainFlag.Value == "chkMain_0" ? true : false;
            }

            targetModel.IsRequired = this.isrequired.Checked;//是否必填

            targetModel.PropertyName = txtName.Text;
            targetModel.PropertyType = Convert.ToInt32(rdoDataType.SelectedValue);

            if (rdoDataType.Items.FindByValue("9").Selected)//数据类型为多选一
            {
                TargetEnum        enumModel = new TargetEnum();
                TargetEnumManager enumBLL   = new TargetEnumManager();

                string temp = HidItem.Value;
                if (temp.EndsWith("$¥$"))
                {
                    temp = temp.TrimEnd("$¥$".ToCharArray());
                }
                temp = temp.Replace("$¥$", "$");
                string[] enumValues = temp.Split('$');

                int id = targetModel.EnumTypeId;

                enumBLL.Delete(id);

                enumModel.EnumTypeId = id;
                for (int i = 0; i < enumValues.Count(); i++)
                {
                    enumModel.EnumId    = i + 1;
                    enumModel.EnumValue = enumValues[i];
                    enumBLL.Add(enumModel);
                }
            }
            return(targetBLL.Update(targetModel));
        }
示例#29
0
        /// <summary>
        /// Updates the source with the current value in the target object.  Uses the ConvertBack function to convert the data if available.
        /// </summary>
        public void UpdateSource()
        {
            if (this.BindingDirection == BindingDirection.OneWay)
            {
                return;
            }
            var value = TargetProperty.GetValue(Target, null);

            if (ConvertBack != null)
            {
                value = ConvertBack(value);
            }
            var converted = Utilities.CoerceValue(
                SourceProperty.PropertyType, TargetProperty.PropertyType, null, value);

            SourceProperty.SetValue(Source,
                                    converted,
                                    null);
        }
 /// <summary>
 /// Update Target / Source on property change events
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnPropertyChangeRaised(object sender, PropertyChangedEventArgs e)
 {
     if (sender == BindingTarget.Target)
     {
         if (e.PropertyName == TargetProperty.Name)
         {
             if (BindingTarget.IsAlive)
             {
                 Property.SetValue(TargetProperty.GetValue(BindingTarget.Target));
             }
         }
     }
     else if (sender == Property)
     {
         if (e.PropertyName == "Value")
         {
             UpdateTarget();
         }
     }
 }