コード例 #1
0
        private void BotSelectionEvent(object sender, RoutedEventArgs e)
        {
            UntoggleAllButtons();
            ToggleButton selected = e.Source as ToggleButton;

            StartGameButton.IsEnabled = true;
            selected.IsChecked        = true;

            if (selected.Equals(EasyBotButton))
            {
                type          = BotType.LEVEL1;
                TextArea.Text = String.Concat(Strings.bot_text_1, Environment.NewLine, Environment.NewLine, String.Format(Strings.Culture, Strings.ui_best_highscore, GameProperties.Props.Get(PropertyKey.PLAYER_HIGHSCORE_SOLO1)));
            }
            else if (selected.Equals(HookerBotButton))
            {
                type          = BotType.LEVEL2;
                TextArea.Text = String.Concat(Strings.bot_text_2, Environment.NewLine, Environment.NewLine, String.Format(Strings.Culture, Strings.ui_best_highscore, GameProperties.Props.Get(PropertyKey.PLAYER_HIGHSCORE_SOLO2)));
            }
            else if (selected.Equals(MedicoreBotButton))
            {
                type          = BotType.LEVEL3;
                TextArea.Text = String.Concat(Strings.bot_text_3, Environment.NewLine, Environment.NewLine, String.Format(Strings.Culture, Strings.ui_best_highscore, GameProperties.Props.Get(PropertyKey.PLAYER_HIGHSCORE_SOLO3)));
            }
            else
            {
                throw new Exception("Unsupported bot type");
            }
        }
コード例 #2
0
        private void MedToLar(ToggleButton bt)
        {
            _flagArr[_currentIndex] = true;
            _gridChildrenArr[_currentIndex, 0].Children.Clear();
            int count = 0;

            for (int i = 0; i < _numItemsArr[_currentIndex]; i++)
            {
                LayoutToLayoutTarget target = (_targetsArr[_currentIndex])[i] as LayoutToLayoutTarget;
                LayoutToLayoutHost   host   = (_hostsArr[_currentIndex])[i] as LayoutToLayoutHost;
                host.BeginAnimating(false);
                ContainerViewUserControl hostcv = host.Child as ContainerViewUserControl;
                ToggleButton             hostBt = hostcv.Minimize;
                if (hostBt.Equals(bt))
                {
                    Grid.SetRow(target, 0);
                    Grid.SetColumn(target, 0);
                    Grid.SetRowSpan(target, _numItemsArr[_currentIndex] - 1);
                    Grid.SetColumnSpan(target, 1);
                }
                else
                {
                    Grid.SetRow(target, count);
                    Grid.SetColumn(target, 1);
                    count++;
                }
                _gridChildrenArr[_currentIndex, 1].Children.Add(target);
            }
        }
コード例 #3
0
        private void ChangeItem(ToggleButton bt)
        {
            int count = 0;

            for (int i = 0; i < _numItemsArr[_currentIndex]; i++)
            {
                LayoutToLayoutTarget target = (_targetsArr[_currentIndex])[i] as LayoutToLayoutTarget;
                LayoutToLayoutHost   host   = (_hostsArr[_currentIndex])[i] as LayoutToLayoutHost;
                host.BeginAnimating(false);
                ContainerViewUserControl hostcv = host.Child as ContainerViewUserControl;
                ToggleButton             hostBt = hostcv.Minimize;
                if (hostBt.Equals(bt))
                {
                    Grid.SetRow(target, 0);
                    Grid.SetColumn(target, 0);
                    Grid.SetRowSpan(target, _numItemsArr[_currentIndex] - 1);
                    Grid.SetColumnSpan(target, 1);
                    //hostBt.IsChecked = true;
                }
                else
                {
                    Grid.SetRow(target, count);
                    Grid.SetColumn(target, 1);
                    Grid.SetRowSpan(target, 1);
                    Grid.SetColumnSpan(target, 1);
                    hostBt.IsChecked = false;
                    count++;
                }
            }
        }
コード例 #4
0
        private void TbToday_OnPreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            var tgBtn = (ToggleButton)sender;

            if (_curSelectTbBtn != null && _curSelectTbBtn.Equals(tgBtn))
            {
                e.Handled = true;
                return;
            }

            if (_curSelectTbBtn != null)
            {
                _curSelectTbBtn.IsChecked = false;
            }
        }
