Пример #1
0
        public override void PropertyInfoChanged(CObjectProperty info)
        {
            base.PropertyInfoChanged(info);

            m_bIsLocked = true;
            if (!m_bItemSourcesSet)
            {
                m_enumType = info.ValueType;

                m_availableAssets.Clear();
                m_availableAssets.AddRange(Enum.GetNames(m_enumType));

                AssetSelector.ItemsSource = m_availableAssets;
                m_bItemSourcesSet         = true;
            }

            if (info.Value != m_oldValue)
            {
                int selectedIndex = -1;
                if (info.Value != null)
                {
                    selectedIndex = m_availableAssets.FindIndex(typeInfo => typeInfo == GetNameByValue(Convert.ToInt32(info.Value)));
                }
                AssetSelector.SelectedIndex = selectedIndex;
            }

            m_oldValue  = info.Value;
            m_bIsLocked = false;
        }
        public override void PropertyInfoChanged(CObjectProperty info)
        {
            base.PropertyInfoChanged(info);

            m_ignoreChanges    = true;
            Checkbox.IsChecked = (bool)info.Value;
            m_ignoreChanges    = false;
        }
 public CInspectorControlInfo(Type type, CObjectProperty property, CCategoryInfo category, BaseInspectorControl control, InspectorPropertyName nameControl)
 {
     categoryInfo        = category;
     inspectorControl    = control;
     valueType           = type;
     objectProperty      = property;
     propertyNameControl = nameControl;
 }
        public override void PropertyInfoChanged(CObjectProperty info)
        {
            base.PropertyInfoChanged(info);

            m_bLocked     = true;
            InputBox.Text = info.Value.ToString();
            m_bLocked     = false;
        }
Пример #5
0
        public override void PropertyInfoChanged(CObjectProperty info)
        {
            base.PropertyInfoChanged(info);

            Color4 color = ToColor4(PropertyInfo.Value);

            ColorButton.Background = new SolidColorBrush(EditorConversionUtility.ConvertEngineColorToSystem(color));
        }
        public InspectorPropertyName(CObjectProperty property, object defaultValue, string name, BaseInspectorControl valueInspector)
        {
            InitializeComponent();

            SetName(name);
            m_property       = property;
            m_defaultValue   = defaultValue;
            m_valueInspector = valueInspector;
        }
        private void DefaultSetter(CObjectProperty property, object oldValue, object newValue, bool bRecordUndoAction)
        {
            if (!ReferenceEquals(oldValue, null) && oldValue.Equals(newValue))
            {
                return;
            }

            void SetValueInternal(CObjectProperty prop, object value)
            {
                if (DispatchSetter)
                {
                    CEngine.Instance.Dispatch(EEngineUpdatePriority.BeginFrame, () =>
                    {
                        if (property.FieldInfo != null)
                        {
                            property.FieldInfo.SetValue(property.Target, value);
                        }
                        else
                        {
                            property.PropertyInfo.SetValue(property.Target, value);
                        }
                    });
                }
                else
                {
                    if (property.FieldInfo != null)
                    {
                        property.FieldInfo.SetValue(property.Target, value);
                    }
                    else
                    {
                        property.PropertyInfo.SetValue(property.Target, value);
                    }
                }
            }

            void Undo()
            {
                SetValueInternal(property, oldValue);
            }

            void Redo()
            {
                SetValueInternal(property, newValue);
            }

            if (bRecordUndoAction)
            {
                CUndoItem item = new CRelayUndoItem(Undo, Redo);
                UndoRedoUtility.Record(item);
            }

            Redo();
        }
