コード例 #1
0
        private void NameTextbox_Create(CompetitorsList list, Thickness BorderThickness, int fontSize, int leftPosition, Grid grid)
        {
            TextBox[] myNTextbox          = new TextBox[list.getSize()];
            Thickness myNTextboxThickness = new Thickness()
            {
                Left = leftPosition
            };
            int height = fontSize * 2 + 4;

            myNTextboxThickness.Top = height - BorderThickness.Top;

            for (int i = 0; i < list.getSize(); i++)
            {
                myNTextboxThickness.Top = (height - BorderThickness.Top) * (i + 1);

                myNTextbox[i] = new TextBox()
                {
                    Text = list.getCompetitor(i).name + "",
                    VerticalAlignment   = VerticalAlignment.Top,
                    Margin              = myNTextboxThickness,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    Height              = height,
                    Width                      = fontSize * 30,
                    FontSize                   = fontSize,
                    BorderBrush                = Brushes.Black,
                    BorderThickness            = BorderThickness,
                    HorizontalContentAlignment = HorizontalAlignment.Center,
                    VerticalContentAlignment   = VerticalAlignment.Center,
                    Name = "myNTextbox" + i
                };
                myNTextbox[i].KeyDown += new KeyEventHandler(MyNTextbox_KeyDown);
                grid.Children.Add(myNTextbox[i]);
            }
        }
コード例 #2
0
        public static CompetitorsList Load_Competitors(string Tournir)
        {
            SQLiteConnection connect = new SQLiteConnection("Data Source=" + databaseName);

            connect.Open();
            //SQLiteCommand command = new SQLiteCommand("SELECT * FROM 'Competitors' WHERE 'Tournir'='"+Tournir+"';", connect);
            SQLiteCommand     command  = new SQLiteCommand("SELECT * FROM 'Competitors';", connect);
            SQLiteDataReader  reader   = command.ExecuteReader();
            List <Competitor> CompList = new List <Competitor>();

            foreach (DbDataRecord record in reader)
            {
                string tournir = record["Tournir"].ToString();
                if (tournir == Tournir)
                {
                    string id    = record["Id"].ToString();
                    int    rnum  = Convert.ToInt32(record["RatingNum"].ToString());
                    string name  = record["Name"].ToString();
                    bool   exist = Convert.ToBoolean(record["Exist"].ToString());

                    CompList.Add(new Competitor(rnum, name, exist, tournir));
                }
            }
            connect.Close();
            CompetitorsList RList = new CompetitorsList(CompList.Count);

            RList.List = CompList.ToArray();
            return(RList);
        }
コード例 #3
0
        public static void Add_Competitors(CompetitorsList List)
        {
            SQLiteConnection connect = new SQLiteConnection("Data Source=" + databaseName);

            connect.Open();
            for (int i = 0; i < List.getSize(); i++)
            {
                Competitor    c       = List.getCompetitor(i);
                SQLiteCommand command = new SQLiteCommand("INSERT INTO 'Competitors' ('RatingNum'," +
                                                          "'Name','Exist','Tournir') VALUES (" + (i + 1) + ",'" + c.name +
                                                          "','" + c.exist + "','" + c.tournir + "');", connect);
                command.ExecuteNonQuery();
            }

            connect.Close();
        }
コード例 #4
0
        private void TournirLabel_Click(object sender, MouseButtonEventArgs e)
        {
            Label           Tournir     = sender as Label;
            InputPage       page        = new InputPage();
            string          iname       = Tournir.Content.ToString();
            CompetitorsList competitors = DataWorker.Load_Competitors(iname);

            foreach (Competitor c in competitors.List)
            {
                page.listTextBox.AppendText(c.name);
            }

            page.sizeComboBox.SelectedIndex = 0;
            page.tNameTextBox.Text          = Tournir.Content.ToString();
            page.button.IsEnabled           = true;
            NavigationService.Navigate(page);
        }
