Example #1
0
        //--------------------------------
        private void btnMask_Click(object sender, EventArgs e)
        {
            // show the texture browser.
            DialogResult result = _textureSelector.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                return;
            }

            List <string> selection = _textureSelector.Selection;

            if (result != DialogResult.No)
            {
                // if no selection was made but "None" was not the result,
                // don't do anything.
                if (selection.Count == 0)
                {
                    return;
                }
                _light.Mask = selection[0];
            }
            else
            {
                _light.Mask = null;
            }
        }
Example #2
0
        void bnTexture_Click(object sender, EventArgs e)
        {
            // try to cast the sending object to a Syncfusion button.
            ButtonAdv button = sender as ButtonAdv;

            if (button == null)
            {
                return;
            }

            // get the current stage.
            bool selectingMask = false;

            Bootstrap.Brush.Stage stage = Bootstrap.Brush.Stage.User;
            string stageName            = "";

            if (button == bnDiffuse)
            {
                stage     = Bootstrap.Brush.Stage.Diffuse;
                stageName = "Diffuse";
            }
            else if (button == bnSpecular)
            {
                stage     = Bootstrap.Brush.Stage.Specular;
                stageName = "Specular";
            }
            else if (button == bnNormal)
            {
                stage     = Bootstrap.Brush.Stage.Normal;
                stageName = "Normal";
            }
            else if (button == bnBump)
            {
                stage     = Bootstrap.Brush.Stage.Bump;
                stageName = "Bump";
            }
            else if (button == bnEmissive)
            {
                stage     = Bootstrap.Brush.Stage.Emissive;
                stageName = "Emissive";
            }
            else if (button == bnAmbient)
            {
                stage     = Bootstrap.Brush.Stage.Ambient;
                stageName = "Ambient";
            }
            else if (sender == bnUser)
            {
                stage     = Bootstrap.Brush.Stage.User;
                stageName = "User";
            }
            else if (sender == bnMask)
            {
                selectingMask = true;
                stageName     = "Mask";
            }

            // now select an image using the texture selector.
            _textureSelector.Text = "Select " + stageName + " Texture";
            DialogResult result = _textureSelector.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                return;
            }

            // determine what to do... grab the result from the dialog or
            // clear the result.
            string imageName = "";

            if (result != DialogResult.No)
            {
                // if no selection was made but "None" was not the result,
                // don't do anything.
                if (_textureSelector.Selection.Count == 0)
                {
                    return;
                }
                imageName = _textureSelector.Selection[0];
            }

            // set filler text if nothing was selected.
            if (imageName == "")
            {
                button.Text = "{not set}";
            }
            else
            {
                button.Text = imageName;
            }

            // now apply the image to the brush.
            if (selectingMask)
            {
                _brush.SetMask(imageName);
            }
            else
            {
                _brush.SetImage(stage, imageName);
            }

            // then persist the change.
            Bootstrap.Brush.SaveBrushes();

            // notify any observers of the change.
            if (BrushEdited != null)
            {
                BrushEdited(this, new EventArgs());
            }
        }