Exemplo n.º 1
0
                    public ParameterItem(ListItem owner, ParameterData data)
                    {
                        this._OwnerListItem = owner;
                        this._Data          = data;
                        this.Height         = 24;
                        this.Padding        = new Thickness(0, 4);

                        this.ColumnDefinitions.Add(1, GridUnitType.Star);
                        this.ColumnDefinitions.Add(2, GridUnitType.Star);
                        this.ColumnDefinitions.Add(2, GridUnitType.Star);

                        _EnumType = new UI.EnumPopup()
                        {
                            Column = 0, Margin = new Thickness(2, 0)
                        };
                        _EnumType.Value         = _Data.Type;
                        _EnumType.ValueChanged += _EnumType_ValueChanged;
                        this.Controls.Add(_EnumType);

                        _TxtName = new UI.TextField()
                        {
                            Column = 1, Text = data.Name, Margin = new Thickness(2, 0)
                        };
                        _TxtName.TextChanged += _TxtName_TextChanged;
                        this.Controls.Add(_TxtName);

                        _IntValue = new UI.IntField()
                        {
                            Column = 2, Margin = new Thickness(2, 0, 6, 0), Visibility = Framework.UI.Visibility.Hidden
                        };
                        this.Controls.Add(_IntValue);
                        _IntValue.ValueChanged += _IntField_ValueChanged;


                        _BoolValue = new UI.ToggleButton()
                        {
                            Column = 2, Margin = new Thickness(2, 0, 6, 0), Visibility = Framework.UI.Visibility.Hidden
                        };
                        this.Controls.Add(_BoolValue);
                        _BoolValue.Changed += _ToggleButton_Changed;

                        _FloatValue = new UI.FloatField()
                        {
                            Column = 2, Margin = new Thickness(2, 0, 6, 0), Visibility = Framework.UI.Visibility.Hidden
                        };
                        this.Controls.Add(_FloatValue);
                        _FloatValue.ValueChanged += _FloatField_ValueChanged;

                        _StringValue = new UI.TextField()
                        {
                            Column = 2, Text = _Data.Value, Margin = new Thickness(2, 0, 6, 0), Visibility = Framework.UI.Visibility.Hidden
                        };
                        this.Controls.Add(_StringValue);
                        _StringValue.TextChanged += _TextField_TextChanged;

                        UpdateValue();
                    }
Exemplo n.º 2
0
 private void RemoveSelectedParameter()
 {
     if (_FieldsList.SelectedItem != null)
     {
         ParameterData pd = (ParameterData)_FieldsList.SelectedItem.UserData;
         _Data.Remove(pd);
         _DataDifinition.Match(_Data);
         Rebuild();
         _Item.RefreshContent();
         _Item.Editor.RefreshSameContent(_Item);
     }
 }
Exemplo n.º 3
0
                void _BtnAdd_Click(object sender, System.EventArgs e)
                {
                    ParameterData data = new ParameterData()
                    {
                        Name = "NewInt", Type = ParameterType.Int, Value = "0"
                    };

                    _Data.Add(data);
                    ParameterItem pi = new ParameterItem(_OwnerListItem, data);

                    _LbItems.Items.Add(pi);
                    _LbItems.SelectedItem = pi;

                    this._OwnerListItem.UpdateContent();
                }
Exemplo n.º 4
0
        private void RenameParameter(ParameterData data)
        {
            int index = -1;

            for (int i = 0; i < _Data.Count; i++)
            {
                if (data == _Data[i])
                {
                    index = i;
                    break;
                }
            }
            if (index >= 0)
            {
                _DataDifinition[index].Name = data.Name;
            }
        }
Exemplo n.º 5
0
        private void AddNewParameter(ParameterType type)
        {
            ParameterData pd = new ParameterData();

            pd.Type = type;
            pd.Name = "new" + type.ToString();

            switch (pd.Type)
            {
            case ParameterType.Int:
                pd.Value = "0";
                break;

            case ParameterType.Bool:
                pd.Value = "false";
                break;

            case ParameterType.Float:
                pd.Value = "0";
                break;

            case ParameterType.String:
                pd.Value = "";
                break;
            }


            int    i    = 0;
            string name = pd.Name;

            while (HasName(_DataDifinition, pd.Name))
            {
                pd.Name = name + (i++).ToString();
            }


            _DataDifinition.Add(pd);
            _Data.Match(_DataDifinition);

            Rebuild();
            _Item.RefreshContent();
            _Item.Editor.RefreshSameContent(_Item);
        }
Exemplo n.º 6
0
            public ParameterField(ParameterEditor owner, ParameterData data)
            {
                this._Owner   = owner;
                this._Data    = data;
                this.UserData = data;
                this.Height   = 22;

                this.ColumnDefinitions.Add(22, Framework.UI.GridUnitType.Pixel);
                this.ColumnDefinitions.Add(1, Framework.UI.GridUnitType.Star);
                this.ColumnDefinitions.Add(1, Framework.UI.GridUnitType.Star);

                _Icon = new Framework.UI.Image()
                {
                    Column = 0, Scale = UnityEngine.ScaleMode.ScaleToFit, Texture = UnityEditor.EditorGUIUtility.FindTexture("Toolbar Minus")
                };
                this.Controls.Add(_Icon);

                _ParameterName = new UI.TextField()
                {
                    Column = 1, Margin = new Framework.UI.Thickness(2), Text = _Data.Name
                };
                this.Controls.Add(_ParameterName);
                _ParameterName.TextChanged += _ParameterName_TextChanged;

                switch (_Data.Type)
                {
                case ParameterType.Int:
                    _ParameterField = new UI.IntField();
                    int v = 0;
                    if (int.TryParse(_Data.Value, out v))
                    {
                        ((UI.IntField)_ParameterField).Value = v;
                    }
                    else
                    {
                        ((UI.IntField)_ParameterField).Value = 0;
                        _Data.Value = "0";
                    }
                    ((UI.IntField)_ParameterField).ValueChanged += intField_ValueChanged;
                    break;

                case ParameterType.Bool:
                    _ParameterField = new UI.ToggleButton();

                    bool b = false;
                    if (bool.TryParse(_Data.Value, out b))
                    {
                        ((UI.ToggleButton)_ParameterField).IsChecked = b;
                    }
                    else
                    {
                        ((UI.ToggleButton)_ParameterField).IsChecked = false;
                        _Data.Value = "false";
                    }
                    ((UI.ToggleButton)_ParameterField).Changed += boolField_Changed;
                    break;

                case ParameterType.Float:
                    _ParameterField = new UI.FloatField();

                    float f = 0;
                    if (float.TryParse(_Data.Value, out f))
                    {
                        ((UI.FloatField)_ParameterField).Value = f;
                    }
                    else
                    {
                        ((UI.FloatField)_ParameterField).Value = 0;
                        _Data.Value = "0";
                    }
                    ((UI.FloatField)_ParameterField).ValueChanged += floatField_ValueChanged;
                    break;

                case ParameterType.String:
                    _ParameterField = new UI.TextField();
                    ((UI.TextField)_ParameterField).Text         = _Data.Value;
                    ((UI.TextField)_ParameterField).TextChanged += textField_TextChanged;
                    break;
                }
                if (_ParameterField != null)
                {
                    _ParameterField.Column = 2;
                    _ParameterField.Margin = new Framework.UI.Thickness(2);
                    this.Controls.Add(_ParameterField);
                }
            }