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 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();
        }
        private void MyNTextbox_KeyDown(object sender, KeyEventArgs e)    //РАБОТАЕТ)))
        {
            if (e.Key == Key.Return)
            {
                TextBox tbox = sender as TextBox;

                for (int i = 0; i < relist.getSize(); i++)
                {
                    if (i + "" == Convert.ToString(tbox.Name.Last()))
                    {
                        Competitor comp = new Competitor(i + 1, tbox.Text + "\n", true, TName);
                        relist.setCompetitor(comp, i);
                        tbox.Background = Brushes.Lavender;
                    }
                }
            }
        }
예제 #4
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");
     }
 }