public void showDeleteDialog()
            {
                ParticleEmitterEditor.PE_EmitterEditor PE_EmitterEditor = "PE_EmitterEditor";

                // Don't allow deleting DefaultParticle.

                if (this.currParticle.getName() == "DefaultParticle")
                {
                    messageBox.MessageBoxOK("Error", "Cannot delete DefaultParticle");
                    return;
                }

                // Check to see if the particle emitter has more than 1 particle on it.

                if (Util.getWordCount(PE_EmitterEditor.currEmitter["particles"]) == 1)
                {
                    messageBox.MessageBoxOK("Error", "At least one particle must remain on the particle emitter.");
                    return;
                }

                // Bring up requester for confirmation.

                if (this.currParticle.isObject())
                {
                    messageBox.MessageBoxYesNoCancel("Delete Particle?",
                                                     "Are you sure you want to delete<br><br>" + this.currParticle.getName() +
                                                     "<br><br> Particle deletion won't take affect until the engine is quit.",
                                                     "PE_ParticleEditor.saveParticleDialogDontSave( " + this.currParticle.getName() +
                                                     " ); PE_ParticleEditor.deleteParticle();",
                                                     "",
                                                     ""
                                                     );
                }
            }
            public void createParticle(string replaceSlot)
            {
                ParticleEmitterEditor.PE_EmitterEditor PE_EmitterEditor = "PE_EmitterEditor";
                ParticleEditor ParticleEditor = "ParticleEditor";


                int particleIndex;

                // Make sure we have a spare slot on the current emitter.

                if (replaceSlot == "")
                {
                    int numExistingParticles = Util.getWordCount(PE_EmitterEditor.currEmitter["particles"]);
                    if (numExistingParticles > 3)
                    {
                        messageBox.MessageBoxOK("Error", "An emitter cannot have more than 4 particles assigned to it.");
                        return;
                    }

                    particleIndex = numExistingParticles;
                }
                else
                {
                    particleIndex = replaceSlot.AsInt() - 1;
                }

                // Create the particle datablock and add to the emitter.

                string newParticle = Util.getUniqueName("newParticle");

                SimObject newParticleNode = new DatablockCreator("ParticleData", newParticle + " : DefaultParticle", typeof(ParticleData)).Create();

                // Submit undo.

                var action = ParticleEditor.createUndo <ParticleEditorUndo.ActionCreateNewParticle>("Create New Particle");

                action["particle"]      = newParticleNode;
                action["particleIndex"] = particleIndex.AsString();
                action["prevParticle"]  =
                    ((GuiPopUpMenuCtrl)("PEE_EmitterParticleSelector" + (particleIndex + 1))).getSelected()
                    .AsString();
                action["emitter"] = PE_EmitterEditor.currEmitter;

                ParticleEditor.submitUndo(action);

                // Execute action.

                action.redo();
            }
            public void deleteParticle()
            {
                ParticleEditor ParticleEditor = "ParticleEditor";

                ParticleEmitterEditor.PE_EmitterEditor PE_EmitterEditor = "PE_EmitterEditor";

                SimObject particle = this.currParticle;

                // Submit undo.

                var action = ParticleEditor.createUndo <ParticleEditorUndo.ActionDeleteParticle>("Delete Particle");

                action["particle"] = particle;
                action["emitter"]  = PE_EmitterEditor.currEmitter;

                ParticleEditor.submitUndo(action);

                // Execute action.

                action.redo();
            }
            public void guiSync()
            {
                GuiPopUpMenuCtrl PEP_ParticleSelector = "PEP_ParticleSelector";

                ParticleEmitterEditor.PE_EmitterEditor PE_EmitterEditor = "PE_EmitterEditor";
                MaterialEditor.gui.CodeBehind.MaterialEditor.MaterialEditorGui MaterialEditorGui = "MaterialEditorGui";
                GuiSwatchButtonCtrl PE_ColorTintSwatch0 = "PE_ColorTintSwatch0";
                GuiSwatchButtonCtrl PE_ColorTintSwatch1 = "PE_ColorTintSwatch1";
                GuiSwatchButtonCtrl PE_ColorTintSwatch2 = "PE_ColorTintSwatch2";
                GuiSwatchButtonCtrl PE_ColorTintSwatch3 = "PE_ColorTintSwatch3";

                GuiBitmapButtonCtrl PEP_previewImage                  = this.FOT("PEP_previewImage");
                GuiTextEditCtrl     PEP_previewImageName              = this.FOT("PEP_previewImageName");
                GuiTextEditCtrl     PEP_lifetimeMS_textEdit           = this.FOT("PEP_lifetimeMS_textEdit");
                GuiTextEditCtrl     PEP_lifetimeVarianceMS_textEdit   = this.FOT("PEP_lifetimeVarianceMS_textEdit");
                GuiTextEditCtrl     PEP_inheritedVelFactor_textEdit   = this.FOT("PEP_inheritedVelFactor_textEdit");
                GuiTextEditCtrl     PEP_constantAcceleration_textEdit = this.FOT("PEP_constantAcceleration_textEdit");
                GuiTextEditCtrl     PEP_gravityCoefficient_textEdit   = this.FOT("PEP_gravityCoefficient_textEdit");
                GuiTextEditCtrl     PEP_dragCoefficient_textEdit      = this.FOT("PEP_dragCoefficient_textEdit");
                GuiTextEditCtrl     PEP_spinRandomMin_textEdit        = this.FOT("PEP_spinRandomMin_textEdit");
                GuiTextEditCtrl     PEP_spinRandomMax_textEdit        = this.FOT("PEP_spinRandomMax_textEdit");
                GuiTextEditCtrl     PEP_spinSpeed_textEdit            = this.FOT("PEP_spinSpeed_textEdit");
                GuiTextEditCtrl     PEP_pointSize_textEdit0           = this.FOT("PEP_pointSize_textEdit0");
                GuiTextEditCtrl     PEP_pointSize_textEdit1           = this.FOT("PEP_pointSize_textEdit1");
                GuiTextEditCtrl     PEP_pointSize_textEdit2           = this.FOT("PEP_pointSize_textEdit2");
                GuiTextEditCtrl     PEP_pointSize_textEdit3           = this.FOT("PEP_pointSize_textEdit3");
                GuiTextEditCtrl     PEP_pointTime_textEdit0           = this.FOT("PEP_pointTime_textEdit0");
                GuiTextEditCtrl     PEP_pointTime_textEdit1           = this.FOT("PEP_pointTime_textEdit1");
                GuiTextEditCtrl     PEP_pointTime_textEdit2           = this.FOT("PEP_pointTime_textEdit2");
                GuiTextEditCtrl     PEP_pointTime_textEdit3           = this.FOT("PEP_pointTime_textEdit3");
                GuiCheckBoxCtrl     PEP_inverseAlpha                  = this.FOT("PEP_inverseAlpha");
                GuiSliderCtrl       PEP_lifetimeMS_slider             = this.FOT("PEP_lifetimeMS_slider");
                GuiSliderCtrl       PEP_lifetimeVarianceMS_slider     = this.FOT("PEP_lifetimeVarianceMS_slider");
                GuiSliderCtrl       PEP_inheritedVelFactor_slider     = this.FOT("PEP_inheritedVelFactor_slider");
                GuiSliderCtrl       PEP_constantAcceleration_slider   = this.FOT("PEP_constantAcceleration_slider");
                GuiSliderCtrl       PEP_gravityCoefficient_slider     = this.FOT("PEP_gravityCoefficient_slider");
                GuiSliderCtrl       PEP_dragCoefficient_slider        = this.FOT("PEP_dragCoefficient_slider");
                GuiSliderCtrl       PEP_spinRandomMin_slider          = this.FOT("PEP_spinRandomMin_slider");
                GuiSliderCtrl       PEP_spinRandomMax_slider          = this.FOT("PEP_spinRandomMax_slider");
                GuiSliderCtrl       PEP_spinSpeed_slider              = this.FOT("PEP_spinSpeed_slider");
                GuiSliderCtrl       PEP_pointSize_slider0             = this.FOT("PEP_pointSize_slider0");
                GuiSliderCtrl       PEP_pointSize_slider1             = this.FOT("PEP_pointSize_slider1");
                GuiSliderCtrl       PEP_pointSize_slider2             = this.FOT("PEP_pointSize_slider2");
                GuiSliderCtrl       PEP_pointSize_slider3             = this.FOT("PEP_pointSize_slider3");
                GuiSliderCtrl       PEP_pointTime_slider0             = this.FOT("PEP_pointTime_slider0");
                GuiSliderCtrl       PEP_pointTime_slider1             = this.FOT("PEP_pointTime_slider1");
                GuiSliderCtrl       PEP_pointTime_slider2             = this.FOT("PEP_pointTime_slider2");
                GuiSliderCtrl       PEP_pointTime_slider3             = this.FOT("PEP_pointTime_slider3");

                // Populate the selector with the particles assigned
                // to the current emitter.

                bool             containsCurrParticle = false;
                GuiPopUpMenuCtrl popup = PEP_ParticleSelector;

                popup.clear();

                foreach (SimObject particle in PE_EmitterEditor.currEmitter["particles"].Split(' '))
                {
                    if (particle.getId() == this.currParticle)
                    {
                        containsCurrParticle = true;
                    }

                    popup.add(particle.getName(), particle.getId());
                }

                // Just in case the particle doesn't exist, fallback gracefully

                if (!containsCurrParticle)
                {
                    this.currParticle = Util.getWord(PE_EmitterEditor.currEmitter["particles"], 0).getID();
                }

                SimObject data = this.currParticle;

                popup.sort();
                popup.setSelected(data);

                string bitmap = MaterialEditorGui.searchForTexture(data.getName(), data["textureName"]);


                if (bitmap != "")
                {
                    PEP_previewImage.setBitmap(bitmap);
                    PEP_previewImageName.setText(bitmap);
                    PEP_previewImageName.tooltip = bitmap;
                }
                else
                {
                    PEP_previewImage.setBitmap("");
                    PEP_previewImageName.setText("None");
                    PEP_previewImageName.tooltip = "None";
                }

                PEP_inverseAlpha.setValue(data["useInvAlpha"]);

                PEP_lifetimeMS_slider.setValue(data["lifetimeMS"]);
                PEP_lifetimeMS_textEdit.setText(data["lifetimeMS"]);

                PEP_lifetimeVarianceMS_slider.setValue(data["lifetimeVarianceMS"]);
                PEP_lifetimeVarianceMS_textEdit.setText(data["lifetimeVarianceMS"]);

                PEP_inheritedVelFactor_slider.setValue(data["inheritedVelFactor"]);
                PEP_inheritedVelFactor_textEdit.setText(data["inheritedVelFactor"]);

                PEP_constantAcceleration_slider.setValue(data["constantAcceleration"]);
                PEP_constantAcceleration_textEdit.setText(data["constantAcceleration"]);

                PEP_gravityCoefficient_slider.setValue(data["gravityCoefficient"]);
                PEP_gravityCoefficient_textEdit.setText(data["gravityCoefficient"]);

                PEP_dragCoefficient_slider.setValue(data["dragCoefficient"]);
                PEP_dragCoefficient_textEdit.setText(data["dragCoefficient"]);

                PEP_spinRandomMin_slider.setValue(data["spinRandomMin"]);
                PEP_spinRandomMin_textEdit.setText(data["spinRandomMin"]);

                PEP_spinRandomMax_slider.setValue(data["spinRandomMax"]);
                PEP_spinRandomMax_textEdit.setText(data["spinRandomMax"]);

                PEP_spinRandomMax_slider.setValue(data["spinRandomMax"]);
                PEP_spinRandomMax_textEdit.setText(data["spinRandomMax"]);

                PEP_spinSpeed_slider.setValue(data["spinSpeed"]);
                PEP_spinSpeed_textEdit.setText(data["spinSpeed"]);

                PE_ColorTintSwatch0["color"] = data["colors[0]"];
                PE_ColorTintSwatch1["color"] = data["colors[1]"];
                PE_ColorTintSwatch2["color"] = data["colors[2]"];
                PE_ColorTintSwatch3["color"] = data["colors[3]"];

                PEP_pointSize_slider0.setValue(data["sizes[0]"]);
                PEP_pointSize_textEdit0.setText(data["sizes[0]"]);

                PEP_pointSize_slider1.setValue(data["sizes[1]"]);
                PEP_pointSize_textEdit1.setText(data["sizes[1]"]);

                PEP_pointSize_slider2.setValue(data["sizes[2]"]);
                PEP_pointSize_textEdit2.setText(data["sizes[2]"]);

                PEP_pointSize_slider3.setValue(data["sizes[3]"]);
                PEP_pointSize_textEdit3.setText(data["sizes[3]"]);

                PEP_pointTime_slider0.setValue(data["times[0]"]);
                PEP_pointTime_textEdit0.setText(data["times[0]"]);

                PEP_pointTime_slider1.setValue(data["times[1]"]);
                PEP_pointTime_textEdit1.setText(data["times[1]"]);

                PEP_pointTime_slider2.setValue(data["times[2]"]);
                PEP_pointTime_textEdit2.setText(data["times[2]"]);

                PEP_pointTime_slider3.setValue(data["times[3]"]);
                PEP_pointTime_textEdit3.setText(data["times[3]"]);
            }