コード例 #1
0
ファイル: main.cs プロジェクト: sohaibafifi/automata
        private void nouvPartiellementGénéraliséMI_Click(object sender, EventArgs e)
        {
            PGfaCreation newPGfa = new PGfaCreation();
            newPGfa.Name_box.Text = "Automate" + Automates_list.Count;

            if (newPGfa.ShowDialog() == DialogResult.OK)
            {
                Auto UserAuto = new Auto(newPGfa.UserPGfa);
                UserAuto.type = Automata.TYPE.PGfa;
                AjouterPGfa(UserAuto);
            }
        }
コード例 #2
0
ファイル: main.cs プロジェクト: sohaibafifi/automata
        private void OpenRight_Click(object sender, EventArgs e)
        {
            if (Automates_tree.SelectedNode == null)
                Automates_tree.SelectedNode = Automates_tree.Nodes[0];
            Selected = getautomate(Automates_tree.SelectedNode.Text);

            tabControl1.SelectedTab = tabControl1.TabPages[0];
        }
コード例 #3
0
ファイル: main.cs プロジェクト: sohaibafifi/automata
 private void nouvFromGrammaireMI_Click(object sender, EventArgs e)
 {
     GrammerCreation GrammerForm = new GrammerCreation();
     if (GrammerForm.ShowDialog() == DialogResult.OK)
     {
         Gfa GGfa = GrammerForm.UserGrammer.toGfa();
         Auto UserAuto = new Auto(GGfa);
         UserAuto.type = Automata.TYPE.Gfa;
         ((Automata)UserAuto.Automate).Name = "Automate"+Automates_list.Count;
         AjouterGfa(UserAuto);
     }
 }
コード例 #4
0
ファイル: main.cs プロジェクト: sohaibafifi/automata
        private void nouvNonDeterministeMI_Click(object sender, EventArgs e)
        {
            NfaCreation newNfa = new NfaCreation();
            newNfa.Name_box.Text = "Automate" + Automates_list.Count;

            if (newNfa.ShowDialog() == DialogResult.OK)
            {
                Auto UserAuto = new Auto(newNfa.UserNfa);
                UserAuto.type = Automata.TYPE.Nfa;
                AjouterNfa(UserAuto);
            }
        }
コード例 #5
0
ファイル: main.cs プロジェクト: sohaibafifi/automata
        private void DessinRight_Click(object sender, EventArgs e)
        {
            //MessageBox.Show(((TreeView)(((ToolStripMenuItem)sender).GetCurrentParent().Parent)).GetType().ToString());

            if (Automates_tree.SelectedNode == null)
                Automates_tree.SelectedNode = Automates_tree.Nodes[0];
            Selected = getautomate(Automates_tree.SelectedNode.Text);

            tabControl1.SelectedTab = tabControl1.TabPages[1];
            if (Selected.Automate != null)
                ((Automata)Selected.Automate).Draw(Drawpanel, fixe.Checked);
        }
コード例 #6
0
ファイル: main.cs プロジェクト: sohaibafifi/automata
        private void miroirMI_Click(object sender, EventArgs e)
        {
            if (Selected.Automate != null)
            {
                PGfa UserPGfa = new PGfa();

                UserPGfa = ((Automata)Selected.Automate).getMirror();
                UserPGfa.Name = "Automate" + Automates_list.Count;
                Auto UserAuto = new Auto(UserPGfa);
                UserAuto.type = Automata.TYPE.PGfa;
                AjouterPGfa(UserAuto);
            }
        }
コード例 #7
0
ファイル: main.cs プロジェクト: sohaibafifi/automata
        private void concaténationMI_Click(object sender, EventArgs e)
        {
            if (Automates_list.Count == 0)
                return;
            Two_Selector Selector = new Two_Selector();
            foreach (Auto automate in Automates_list)
            {
                Selector.listAuto1.Items.Add(automate.ToString());
                Selector.ListAuto2.Items.Add(automate.ToString());
            }
            Selector.listAuto1.SelectedIndex = 0;
            Selector.ListAuto2.SelectedIndex = 0;
            if (Selector.ShowDialog() == DialogResult.OK)
            {
                Auto Automate1 = getautomate(Selector.listAuto1.SelectedItem.ToString());
                Auto Automate2 = getautomate(Selector.ListAuto2.SelectedItem.ToString());

                PGfa UserPGfa = Automata.Concatenation(((Automata)Automate1.Automate), ((Automata)Automate2.Automate));

                UserPGfa = ((Automata)Selected.Automate).getIterationPositive();
                UserPGfa.Name = "Automate" + Automates_list.Count;
                Auto UserAuto = new Auto(UserPGfa);
                UserAuto.type = Automata.TYPE.PGfa;

                AjouterPGfa(UserAuto);

            }
        }
