Beispiel #1
0
        //!!!!
        public static bool CanBeShaderParameter(object obj, Metadata.Property property, out object value)
        {
            if (property.Static)
            {
                value = null;
                return(false);
            }
            if (property.HasIndexers)
            {
                value = null;
                return(false);
            }
            //!!!!?
            if (!property.Browsable)
            {
                value = null;
                return(false);
            }
            //!!!!что еще проверять


            value = property.GetValue(obj, null);
            if (value == null)
            {
                return(false);
            }

            var reference = value as IReference;

            ////!!!!check
            ////Component_Texture default value
            //if( reference != null && !reference.ReferenceSpecified && MetadataManager.GetTypeOfNetType( typeof( Component_Texture ) ).IsAssignableFrom( property.TypeUnreferenced ) )
            //{
            //	//!!!!какую именно возвращать
            //	value = ResourceUtils.WhiteTexture2D;
            //	return true;
            //}

            if (reference != null)
            {
                value = reference.ValueAsObject;
                if (value == null)
                {
                    //!!!!invalid reference?
                    return(false);
                }
            }

            var type = value.GetType();

            //!!!!поддержать все

            if (!CanBeShaderParameter(type))
            {
                return(false);
            }

            return(true);
        }
        protected override void GetExpandablePropertiesFilter(Metadata.Property p, ref bool skip)
        {
            base.GetExpandablePropertiesFilter(p, ref skip);

            //ColorValueNoAlphaAttribute
            if (p.Name == "Alpha" && Property.GetCustomAttributes(typeof(ColorValueNoAlphaAttribute), true).Length != 0)
            {
                skip = true;
            }
        }
            public Item(object obj, Metadata.Property property, object restoreValue, object[] indexes = null)
            {
                if (indexes == null)
                {
                    indexes = new object[0];
                }

                if (property == null)
                {
                    //fatal?
                    Log.Fatal("UndoActionPropertiesChange: Item: Constructor: property == null.");
                }

                this.obj          = obj;
                this.property     = property;
                this.restoreValue = restoreValue;
                this.indexes      = indexes;
            }
Beispiel #4
0
                public ItemProperty(Representation owner, /*int index, bool input, bool output, */ Metadata.Property property)
                    : base(owner)                      //, index, input, output )
                {
                    this.property = property;

                    //calculate displayName
                    var ar = property.GetCustomAttributes(typeof(DisplayNameAttribute), true);

                    if (ar.Length != 0)
                    {
                        var attrib = (DisplayNameAttribute)ar[0];
                        displayName = attrib.DisplayName;
                    }
                    if (displayName == null)
                    {
                        displayName = property.Name;
                    }
                }
Beispiel #5
0
        //

        public HCItemCheckBox(HierarchicalContainer owner, HierarchicalContainer.Item parent, object[] controlledObjects, Metadata.Property property, object[] indexers)
            : base(owner, parent, controlledObjects, property, indexers)
        {
        }