コード例 #5
0
 public static DuelList createDuels(CompetitorsList compList, int dNum = 0)   //create new duel list
 {
     if (dNum >= 0)
     {
         int      compNum = compList.getSize();
         DuelList myList  = new DuelList(compNum / 2);
         for (int i = 0; i < myList.getSize(); i++)
         {
             Duel newDuel = new Duel(compList.getCompetitor(i), compList.getCompetitor(compNum - (i + 1)), dNum);
             myList.setDuel(newDuel, dNum);
             dNum++;
         }
         return(myList);
     }
     else
     {
         throw new ArgumentException("Parameter cannot be smaller then zero", "dNum");
     }
 }
コード例 #6
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            if (tNameTextBox.Text.Length != 0)
            {
                switch (tTypeComboBox.SelectedIndex)
                {
                case 0:
                    RoundEliminationPage page1 = new RoundEliminationPage();



                    switch (sizeComboBox.SelectedIndex)
                    {
                    case 0:
                        page1.GridSize = listTextBox.LineCount;
                        CompetitorsList newList1 = new CompetitorsList(listTextBox.LineCount);

                        for (int i = 0; i < listTextBox.LineCount; i++)
                        {
                            Competitor comp = new Competitor(i, listTextBox.GetLineText(i), true, tNameTextBox.Text);
                            newList1.setCompetitor(comp, i);
                        }
                        page1.Relist = newList1;
                        page1.TName  = tNameTextBox.Text;
                        NavigationService.Navigate(page1);
                        break;

                    case 1:

                        page1.GridSize = Convert.ToInt16(sizeTextBox.Text);


                        CompetitorsList newList2 = new CompetitorsList(Convert.ToInt16(sizeTextBox.Text));

                        for (int i = 0; i < Convert.ToInt16(sizeTextBox.Text); i++)
                        {
                            newList2.setCompetitor(new Competitor(i, "", true, tNameTextBox.Text), i);
                        }

                        page1.Relist = newList2;



                        page1.TName = tNameTextBox.Text;
                        NavigationService.Navigate(page1);
                        break;

                    default:
                        errorView();
                        break;
                    }

                    break;

                case 1:
                    SingleEliminaionPage page2 = new SingleEliminaionPage();

                    switch (sizeComboBox.SelectedIndex)
                    {
                    case 0:
                        page2.Steps    = TrueSingleElimSize(listTextBox.LineCount);
                        page2.GridSize = (int)Math.Pow(2, page2.Steps);

                        CompetitorsList newList1 = new CompetitorsList(page2.GridSize);

                        for (int i = 0; i < page2.GridSize; i++)
                        {
                            if (i < listTextBox.LineCount)
                            {
                                newList1.setCompetitor(new Competitor(i + 1, listTextBox.GetLineText(i), true, tNameTextBox.Text), i);
                            }
                            else
                            {
                                newList1.setCompetitor(new Competitor(i + 1, "", false, tNameTextBox.Text), i);
                            }
                        }
                        page2.Selist = newList1;
                        page2.TName  = tNameTextBox.Text;
                        NavigationService.Navigate(page2);
                        break;

                    case 1:
                        page2.Steps    = TrueSingleElimSize(Convert.ToInt16(sizeTextBox.Text));
                        page2.GridSize = (int)Math.Pow(2, TrueSingleElimSize(Convert.ToInt16(sizeTextBox.Text)));


                        CompetitorsList newList2 = new CompetitorsList(page2.GridSize);

                        for (int i = 0; i < page2.GridSize; i++)
                        {
                            if (i < Convert.ToInt16(sizeTextBox.Text))
                            {
                                newList2.setCompetitor(new Competitor(i + 1, "", true, tNameTextBox.Text), i);
                            }
                            else
                            {
                                newList2.setCompetitor(new Competitor(i + 1, "", false, tNameTextBox.Text), i);
                            }
                        }

                        page2.Selist = newList2;

                        page2.TName = tNameTextBox.Text;
                        NavigationService.Navigate(page2);
                        break;

                    default:
                        errorView();
                        break;
                    }
                    break;

                default:
                    errorView();
                    break;
                }
            }
            else
            {
                errorView();
            }
        }