Ejemplo n.º 1
0
        private void Ajouter_Click(object sender, EventArgs e)
        {
            int Si = (int)SI.SelectedIndex;
            int Sj = (int)SJ.SelectedIndex;
            char car = (char)UserDfa.X[SiXSj.SelectedIndex];

            Instruction trip = new Instruction(Si, car, Sj);

            if (UserDfa.getInstruction(Si, car) == -1) {
                UserDfa.AddInstruction(Si, car, Sj);
                transitions.Items.Add(trip);
            }else
                if (UserDfa.getInstruction(Si, car) != Sj)
                {

                    Instruction tripold = new Instruction(Si, car, UserDfa.getInstruction(Si,car));
                    int rep = UserDfa.AddInstruction(Si, car, Sj);
                    if (rep == 1) {
                        int i = 0;
                        foreach (Instruction instr in transitions.Items)
                        {
                            if (instr.Equals(tripold))
                                break;
                            i++;
                        }
                        transitions.Items.RemoveAt(i);
                        transitions.Items.Add(trip);

                    }

                }
        }
Ejemplo n.º 2
0
        private void Ajouter_Click(object sender, EventArgs e)
        {
            int Si = (int)SI.SelectedIndex;
            char car = (char)UserNfa.X[SiXSj.SelectedIndex];
            foreach (string j in SJ.SelectedItems)
            {
                int Sj = SJ.Items.IndexOf(j);
                Instruction trip = new Instruction(Si, car, Sj);

                if (!UserNfa.getInstruction(Si, car).Contains(Sj))
                {
                    transitions.Items.Add(trip);
                    UserNfa.AddInstruction(trip);
                }
            }
        }
Ejemplo n.º 3
0
 public bool Equals(Instruction instruction)
 {
     return (this.Si == instruction.Si) && (this.Xi == instruction.Xi) && (this.Sj == instruction.Sj);
 }
Ejemplo n.º 4
0
 private void InstructionAdd_Click(object sender, EventArgs e)
 {
     if (stSI.SelectedItem != null && stXI.SelectedItem != null && stSJ.SelectedItems != null)
     {
         int Si = stSI.Items.IndexOf(stSI.SelectedItem);
         char xi = (char)stXI.SelectedItem;
         int Xi = myNfa.toIndex(xi);
         bool empty = InstructionList.Items.Count==0;
         foreach (string SjItem in stSJ.SelectedItems)
         {
             int Sj = stSJ.Items.IndexOf(SjItem);
             Instruction instr = new Instruction(Si,xi,Sj);
             //string instrs = "(" + stSI.Items[Si] + "," + (char)stXI.SelectedItem + "," + stSJ.Items[Sj] + ")";
             bool contains=false;
             if (!empty)
             {
                 contains=(myNfa.I[Si,Xi].Contains(Sj));
             }
             if (!contains)
             {
                 InstructionList.Items.Add(instr);
                 if (myNfa.I[Si, Xi].Contains(-1))
                     myNfa.I[Si, Xi].Clear();
                 myNfa.I[Si, Xi].Add(Sj);
                 myNfa.I[Si, Xi].Sort();
                 if (ValidateInstructions.Enabled == false) ValidateInstructions.Enabled = true;
             }
         }
         stSJ.SelectedItems.Clear();
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Ajouter une instruction au table des instructions de l'automate
 /// </summary>
 /// <param name="instruction">l'instruction à ajouter</param>
 public void AddInstruction(Instruction instruction)
 {
     AddInstruction(instruction.Si, instruction.Xi, instruction.Sj);
     isConverted = false;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Supprimer une instruction
 /// </summary>
 /// <param name="instruction">l'instruction à supprimer</param>
 public void RemoveInstruction(Instruction instruction)
 {
     RemoveInstruction(instruction.Si, instruction.Xi, instruction.Sj);
     isConverted = false;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Supprimer une transition Si -Xi-> Sj
 /// </summary>
 public int RemoveInstruction(Instruction instruction)
 {
     return this.RemoveInstruction(instruction.Si, instruction.Xi, instruction.Sj);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Ajouter une transition
 /// </summary>
 /// <param name="instruction">La transition à ajouter</param>
 /// <param name="replace">true pour le remplacement en cas de l'existance de cette transition</param>
 /// <returns>retourne 0 en cas de succes ,1 en cas de remplacement et 2 sinon</returns>
 public int AddInstruction(Instruction instruction, bool replace)
 {
     return this.AddInstruction(instruction.Si, instruction.Xi, instruction.Sj, replace);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Ajouter une transition
 /// </summary>
 /// <param name="instruction">La transition à ajouter</param>
 /// <returns>retourne 0 en cas de succes ,1 en cas de remplacement et 2 si rien n'est fait</returns>
 public int AddInstruction(Instruction instruction)
 {
     return this.AddInstruction(instruction.Si, instruction.Xi, instruction.Sj);
 }