示例#1
0
        private void toolStripButtonViewShape_Click(object sender, EventArgs e)
        {
            ShapeSelection shapeSelection = new ShapeSelection();
            EmitterShape   currentShape   = particleEffectControl.ParticleEffect.Emitter.Shape;

            shapeSelection.ShapeType   = currentShape.Type;
            shapeSelection.ShapeOffset = currentShape.Offset;
            shapeSelection.ShapeSize   = currentShape.Size;
            shapeSelection.TexturePath = lastTextureMaskPath;
            if (shapeSelection.ShowDialog() == DialogResult.OK)
            {
                EmitterShape shape = new EmitterShape(shapeSelection.ShapeType, shapeSelection.ShapeSize,
                                                      particleEffectControl.ParticleEffect.Position, shapeSelection.ShapeOffset);
                // if it's a mask, construct it
                if (shape.Type == EmitterShapeType.TextureMask)
                {
                    try
                    {
                        lastTextureMaskPath = shapeSelection.TexturePath;
                        Texture2D maskTexture = Texture2D.FromStream(DrawingManager.GraphicsDevice, System.IO.File.OpenRead(shapeSelection.TexturePath));
                        shape.CreateTextureMaskFromTexture2D(maskTexture, shapeSelection.UseFilled, shapeSelection.UseLeft,
                                                             shapeSelection.UseRight, shapeSelection.UseTop, shapeSelection.UseBottom);
                    }
                    catch
                    {
                        MessageBox.Show("Error: " + e.ToString(), "Error while loading texture",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                shape.Initialize();
                particleEffectControl.ParticleEffect.Emitter.Shape = shape;
            }
        }
 private void toolStripButtonViewShape_Click(object sender, EventArgs e)
 {
     ShapeSelection shapeSelection = new ShapeSelection();
     EmitterShape currentShape = particleEffectControl.ParticleEffect.Emitter.Shape;
     shapeSelection.ShapeType = currentShape.Type;
     shapeSelection.ShapeOffset = currentShape.Offset;
     shapeSelection.ShapeSize = currentShape.Size;
     shapeSelection.TexturePath = lastTextureMaskPath;
     if (shapeSelection.ShowDialog() == DialogResult.OK)
     {
         EmitterShape shape = new EmitterShape(shapeSelection.ShapeType, shapeSelection.ShapeSize,
             particleEffectControl.ParticleEffect.Position, shapeSelection.ShapeOffset);
         // if it's a mask, construct it
         if (shape.Type == EmitterShapeType.TextureMask)
         {
             try
             {
                 lastTextureMaskPath = shapeSelection.TexturePath;
                 Texture2D maskTexture = Texture2D.FromFile(DrawingManager.GraphicsDevice, shapeSelection.TexturePath);
                 shape.CreateTextureMaskFromTexture2D(maskTexture, shapeSelection.UseFilled, shapeSelection.UseLeft,
                     shapeSelection.UseRight, shapeSelection.UseTop, shapeSelection.UseBottom);
             }
             catch
             {
                 MessageBox.Show("Error: " + e.ToString(), "Error while loading texture", 
                     MessageBoxButtons.OK, MessageBoxIcon.Error);                        
             }
         }
         shape.Initialize();
         particleEffectControl.ParticleEffect.Emitter.Shape = shape;
     }            
 }