コード例 #8
0
ファイル: main.cs プロジェクト: sohaibafifi/automata
        private void complementMI_Click(object sender, EventArgs e)
        {
            if (Selected.Automate != null)
            {
                Dfa UserDfa = new Dfa();

                UserDfa = ((Automata)Selected.Automate).getComplementary();
                UserDfa.Name = "Automate" + Automates_list.Count;
                Auto UserAuto = new Auto(UserDfa);
                UserAuto.type = Automata.TYPE.Dfa;
                AjouterDfa(UserAuto);
            }
        }
コード例 #9
0
ファイル: main.cs プロジェクト: sohaibafifi/automata
        private void Automates_tree_DoubleClick(object sender, EventArgs e)
        {
            try
            {

                Selected = getautomate(Automates_tree.SelectedNode.Text);
                //////////////////////////////
                if (Selected.Automate == null) return;
                //////////////////////////////
                Grammer UserGrammer = new Grammer();
                switch (Selected.type)
                {
                    case Automata.TYPE.Dfa:
                        ((Dfa)Selected.Automate).Afficher_grid(transition_Grid);
                        ((Dfa)Selected.Automate).Draw(Drawpanel, true);
                        UserGrammer = ((Dfa)Selected.Automate).toGrammer();
                        GrammerRTF.Text = UserGrammer.ToString();
                        break;
                    case Automata.TYPE.Nfa:

                        ((Nfa)Selected.Automate).Afficher_grid(transition_Grid);
                        ((Nfa)Selected.Automate).Draw(Drawpanel, true);
                        UserGrammer = ((Nfa)Selected.Automate).toGrammer();
                        GrammerRTF.Text = UserGrammer.ToString();
                        break;
                    case Automata.TYPE.PGfa:
                        ((PGfa)Selected.Automate).Afficher_grid(transition_Grid);
                        ((PGfa)Selected.Automate).Draw(Drawpanel, true);
                        UserGrammer = ((PGfa)Selected.Automate).toGrammer();
                        GrammerRTF.Text = UserGrammer.ToString();
                        break;
                    case Automata.TYPE.Gfa:
                        ((Gfa)Selected.Automate).Afficher_grid(transition_Grid);
                        ((Gfa)Selected.Automate).Draw(Drawpanel, true);
                        try
                        {
                            UserGrammer = ((Gfa)Selected.Automate).toGrammer();
                        }
                        catch (Exception)
                        {
                            break;
                        }

                        break;
                    default:
                        break;

                }
                UserGrammer.AfficherGrammair(GrammerRTF);

                Type_label.Text = "L'automate : " + ((Automata)Selected.Automate).Name + "  de type : " + Selected.type.ToString();
            }
            catch (Exception)
            {
                Type_label.Text = "L'automate : " + ((Automata)Selected.Automate).Name + "  de type : " + Selected.type.ToString() + "!!!";
            }
        }
