Example #1
0
            /// <summary>
            /// Generate based on property
            /// </summary>
            /// <param name="propInfo"></param>
            public TypeRow(Data.EditableValue propInfo)
            {
                editableValue = propInfo;

                Title       = editableValue.Title;
                Description = editableValue.Description;
                EnableUndo  = editableValue.IsUndoEnabled;
                var shown = editableValue.IsShown;

                IParameterControl gui = null;
                var type = editableValue.Value.GetType();

                if (!shown)
                {
                    gui = null;
                    return;
                }

                gui = ParameterListComponentFactory.Generate(type);

                if (gui != null)
                {
                    // already generated
                }
                else if (type == typeof(Data.Value.String))
                {
                    gui = new String();
                }
                else if (type == typeof(Data.Value.Boolean))
                {
                    gui = new Boolean();
                }
                else if (type == typeof(Data.Value.Int))
                {
                    gui = new Int();
                }
                else if (type == typeof(Data.Value.IntWithInifinite))
                {
                    gui = new IntWithInifinite();
                }
                else if (type == typeof(Data.Value.IntWithRandom))
                {
                    gui = new IntWithRandom();
                }
                else if (type == typeof(Data.Value.Float))
                {
                    gui = new Float();
                }
                else if (type == typeof(Data.Value.FloatWithRandom))
                {
                    gui = new FloatWithRandom();
                }
                else if (type == typeof(Data.Value.Vector2D))
                {
                    gui = new Vector2D();
                }
                else if (type == typeof(Data.Value.Vector2DWithRandom))
                {
                    gui = new Vector2DWithRandom();
                }
                else if (type == typeof(Data.Value.Vector3D))
                {
                    gui = new Vector3D();
                }
                else if (type == typeof(Data.Value.Vector3DWithRandom))
                {
                    gui = new Vector3DWithRandom();
                }
                else if (type == typeof(Data.Value.Vector4D))
                {
                    gui = new Vector4D();
                }
                else if (type == typeof(Data.Value.Color))
                {
                    gui = new ColorCtrl();
                }
                else if (type == typeof(Data.Value.ColorWithRandom))
                {
                    gui = new ColorWithRandom();
                }
                else if (type == typeof(Data.Value.Path))
                {
                    gui = null;
                    return;
                }
                else if (type == typeof(Data.Value.PathForModel))
                {
                    gui = new PathForModel();
                }
                else if (type == typeof(Data.Value.PathForImage))
                {
                    gui = new PathForImage();
                }
                else if (type == typeof(Data.Value.PathForSound))
                {
                    gui = new PathForSound();
                }
                else if (type == typeof(Data.Value.PathForMaterial))
                {
                    gui = new PathForMaterial();
                }
                else if (type == typeof(Data.Value.FCurveScalar))
                {
                    gui = new FCurveButton();
                }
                else if (type == typeof(Data.Value.FCurveVector2D))
                {
                    gui = new FCurveButton();
                }
                else if (type == typeof(Data.Value.FCurveVector3D))
                {
                    gui = new FCurveButton();
                }
                else if (type == typeof(Data.Value.FCurveColorRGBA))
                {
                    gui = new FCurveButton();
                }
                else if (editableValue.Value is Data.IEditableValueCollection)
                {
                    gui = new Dummy();
                }
                else if (type == typeof(Data.Value.FCurve <float>))
                {
                    gui = null;
                    return;
                }
                else if (type == typeof(Data.Value.FCurve <byte>))
                {
                    gui = null;
                    return;
                }
                else if (type == typeof(Data.Value.IFCurveKey))
                {
                    gui = null;
                    return;
                }
                else if (type.IsGenericType)
                {
                    var types = type.GetGenericArguments();
                    gui = new Enum();

                    var dgui = (dynamic)gui;
                    dgui.Initialize(types[0]);
                }

                if (editableValue.SelfSelectorID >= 0)
                {
                    IsSelector     = true;
                    SelfSelectorID = editableValue.SelfSelectorID;
                }
                else
                {
                    IsSelector     = false;
                    SelfSelectorID = -1;
                }

                Control = gui;

                Label = Title;

                ControlDynamic = Control;

                if (Control != null)
                {
                    Control.EnableUndo = EnableUndo;
                }
            }
