Esempio n. 1
0
        public void UpdateProperties(MapObjectGroup selection)
        {
            int detailSolids    = 0;
            int nonDetailSolids = 0;
            int hiddenSolids    = 0;
            int nonHiddenSolids = 0;

            if (!selection.Empty)
            {
                Enabled = true;
                CustomOperation operation = new CustomOperation
                {
                    OnSolid = (solid) =>
                    {
                        // check hidden property
                        if (solid.Hidden)
                        {
                            hiddenSolids++;
                        }
                        else
                        {
                            nonHiddenSolids++;
                        }

                        CheckState binairCheckstate = hiddenSolids == 0 ? CheckState.Unchecked : CheckState.Checked;
                        hiddenSolid.CheckState = hiddenSolids > 0 && nonHiddenSolids > 0
                            ? CheckState.Indeterminate
                            : binairCheckstate;

                        // check detail property
                        if (solid.Detail)
                        {
                            detailSolids++;
                        }
                        else
                        {
                            nonDetailSolids++;
                        }

                        binairCheckstate       = detailSolids == 0 ? CheckState.Unchecked : CheckState.Checked;
                        detailSolid.CheckState = detailSolids > 0 && nonDetailSolids > 0
                            ? CheckState.Indeterminate
                            : binairCheckstate;
                    }
                };
                operation.OnMapObjectGroup = (group) =>
                {
                    group.MapObjectList.ForEach((subGroup) => subGroup.PerformOperation(operation));
                };
                selection.PerformOperation(operation);
            }
            else
            {
                detailSolid.CheckState = CheckState.Unchecked;
                hiddenSolid.CheckState = CheckState.Unchecked;
                Enabled = false;
            }
        }
Esempio n. 2
0
        public void UpdateProperties(MapObjectGroup selection)
        {
            ignoreChangedEvent = true;
            bool uShiftIsDifferent    = false;
            bool vShiftIsDifferent    = false;
            bool uScaleIsDifferent    = false;
            bool vScaleIsDifferent    = false;
            bool rotationIsDifferent  = false;
            bool textureLockDifferent = false;
            int  faceCount            = 0;

            if (!selection.Empty)
            {
                CustomOperation operation = new CustomOperation
                {
                    OnSolid = (solid) => solid.Faces.Where(f => f.Selected).ToList().ForEach((face) =>
                    {
                        faceCount++;

                        uScaleNumeric.Value = (decimal)face.TextureMapping.UScale;
                        if (uScaleNumeric.Value != (decimal)face.TextureMapping.UScale)
                        {
                            uScaleIsDifferent = true;
                        }

                        vScaleNumeric.Value = (decimal)face.TextureMapping.VScale;
                        if (vScaleNumeric.Value != (decimal)face.TextureMapping.VScale)
                        {
                            vScaleIsDifferent = true;
                        }

                        uShiftNumeric.Value = (decimal)face.TextureMapping.UShift;
                        if (uShiftNumeric.Value != (decimal)face.TextureMapping.UShift)
                        {
                            uShiftIsDifferent = true;
                        }

                        vShiftNumeric.Value = (decimal)face.TextureMapping.VShift;
                        if (vShiftNumeric.Value != (decimal)face.TextureMapping.VShift)
                        {
                            vShiftIsDifferent = true;
                        }

                        rotationNumeric.Value = (decimal)face.TextureMapping.Rotation;
                        if (rotationNumeric.Value != (decimal)face.TextureMapping.Rotation)
                        {
                            rotationIsDifferent = true;
                        }

                        textureLockButton.Checked = face.TextureMapping.TextureLocked;
                        if (textureLockButton.Checked != face.TextureMapping.TextureLocked)
                        {
                            textureLockDifferent = true;
                        }
                    })
                };
                operation.OnMapObjectGroup = (group) =>
                {
                    group.MapObjectList.ForEach((subGroup) => subGroup.PerformOperation(operation));
                };
                selection.PerformOperation(operation);
            }
            else
            {
                ResetValues();
            }

            TreatAsOneCheckbox.Enabled = faceCount > 1;

            // check if we need to set default values
            if (uScaleIsDifferent)
            {
                uScaleNumeric.Value = TextureMapping.DefaultScaleValue;
            }

            if (vScaleIsDifferent)
            {
                vScaleNumeric.Value = TextureMapping.DefaultScaleValue;
            }

            if (uShiftIsDifferent)
            {
                vShiftNumeric.Value = TextureMapping.DefaultShiftValue;
            }

            if (vShiftIsDifferent)
            {
                vShiftNumeric.Value = TextureMapping.DefaultShiftValue;
            }

            if (rotationIsDifferent)
            {
                rotationNumeric.Value = TextureMapping.DefaultRotationValue;
            }

            if (textureLockDifferent)
            {
                textureLockButton.Checked = TextureMapping.DefaultTextureLockValue;
            }

            ignoreChangedEvent = false;
        }