Ejemplo n.º 1
0
        /// <summary>
        /// Create a new Petri net.
        /// </summary>
        private void petriNetworkToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // if (CryptoHelper.getInstance().HasKey)
            {
                this.writeConsole("Let's create a new Petri net!");
                try
                {
                    CreateNewPetriNetwork dialog = new CreateNewPetriNetwork(this.rand, this.numberOfMdiChildren);
                    bool restoreCheck = false;
                    if (!this.toolWindowsAlwaysOnTopToolStripMenuItem.Checked)
                    {
                        restoreCheck = true;
                        this.toolWindowsAlwaysOnTopToolStripMenuItem.Checked = true;
                    }
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        PetriNetworkForm child = new PetriNetworkForm(dialog.Network);
                        child.MdiParent = this;
                        child.networkItemSelected += new NetworkItemHandler(child_networkItemSelected);
                        child.childFormClosed += new ChildFormHandler(childFormClosed);
                        child.simulationNotifier += new SimulationNotifierHandler(childSimulationNotifier);

                        this.beforeOpenMdiChild();
                        child.Show();
                        this.refreshToolWindowsPetriNetwork(dialog.Network);
                        this.reDrawActivePetriNetwork(false);
                        this.child_networkItemSelected(dialog.Network.SelectedItems, false);
                        this.writeConsole("A new Petri network (" + dialog.Network.Name + ") was created.");
                    }
                    if (restoreCheck)
                    {
                        this.toolWindowsAlwaysOnTopToolStripMenuItem.Checked = false;
                    }
                }
                catch (SimApplicationException ex)
                {
                    this.writeConsole("Application error. Please send an email to the creators (" + ex.Message + ").");
                }
            }
        }
Ejemplo n.º 2
0
        private void openPetriNetwork(string fileName)
        {
            try
            {
                PetriNetwork network = PetriNetwork.openFromXml(this.rand, fileName);
                if (network != null)
                {
                    PetriNetworkForm child = new PetriNetworkForm(network);
                    child.MdiParent = this;
                    child.networkItemSelected += new NetworkItemHandler(child_networkItemSelected);
                    child.childFormClosed += new ChildFormHandler(childFormClosed);
                    child.simulationNotifier +=new SimulationNotifierHandler(childSimulationNotifier);

                    this.beforeOpenMdiChild();
                    child.Show();

                    this.reDrawActivePetriNetwork(false);
                    this.child_networkItemSelected(network.SelectedItems, false);
                    this.recentFilesHelper.addRecentFile(network.PetriRecentFile);
                    this.writeConsole("A Petri network (" + network.Name + ") was opened.");
                }
            }
            catch (Exception e)
            {
                this.writeConsole(e.Message);
            }
        }