Example #2
0
            /// <summary>
            /// プロパティから生成
            /// </summary>
            /// <param name="properties"></param>
            public TypeRow(PropertyInfo[] properties, List <TypeRow> sameLayer, TypeRow parent)
            {
                Parent = parent;

                var p          = properties.LastOrDefault();
                var attributes = p.GetCustomAttributes(false);

                Control gui = null;

                var undo = attributes.Where(_ => _.GetType() == typeof(Effekseer.Data.UndoAttribute)).FirstOrDefault() as Effekseer.Data.UndoAttribute;

                if (undo != null && !undo.Undo)
                {
                    EnableUndo = false;
                }
                else
                {
                    EnableUndo = true;
                }

                var shown = attributes.Where(_ => _.GetType() == typeof(Effekseer.Data.ShownAttribute)).FirstOrDefault() as Effekseer.Data.ShownAttribute;

                if (shown != null && !shown.Shown)
                {
                    gui = null;
                    return;
                }
                else if (p.PropertyType == typeof(Data.Value.String))
                {
                    gui = new String();
                }
                else if (p.PropertyType == typeof(Data.Value.Boolean))
                {
                    gui = new Boolean();
                }
                else if (p.PropertyType == typeof(Data.Value.Int))
                {
                    gui = new Int();
                }
                else if (p.PropertyType == typeof(Data.Value.IntWithInifinite))
                {
                    gui = new IntWithInifinite();
                }
                else if (p.PropertyType == typeof(Data.Value.IntWithRandom))
                {
                    gui = new IntWithRandom();
                }
                else if (p.PropertyType == typeof(Data.Value.Float))
                {
                    gui = new Float();
                }
                else if (p.PropertyType == typeof(Data.Value.FloatWithRandom))
                {
                    gui = new FloatWithRandom();
                }
                else if (p.PropertyType == typeof(Data.Value.Vector2D))
                {
                    gui = new Vector2D();
                }
                else if (p.PropertyType == typeof(Data.Value.Vector2DWithRandom))
                {
                    gui = new Vector2DWithRandom();
                }
                else if (p.PropertyType == typeof(Data.Value.Vector3D))
                {
                    gui = new Vector3D();
                }
                else if (p.PropertyType == typeof(Data.Value.Vector3DWithRandom))
                {
                    gui = new Vector3DWithRandom();
                }
                else if (p.PropertyType == typeof(Data.Value.Color))
                {
                    gui = new ColorCtrl();
                }
                else if (p.PropertyType == typeof(Data.Value.ColorWithRandom))
                {
                    gui = new ColorWithRandom();
                }
                else if (p.PropertyType == typeof(Data.Value.Path))
                {
                    gui = new Path();
                }
                else if (p.PropertyType == typeof(Data.Value.PathForModel))
                {
                    gui = new PathForModel();
                }
                else if (p.PropertyType == typeof(Data.Value.PathForImage))
                {
                    gui = new PathForImage();
                }
                else if (p.PropertyType == typeof(Data.Value.PathForSound))
                {
                    gui = new PathForSound();
                }
                else if (p.PropertyType == typeof(Data.Value.FCurveVector2D))
                {
                    FCurveButton button = new FCurveButton();
                    gui = button;
                }
                else if (p.PropertyType == typeof(Data.Value.FCurveVector3D))
                {
                    FCurveButton button = new FCurveButton();
                    gui = button;
                }
                else if (p.PropertyType == typeof(Data.Value.FCurveColorRGBA))
                {
                    FCurveButton button = new FCurveButton();
                    gui = button;
                }
                else if (p.PropertyType == typeof(Data.Value.FCurve <float>))
                {
                    gui = null;
                    return;
                }
                else if (p.PropertyType == typeof(Data.Value.FCurve <byte>))
                {
                    gui = null;
                    return;
                }
                else if (p.PropertyType == typeof(Data.Value.IFCurveKey))
                {
                    gui = null;
                    return;
                }
                else if (p.PropertyType == typeof(Data.Value.Enum <Language>))
                {
                    gui = new GuiLanguage();
                }
                else if (p.PropertyType.IsGenericType)
                {
                    var types = p.PropertyType.GetGenericArguments();
                    gui = new Enum();

                    var dgui = (dynamic)gui;
                    dgui.Initialize(types[0]);
                }

                var selector_attribute = (from a in attributes where a is Data.SelectorAttribute select a).FirstOrDefault() as Data.SelectorAttribute;

                if (selector_attribute != null)
                {
                    IsSelector = true;
                    SelectorID = selector_attribute.ID;
                }
                else
                {
                    IsSelector = false;
                    SelectorID = -1;
                }

                Properties  = properties.Clone() as PropertyInfo[];
                Title       = NameAttribute.GetName(attributes);
                Description = DescriptionAttribute.GetDescription(attributes);
                Control     = gui;

                // Selector
                var selected_attribute = (from a in attributes where a is Data.SelectedAttribute select a).FirstOrDefault() as Data.SelectedAttribute;

                if (selected_attribute != null)
                {
                    var selector = sameLayer.Where(_ => _.IsSelector && _.SelectorID == selected_attribute.ID).LastOrDefault();

                    if (selector != null)
                    {
                        Selector      = selector;
                        SelectorValue = selected_attribute.Value;
                    }
                }

                Label           = new Label();
                Label.Width     = 0;
                Label.AutoSize  = true;
                Label.Text      = Title;
                Label.TextAlign = ContentAlignment.MiddleCenter;
                Label.Font      = new Font(Label.Font.FontFamily, 9);
                ControlDynamic  = Control;

                if (Control != null && !(Control is Button))
                {
                    ControlDynamic.EnableUndo = EnableUndo;
                }
            }