Пример #8
0
        public override void PropertyInfoChanged(CObjectProperty info)
        {
            base.PropertyInfoChanged(info);

            m_collectionElementType = PropertyInfo.ValueType.GenericTypeArguments[0];

            if (info.Value != null)
            {
                dynamic list = info.Value;

                if (EqualsContentwise(info.Value as IList))
                {
                    ListExpander.Header = m_displayedList.Count + " Elements";
                    return;
                }

                int count = list.Count;
                if (m_displayedList.Count < count)
                {
                    int oldSize = m_displayedList.Count;

                    for (int i = oldSize; i < count; i++)
                    {
                        m_displayedList.Add(new CListEntryViewModel(i, null, m_collectionElementType));
                    }
                }
                else if (m_displayedList.Count > count)
                {
                    m_displayedList.RemoveRange(count, m_displayedList.Count - count);
                }

                for (int i = 0; i < count; i++)
                {
                    m_displayedList[i].Value = list[i];
                    m_displayedList[i].Type  = m_collectionElementType;
                }

                ListExpander.Header        = count + " Elements";
                CollectionList.ItemsSource = null;
                CollectionList.ItemsSource = m_displayedList;
            }
            else
            {
                //Collection is null. Show empty collection instead
                m_displayedList.Clear();
                ListExpander.Header        = "0 Elements";
                CollectionList.ItemsSource = null;
                CollectionList.ItemsSource = m_displayedList;
            }
        }
Пример #9
0
        public override void PropertyInfoChanged(CObjectProperty info)
        {
            base.PropertyInfoChanged(info);
            m_bIsLocked = true;
            Type newAssetType = null;

            if (info.ValueType.IsGenericType && info.ValueType.GenericTypeArguments.Length > 0)
            {
                newAssetType = info.ValueType.GenericTypeArguments[0];
            }
            else
            {
                newAssetType = typeof(CAsset);
            }

            if (!m_bItemSourcesSet || m_assetType != newAssetType)
            {
                m_assetType = newAssetType;
                m_availableAssets.Clear();
                Type       assetReferenceType = typeof(CAssetReference <>).MakeGenericType(m_assetType);
                Type       listType           = typeof(List <>).MakeGenericType(assetReferenceType);
                object     referenceList      = Activator.CreateInstance(listType);
                MethodInfo getAssets          = m_getAssetsMethod.MakeGenericMethod(m_assetType);
                getAssets.Invoke(CAssetRegistry.Instance, new object[] { referenceList });
                dynamic dynList = referenceList;
                foreach (dynamic reference in dynList)
                {
                    m_availableAssets.Add(reference.GetAsset());
                }

                AssetSelector.ItemsSource = m_availableAssets;

                m_bItemSourcesSet = true;
            }

            if (info.Value != m_oldValue)
            {
                int selectedIndex = -1;
                if (info.Value != null)
                {
                    dynamic dynValue = info.Value;
                    selectedIndex = m_availableAssets.FindIndex((asset => ReferenceEquals(asset, dynValue.GetAsset())));
                }
                AssetSelector.SelectedIndex = selectedIndex;
            }

            m_oldValue  = info.Value;
            m_bIsLocked = false;
        }
Пример #10
0
        public override void PropertyInfoChanged(CObjectProperty info)
        {
            base.PropertyInfoChanged(info);
            Type newParentType = null;

            if (info.ValueType.IsGenericType && info.ValueType.GenericTypeArguments.Length > 0)
            {
                newParentType = info.ValueType.GenericTypeArguments[0];
            }
            else
            {
                newParentType = typeof(object);
            }

            m_bIsLocked = true;
            if (!m_bItemSourcesSet || newParentType != m_parentType)
            {
                m_parentType = newParentType;
                m_possibleTypes.Clear();
                foreach (CKlaxScriptTypeInfo klaxType in CKlaxScriptRegistry.Instance.Types)
                {
                    if (m_parentType.IsAssignableFrom(klaxType.Type))
                    {
                        m_possibleTypes.Add(klaxType);
                    }
                }

                AssetSelector.ItemsSource = m_possibleTypes;
                m_bItemSourcesSet         = true;
            }

            if (info.Value != m_oldValue)
            {
                int selectedIndex = -1;
                if (info.Value != null)
                {
                    dynamic subtypeValue = info.Value;
                    selectedIndex = m_possibleTypes.FindIndex(typeInfo => typeInfo.Type == subtypeValue.Type);
                }
                AssetSelector.SelectedIndex = selectedIndex;
            }

            m_oldValue  = info.Value;
            m_bIsLocked = false;
        }
