Example #1
0
        /**
         * AƱade un menu a partir de un registro
         */
        public void addMenuFromClass(MenuClass m)
        {
            ComboBoxItem newButton = new ComboBoxItem();

            newButton.Content    = m.nombre;
            newButton.FontWeight = FontWeights.Bold;
            newButton.Foreground = Brushes.White;
            newButton.Visibility = Visibility.Visible;

            _botonesMenu.Add(newButton);
            Lista.addMenu(m);
            Lista.addButtonMenu(newButton);

            menu.Items.Add(newButton);

            string             name = newButton.Content.ToString();
            WrapPanelPrincipal wp   = new WrapPanelPrincipal();

            Grid.SetRow(wp, 1);
            wp.name = name;
            gridPrincipal.Children.Add(wp);
            wp.Visibility    = Visibility.Visible;
            _activatedButton = newButton;
            _wrapsPrincipales.Add(wp);

            Lista.addWrapPrincipal(wp);
            wp.setButton(newButton);

            onClickButtonMenuEspecial(newButton);
        }
Example #2
0
        /**
         * Muestra un panel para agregar un menu a la aplicacion
         */
        private void addMenuClick(object sender, EventArgs e)
        {
            try {
                ComboBoxItem newButton = new ComboBoxItem();
                newButton.Content = "";
                AddButton a = new AddButton(newButton);
                a.ShowDialog();
                if (a.isAdded())
                {
                    newButton.Foreground = Brushes.Black;
                    newButton.Visibility = Visibility.Visible;
                    newButton.Style      = (Style)Application.Current.Resources["CustomButtonStyle"];


                    _botonesMenu.Add(newButton);
                    MenuClass mc = new MenuClass(newButton.Content.ToString(), _profile.id);
                    mc = Conexion.saveMenu(mc);
                    if (mc != null)
                    {
                        Lista.addMenu(mc);
                        menu.Items.Add(newButton);
                        string             name = newButton.Content.ToString();
                        WrapPanelPrincipal wp   = new WrapPanelPrincipal();
                        wp.name = name;
                        gridPrincipal.Children.Add(wp);
                        wp.Visibility    = Visibility.Visible;
                        _activatedButton = newButton;
                        _wrapsPrincipales.Add(wp);

                        Lista.addWrapPrincipal(wp);
                        wp.setButton(newButton);

                        onClickButtonMenu(newButton, e);
                    }
                    else
                    {
                        MessageBox.Show("No se ha podido crear el Menu");
                    }
                }
            } catch (MySqlException exc) {
                MessageBox.Show("No se ha podido conectar a la base de datos");
            }
        }