Beispiel #6
0
        //!!!!если надо, то как EditorAction
        //public static void ShowObjectDetailsAsDocument( object obj )
        //{
        //	List<string> lines = new List<string>( 256 );

        //	lines.Add( obj.ToString() );
        //	lines.Add( "" );
        //	lines.Add( "----------------------------------------------------------------------------------------------------" );

        //	lines.Add( "Inheritance Hierarchy" );
        //	lines.Add( "" );

        //	var type = MetadataManager.MetadataGetType( obj );
        //	int step = 0;
        //	do
        //	{
        //		lines.Add( new string( ' ', step * 3 ) + type.ToString() );

        //		step++;
        //		type = type.BaseType;
        //	} while( type != null );

        //	//lines.Add( "Type \'" + MetadataManager.MetadataGetType( obj ).ToString() + "\'" );
        //	//lines.Add( ".NET type \'" + obj.GetType().ToString() + "\'" );
        //	lines.Add( "" );
        //	lines.Add( "----------------------------------------------------------------------------------------------------" );
        //	lines.Add( "" );

        //	foreach( var member in MetadataManager.MetadataGetMembers( obj ) )
        //	{
        //		Metadata.Method method = member as Metadata.Method;
        //		if( method != null )
        //		{
        //			lines.Add( method.Signature );
        //			lines.Add( "    " + method.ToString() );
        //			lines.Add( "" );
        //		}
        //	}

        //	lines.Add( "----------------------------------------------------------------------------------------------------" );
        //	lines.Add( "" );

        //	foreach( var member in MetadataManager.MetadataGetMembers( obj ) )
        //	{
        //		Metadata.Event evt = member as Metadata.Event;
        //		if( evt != null )
        //		{
        //			lines.Add( evt.Signature );
        //			lines.Add( "    " + evt.ToString() );
        //			lines.Add( "" );
        //		}
        //	}

        //	lines.Add( "----------------------------------------------------------------------------------------------------" );
        //	lines.Add( "" );

        //	foreach( var member in MetadataManager.MetadataGetMembers( obj ) )
        //	{
        //		Metadata.Property prop = member as Metadata.Property;
        //		if( prop != null )
        //		{
        //			lines.Add( prop.Signature );
        //			lines.Add( "    " + prop.ToString() );
        //			lines.Add( "" );
        //		}
        //	}

        //	//lines.Add( "Type: " + MetadataManager.MetadataGetType( obj ).ToString() );
        //	//lines.Add( "Net type: " + obj.GetType().ToString() );
        //	//lines.Add( "" );
        //	//lines.Add( "ToString(): " + obj.ToString() );
        //	//lines.Add( "" );
        //	//lines.Add( "----------------------------------------------------------------------------------------------------" );
        //	//lines.Add( "Metadata:" );



        //	//!!!!!!
        //	//if( component != null )
        //	//{
        //	//	List<string> list = new List<string>();

        //	//	var members = component.MetadataGetMembers( true );

        //	//	list.Add( component.ToString() );

        //	//	list.Add( "" );
        //	//	list.Add( "Events:" );
        //	//	foreach( var m in members )
        //	//	{
        //	//		var evn = m as Metadata.Event;
        //	//		if( evn != null )
        //	//			list.Add( evn.ToString() + " - " + evn.Signature );
        //	//	}

        //	//	list.Add( "" );
        //	//	list.Add( "Properties:" );
        //	//	foreach( var m in members )
        //	//	{
        //	//		var p = m as Metadata.Property;
        //	//		if( p != null )
        //	//			list.Add( p.ToString() + " - " + p.Signature );
        //	//	}

        //	//	list.Add( "" );
        //	//	list.Add( "Methods:" );
        //	//	foreach( var m in members )
        //	//	{
        //	//		var method = m as Metadata.Method;
        //	//		if( method != null )
        //	//			list.Add( method.ToString() + " - " + method.Signature );
        //	//	}

        //	//	//!!!!!!log out
        //	//	{
        //	//		Log.Info( "" );
        //	//		Log.Info( "" );
        //	//		Log.Info( "---------------------------------- START -------------------------------------" );

        //	//		foreach( var t in list )
        //	//			Log.Info( t );

        //	//		Log.Info( "----------------------------------- END --------------------------------------" );
        //	//	}

        //	//	viewport.GuiRenderer.AddTextLines( list, new Vec2( .03, .1 ), EHorizontalAlign.Left, EVerticalAlign.Top, 0,
        //	//		new ColorValue( 1, 1, 0 ) );
        //	//}

        //	StringBuilder text = new StringBuilder();
        //	foreach( var line in lines )
        //		text.Append( line + "\r\n" );
        //	EditorForm.Instance.OpenTextAsDocument( text.ToString(), MetadataManager.MetadataGetType( obj ).ToString(), true );
        //}

        public static void SetPropertyReference(DocumentInstance document, object /* Component*/[] objects, Metadata.Property property, object[] indexers, string[] referenceValues)
        {
            var netType        = property.Type.GetNetType();
            var underlyingType = ReferenceUtility.GetUnderlyingType(netType);

            var undoItems = new List <UndoActionPropertiesChange.Item>();

            //!!!!try, catch? где еще

            for (int n = 0; n < objects.Length; n++)
            {
                var obj = objects[n];

                var value    = ReferenceUtility.MakeReference(underlyingType, null, referenceValues[n]);
                var oldValue = (IReference)property.GetValue(obj, indexers);

                //bool change = true;
                //if( /*skipSame && */oldValue != null && value.GetByReference == oldValue.GetByReference )
                //	change = false;

                if (!value.Equals(oldValue))
                {
                    property.SetValue(obj, value, indexers);
                    undoItems.Add(new UndoActionPropertiesChange.Item(obj, property, oldValue, indexers));
                }
            }

            //undo
            if (undoItems.Count != 0)
            {
                var action = new UndoActionPropertiesChange(undoItems.ToArray());
                document.UndoSystem.CommitAction(action);
                document.Modified = true;
            }
        }
Beispiel #7
0
            //

            public PropertyImpl(object owner, string name, bool isStatic, Metadata.TypeInfo type, Metadata.TypeInfo typeUnreferenced, Metadata.Parameter[] indexers, bool readOnly, Metadata.Property sourceProperty, Component_ProjectSettings settings)
                : base(owner, name, isStatic, type, typeUnreferenced, indexers, readOnly)
            {
                this.sourceProperty = sourceProperty;
                this.settings       = settings;
            }
Beispiel #8
0
        public static void OpenSetReferenceWindow(DocumentWindow documentWindow, Component[] selectedComponents, object[] propertyOwners, Metadata.Property property, object[] propertyIndexes)
        //, Metadata.TypeInfo demandedType, bool allowNull )
        {
            //!!!!

            var window = new SetReferenceWindow();

            window.documentWindow = documentWindow;

            var data = new ContentBrowser.SetReferenceModeDataClass();

            data.selectedComponents     = selectedComponents;
            data.propertyOwners         = propertyOwners;
            data.property               = property;
            data.propertyIndexes        = propertyIndexes;
            window.setReferenceModeData = data;

            //!!!!начальное положение, настройки. везде так

            EditorForm.Instance.WorkspaceController.AddDockWindow(window, true, true);
        }
Beispiel #9
0
 public ReferenceValueType_Property(Metadata.Property member, object obj)
     : base(member, obj)
 {
 }
Beispiel #10
0
 public HCItemСontentBrowserForCollection(HierarchicalContainer owner, HierarchicalContainer.Item parent, object[] controlledObjects, Metadata.Property property, object[] indexers)
     : base(owner, parent, controlledObjects, property, indexers)
 {
 }