Example #3
0
            /// <summary>
            /// プロパティから生成
            /// </summary>
            /// <param name="properties"></param>
            public TypeRow(PropertyInfo[] properties, List<TypeRow> sameLayer, TypeRow parent)
            {
                Parent = parent;

                var p = properties.LastOrDefault();
                var attributes = p.GetCustomAttributes(false);

                Control gui = null;

                var undo = attributes.Where(_ => _.GetType() == typeof(Effekseer.Data.UndoAttribute)).FirstOrDefault() as Effekseer.Data.UndoAttribute;
                if (undo != null && !undo.Undo)
                {
                    EnableUndo = false;
                }
                else
                {
                    EnableUndo = true;
                }

                var shown = attributes.Where(_ => _.GetType() == typeof(Effekseer.Data.ShownAttribute)).FirstOrDefault() as Effekseer.Data.ShownAttribute;

                if (shown != null && !shown.Shown)
                {
                    gui = null;
                    return;
                }
                else if (p.PropertyType == typeof(Data.Value.String))
                {
                    gui = new String();
                }
                else if (p.PropertyType == typeof(Data.Value.Boolean))
                {
                    gui = new Boolean();
                }
                else if (p.PropertyType == typeof(Data.Value.Int))
                {
                    gui = new Int();
                }
                else if (p.PropertyType == typeof(Data.Value.IntWithInifinite))
                {
                    gui = new IntWithInifinite();
                }
                else if (p.PropertyType == typeof(Data.Value.IntWithRandom))
                {
                    gui = new IntWithRandom();
                }
                else if (p.PropertyType == typeof(Data.Value.Float))
                {
                    gui = new Float();
                }
                else if (p.PropertyType == typeof(Data.Value.FloatWithRandom))
                {
                    gui = new FloatWithRandom();
                }
                else if (p.PropertyType == typeof(Data.Value.Vector2D))
                {
                    gui = new Vector2D();
                }
                else if (p.PropertyType == typeof(Data.Value.Vector2DWithRandom))
                {
                    gui = new Vector2DWithRandom();
                }
                else if (p.PropertyType == typeof(Data.Value.Vector3D))
                {
                    gui = new Vector3D();
                }
                else if (p.PropertyType == typeof(Data.Value.Vector3DWithRandom))
                {
                    gui = new Vector3DWithRandom();
                }
                else if (p.PropertyType == typeof(Data.Value.Color))
                {
                    gui = new ColorCtrl();
                }
                else if (p.PropertyType == typeof(Data.Value.ColorWithRandom))
                {
                    gui = new ColorWithRandom();
                }
                else if (p.PropertyType == typeof(Data.Value.Path))
                {
                    gui = new Path();
                }
                else if (p.PropertyType == typeof(Data.Value.PathForImage))
                {
                    gui = new PathForImage();
                }
                else if (p.PropertyType == typeof(Data.Value.PathForSound))
                {
                    gui = new PathForSound();
                }
                else if (p.PropertyType == typeof(Data.Value.FCurveVector3D))
                {
                    FCurveButton button = new FCurveButton();
                    button.Text = "Fカーブ";
                    gui = button;
                }
                else if (p.PropertyType == typeof(Data.Value.FCurveColorRGBA))
                {
                    FCurveButton button = new FCurveButton();
                    button.Text = "Fカーブ";
                    gui = button;
                }
                else if (p.PropertyType == typeof(Data.Value.FCurve<float>))
                {
                    gui = null;
                    return;
                }
                else if (p.PropertyType == typeof(Data.Value.FCurve<byte>))
                {
                    gui = null;
                    return;
                }
                else if (p.PropertyType == typeof(Data.Value.IFCurveKey))
                {
                    gui = null;
                    return;
                }
                else if (p.PropertyType.IsGenericType)
                {
                    var types = p.PropertyType.GetGenericArguments();
                    var generic_type = typeof(Enum<>).MakeGenericType(types);
                    var constructor = generic_type.GetConstructor(new Type[] { });
                    gui = constructor.Invoke(null) as Control;
                }

                var selector_attribute = (from a in attributes where a is Data.SelectorAttribute select a).FirstOrDefault() as Data.SelectorAttribute;
                if (selector_attribute != null)
                {
                    IsSelector = true;
                    SelectorID = selector_attribute.ID;
                }
                else
                {
                    IsSelector = false;
                    SelectorID = -1;
                }

                Properties = properties.Clone() as PropertyInfo[];
                Title = NameAttribute.GetName(attributes);
                Description = DescriptionAttribute.GetDescription(attributes);
                Control = gui;

                // Selector
                var selected_attribute = (from a in attributes where a is Data.SelectedAttribute select a).FirstOrDefault() as Data.SelectedAttribute;
                if (selected_attribute != null)
                {
                    var selector = sameLayer.Where(_ => _.IsSelector && _.SelectorID == selected_attribute.ID).LastOrDefault();

                    if (selector != null)
                    {
                        Selector = selector;
                        SelectorValue = selected_attribute.Value;
                    }
                }

                Label = new Label();
                Label.Width = 0;
                Label.AutoSize = true;
                Label.Text = Title;
                Label.TextAlign = ContentAlignment.MiddleCenter;
                Label.Font = new Font(Label.Font.FontFamily, 9);
                ControlDynamic = Control;

                if (Control != null && !(Control is Button))
                {
                    ControlDynamic.EnableUndo = EnableUndo;
                }
            }