示例#1
0
 public override void    CollectUpdates(List <MonitorData> updates)
 {
     //Debug.Log("C"+this.fieldInfo.Name + "=" + this.value + " <> "+ this.fieldInfo.GetValue(this.instance));
     if ((Color)this.value != valueGetter.GetValue <Color>(this.getInstance()))
     {
         updates.Add(this);
     }
 }
示例#2
0
 public override void    CollectUpdates(List <MonitorData> updates)
 {
     //UnityEngine.Debug.Log("S"+this.path + "=" + this.value + " <> "+ valueGetter.GetValue<string>(this.getInstance()));
     if (string.Compare((string)this.value, valueGetter.GetValue <string>(this.getInstance())) != 0)
     {
         updates.Add(this);
     }
 }
示例#3
0
        public MonitorBounds(string path, Func <object> getInstance, IValueGetter valueGetter) : base(path, getInstance)
        {
            Func <object> subGetInstance = () => valueGetter.GetValue <Bounds>(getInstance());

            this.children = new List <MonitorData>(2)
            {
                new MonitorProperty(this.path + NGServerScene.ValuePathSeparator + "extents", subGetInstance, valueGetter.Type.GetProperty("extents")),
                new MonitorProperty(this.path + NGServerScene.ValuePathSeparator + "center", subGetInstance, valueGetter.Type.GetProperty("center"))
            };
        }
示例#4
0
        public MonitorQuaternion(string path, Func <object> getInstance, IValueGetter valueGetter) : base(path, getInstance)
        {
            Func <object> subGetInstance = () => valueGetter.GetValue <Quaternion>(getInstance());

            this.children = new List <MonitorData>(4)
            {
                new MonitorField(this.path + NGServerScene.ValuePathSeparator + 'x', subGetInstance, valueGetter.Type.GetField("x")),
                new MonitorField(this.path + NGServerScene.ValuePathSeparator + 'y', subGetInstance, valueGetter.Type.GetField("y")),
                new MonitorField(this.path + NGServerScene.ValuePathSeparator + 'z', subGetInstance, valueGetter.Type.GetField("z")),
                new MonitorField(this.path + NGServerScene.ValuePathSeparator + 'w', subGetInstance, valueGetter.Type.GetField("w"))
            };
        }
示例#5
0
        public MonitorRect(string path, Func <object> getInstance, IValueGetter valueGetter) : base(path, getInstance)
        {
            Func <object> subGetInstance = () => valueGetter.GetValue <Rect>(getInstance());

            this.children = new List <MonitorData>(4)
            {
                new MonitorProperty(this.path + NGServerScene.ValuePathSeparator + 'x', subGetInstance, valueGetter.Type.GetProperty("x")),
                new MonitorProperty(this.path + NGServerScene.ValuePathSeparator + 'y', subGetInstance, valueGetter.Type.GetProperty("y")),
                new MonitorProperty(this.path + NGServerScene.ValuePathSeparator + "width", subGetInstance, valueGetter.Type.GetProperty("width")),
                new MonitorProperty(this.path + NGServerScene.ValuePathSeparator + "height", subGetInstance, valueGetter.Type.GetProperty("height"))
            };
        }
        public void UpdateOptionItem(IOptionItem oi)
        {
            if (inUpdate)
            {
                return;
            }
//      if (!optionItem.IsAlive) {
//        return;
//      }
//
//      IOptionItem oi = (IOptionItem)optionItem.Target;
            //lock...
            inUpdate = true;

            ICollection <IPropertyItemDescriptor <T> > descriptors;

            descriptors = selection.Selection;
            if (descriptors.Count == 0)
            {
                SetUndefinedValue(oi);
                inUpdate = false;
                return;
            }
            bool   filled           = false;
            object accumulatedValue = null;


            foreach (IPropertyItemDescriptor <T> descriptor in descriptors)
            {
                //get the propertyItem from the current lookup

                IPropertyMap map = descriptor.Properties;
                if (map == null)
                {
                    continue;
                }
                IPropertyItem item = map.GetEntry(virtualPropertyName);
                if (item == null)
                {
                    continue;
                }
                //get value from current selection item
                IValueGetter getter = item.Getter;
                if (getter == null || !getter.CanGet())
                {
                    continue;
                }

                object value = getter.GetValue();
                if (!filled)
                {
                    //first value
                    accumulatedValue = value;
                    filled           = true;
                }
                else
                {
                    //check if value is different?
                    IEqualityComparer comparer = item.EqualityComparer;
                    if (comparer != null)
                    {
                        if (!comparer.Equals(accumulatedValue, value))
                        {
                            SetUndefinedValue(oi);
                            inUpdate = false;
                            return;
                        }
                    }
                    else
                    {
                        if (accumulatedValue != null && !accumulatedValue.Equals(value))
                        {
                            SetUndefinedValue(oi);
                            inUpdate = false;
                            return;
                        }
                        else if (accumulatedValue == null && value != null)
                        {
                            SetUndefinedValue(oi);
                            inUpdate = false;
                            return;
                        }
                    }
                }
            }
            if (accumulatedValue == null)
            {
                if ((bool)oi.Attributes[OptionItem.SupportNullValueAttribute])
                {
                    oi.Value = accumulatedValue;
                }
            }
            else
            {
                oi.Value = accumulatedValue;
            }
            inUpdate = false;
        }
 public object GetValue(KeyValuePair <TKey, TValue> item)
 => _underlying.GetValue(item.Key);
示例#8
0
 public MonitorColor(string path, Func <object> getInstance, IValueGetter valueGetter) : base(path, getInstance)
 {
     this.valueGetter = valueGetter;
     this.typeHandler = TypeHandlersManager.GetTypeHandler(valueGetter.Type);
     this.value       = valueGetter.GetValue <Color>(this.getInstance());
 }