Пример #1
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="parent"></param>
		public override void Remove(Component parent)
		{
			//Debug.Log("SetProperty->Remove: Name: " + Name + "; Value: " + Value);

			//_appliedTarget = GetTarget(_appliedTarget, parent);
			_pseudonym = GetPseudonym(_appliedTarget, Name);

			// Special case for width and height. Restore the "width" and
			// "height" properties instead of explicitWidth/explicitHeight
			// so they can be kept in sync.
			if ((Name == "Width" || Name == "Height") && null != (_oldValue as float?))
			{
				_pseudonym = Name;
			}

			_mp = new MemberProxy(_appliedTarget, _pseudonym); // buggy caching (tries to do Color to Rotation)
            _mp.SetValue(_oldValue);
            /*MemberWrapper mw = new MemberWrapper(_appliedTarget.GetType(), _pseudonym);
            mw.SetValue(_appliedTarget, _oldValue);*/

			_oldValue = null;

			//_relatedProps = GetRelatedProperties(_appliedTarget, _pseudonym);
			if (null != _relatedProps)
			{
				for (var i = 0; i < _relatedProps.Count; i++)
				{
					_mp = new MemberProxy(_appliedTarget, _relatedProps[i]);
					_mp.SetValue(_oldRelatedValues[i]);
				}
			}

			Applied = false;
			_appliedTarget = null;
		}
Пример #2
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="parent"></param>
		public override void Remove(Component parent)
		{
			//Debug.Log("SetStyle->Remove: Name: " + Name + "; Value: " + Value);

		    var obj = (IStyleClient) _appliedTarget;

            // ovo je fakat čudno, njihova logika ne radi (ili ima bug)
            // što znači "clearate" style - maknut ga iz style deklaracije ili ga staviti unutra s vrijednosti "undefined"???

            if (_wasInline)
            {
                // Restore the old value
                /*if (_oldValue == null)
                    obj.ClearStyle(Name);
                else*/
                obj.SetStyle(Name, _oldValue); // apply whatever the old value is
            }
            else
            {
                obj.ClearStyle(Name);
            }

            //obj.SetStyle(Name, _oldValue);

            //_relatedProps = GetRelatedProperties(_appliedTarget, _pseudonym);
            if (null != _relatedProps)
            {
                for (var i = 0; i < _relatedProps.Count; i++)
                {
                    _mp = new MemberProxy(_appliedTarget, _relatedProps[i]);
                    _mp.SetValue(_oldRelatedValues[i]);
                }
            }

			Applied = false;
			_appliedTarget = null;
		}
Пример #3
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="parent"></param>
		public override void Apply(Component parent)
		{
			//Debug.Log("SetProperty->Apply: Name: " + Name + "; Value: " + Value);

			_appliedTarget = GetTarget(Target, parent);
			_pseudonym = GetPseudonym(_appliedTarget, Name);
			
            _mp = new MemberProxy(_appliedTarget, _pseudonym); //_mp = GetMember(Target, parent, _pseudonym);
            if (!Applied)
			{
				_oldValue = _mp.GetValue();
			}
			_mp.SetValue(Value);
            
            // buggy caching (tries to do Color to Rotation)
            //MemberWrapper mw = new MemberWrapper(_appliedTarget.GetType(), _pseudonym);
            /*MemberWrapper mw = GlobalMemberCache.Instance.Get(_appliedTarget.GetType(), _pseudonym);
            if (null == mw) { 
                mw = new MemberWrapper(_appliedTarget.GetType(), _pseudonym);
                GlobalMemberCache.Instance.Put(_appliedTarget.GetType(), _pseudonym, mw);
            }
            if (!Applied)
            {
                _oldValue = mw.GetValue(_appliedTarget);
            }
            mw.SetValue(_appliedTarget, Value);*/

			_relatedProps = GetRelatedProperties(_appliedTarget, _pseudonym);
			if (_relatedProps.Count > 0)
			{
				if (null == _oldRelatedValues)
					_oldRelatedValues = new List<object>(); // lazily
				else
					_oldRelatedValues.Clear();

				foreach (string property in _relatedProps) {
					_oldRelatedValues.Add(new MemberProxy(_appliedTarget, property).GetValue());
				}
			}

			Applied = true;
		}