コード例 #5
0
        /// <summary> Return the outer key of the given <paramref name="toggleButton"/>. </summary>
        /// <param name="toggleButton"> The button whose outer key to get. </param>
        /// <returns></returns>
        public T GetOuterKey(ToggleButton toggleButton)
        {
            foreach (var buttonColumnKeyValuePair in ToggleColumns)
            {
                var owner        = buttonColumnKeyValuePair.Key;
                var buttonColumn = buttonColumnKeyValuePair.Value;

                foreach (var existingButton in buttonColumn.Buttons.Values)
                {
                    if (toggleButton.Equals(existingButton))
                    {
                        return(owner);
                    }
                }
            }
            return(default);
コード例 #6
0
        private void addStock_Click(object sender, RoutedEventArgs e)
        {
            if (answerCodigoProduto.Text == "" || answerQuantidadeProduto.Text == "")
            {
                MessageBox.Show("Tem de preencher todos os campos!");
            }
            else
            {
                if (activeButton.Equals(addStock))
                {
                    if (validarCodigo(answerCodigoProduto, "Código") && validarInt(answerQuantidadeProduto, "Quantidade"))
                    {
                        try
                        {
                            SqlCommand cmd = new SqlCommand("Games.AddStock", Connection.Conn);
                            cmd.CommandType = CommandType.StoredProcedure;

                            cmd.Parameters.Add(new SqlParameter("@codigo", SqlDbType.VarChar));
                            cmd.Parameters["@codigo"].Value = answerCodigoProduto.Text;

                            cmd.Parameters.Add(new SqlParameter("@quantidade", SqlDbType.VarChar));
                            cmd.Parameters["@quantidade"].Value = answerQuantidadeProduto.Text;

                            cmd.Parameters.Add(new SqlParameter("@idLoja", SqlDbType.VarChar));
                            cmd.Parameters["@idLoja"].Value = MainWindow.idLoja;

                            Connection.Conn.Open();
                            cmd.ExecuteNonQuery();
                            Connection.Conn.Close();

                            tipoProdutoStock.SelectedIndex = -1;
                            scrollSet("", Visibility.Visible, true);
                            MessageBox.Show("Stock adicionado com sucesso");
                        }
                        catch
                        {
                            MessageBox.Show("Erro na Rede");
                        }
                    }
                }
                else if (activeButton.Equals(changeProduct))
                {
                    if (validarCodigo(answerCodigoProduto, "Código") && validarInt(answerQuantidadeProduto, "Preço"))
                    {
                        try
                        {
                            SqlCommand cmd = new SqlCommand("Games.UpdateProduct", Connection.Conn);
                            cmd.CommandType = CommandType.StoredProcedure;

                            cmd.Parameters.Add(new SqlParameter("@id", SqlDbType.VarChar));
                            cmd.Parameters["@id"].Value = answerCodigoProduto.Text;

                            cmd.Parameters.Add(new SqlParameter("@preco", SqlDbType.Decimal));
                            cmd.Parameters["@preco"].Value = decimal.Parse(answerQuantidadeProduto.Text);

                            Connection.Conn.Open();
                            cmd.ExecuteNonQuery();
                            Connection.Conn.Close();
                            tipoProdutoStock.SelectedIndex = -1;
                            answerCodigoProduto.Text       = "";
                            answerQuantidadeProduto.Text   = "";
                            answerPrecoProduto.Text        = "";

                            scrollSet("", Visibility.Visible, true);
                            MessageBox.Show("Preço do produto alterado com sucesso");
                        }
                        catch
                        {
                            MessageBox.Show("Erro na Rede");
                        }
                    }
                }
            }
        }
コード例 #7
0
ファイル: Juego1.xaml.cs プロジェクト: JosephMG28/Minijuegos
        /// <summary>
        /// Every control's Click event is handled by this event handler.
        /// </summary>
        /// <param name="sender">The control that was clicked.</param>
        /// <param name="e"></param>
        private void ToggleButton_Click(object sender, RoutedEventArgs e)
        {
            // The timer is only on after two non-matching
            // icons have been shown to the player,
            // so ignore any clicks if the timer is running
            if (timer1.IsEnabled == true)
            {
                btmDummy           = (ToggleButton)sender;
                btmDummy.IsChecked = true;
                return;
            }
            else
            {
                ToggleButton clickedLabel = (ToggleButton)sender;

                if (clickedLabel != null)
                {
                    // If the clicked Control is is not checked, the player clicked
                    // an icon that's already been revealed --
                    // ignore the click.
                    //if (clickedLabel.IsChecked == false)
                    //{
                    //    // All done - leave the if statements.
                    //    clickedLabel.IsChecked = false;
                    //    return;
                    //}
                    if (clickedLabel.Equals(PrimerClic))
                    {
                        // All done - leave the if statements.
                        clickedLabel.IsChecked = false;
                        return;
                    }
                    else
                    {
                        // If firstClicked is null, this is the first icon
                        // in the pair that the player clicked,
                        // so set firstClicked to the label that the player
                        // clicked, change its color to black, and return.
                        if (PrimerClic == null)
                        {
                            PrimerClic           = clickedLabel;
                            PrimerClic.IsChecked = false;
                            Icono1 = (TextBlock)PrimerClic.Content;

                            // All done - leave the if statements.
                            return;
                        }
                        else
                        {
                            // If the player gets this far, the timer isn't
                            // running and firstClicked isn't null,
                            // so this must be the second icon the player clicked
                            // Set its color to black.
                            SegundoClic           = clickedLabel;
                            SegundoClic.IsChecked = false;
                            Icono2 = (TextBlock)SegundoClic.Content;

                            // If the player clicked two matching icons, keep them
                            // black and reset firstClicked and secondClicked
                            // so the player can click another icon.
                            if (Icono1.Text == Icono2.Text)
                            {
                                //TextBlock txt = (TextBlock)PrimerClic.Content;
                                //txt.Foreground = Application.Current.Resources["SecondaryAccentBrush"] as Brush;
                                //PrimerClic.Content = txt;
                                //SegundoClic.Content = txt;
                                PrimerClic.IsEnabled  = false;
                                SegundoClic.IsEnabled = false;

                                macheados++;
                                // Check to see if the player won.
                                if (macheados == 15)
                                {
                                    MessageBox.Show("You matched all the icons!", "Congratulations!");
                                }

                                PrimerClic = SegundoClic = null;
                                Icono1     = Icono2 = null;
                                return;
                            }
                            else
                            {
                                // If the player gets this far, the player
                                // clicked two different icons, so start the
                                // timer (which will wait three quarters of
                                // a second, and then hide the icons)....
                                timer1.Start();
                            }
                        }
                    }
                }
            }
        }