コード例 #10
0
ファイル: main.cs プロジェクト: sohaibafifi/automata
        public void AjouterDfa(Auto UserAuto)
        {
            if (UserAuto.Automate == null) return;
            Selected = UserAuto;

            Automates_list.Add(UserAuto);

            // l'automate Dfa
            Dfa UserDfa_ = new Dfa();
            UserDfa_ = ((Dfa)UserAuto.Automate).toDfa();
            UserDfa_.Name = ((Dfa)UserAuto.Automate).Name + "[Dfa]";

            Auto UserAuto_Dfa_ = new Auto(UserDfa_);
            UserAuto_Dfa_.type = Automata.TYPE.Dfa;
            Automates_list.Add(UserAuto_Dfa_);

            // l'automate Nfa
            Nfa UserNfa_ = new Nfa();
            UserNfa_ = ((Dfa)UserAuto.Automate).toNfa();
            UserNfa_.Name = ((Dfa)UserAuto.Automate).Name + "[Nfa]";

            Auto UserAuto_Nfa_ = new Auto(UserNfa_);
            UserAuto_Nfa_.type = Automata.TYPE.Nfa;
            Automates_list.Add(UserAuto_Nfa_);

            // l'automate PGfa
            PGfa UserPGfa = new PGfa();
            UserPGfa = ((Dfa)UserAuto.Automate).toPGfa();
            UserPGfa.Name = ((Dfa)UserAuto.Automate).Name + "[PGfa]";

            Auto UserAuto_PGfa = new Auto(UserPGfa);
            UserAuto_PGfa.type = Automata.TYPE.PGfa;
            Automates_list.Add(UserAuto_PGfa);

            // l'automate Gfa
            Gfa UserGfa = new Gfa();
            UserGfa = ((Dfa)UserAuto.Automate).toGfa();
            UserGfa.Name = ((Dfa)UserAuto.Automate).Name + "[Gfa]";

            Auto UserAuto_Gfa = new Auto(UserGfa);
            UserAuto_Gfa.type = Automata.TYPE.Gfa;
            Automates_list.Add(UserAuto_Gfa);

            // l'automate reduit
            Dfa UserDfa_reduit = new Dfa();
            UserDfa_reduit = ((Dfa)UserAuto.Automate).toReduced();
            UserDfa_reduit.Name = ((Dfa)UserAuto.Automate).Name + "[Reduit]";

            Auto UserAuto_DfaReduit = new Auto(UserDfa_reduit);
            UserAuto_DfaReduit.type = Automata.TYPE.Dfa;
            Automates_list.Add(UserAuto_DfaReduit);

            // l'automate complet
            Dfa UserDfa_complet = new Dfa();
            UserDfa_complet = ((Dfa)UserAuto.Automate).toComplete();
            UserDfa_complet.Name = ((Dfa)UserAuto.Automate).Name + "[Complet]";

            Auto UserAuto_DfaComplet = new Auto(UserDfa_complet);
            UserAuto_DfaComplet.type = Automata.TYPE.Dfa;
            Automates_list.Add(UserAuto_DfaComplet);

            TreeNode node_automate = new TreeNode(UserAuto.ToString());
            TreeNode node_automate_Dfa = new TreeNode(UserAuto_Dfa_.ToString());
            TreeNode node_automate_Nfa = new TreeNode(UserAuto_Nfa_.ToString());
            TreeNode node_automate_PGfa = new TreeNode(UserAuto_PGfa.ToString());
            TreeNode node_automate_Gfa = new TreeNode(UserAuto_Gfa.ToString());
            TreeNode node_automate_DfaReduit = new TreeNode(UserAuto_DfaReduit.ToString());
            TreeNode node_automate_DfaComplet = new TreeNode(UserAuto_DfaComplet.ToString());

            node_automate.ContextMenuStrip = RightMenu;
            node_automate_Dfa.ContextMenuStrip = RightMenu;
            node_automate_Nfa.ContextMenuStrip = RightMenu;
            node_automate_PGfa.ContextMenuStrip = RightMenu;
            node_automate_Gfa.ContextMenuStrip = RightMenu;
            node_automate_DfaReduit.ContextMenuStrip = RightMenu;
            node_automate_DfaComplet.ContextMenuStrip = RightMenu;

            node_automate.ToolTipText = Enum.GetName(typeof(Automata.TYPE), UserAuto.type);
            node_automate_Dfa.ToolTipText = Enum.GetName(typeof(Automata.TYPE), UserAuto_Dfa_.type);
            node_automate_Nfa.ToolTipText = Enum.GetName(typeof(Automata.TYPE), UserAuto_Nfa_.type);
            node_automate_PGfa.ToolTipText = Enum.GetName(typeof(Automata.TYPE), UserAuto_PGfa.type);
            node_automate_Gfa.ToolTipText = Enum.GetName(typeof(Automata.TYPE), UserAuto_Gfa.type);
            node_automate_DfaReduit.ToolTipText = Enum.GetName(typeof(Automata.TYPE), UserAuto_DfaReduit.type);
            node_automate_DfaComplet.ToolTipText = Enum.GetName(typeof(Automata.TYPE), UserAuto_DfaComplet.type);

            node_automate.Nodes.Add(node_automate_Dfa);
            node_automate.Nodes.Add(node_automate_Nfa);
            node_automate.Nodes.Add(node_automate_PGfa);
            node_automate.Nodes.Add(node_automate_Gfa);
            node_automate.Nodes.Add(node_automate_DfaReduit);
            node_automate.Nodes.Add(node_automate_DfaComplet);
            Automates_tree.Nodes.Add(node_automate);

            //node_automate.Nodes.Add(node_automate);
            node_automate.Expand();

            ((Dfa)UserAuto.Automate).Draw(Drawpanel, true);
            ((Dfa)UserAuto.Automate).Afficher_grid(transition_Grid);
            Type_label.Text = "L'automate : " + ((Automata)Selected.Automate).Name + "  de type : " + Selected.type.ToString();
            Drawpanel.Refresh();
        }
