Beispiel #1
0
 private void BtnYes_Click(object sender, RoutedEventArgs e)
 {
     //START A NEW AREA IDENTIFICATION TEST
     if (kind == AchievementKind.BookReplace)
     {
         BookReplaceTest bookReplaceTest =
             new BookReplaceTest();
         bookReplaceTest.Show();
     }
     else if (kind == AchievementKind.AreaIdentification)
     {
         AreaIdentificationTest areaIdentificationTest =
             new AreaIdentificationTest();
         areaIdentificationTest.Show();
         areaIdentificationTest.Top = Top;
         areaIdentificationTest.Top = Top;
     }
     else
     {
         FindCallNumbersTest findCallNumbersTest =
             new FindCallNumbersTest();
         findCallNumbersTest.Show();
         findCallNumbersTest.Top  = Top;
         findCallNumbersTest.Left = Left;
     }
     Close();
 }
Beispiel #2
0
        //GENERATEBOOKS METHOD (POPULATES THE LIST WITH RANDOM CALL NUMBERS)
        public static string GenerateBooks(string trickEntry)
        {
            //CREATE NEEDED COMPONENTS
            ListBoxItem      listBoxItem = new ListBoxItem();
            Grid             grid        = new Grid();
            ColumnDefinition columnIcon  = new ColumnDefinition
            {
                Width = new GridLength(1, GridUnitType.Star)
            };
            ColumnDefinition columnContent = new ColumnDefinition
            {
                Width = new GridLength(1, GridUnitType.Star)
            };

            grid.ColumnDefinitions.Add(columnIcon);
            grid.ColumnDefinitions.Add(columnContent);
            PackIcon packIcon = new PackIcon
            {
                Kind = PackIconKind.Book
            };

            listBoxItem.FontSize = 16;
            packIcon.Width       = 32;
            packIcon.Height      = 32;
            listBoxItem.SetValue(Grid.ColumnProperty, 1);

            //GENERATE A RANDOM CALL NUMBER USING THE RANDOMGEN CLASS
            string callNumber = RandomNumber() + "." +
                                RandomNumber() + " " + RandomString();

            if (trickEntry == null)
            {
                //ADD THE CALL NUMBER TO THE LIST
                BookReplaceTest.books.Add(callNumber);
                listBoxItem.Content = callNumber;
            }
            else
            {
                BookReplaceTest.books.Add(trickEntry);
                listBoxItem.Content = trickEntry;
            }

            listBoxItem.IsEnabled = false;
            grid.Children.Add(packIcon);
            grid.Children.Add(listBoxItem);
            BookReplaceTest bookReplaceTest = BookReplaceTest.instance;

            bookReplaceTest.LstBooks.Items.Add(grid);
            return(listBoxItem.Content.ToString());
        }
        //CONSTRUCTOR
        public BookReplaceTest()
        {
            InitializeComponent();

            books.Clear();
            instance = this;
            //GENERATE A RANDOM INDEX TO INSERT THE TRICK CALL NUMBER
            //(SAME NUMBER BUT DIFFERENT LETTERS)
            int    generatedRandom = Generation.random.Next(1, 9);
            string item            = null;

            //CALL THE GENERATEBOOKS METHOD 10 TIMES
            for (int i = 0; i < 10; i++)
            {
                //COPY THE PREVIOUS INDEX OF THE RANDOM INDEX
                if (i == generatedRandom - 1)
                {
                    item = Generation.GenerateBooks(null);
                }
                else if (i == generatedRandom)
                {
                    //COPY THE NUMBERS OF THE COPIED INDEX
                    string trickEntry = item.Split(' ')[0];
                    //GENERATE 3 RANDOM CHARACTERS TO ADD ONTO THE COPIED INDEX
                    trickEntry += " " + Generation.RandomString();
                    //INSERT THE TRICK ENTRY
                    Generation.GenerateBooks(trickEntry);
                }
                else
                {
                    Generation.GenerateBooks(null);
                }
            }

            //SORT THE BOOKS INTO THE CORRECT ORDER
            //(BY NUMBER THEN BY LETTER) (IT WORKS, EVEN IF THE NUMBERS ARE THE SAME! :D)
            books.Sort();

            //START THE STOPWATCH TO TIME THE USER
            timer.Interval = TimeSpan.FromMilliseconds(10);
            timer.Tick    += Timer_Tick;
            timer.Start();
            stopWatch.Start();
        }