Пример #1
0
    private void CreateUI()
    {
        _Frame = new Skill.Editor.UI.EditorFrame("Frame", this);
        _Frame.Grid.RowDefinitions.Add(140, Skill.Framework.UI.GridUnitType.Pixel); // Panel
        _Frame.Grid.RowDefinitions.Add(1, Skill.Framework.UI.GridUnitType.Star);    // Empty
        _Frame.Grid.Padding = new Skill.Framework.UI.Thickness(2, 4);

        _Panel = new Skill.Framework.UI.Grid();
        _Panel.RowDefinitions.Add(24, Skill.Framework.UI.GridUnitType.Pixel); // _UnitsField
        _Panel.RowDefinitions.Add(36, Skill.Framework.UI.GridUnitType.Pixel); // _BtnOrganizeByPrefab
        _Panel.RowDefinitions.Add(36, Skill.Framework.UI.GridUnitType.Pixel); // _BtnOrganizeByUnits
        _Panel.RowDefinitions.Add(36, Skill.Framework.UI.GridUnitType.Pixel); // _BtnRemoveEmptyObjects
        _Panel.RowDefinitions.Add(4, Skill.Framework.UI.GridUnitType.Pixel);  // empty
        _Frame.Controls.Add(_Panel);

        var margin = new Skill.Framework.UI.Thickness(0, 4, 0, 0);

        Grid g = new Grid()
        {
            Row = 0, Column = 0, Margin = margin
        };

        g.ColumnDefinitions.Add(40, GridUnitType.Pixel);
        g.ColumnDefinitions.Add(1, GridUnitType.Star);
        _UnitsLabel = new Label()
        {
            Column = 0, Text = "Units"
        };
        g.Controls.Add(_UnitsLabel);

        _BtnOrganizeByPrefab = new Button()
        {
            Row = 1, Column = 0, Margin = margin
        }; _BtnOrganizeByPrefab.Content.text = "Organize by prefab";
        _Panel.Controls.Add(_BtnOrganizeByPrefab);

        _UnitsField = new Skill.Editor.UI.Vector3Field()
        {
            Column = 1, Value = _UnitLength
        };
        g.Controls.Add(_UnitsField);

        _Panel.Controls.Add(g);

        _BtnOrganizeByUnits = new Button()
        {
            Row = 2, Column = 0, Margin = margin
        }; _BtnOrganizeByUnits.Content.text = "Organize by units";
        _Panel.Controls.Add(_BtnOrganizeByUnits);

        _BtnRemoveEmptyObjects = new Button()
        {
            Row = 3, Column = 0, Margin = margin
        }; _BtnRemoveEmptyObjects.Content.text = "Delete empty objects";
        _Panel.Controls.Add(_BtnRemoveEmptyObjects);

        _BtnOrganizeByPrefab.Click   += _BtnOrganizeByPrefab_Click;
        _BtnOrganizeByUnits.Click    += _BtnOrganizeByUnits_Click;
        _BtnRemoveEmptyObjects.Click += _BtnRemoveEmptyObjects_Click;
        _UnitsField.ValueChanged     += _UnitsField_ValueChanged;
    }
Пример #2
0
        private void CreateUI()
        {
            _Frame = new Skill.Editor.UI.EditorFrame("Frame", this);
            _Frame.Grid.RowDefinitions.Add(120, Skill.Framework.UI.GridUnitType.Pixel); // Panel
            _Frame.Grid.RowDefinitions.Add(1, Skill.Framework.UI.GridUnitType.Star);    // Empty
            _Frame.Grid.Padding = new Skill.Framework.UI.Thickness(2, 4);


            _Panel = new Skill.Framework.UI.Grid();
            _Panel.RowDefinitions.Add(36, Skill.Framework.UI.GridUnitType.Pixel); // Axis step
            _Panel.RowDefinitions.Add(24, Skill.Framework.UI.GridUnitType.Pixel); // _BtnLocal
            _Panel.RowDefinitions.Add(22, Skill.Framework.UI.GridUnitType.Pixel); // Duplicate
            _Panel.RowDefinitions.Add(1, Skill.Framework.UI.GridUnitType.Star);   // MoveButton
            _Panel.ColumnDefinitions.Add(1, Skill.Framework.UI.GridUnitType.Star);
            _Panel.ColumnDefinitions.Add(1, Skill.Framework.UI.GridUnitType.Star);
            _Frame.Controls.Add(_Panel);

            var margin    = new Skill.Framework.UI.Thickness(0, 4, 0, 0);
            var alignment = Skill.Framework.UI.VerticalAlignment.Top;

            Grid xyzStep = new Grid()
            {
                Row = 0, Column = 0, ColumnSpan = 2
            };

            xyzStep.ColumnDefinitions.Add(1, GridUnitType.Star);
            xyzStep.ColumnDefinitions.Add(1, GridUnitType.Star);
            xyzStep.ColumnDefinitions.Add(1, GridUnitType.Star);
            _Panel.Controls.Add(xyzStep);

            _XStep = new FieldComponent()
            {
                Column = 0, Value = _SerializedStep.x, Label = "X", Margin = new Thickness()
            };
            xyzStep.Controls.Add(_XStep);

            _YStep = new FieldComponent()
            {
                Column = 1, Value = _SerializedStep.y, Label = "Y", Margin = new Thickness(4, 0, 0, 0)
            };
            xyzStep.Controls.Add(_YStep);

            _ZStep = new FieldComponent()
            {
                Column = 2, Value = _SerializedStep.z, Label = "Z", Margin = new Thickness(4, 0, 0, 0)
            };
            xyzStep.Controls.Add(_ZStep);


            _BtnLocal = new Framework.UI.Button()
            {
                Row = 1, Column = 0, ColumnSpan = 2, Margin = margin
            };
            _BtnLocal.Content.text    = _SerializedLocal ? "Local" : "Global";
            _BtnLocal.Content.tooltip = "local or global space";
            _Panel.Controls.Add(_BtnLocal);

            _TbDuplicate = new Skill.Editor.UI.ToggleButton()
            {
                Row = 2, Column = 0, Left = true, IsChecked = _SerializedDuplicate, Margin = margin, VerticalAlignment = alignment
            };
            _TbDuplicate.Label.text    = "Duplicate";
            _TbDuplicate.Label.tooltip = "duplicate instance";
            _Panel.Controls.Add(_TbDuplicate);

            _IntInstance = new Skill.Editor.UI.IntField()
            {
                Row = 2, Column = 1, Value = _SerializedInstances, IsEnabled = false, Margin = margin, VerticalAlignment = alignment, ChangeOnReturn = false
            };
            _IntInstance.Label.tooltip = "duplicate instance";
            _Panel.Controls.Add(_IntInstance);

            _BtnMove = new Skill.Framework.UI.Button()
            {
                Row = 3, Column = 0, ColumnSpan = 2
            };
            SetMoveText();
            _Panel.Controls.Add(_BtnMove);

            _TbDuplicate.Changed      += _TbDuplicate_Changed;
            _IntInstance.ValueChanged += _IntInstance_ValueChanged;
            _XStep.ValueChanged       += _XYZStep_ValueChanged;
            _YStep.ValueChanged       += _XYZStep_ValueChanged;
            _ZStep.ValueChanged       += _XYZStep_ValueChanged;
            _BtnMove.Click            += _BtnMove_Click;
            _BtnLocal.Click           += _BtnLocal_Click;
        }