示例#1
0
        private void TextBox_LostFocus(object sender, RoutedEventArgs e)
        {
            TextBox tempTextBox = sender as TextBox;
            var target =MainGrid.Children.Cast<UIElement>().OfType<Label>().Where(c => Grid.GetRow(c) == Grid.GetRow(tempTextBox));
            string[] splitedNumbers= target.Single().Content.ToString().Split(' ');
            int[] tempNumbers = {Convert.ToInt32(splitedNumbers[0]), Convert.ToInt32(splitedNumbers[1]) , Convert.ToInt32(splitedNumbers[2]) , Convert.ToInt32(splitedNumbers[3])};

            ConfirmNumbers tempConfirmer = new ConfirmNumbers(tempNumbers);
            if (tempConfirmer.ConfirmIt(tempTextBox.Text) == true)
            {
                if (Calculater.SimpleAlgebra.Deal(tempTextBox.Text) == 24)
                {
                    tempTextBox.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFC0FFBA"));
                    tempTextBox.Uid = "passed";
                }
                else
                {
                    tempTextBox.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFFBABA"));
                    tempTextBox.Uid = "";
                }
            }
            else
            {
                tempTextBox.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFFBABA"));
                tempTextBox.Uid = "";
            }
        }
示例#2
0
        private void Reflash_Click(object sender, RoutedEventArgs e)
        {
            answer.Clear();
            RandomNumbersHub.RenderRandomNumbers();
            string imagePathFrontPart = "image/poker.cards_";
            card1.Source = new BitmapImage(new Uri(imagePathFrontPart+  RandomNumbersHub.PickupRandomNumber(0).ToString().PadLeft(2,'0')+".png",UriKind.Relative));
            card2.Source = new BitmapImage(new Uri(imagePathFrontPart + RandomNumbersHub.PickupRandomNumber(1).ToString().PadLeft(2, '0') + ".png", UriKind.Relative));
            card3.Source = new BitmapImage(new Uri(imagePathFrontPart + RandomNumbersHub.PickupRandomNumber(2).ToString().PadLeft(2, '0') + ".png", UriKind.Relative));
            card4.Source = new BitmapImage(new Uri(imagePathFrontPart + RandomNumbersHub.PickupRandomNumber(3).ToString().PadLeft(2, '0') + ".png", UriKind.Relative));

            int[] tempArray = { RandomNumbersHub.NumberA,RandomNumbersHub.NumberB,RandomNumbersHub.NumberC,RandomNumbersHub.NumberD };
            MainConfirmNumbers = new ConfirmNumbers(tempArray);

            MainClock = new Time();

            if (MainCounter != null)
            {
                MainCounter.Stop();
            }
            MainCounter = new DispatcherTimer();
            MainCounter.Interval = TimeSpan.FromMilliseconds(50);
            MainCounter.Tick += new EventHandler(ChangeTheValueOfClock);

            MainCounter.Start();
        }