private void Number_Click(object sender, RoutedEventArgs e)
        {
            DefinitionAutomaton definitionAutomaton = new DefinitionAutomaton();

            definitionAutomaton.Type     = 2;
            definitionAutomaton.Q        = new string[] { "q0", "q1", "q2", "q3", "q4", "q5" };
            definitionAutomaton.Sigma    = new string[] { "ε", "+", "-", ".", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
            definitionAutomaton.Q0       = "q0";
            definitionAutomaton.F        = new string[] { "q5" };
            definitionAutomaton.ItIsTest = true;
            definitionAutomaton.Tabel    = new string[] {
                "q1", "q1", "q1", "", "", "", "", "", "", "", "", "", "", "",
                "", "", "", "q2", "q1 q4", "q1 q4", "q1 q4", "q1 q4", "q1 q4", "q1 q4", "q1 q4", "q1 q4", "q1 q4", "q1 q4",
                "", "", "", "", "q3", "q3", "q3", "q3", "q3", "q3", "q3", "q3", "q3", "q3",
                "q5", "", "", "", "q3", "q3", "q3", "q3", "q3", "q3", "q3", "q3", "q3", "q3",
                "", "", "", "q3", "", "", "", "", "", "", "", "", "", "",
                "", "", "", "", "", "", "", "", "", "", "", "", "", ""
            };

            StaticAnyWhere.Def = definitionAutomaton;

            Frame FrameMain = new Frame();

            FrameMain.NavigationUIVisibility = NavigationUIVisibility.Hidden;
            FrameMain.NavigationService.Navigate(new Uri("Pages/SettingTheTransitionFunction.xaml", UriKind.Relative));
            TabControlMain.Items.Add(new TabItem
            {
                Header = new TextBlock {
                    Text = "Тест цифры"
                },
                Content = FrameMain
            });
        }
        private void WebEbayNFA_Click(object sender, RoutedEventArgs e)
        {
            DefinitionAutomaton definitionAutomaton = new DefinitionAutomaton();

            definitionAutomaton.Type     = 1;
            definitionAutomaton.Q        = new string[] { "1", "2", "3", "4", "5", "6", "7", "8" };
            definitionAutomaton.Sigma    = new string[] { "w", "e", "b", "a", "y", "q", "r", "t", "u", "i", "o", "p", "s", "d", "f", "g", "h", "j", "k", "l", "z", "x", "c", "v", "n", "m", ",", ".", "?", ":", ";", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
            definitionAutomaton.Q0       = "1";
            definitionAutomaton.F        = new string[] { "4", "8" };
            definitionAutomaton.ItIsTest = true;
            definitionAutomaton.Tabel    = new string[] {
                "1 2", "1 5", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
                "", "3", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
                "", "", "4", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
                "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
                "", "", "6", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
                "", "", "", "7", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
                "", "", "", "", "8", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
                "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
            };

            StaticAnyWhere.Def = definitionAutomaton;

            Frame FrameMain = new Frame();

            FrameMain.NavigationUIVisibility = NavigationUIVisibility.Hidden;
            FrameMain.NavigationService.Navigate(new Uri("Pages/SettingTheTransitionFunction.xaml", UriKind.Relative));
            TabControlMain.Items.Add(new TabItem
            {
                Header = new TextBlock {
                    Text = "Тест Ebay и web без e"
                },
                Content = FrameMain
            });
        }
        private string[] NewStates(DefinitionAutomaton def)
        {
            string[] str   = new string[(int)Math.Pow(2, def.Q.Length)];
            int[]    a     = new int[def.Q.Length + 1];
            int      count = 1;

            for (int m = 1; m < def.Q.Length + 1; m++)
            {
                for (int i = 0; i < def.Q.Length + 1; i++)
                {
                    a[i] = i + 1;
                }
                int num = 1;
                for (int i = 0; i < m; i++)
                {
                    str[count] += a[i] + " ";
                }
                count++;
                if (def.Q.Length >= m)
                {
                    while (NextSet(ref a, def.Q.Length, m))
                    {
                        num = 1;
                        for (int i = 0; i < m; i++)
                        {
                            str[count] += a[i] + " ";
                        }
                        count++;
                    }
                }
            }


            for (int i = 1; i < str.Length; i++)
            {
                for (int j = 0; j < def.Q.Length; j++)
                {
                    str[i] = str[i].Replace(Convert.ToString(j + 1), def.Q[j]);
                }
            }

            for (int i = 1; i < str.Length; i++)
            {
                str[i] = str[i].Trim();
                str[i] = str[i].Replace(" ", ",");
            }

            return(str);
        }
Esempio n. 4
0
        /// <summary>
        /// Создания матрицы для ввода таблицы переходов
        /// </summary>
        private void prepar()
        {
            transToDFABtn.Visibility = Visibility.Collapsed;
            viewToDFABtn.Visibility  = Visibility.Collapsed;
            def = StaticAnyWhere.Def;



            CanvasTB.Width  = 60 * (def.Sigma.Length + 1);
            CanvasTB.Height = 35 * (def.Q.Length + 1);

            for (int i = 0, countTestQ = 0; i < def.Q.Length + 1; i++)
            {
                for (int j = 0; j < def.Sigma.Length + 1; j++)
                {
                    TextBox Tb = new TextBox();
                    Tb.Width    = 50;
                    Tb.Height   = 25;
                    Tb.FontSize = 16;
                    // Tb.Name = Tb + Convert.ToString(i) + Convert.ToString(j);
                    Tb.Margin = new Thickness(j * (Tb.Width + 10), i * (Tb.Height + 20), 0, 0);

                    if (i == 0)
                    {
                        if (j == 0)
                        {
                            Tb.Text = "delta";
                        }
                        else
                        {
                            Tb.Text = def.Sigma[j - 1];
                        }

                        Tb.IsEnabled = false;
                    }
                    else if ((i > 0) & (j == 0))
                    {
                        Tb.Text = "";

                        Tb.Text      = def.Q[i - 1];
                        Tb.IsEnabled = false;

                        if (def.Q[i - 1] == def.Q0)
                        {
                            Tb.Text = "->" + Tb.Text;
                        }

                        if (StaticAnyWhere.occurrence(def.F, new string[] { def.Q[i - 1] }))
                        {
                            Tb.Text = "*" + Tb.Text;
                        }
                    }
                    else
                    {
                        if (def.ItIsTest == true)
                        {
                            Tb.Text = def.Tabel[countTestQ];
                            countTestQ++;
                        }
                        else
                        {
                            Tb.Text = "";
                        }

                        Tb.Background = Brushes.LightYellow;
                        C.Add(Tb);
                    }

                    this.CanvasTB.Children.Add(Tb);
                }
            }
        }