コード例 #11
0
        public Auto read(String Path)
        {
            Auto Auto = new Auto();

            try
            {

                XPathDocument doc = new XPathDocument(Path);

                XPathNavigator nav_Auto = doc.CreateNavigator();
                XPathNodeIterator iter_Auto = nav_Auto.Select("Automate");

                iter_Auto.MoveNext(); // puisque il existe un seul automate node
                {
                    string type = iter_Auto.Current.SelectSingleNode("Type").Value;

                    Auto.type = (Automata.TYPE)int.Parse(iter_Auto.Current.SelectSingleNode("Type").Value);

                    switch (Auto.type)
                    {
                        case Automata.TYPE.Dfa:
                            Auto.Automate = new Dfa();
                            break;
                        case Automata.TYPE.Nfa:
                            Auto.Automate = new Nfa();
                            break;
                        case Automata.TYPE.PGfa:
                            Auto.Automate = new PGfa();
                            break;
                        case Automata.TYPE.Gfa:
                            Auto.Automate = new Gfa();
                            break;
                        default:
                            break;
                    }

                    ((Automata)Auto.Automate).Name = iter_Auto.Current.SelectSingleNode("Name").Value;

                    XPathNodeIterator iter_X = iter_Auto.Current.Select("X/car");
                    ((Automata)Auto.Automate).X = new ArrayList();
                    while (iter_X.MoveNext())
                    {
                        ((Automata)Auto.Automate).X.Add(Char.Parse(iter_X.Current.Value));
                        if (((Automata)Auto.Automate).getType() == Automata.TYPE.Gfa)
                            ((Gfa)Auto.Automate).Read.Add(Char.Parse(iter_X.Current.Value));
                    }

                    ((Automata)Auto.Automate).S0 = int.Parse(iter_Auto.Current.SelectSingleNode("S0").Value);
                    ((Automata)Auto.Automate).S = int.Parse(iter_Auto.Current.SelectSingleNode("S").Value);

                    XPathNodeIterator iter_F = iter_Auto.Current.Select("F/fi");
                    ((Automata)Auto.Automate).F = new ArrayList();
                    while (iter_F.MoveNext())
                    {
                        ((Automata)Auto.Automate).F.Add(int.Parse(iter_F.Current.Value));
                    }

                    if (Auto.type == Automata.TYPE.Dfa)
                    {
                        ((Dfa)Auto.Automate).InitI();
                        XPathNodeIterator iter_I = iter_Auto.Current.Select("I/triplet");
                        ArrayList triplets = new ArrayList();
                        while (iter_I.MoveNext())
                        {
                            triplets.Add(iter_I.Current.Value);

                        }

                        for (int i = 0; i < ((Dfa)Auto.Automate).S; i++)
                            foreach (char car in ((Dfa)Auto.Automate).X)
                                for (int j = 0; j < ((Dfa)Auto.Automate).S; j++)
                                    if (triplets.Contains("(" + i + "," + car + "," + j + ")"))
                                        ((Dfa)Auto.Automate).AddInstruction(i, car, j, true);

                    }
                    else
                    {
                        ((Automata)Auto.Automate).InitI();
                        XPathNodeIterator iter_I = iter_Auto.Current.Select("I/triplet");
                        ArrayList triplets = new ArrayList();
                        while (iter_I.MoveNext())
                        {
                            triplets.Add(iter_I.Current.Value);

                        }

                        for (int i = 0; i < ((Automata)Auto.Automate).S; i++)
                            foreach (char car in ((Automata)Auto.Automate).X)
                                for (int j = 0; j < ((Automata)Auto.Automate).S; j++)
                                {
                                    if (triplets.Contains("(" + i + "," + car + "," + j + ")"))
                                        switch (Auto.type)
                                        {
                                            case Automata.TYPE.Nfa:
                                                ((Nfa)Auto.Automate).AddInstruction(i, car, j);
                                                break;
                                            case Automata.TYPE.PGfa:
                                                ((PGfa)Auto.Automate).AddInstruction(i, car, j);
                                                break;
                                            case Automata.TYPE.Gfa:
                                                ((Gfa)Auto.Automate).AddInstruction(i, car, j);
                                                break;
                                            default:
                                                break;

                                        }

                                }
                    }
                }
            }
            catch (Exception ex)
            {
                Auto.Automate = null;
                MessageBox.Show(ex.Message + "\n" + ex.Source + "\n dans la methode : "+ex.TargetSite+ "\n Verifier si le fichier n'est pas endommagé ", "Erreur lors de l'ecture de l'automate", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return Auto;
        }