Пример #11
0
        public override void PropertyInfoChanged(CObjectProperty info)
        {
            base.PropertyInfoChanged(info);

            m_isRawType = false;

            CKlaxScriptTypeInfo typeInfo = info.Value as CKlaxScriptTypeInfo;

            if (typeInfo == null && info.ValueType == typeof(Type))
            {
                m_isRawType = true;
                CKlaxScriptRegistry.Instance.TryGetTypeInfo(info.Value as Type, out typeInfo);
            }

            m_bIsLocked = true;
            if (!m_bItemSourcesSet)
            {
                m_availableAssets.Clear();
                foreach (CKlaxScriptTypeInfo klaxType in CKlaxScriptRegistry.Instance.Types)
                {
                    m_availableAssets.Add(klaxType);
                }

                AssetSelector.ItemsSource = m_availableAssets;
                m_bItemSourcesSet         = true;
            }

            if (typeInfo != m_oldValue)
            {
                int selectedIndex = -1;
                if (info.Value != null)
                {
                    selectedIndex = m_availableAssets.FindIndex(availableTypeInfo => availableTypeInfo.Type == typeInfo.Type);
                }
                AssetSelector.SelectedIndex = selectedIndex;
            }

            m_oldValue  = typeInfo;
            m_bIsLocked = false;
        }
        private void CreateMaterialProperties()
        {
            MaterialProperties.Clear();
            CCategoryInfo category = new CCategoryInfo()
            {
                Name = "Material", Priority = 0
            };

            foreach (MaterialParameterViewModel parameterEntry in ParameterEntries)
            {
                Type paramType = ShaderHelpers.GetTypeFromParameterType(parameterEntry.ParameterType);
                if (parameterEntry.ParameterType == EShaderParameterType.Texture)
                {
                    paramType = typeof(CAssetReference <CTextureAsset>);
                }
                PropertyInfo    valuePropertyInfo = typeof(MaterialParameterViewModel).GetProperty("Value");
                CObjectProperty objectProperty    = new CObjectProperty(parameterEntry.Name, category, parameterEntry, parameterEntry.Value, paramType, valuePropertyInfo, null);
                MaterialProperties.Add(objectProperty);
            }

            m_propertyInspector.ShowInspectors(MaterialProperties);
        }
        public override void PropertyInfoChanged(CObjectProperty info)
        {
            base.PropertyInfoChanged(info);

            UpdateDisplay((Vector3)info.Value);
        }
        public override void PropertyInfoChanged(CObjectProperty info)
        {
            base.PropertyInfoChanged(info);

            KeyType   = PropertyInfo.ValueType.GenericTypeArguments[0];
            ValueType = PropertyInfo.ValueType.GenericTypeArguments[1];

            if (info.Value != null)
            {
                dynamic     dictionary          = info.Value;
                IDictionary dictionaryInterface = info.Value as IDictionary;

                var keyCollection   = dictionaryInterface.Keys;
                var valueCollection = dictionaryInterface.Values;

                object[] keys   = new object[keyCollection.Count];
                object[] values = new object[valueCollection.Count];

                keyCollection.CopyTo(keys, 0);
                valueCollection.CopyTo(values, 0);

                if (EqualsContentwise(dictionaryInterface, keys, values))
                {
                    HeaderText = m_displayedList.Count + " Elements";
                    return;
                }

                int count = dictionary.Count;
                if (m_displayedList.Count < count)
                {
                    int oldSize = m_displayedList.Count;

                    for (int i = oldSize; i < count; i++)
                    {
                        m_displayedList.Add(new CDictionaryEntryViewModel(i, keys[i], values[i], m_keyType, m_valueType));
                    }
                }
                else if (m_displayedList.Count > count)
                {
                    m_displayedList.RemoveRange(count, m_displayedList.Count - count);
                }

                for (int i = 0; i < count; i++)
                {
                    CDictionaryEntryViewModel model = m_displayedList[i];
                    model.Index     = i;
                    model.Key       = keys[i];
                    model.Value     = values[i];
                    model.KeyType   = m_keyType;
                    model.ValueType = m_valueType;
                }

                HeaderText = count + " Elements";
                CollectionList.ItemsSource = null;
                CollectionList.ItemsSource = m_displayedList;
            }
            else
            {
                //Collection is null. Show empty collection instead
                m_displayedList.Clear();
                HeaderText = "0 Elements";
                CollectionList.ItemsSource = null;
                CollectionList.ItemsSource = m_displayedList;
            }
        }
        public void ShowInspectors(IEnumerable <CObjectBase> baseInfos)
        {
            if (m_bLocked)
            {
                return;
            }

            inspectorTypes.Clear();
            supportedProperties.Clear();

            foreach (var baseObj in baseInfos)
            {
                if (baseObj is CObjectProperty prop)
                {
                    if (GetInspectorType(prop.ValueType, out InspectorType outResult))
                    {
                        inspectorTypes.Add(outResult);
                        supportedProperties.Add(prop);
                    }
                }
                else if (baseObj is CObjectFunction func)
                {
                }
            }

            bool bValidLayout = !m_bLayoutInvalidated;

            bValidLayout &= m_controls.Count == inspectorTypes.Count;

            if (bValidLayout)
            {
                for (int i = 0, count = m_controls.Count; i < count; i++)
                {
                    Type existingType = m_controls[i].objectProperty.ValueType;

                    if (!supportedProperties[i].Category.Equals(m_controls[i].categoryInfo) || supportedProperties[i].ValueType != existingType)
                    {
                        bValidLayout = false;
                        break;
                    }
                }
            }

            if (bValidLayout)
            {
                //Reuse layout
                for (int i = 0, count = m_controls.Count; i < count; i++)
                {
                    CInspectorControlInfo info = m_controls[i];
                    info.objectProperty = supportedProperties[i];
                    info.inspectorControl.PropertyInfoChanged(info.objectProperty);
                    info.propertyNameControl.PropertyInfoChanged(info.objectProperty);
                }
            }
            else
            {
                ClearInspector();

                for (int i = 0, count = supportedProperties.Count; i < count; i++)
                {
                    CObjectProperty property = supportedProperties[i];

                    CBaseInspectorCategory categoryControl = null;
                    if (!m_categoryMap.TryGetValue(property.Category, out categoryControl))
                    {
                        if (UseSimpleCategoryDisplay)
                        {
                            categoryControl = new SimpleInspectorCategory(property.Category, this);
                        }
                        else
                        {
                            categoryControl = new ExpandableInspectorCategory(property.Category, this);
                        }

                        m_categoryMap.Add(property.Category, categoryControl);
                        m_categories.Add(categoryControl);

                        if (m_categoryLeftColumnSize.HasValue)
                        {
                            categoryControl.ResizeColumns(m_categoryLeftColumnSize.Value);
                        }
                    }

                    Type inspectorControlType = inspectorTypes[i].controlType;
                    BaseInspectorControl newPropertyInspector = (BaseInspectorControl)Activator.CreateInstance(inspectorControlType);
                    newPropertyInspector.Init(this);
                    newPropertyInspector.PropertyInfoChanged(property);

                    InspectorPropertyName newNameControl = new InspectorPropertyName(property, inspectorTypes[i].defaultValue, property.Name, newPropertyInspector);
                    CInspectorControlInfo info           = new CInspectorControlInfo(inspectorControlType, property, property.Category, newPropertyInspector, newNameControl);
                    categoryControl.AddPropertyInspector(newPropertyInspector, newNameControl);

                    m_controls.Add(info);
                }

                List <CBaseInspectorCategory> categories = new List <CBaseInspectorCategory>(m_categories);
                int Comp(CBaseInspectorCategory x, CBaseInspectorCategory y)
                {
                    return(x.Priority - y.Priority);
                }

                categories.Sort(Comp);
                CategoryPanel.Children.Clear();

                foreach (var element in categories)
                {
                    CategoryPanel.Children.Add(element);
                }
            }

            m_currentlyDisplayedList = baseInfos;
            m_bLayoutInvalidated     = false;
        }
Пример #16
0
        public override void PropertyInfoChanged(CObjectProperty info)
        {
            base.PropertyInfoChanged(info);

            InputBox.Text = info.Value != null?info.Value.ToString() : "";
        }
 internal void PropertyInfoChanged(CObjectProperty objectProperty)
 {
     m_property = objectProperty;
 }
 public void SetInspectorValue <T>(CObjectProperty property, T oldValue, T newValue, bool bRecordUndoAction = true)
 {
     m_inspector.PropertySetter(property, oldValue, newValue, bRecordUndoAction);
 }
 public virtual void PropertyInfoChanged(CObjectProperty info)
 {
     PropertyInfo = info;
 }