Inheritance: MonoBehaviour
Exemplo n.º 1
0
        static void Main(string[] args)
        {
            int    cod         = 0;
            string descripcion = "hola";

            Boton       btn         = new Boton(cod, descripcion);
            Controlador controlador = new CuartaClaseLibrary.entidades.Controlador();

            try {
                controlador.AgregarBoton(btn);
            } catch (BotonYaExistenteException ex)
            {
                Console.WriteLine(ex);
            }

            try
            {
                controlador.EliminarBoton(btn);
            } catch (BotonNoExistenteException ex)
            {
                Console.WriteLine(ex);
            }

            try
            {
                string desc1 = controlador.TraerDescripcion(cod);
                Console.WriteLine("la descripcion del boton es: {0}", desc1);
            }
            catch (BotonNoExistenteException ex)
            {
                Console.WriteLine(ex);
            }

            Console.ReadKey();
        }
Exemplo n.º 2
0
        public MenuPrincipal(string MediaDir, TgcD3dInput input)
        {
            tituloPrincipal = new Simbolo(MediaDir, "titulo.png", input);
            empezar         = new Boton(MediaDir, "empezar.png", input, "seleccion_empezar.png", new AccionEmpezar());
            opciones        = new Boton(MediaDir, "opciones.png", input, "seleccion_opciones.png", new AccionOpciones());
            salir           = new Boton(MediaDir, "salir.png", input, "seleccion_salir.png", new AccionSalir());

            tituloPrincipal.Position = posicionTitulo;
            empezar.Position         = new TGCVector2(100, H / 4);
            opciones.Position        = new TGCVector2(100, H / 2.25f);
            salir.Position           = new TGCVector2(100, H / 1.5f);
            tituloPrincipal.Scaling  = new TGCVector2(1f, 1f);
            empezar.Scaling          = new TGCVector2(0.6f, 0.6f);
            opciones.Scaling         = new TGCVector2(0.6f, 0.6f);
            salir.Scaling            = new TGCVector2(0.6f, 0.6f);

            tituloPrincipal.Scaling = new TGCVector2(0.8f, 0.8f);
            this.simbolos           = new List <Simbolo>();
            simbolos.Add(tituloPrincipal);

            this.botonesMenuPrincipal = new List <Boton>();
            botonesMenuPrincipal.Add(empezar);
            botonesMenuPrincipal.Add(opciones);
            botonesMenuPrincipal.Add(salir);
        }
Exemplo n.º 3
0
    void CrearPanel()
    {
        string[] indice = manager.DevolverIndiceSimple(true).ToArray();

        int x      = 0;
        int totalX = 9;
        int y      = 0;

        for (int i = 0; i < indice.Length; i++)
        {
            GameObject _obj = Instantiate(prefab);
            _obj.transform.parent = panel.transform;

            Carta _carta = _obj.GetComponent <Carta>();
            if (_carta != null)
            {
                _carta.ConfigurarCarta(new CartaInfo(indice[i].ToUpper()));
                Boton _boton = _obj.GetComponent <Boton>();
                _boton.pulsarBoton.AddListener(() => SeleccionarBoton(_carta, _boton));
            }

            _obj.transform.localPosition = new Vector3(inicialPos.x + sepX * x, inicialPos.y - sepY * y, inicialPos.z);

            x++;

            if (x == totalX)
            {
                x = 0;
                y++;
                totalX       = (y % 2 == 0) ? 9 : 10;
                inicialPos.x = (y % 2 == 0) ? -3.9f : -4.5f;
            }
        }
    }
 void Start()
 {
     botonAcces = GameObject.FindGameObjectWithTag("DatabaseAccess").GetComponent <Boton>();
     upSprite.SetActive(true);
     downSprite.SetActive(false);
     WaypointPatrol.muerto = false;
 }
Exemplo n.º 5
0
        public MenuAudio(string MediaDir, TgcD3dInput input)
        {
            atras            = new Boton(MediaDir, "atras.png", input, "seleccion_atras.png", new AccionAtras());
            sonidoMenu       = new Boton(MediaDir, "sonido_menu.png", input, "seleccion_sonido_menu.png", new AccionSonido(new AccionSonidoMenu(), MediaDir));
            sonidoDisparos   = new Boton(MediaDir, "sonido_disparos.png", input, "seleccion_sonido_disparos.png", new AccionSonido(new AccionSonidoDisparos(), MediaDir));
            sonidoAmbiente   = new Boton(MediaDir, "sonido_ambiente.png", input, "seleccion_sonido_ambiente.png", new AccionSonido(new AccionSonidoAmbiente(), MediaDir));
            onSonidoMenu     = new Simbolo(MediaDir, "on.png", input);
            onSonidoDisparos = new Simbolo(MediaDir, "on.png", input);
            onSonidoAmbiente = new Simbolo(MediaDir, "on.png", input);

            atras.Position            = new TGCVector2(75, H / 1.15f);
            sonidoAmbiente.Position   = new TGCVector2(100, H / 3.5f);
            sonidoDisparos.Position   = new TGCVector2(100, H / 2.5f);
            sonidoMenu.Position       = new TGCVector2(100, H / 2f);
            onSonidoMenu.Position     = new TGCVector2(600, H / 2f);
            onSonidoAmbiente.Position = new TGCVector2(600, H / 3.5f);
            onSonidoDisparos.Position = new TGCVector2(600, H / 2.5f);
            sonidoAmbiente.Scaling    = new TGCVector2(0.4f, 0.4f);
            sonidoDisparos.Scaling    = new TGCVector2(0.4f, 0.4f);
            sonidoMenu.Scaling        = new TGCVector2(0.4f, 0.4f);
            onSonidoAmbiente.Scaling  = new TGCVector2(0.4f, 0.4f);
            onSonidoDisparos.Scaling  = new TGCVector2(0.4f, 0.4f);
            onSonidoMenu.Scaling      = new TGCVector2(0.4f, 0.4f);
            atras.Scaling             = new TGCVector2(0.4f, 0.4f);

            this.botonesSonidos = new List <Boton>();
            botonesSonidos.Add(sonidoMenu);
            botonesSonidos.Add(sonidoDisparos);
            botonesSonidos.Add(sonidoAmbiente);

            this.simbolosSonido = new List <Simbolo>();
            simbolosSonido.Add(onSonidoDisparos);
            simbolosSonido.Add(onSonidoMenu);
            simbolosSonido.Add(onSonidoAmbiente);
        }
Exemplo n.º 6
0
 public void entraEnElColiderDeBoton(Boton boton, GameObject colision)
 {
     if (Input.GetButton(botones[(int)boton]))
     {
         contador++;
         contadorPuntos.GetComponent <TextMesh>().text = "x" + contador;
         Destroy(colision);
         audio.playSucces();
     }
 }
Exemplo n.º 7
0
        public void Estilo2Sale(Boton boton)
        {
            if (boton.hover == true)
            {
                Cursor.SetCursor(cursor1, Vector2.zero, CursorMode.Auto);

                CambiarBotonFondo(boton.gameObject.GetComponent <Button>(), colorTransparente);
                CambiarTextoProColor(boton.gameObject.transform.GetChild(0), colorTextoSale);
            }
        }
Exemplo n.º 8
0
        void boton_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Boton     botonEvento = (Boton)sender;
            FieldInfo campo       = tipoObjeto.GetField(botonEvento.Name.Replace("btn_", ""), BindingFlags.Instance | BindingFlags.NonPublic);
            //ObjetoBase objeto = (ObjetoBase)campo.GetValue(objetoBase);


            CatalogoAutomatico cat = new CatalogoAutomatico(null, campo.FieldType);

            cat.ShowDialog();
        }
Exemplo n.º 9
0
    void CogerComponentes()
    {
        boton    = (Boton)target;
        property = new SerializedObject((Boton)target);

        if (mesh != null)
        {
            return;
        }
        mesh = boton.GetComponent <MeshRenderer>();
    }
Exemplo n.º 10
0
    void SeleccionarBoton(Carta carta, Boton boton)
    {
        if (comodin == null)
        {
            Debug.Log("No hay comodin seleccionado");
            return;
        }

        comodin.SetVisualLetterForComodin(carta.GetTrueLetter());
        comodin = null;
        boton.contorno.SetActive(false);
        panel.SetActive(false);
    }
        public MenuControles(string MediaDir, TgcD3dInput input)
        {
            accion     = new Simbolo(MediaDir, "accion.png", input);
            tecla      = new Simbolo(MediaDir, "tecla.png", input);
            derecha    = new Simbolo(MediaDir, "derecha.png", input);
            izquierda  = new Simbolo(MediaDir, "izquierda.png", input);
            afterBurn  = new Simbolo(MediaDir, "afterburn.png", input);
            disparar   = new Simbolo(MediaDir, "disparar.png", input);
            d          = new Simbolo(MediaDir, "d.png", input);
            a          = new Simbolo(MediaDir, "a.png", input);
            left_click = new Simbolo(MediaDir, "left_click.png", input);
            shift      = new Simbolo(MediaDir, "shift.png", input);
            atras      = new Boton(MediaDir, "atras.png", input, "seleccion_atras.png", new AccionAtras());

            accion.Scaling     = new TGCVector2(0.6f, 0.6f);
            tecla.Scaling      = new TGCVector2(0.6f, 0.6f);
            derecha.Scaling    = new TGCVector2(0.4f, 0.5f);
            izquierda.Scaling  = new TGCVector2(0.4f, 0.5f);
            afterBurn.Scaling  = new TGCVector2(0.4f, 0.5f);
            d.Scaling          = new TGCVector2(0.4f, 0.5f);
            a.Scaling          = new TGCVector2(0.4f, 0.5f);
            left_click.Scaling = new TGCVector2(0.4f, 0.5f);
            atras.Scaling      = new TGCVector2(0.4f, 0.4f);
            disparar.Scaling   = new TGCVector2(0.4f, 0.4f);
            shift.Scaling      = new TGCVector2(0.4f, 0.4f);

            accion.Position     = new TGCVector2(75, H / 5.5f);
            derecha.Position    = new TGCVector2(100, H / 3.25f);
            izquierda.Position  = new TGCVector2(100, H / 2.25f);
            afterBurn.Position  = new TGCVector2(100, H / 1.75f);
            disparar.Position   = new TGCVector2(100, H / 1.45f);
            atras.Position      = new TGCVector2(75, H / 1.15f);
            d.Position          = new TGCVector2(625, H / 3.25f);
            a.Position          = new TGCVector2(625, H / 2.25f);
            left_click.Position = new TGCVector2(625, H / 1.45f);
            shift.Position      = new TGCVector2(625, H / 1.75f);
            tecla.Position      = new TGCVector2(570, H / 5.5f);

            simbolos = new List <Simbolo>();
            simbolos.Add(accion);
            simbolos.Add(tecla);
            simbolos.Add(d);
            simbolos.Add(derecha);
            simbolos.Add(izquierda);
            simbolos.Add(a);
            simbolos.Add(disparar);
            simbolos.Add(left_click);
            simbolos.Add(afterBurn);
            simbolos.Add(shift);
        }
Exemplo n.º 12
0
        public async Task <ActionResult> Post(Boton btn)
        {
            try
            {
                await _context.Boton.AddAsync(btn);

                await _context.SaveChangesAsync();
            }
            catch (Exception e)
            {
            }

            return(new JsonResult(true));
        }
Exemplo n.º 13
0
    void loadLvl(SaveManager.GameSave lvlLoader_)
    {
        ammo_ = lvlLoader_.ammo_;
        Instantiate(PlayerPrefab, lvlLoader_.playerPos_, Quaternion.identity);

        int i = 0;

        foreach (SaveManager.EnemySettings e in lvlLoader_.enemies_)
        {
            EnemigoManager enemy = Instantiate(EnemigoPrefab, e.tr_, Quaternion.identity).GetComponent <EnemigoManager>();
            enemy.transform.parent = EnemiesPool.transform;
            enemy.name             = "Enemigo" + i;
            enemy.LoadEnemy(e.nodes_.nodes, e.nodes_.count, e.state, e.prevstate);
            i++;
        }
        i = 0;
        foreach (SaveManager.PuertasStates p in lvlLoader_.puertas_)
        {
            Puerta puerta = Instantiate(PuertaPrefab, p.position_, Quaternion.Euler(p.rotation_)).GetComponent <Puerta>();
            puerta.transform.parent = PuertaPool.transform;
            puerta.name             = "Puerta" + i;
            puerta.SetPuerta(p.open_);
            i++;
        }
        i = 0;
        foreach (SaveManager.BotonStates b in lvlLoader_.botones_)
        {
            Boton boton = Instantiate(BotonPrefab, b.position_, Quaternion.identity).GetComponent <Boton>();
            boton.transform.parent = BotonesPool.transform;
            boton.name             = "Boton" + i;
            i++;

            if (b.active)
            {
                List <GameObject> LaserIn = new List <GameObject>();
                foreach (SaveManager.LaserTr l in b.laser)
                {
                    GameObject laser = Instantiate(LaserPrefab, l.positon_, Quaternion.Euler(l.rotation_));
                    laser.GetComponent <Laser>().SetIntermitencia(l.intermitencia_);
                    LaserIn.Add(laser);
                }
                boton.SetButton(LaserIn, true);
            }
            else
            {
                boton.SetButton(null, false);
            }
        }
    }
Exemplo n.º 14
0
        public void Estilo2Entra(Boton boton)
        {
            if (boton.hover == true)
            {
                if (sonido != null)
                {
                    sonido.RatonEntra();
                }

                Cursor.SetCursor(cursor2, Vector2.zero, CursorMode.Auto);

                CambiarBotonFondo(boton.gameObject.GetComponent <Button>(), colorBotonEntra);
                CambiarTextoProColor(boton.gameObject.transform.GetChild(0), colorTextoEntra);
            }
        }
Exemplo n.º 15
0
        public MenuInstrucciones(string MediaDir, TgcD3dInput input)
        {
            parrafo1 = new Simbolo(MediaDir, "parrafo1.png", input);
            parrafo2 = new Simbolo(MediaDir, "parrafo2.png", input);
            parrafo3 = new Simbolo(MediaDir, "parrafo3.png", input);
            atras    = new Boton(MediaDir, "atras.png", input, "seleccion_atras.png", new AccionAtras());

            parrafo1.Position = new TGCVector2(W / 7.5f, H / 3f);
            parrafo2.Position = new TGCVector2(W / 7.5f, H / 2.5f);
            parrafo3.Position = new TGCVector2(W / 7.5f, H / 2.15f);
            atras.Position    = new TGCVector2(75, H / 1.15f);
            atras.Scaling     = new TGCVector2(0.4f, 0.4f);

            simbolos = new List <Simbolo>();
            simbolos.Add(parrafo1);
            simbolos.Add(parrafo2);
            simbolos.Add(parrafo3);
        }
Exemplo n.º 16
0
    void BotonSeleccionado(int index, int precio, int posicion)
    {
        GameObject _obj = productos[index];

        if (_obj == null)
        {
            return;
        }

        Boton _boton = _obj.GetComponent <Boton>();

        if (_boton == null)
        {
            return;
        }

        _boton.pulsarBoton.AddListener(() => SeleccionarProducto(index, precio, posicion));
    }
Exemplo n.º 17
0
    static void Main(string[] args)
    {
        Formulario formulario = new Formulario();

        formulario.AgregaControl(new ZonaInformacion("Nombre"));
        formulario.AgregaControl(new ZonaInformacion("Apellidos"));
        PopupMenu menu = new PopupMenu("Coprestatario");

        menu.AgregaOpcion("sin prestatario");
        menu.AgregaOpcion("con prestatario");
        formulario.AgregaControl(menu);
        formulario.MenuCoprestatario = menu;
        Boton boton = new Boton("OK");

        formulario.AgregaControl(boton);
        formulario.BotonOK = boton;
        formulario.AgregaControlCoprestatario(new ZonaInformacion("Nombre del coprestatario"));
        formulario.AgregaControlCoprestatario(new ZonaInformacion("Apellidos del coprestatario"));
        formulario.Informa();
    }
Exemplo n.º 18
0
        public MenuOpciones(string MediaDir, TgcD3dInput input)
        {
            audio         = new Boton(MediaDir, "audio.png", input, "seleccion_audio.png", new AccionAudio());
            instrucciones = new Boton(MediaDir, "instrucciones.png", input, "seleccion_instrucciones.png", new AccionInstrucciones());
            controles     = new Boton(MediaDir, "controles.png", input, "seleccion_controles.png", new AccionControles());
            volver        = new Boton(MediaDir, "volver.png", input, "seleccion_volver.png", new AccionVolver());

            instrucciones.Position = new TGCVector2(100, H / 3.25f);
            audio.Position         = new TGCVector2(100, H / 2.25f);
            controles.Position     = new TGCVector2(100, H / 1.75f);
            volver.Position        = new TGCVector2(100, H / 1.25f);
            instrucciones.Scaling  = new TGCVector2(0.5f, 0.6f);
            audio.Scaling          = new TGCVector2(0.6f, 0.6f);
            controles.Scaling      = new TGCVector2(0.6f, 0.6f);
            volver.Scaling         = new TGCVector2(0.4f, 0.4f);

            this.botonesOpciones = new List <Boton>();
            botonesOpciones.Add(audio);
            botonesOpciones.Add(instrucciones);
            botonesOpciones.Add(controles);
            botonesOpciones.Add(volver);
        }
Exemplo n.º 19
0
        private void FuncionesBotones(String botonAction, Boton boton)
        {
            FragmentoConfiguration fragmentoConfiguration = new FragmentoConfiguration();

            String regexCodigoDato = "\\d.*\\d";
            Regex  regex           = new Regex(regexCodigoDato, RegexOptions.IgnoreCase);

            if (botonAction.Equals("Pagar"))
            {
                Intent intent = new Intent(Activity, typeof(PanelDePago));
                StartActivity(intent);
            }
            //Algunos volver en ciertos teclados cierran un fragment, no una actividad
            //los que tengan Label vacío cierran fragment, los que no, cierran actividades
            else if (botonAction.Equals("Volver") && boton.getLabel().Length == 0)
            {
                Fragment fragmentoBotoneraPrincipal = FragmentManager.FindFragmentByTag("BOTONERA_PRINCIPAL");
                fragmentoConfiguration.removeFragment(fragmentoBotoneraPrincipal, FragmentManager);
            }
            else if (botonAction.Equals("Volver"))
            {
                Activity.Finish();
            }
            else if (boton.getCategorias().Equals("Categorias"))
            {
                FragmentoBotoneraPrincipal fragmentoBotoneraPrincipal = new FragmentoBotoneraPrincipal(boton.getDato());

                fragmentoConfiguration.replaceFragments(fragmentoBotoneraPrincipal, Resource.Id.fragment_container, "BOTONERA_PRINCIPAL", FragmentManager);
                Toast.MakeText(Application.Context, boton.getDato(), ToastLength.Short).Show();
            }
            //Si un boton posee un dato, y ese dato posee solo números, se trata de un PRODUCTO
            //Se usa la expresión regular declarada arriba y se compara con el dato de un botón
            else if (regex.Match(boton.getDato()).Success)
            {
                AccionBotonArticulo(boton);
            }
            boton.GetButtonLayout().SetBackgroundColor(new Android.Graphics.Color(Application.Context.GetColor(Resource.Color.colorPrimaryDark)));
        }
Exemplo n.º 20
0
 void Awake()
 {
     boton = GetComponent <Boton>();
     coll  = GetComponent <BoxCollider>();
 }
Exemplo n.º 21
0
 public void AddButton(Boton boton)
 {
     botones_.Add(boton);
 }
Exemplo n.º 22
0
// Start is called before the first frame update
    void Start()
    {
        Detener = GameObject.Find("Boton").GetComponent <Boton>();
    }
Exemplo n.º 23
0
    bool BotonReplayActive()
    {
        Boton aux = botonReplay.GetComponent <Boton>();

        return(aux.GetActiveBoton());
    }
Exemplo n.º 24
0
 void Awake()
 {
     instancia = this;
 }
Exemplo n.º 25
0
        public CatalogoAutomatico(ObjetoBase objeto, Type tipoObjeto)
        {
            InitializeComponent();
            objetoBase      = objeto;
            this.tipoObjeto = tipoObjeto;
            FieldInfo[] campos = tipoObjeto.GetFields(BindingFlags.CreateInstance | BindingFlags.NonPublic | BindingFlags.Instance);

            int altoEstandar        = 25;
            int altoEstandarAumento = 10;



            int altoGrid = 0;

            int i = 0;

            foreach (FieldInfo campo in campos)
            {
                if (!campo.Name.StartsWith("_"))
                {
                    continue;
                }
                if (campo.FieldType == typeof(String) || campo.FieldType == typeof(Double) || campo.FieldType == typeof(Int32) || campo.FieldType == typeof(Int64) || campo.FieldType == typeof(Decimal))
                {
                    RowDefinition renglon = new RowDefinition();
                    renglon.Height = new GridLength(altoEstandar + altoEstandarAumento);

                    altoGrid += altoEstandar + altoEstandarAumento;

                    grd_GridControles.RowDefinitions.Add(renglon);
                    Label label = new Label();
                    label.Name    = "lbl_" + campo.Name;
                    label.Content = ObtenerNombreCampo(campo.Name);
                    label.Height  = altoEstandar;
                    UserControl textbox = null;
                    if (campo.FieldType == typeof(String))
                    {
                        textbox = new TextboxNormal();
                        ((TextboxNormal)textbox).TipoTextBox = TextboxNormal.Tipo.conEspacios;
                    }
                    else if (campo.FieldType == typeof(Int32) || campo.FieldType == typeof(Int64))
                    {
                        textbox = new TextboxSoloNumero();
                    }
                    else if (campo.FieldType == typeof(Double) || campo.FieldType == typeof(float) || campo.FieldType == typeof(Decimal))
                    {
                        textbox = new TextboxSoloNumeroDecimal();
                    }
                    textbox.Name   = "txt_" + campo.Name;
                    textbox.Height = altoEstandar;

                    Grid.SetRow(label, i);
                    Grid.SetColumn(label, 0);

                    Grid.SetRow(textbox, i);
                    Grid.SetColumn(textbox, 1);

                    grd_GridControles.Children.Add(label);
                    grd_GridControles.Children.Add(textbox);
                    i++;
                }
                else if (campo.FieldType == typeof(Boolean))
                {
                    RowDefinition renglon = new RowDefinition();
                    renglon.Height = new GridLength(altoEstandar + altoEstandarAumento);
                    altoGrid      += altoEstandar + altoEstandarAumento;
                    grd_GridControles.RowDefinitions.Add(renglon);
                    Label label = new Label();
                    label.Name    = "lbl_" + campo.Name;
                    label.Content = ObtenerNombreCampo(campo.Name);

                    CheckBox checkbox = new CheckBox();
                    checkbox.Name = "chb_" + campo.Name;

                    checkbox.Width = 160;
                    checkbox.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                    checkbox.VerticalAlignment   = System.Windows.VerticalAlignment.Center;

                    label.Height    = altoEstandar;
                    checkbox.Height = 15;

                    Grid.SetRow(label, i);
                    Grid.SetColumn(label, 0);

                    Grid.SetRow(checkbox, i);
                    Grid.SetColumn(checkbox, 1);

                    grd_GridControles.Children.Add(label);
                    grd_GridControles.Children.Add(checkbox);

                    i++;
                }
                else if (campo.FieldType == typeof(DateTime))
                {
                    RowDefinition renglon = new RowDefinition();
                    renglon.Height = new GridLength(altoEstandar + altoEstandarAumento);
                    altoGrid      += altoEstandar + altoEstandarAumento;
                    grd_GridControles.RowDefinitions.Add(renglon);
                    Label label = new Label();
                    label.Name    = "lbl_" + campo.Name;
                    label.Content = ObtenerNombreCampo(campo.Name);

                    DatePicker datePicker = new DatePicker();
                    datePicker.Name = "dtp_" + campo.Name;

                    datePicker.Width = 160;
                    datePicker.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;

                    label.Height      = altoEstandar;
                    datePicker.Height = altoEstandar;

                    Grid.SetRow(label, i);
                    Grid.SetColumn(label, 0);

                    Grid.SetRow(datePicker, i);
                    Grid.SetColumn(datePicker, 1);

                    grd_GridControles.Children.Add(label);
                    grd_GridControles.Children.Add(datePicker);

                    i++;
                }

                else if (campo.FieldType.BaseType == typeof(ObjetoBase))
                {
                    RowDefinition renglon = new RowDefinition();
                    renglon.Height = new GridLength(altoEstandar + altoEstandarAumento);
                    altoGrid      += altoEstandar + altoEstandarAumento;

                    grd_GridControles.RowDefinitions.Add(renglon);
                    Label label = new Label();
                    label.Name    = "lbl_" + campo.Name;
                    label.Content = ObtenerNombreCampo(campo.Name);

                    Boton boton = new Boton();
                    boton.Name  = "btn_" + campo.Name;
                    boton.Text  = "Seleccionar";
                    boton.Width = boton.Text.Length * 12;
                    boton.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                    boton.MouseDown          += boton_MouseDown;
                    label.Height = altoEstandar;
                    boton.Height = altoEstandar;

                    Grid.SetRow(label, i);
                    Grid.SetColumn(label, 0);

                    Grid.SetRow(boton, i);
                    Grid.SetColumn(boton, 1);

                    grd_GridControles.Children.Add(label);
                    grd_GridControles.Children.Add(boton);

                    i++;
                }
                else if (campo.FieldType.Name.Contains("List") && campo.FieldType.GetGenericArguments()[0].Name.StartsWith("_"))
                {
                    RowDefinition renglon = new RowDefinition();
                    renglon.Height = new GridLength(125);
                    altoGrid      += 125;

                    grd_GridControles.RowDefinitions.Add(renglon);
                    Label label = new Label();
                    label.Name              = "lbl_" + campo.Name;
                    label.Content           = ObtenerNombreCampo(campo.Name);
                    label.VerticalAlignment = System.Windows.VerticalAlignment.Top;

                    ListBox listBox = new ListBox();
                    listBox.Name              = "lb_" + campo.Name;
                    listBox.Height            = 100;
                    listBox.VerticalAlignment = System.Windows.VerticalAlignment.Top;

                    Boton boton = new Boton();
                    boton.Name  = "btn_" + campo.Name;
                    boton.Text  = "Agregar";
                    boton.Width = boton.Text.Length * 12;
                    boton.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                    boton.VerticalAlignment   = System.Windows.VerticalAlignment.Bottom;
                    boton.MouseDown          += boton_MouseDownLista;

                    label.Height = altoEstandar;
                    boton.Height = altoEstandar;

                    Grid.SetRow(label, i);
                    Grid.SetColumn(label, 0);

                    Grid.SetRow(listBox, i);
                    Grid.SetColumn(listBox, 1);

                    Grid.SetRow(boton, i);
                    Grid.SetColumn(boton, 1);

                    grd_GridControles.Children.Add(label);
                    grd_GridControles.Children.Add(listBox);
                    grd_GridControles.Children.Add(boton);


                    i++;
                }
            }
            grd_GridControles.Height = altoGrid;
        }
Exemplo n.º 26
0
 public void foco()
 {
     Boton.Focusable = true;
     Boton.Focus();
 }
Exemplo n.º 27
0
        /// <summary>
        /// Guarda Diapositiva
        /// </summary>
        /// <param name="diapositiva"></param>
        /// <param name="cursoID"></param>
        /// <returns></returns>
        public ActionResult Save(DiapositivaVM dvm, long cursoID, List <long> DiapositivasID, long ddlPlantilla, bool isDiapositivaAudio)
        {
            // -- Seteo la plantilla
            dvm.Diapositiva.Plantilla = new Plantilla {
                EntityID = ddlPlantilla
            };
            // -- Seteo si la diapositiva es de audio
            dvm.Diapositiva.IsDiapositivaAudio = isDiapositivaAudio;
            // -- Si viene como nulo lo instancio
            if (DiapositivasID == null)
            {
                DiapositivasID = new List <long>();
            }
            // -- Recupero diapositva por orden
            diapositvaPorOrden = logic.GetByOrdenYCurso(cursoID, dvm.Diapositiva.Orden);
            // -- SI existe diapositva con el orden ingresado
            if (diapositvaPorOrden != null && dvm.Diapositiva.EntityID != diapositvaPorOrden.EntityID)
            {
                // -- Agrego el error
                ModelState.AddModelError("Diapositiva.Orden", "Ya existe una diapositiva con el orden ingresado");
            }

            if (ModelState.IsValid)
            {
                // -- Agrego diapositivas
                dvm.Diapositiva.DiapositivasReferidas = new List <Diapositiva>();
                DiapositivasID.ForEach(x => dvm.Diapositiva.DiapositivasReferidas.Add(new Diapositiva {
                    EntityID = x
                }));
                dvm.Diapositiva.Curso = new Curso {
                    EntityID = cursoID
                };

                #region Tipo de plantilla

                double duracion      = 0;
                double duracionTotal = 0;
                switch (ddlPlantilla)
                {
                case ParameterProvider.TipoPlantilla.Botones:
                    #region Botones
                    if (!string.IsNullOrWhiteSpace(dvm.TituloBoton1))
                    {
                        Boton boton1 = new Boton {
                            Orden = 1, Color = dvm.ColorBoton1, Contenido = dvm.ContenidoBoton1, Nombre = dvm.TituloBoton1, Activo = true
                        };
                        boton1.Audio   = SubirArchivoAudio(dvm, "AudioBoton1", 1, ref duracion);
                        duracionTotal += duracion;
                        dvm.Diapositiva.Botones.Add(boton1);
                    }
                    if (!string.IsNullOrWhiteSpace(dvm.TituloBoton2))
                    {
                        Boton boton2 = new Boton {
                            Orden = 2, Color = dvm.ColorBoton2, Contenido = dvm.ContenidoBoton2, Nombre = dvm.TituloBoton2, Activo = true
                        };
                        boton2.Audio   = SubirArchivoAudio(dvm, "AudioBoton2", 2, ref duracion);
                        duracionTotal += duracion;
                        dvm.Diapositiva.Botones.Add(boton2);
                    }
                    if (!string.IsNullOrWhiteSpace(dvm.TituloBoton3))
                    {
                        Boton boton3 = new Boton {
                            Orden = 3, Color = dvm.ColorBoton3, Contenido = dvm.ContenidoBoton3, Nombre = dvm.TituloBoton3, Activo = true
                        };
                        boton3.Audio   = SubirArchivoAudio(dvm, "AudioBoton3", 3, ref duracion);
                        duracionTotal += duracion;
                        dvm.Diapositiva.Botones.Add(boton3);
                    }
                    if (!string.IsNullOrWhiteSpace(dvm.TituloBoton4))
                    {
                        Boton boton4 = new Boton {
                            Orden = 4, Color = dvm.ColorBoton4, Contenido = dvm.ContenidoBoton4, Nombre = dvm.TituloBoton4, Activo = true
                        };
                        boton4.Audio   = SubirArchivoAudio(dvm, "AudioBoton4", 4, ref duracion);
                        duracionTotal += duracion;
                        dvm.Diapositiva.Botones.Add(boton4);
                    }
                    if (!string.IsNullOrWhiteSpace(dvm.TituloBoton5))
                    {
                        Boton boton5 = new Boton {
                            Orden = 5, Color = dvm.ColorBoton5, Contenido = dvm.ContenidoBoton5, Nombre = dvm.TituloBoton5, Activo = true
                        };
                        boton5.Audio   = SubirArchivoAudio(dvm, "AudioBoton5", 5, ref duracion);
                        duracionTotal += duracion;
                        dvm.Diapositiva.Botones.Add(boton5);
                    }
                    break;

                    #endregion
                case ParameterProvider.TipoPlantilla.TextosCentrados:
                    #region Textos centrados y horizontales
                    if (!string.IsNullOrWhiteSpace(dvm.TextoAlineado1))
                    {
                        Texto texto1 = new Texto {
                            Orden = 1, Contenido = dvm.TextoAlineado1, Activo = true
                        };
                        texto1.TiempoDeArranque = duracionTotal;
                        texto1.Audio            = SubirArchivoAudio(dvm, "AudioTextoAlineado1", 1, ref duracion);
                        duracionTotal          += duracion;
                        dvm.Diapositiva.Textos.Add(texto1);
                    }
                    if (!string.IsNullOrWhiteSpace(dvm.TextoAlineado2))
                    {
                        Texto texto2 = new Texto {
                            Orden = 2, Contenido = dvm.TextoAlineado2, Activo = true
                        };
                        texto2.TiempoDeArranque = duracionTotal;
                        texto2.Audio            = SubirArchivoAudio(dvm, "AudioTextoAlineado2", 2, ref duracion);
                        duracionTotal          += duracion;
                        dvm.Diapositiva.Textos.Add(texto2);
                    }
                    if (!string.IsNullOrWhiteSpace(dvm.TextoAlineado3))
                    {
                        Texto texto3 = new Texto {
                            Orden = 3, Contenido = dvm.TextoAlineado3, Activo = true
                        };
                        texto3.TiempoDeArranque = duracionTotal;
                        texto3.Audio            = SubirArchivoAudio(dvm, "AudioTextoAlineado3", 3, ref duracion);
                        duracionTotal          += duracion;
                        dvm.Diapositiva.Textos.Add(texto3);
                    }
                    if (!string.IsNullOrWhiteSpace(dvm.TextoAlineado4))
                    {
                        Texto texto4 = new Texto {
                            Orden = 4, Contenido = dvm.TextoAlineado4, Activo = true
                        };
                        texto4.TiempoDeArranque = duracionTotal;
                        texto4.Audio            = SubirArchivoAudio(dvm, "AudioTextoAlineado4", 4, ref duracion);
                        duracionTotal          += duracion;
                        dvm.Diapositiva.Textos.Add(texto4);
                    }
                    if (!string.IsNullOrWhiteSpace(dvm.TextoAlineado5))
                    {
                        Texto texto5 = new Texto {
                            Orden = 5, Contenido = dvm.TextoAlineado5, Activo = true
                        };
                        texto5.TiempoDeArranque = duracionTotal;
                        texto5.Audio            = SubirArchivoAudio(dvm, "AudioTextoAlineado5", 5, ref duracion);
                        duracionTotal          += duracion;
                        dvm.Diapositiva.Textos.Add(texto5);
                    }
                    break;

                    #endregion
                case ParameterProvider.TipoPlantilla.TextosDiferentesPosiciones:
                    #region Textos zonas

                    if (!string.IsNullOrWhiteSpace(dvm.TextoDistribuido1))
                    {
                        Texto texto1 = new Texto {
                            Orden = 1, Contenido = dvm.TextoDistribuido1, Activo = true
                        };
                        texto1.TiempoDeArranque = duracionTotal;
                        texto1.Audio            = SubirArchivoAudio(dvm, "AudioTextoDistribuido1", 1, ref duracion);
                        duracionTotal          += duracion;
                        dvm.Diapositiva.Textos.Add(texto1);
                    }
                    if (!string.IsNullOrWhiteSpace(dvm.TextoDistribuido2))
                    {
                        Texto texto2 = new Texto {
                            Orden = 2, Contenido = dvm.TextoDistribuido2, Activo = true
                        };
                        texto2.TiempoDeArranque = duracionTotal;
                        texto2.Audio            = SubirArchivoAudio(dvm, "AudioTextoDistribuido2", 2, ref duracion);
                        duracionTotal          += duracion;
                        dvm.Diapositiva.Textos.Add(texto2);
                    }
                    if (!string.IsNullOrWhiteSpace(dvm.TextoDistribuido3))
                    {
                        Texto texto3 = new Texto {
                            Orden = 3, Contenido = dvm.TextoDistribuido3, Activo = true
                        };
                        texto3.TiempoDeArranque = duracionTotal;
                        texto3.Audio            = SubirArchivoAudio(dvm, "AudioTextoDistribuido3", 3, ref duracion);
                        duracionTotal          += duracion;
                        dvm.Diapositiva.Textos.Add(texto3);
                    }
                    if (!string.IsNullOrWhiteSpace(dvm.TextoDistribuido4))
                    {
                        Texto texto4 = new Texto {
                            Orden = 4, Contenido = dvm.TextoDistribuido4, Activo = true
                        };
                        texto4.TiempoDeArranque = duracionTotal;
                        texto4.Audio            = SubirArchivoAudio(dvm, "AudioTextoDistribuido4", 4, ref duracion);
                        duracionTotal          += duracion;
                        dvm.Diapositiva.Textos.Add(texto4);
                    }
                    if (!string.IsNullOrWhiteSpace(dvm.TextoDistribuido5))
                    {
                        Texto texto5 = new Texto {
                            Orden = 5, Contenido = dvm.TextoDistribuido5, Activo = true
                        };
                        texto5.TiempoDeArranque = duracionTotal;
                        texto5.Audio            = SubirArchivoAudio(dvm, "AudioTextoDistribuido5", 5, ref duracion);
                        duracionTotal          += duracion;
                        dvm.Diapositiva.Textos.Add(texto5);
                    }

                    #endregion
                    break;

                case ParameterProvider.TipoPlantilla.TextosApiladosHorizontal:
                    #region Textos horizontales
                    if (!string.IsNullOrWhiteSpace(dvm.TextoAlineado1))
                    {
                        Texto texto1 = new Texto {
                            Orden = 1, Contenido = dvm.TextoAlineado1, Activo = true
                        };
                        texto1.TiempoDeArranque = duracionTotal;
                        texto1.Audio            = SubirArchivoAudio(dvm, "AudioTextoAlineado1", 1, ref duracion);
                        duracionTotal          += duracion;
                        dvm.Diapositiva.Textos.Add(texto1);
                    }
                    if (!string.IsNullOrWhiteSpace(dvm.TextoAlineado2))
                    {
                        Texto texto2 = new Texto {
                            Orden = 2, Contenido = dvm.TextoAlineado2, Activo = true
                        };
                        texto2.TiempoDeArranque = duracionTotal;
                        texto2.Audio            = SubirArchivoAudio(dvm, "AudioTextoAlineado2", 2, ref duracion);
                        duracionTotal          += duracion;
                        dvm.Diapositiva.Textos.Add(texto2);
                    }
                    if (!string.IsNullOrWhiteSpace(dvm.TextoAlineado3))
                    {
                        Texto texto3 = new Texto {
                            Orden = 3, Contenido = dvm.TextoAlineado3, Activo = true
                        };
                        texto3.TiempoDeArranque = duracionTotal;
                        texto3.Audio            = SubirArchivoAudio(dvm, "AudioTextoAlineado3", 3, ref duracion);
                        duracionTotal          += duracion;
                        dvm.Diapositiva.Textos.Add(texto3);
                    }
                    if (!string.IsNullOrWhiteSpace(dvm.TextoAlineado4))
                    {
                        Texto texto4 = new Texto {
                            Orden = 4, Contenido = dvm.TextoAlineado4, Activo = true
                        };
                        texto4.TiempoDeArranque = duracionTotal;
                        texto4.Audio            = SubirArchivoAudio(dvm, "AudioTextoAlineado4", 4, ref duracion);
                        duracionTotal          += duracion;
                        dvm.Diapositiva.Textos.Add(texto4);
                    }
                    if (!string.IsNullOrWhiteSpace(dvm.TextoAlineado5))
                    {
                        Texto texto5 = new Texto {
                            Orden = 5, Contenido = dvm.TextoAlineado5, Activo = true
                        };
                        texto5.TiempoDeArranque = duracionTotal;
                        texto5.Audio            = SubirArchivoAudio(dvm, "AudioTextoAlineado5", 5, ref duracion);
                        duracionTotal          += duracion;
                        dvm.Diapositiva.Textos.Add(texto5);
                    }
                    break;

                    #endregion
                case ParameterProvider.TipoPlantilla.Video:
                    #region Video
                    var videoFile = Request.Files["VideoDiapositiva"];
                    // -- Si tiene video
                    if (videoFile != null && videoFile.ContentLength > 0 && !string.IsNullOrEmpty(videoFile.FileName))
                    {
                        FileInfo fileInfo = new FileInfo(videoFile.FileName);
                        if (fileInfo.Extension.ToLower().Equals(".mp4") ||
                            fileInfo.Extension.ToLower().Equals(".avi") ||
                            fileInfo.Extension.ToLower().Equals(".mpeg") ||
                            fileInfo.Extension.ToLower().Equals(".mpg") ||
                            fileInfo.Extension.ToLower().Equals(".wmv"))
                        {
                            // -- Puntero
                            if (ModelState.IsValid)
                            {
                                // -- Si es nuevo lo agrego para tener el id del video
                                if (dvm.Diapositiva.EntityID == 0)
                                {
                                    logic.Add(dvm.Diapositiva);
                                }

                                string appPath = HttpContext.Server.MapPath(VideosPath);

                                Stream fileStream = videoFile.InputStream;
                                string extension  = fileInfo.Extension;

                                var    length = Convert.ToInt32(fileStream.Length);
                                byte[] data   = null;

                                using (var reader = new BinaryReader(fileStream))
                                {
                                    data = reader.ReadBytes(length);
                                }

                                string[] extensions = { ".mp4", ".avi", ".mpeg", ".mpg", ".wmv" };
                                string   deletePath;

                                // -- Si existe la imagen la borro
                                for (int i = 0; i <= 4; i++)
                                {
                                    deletePath = appPath + string.Format(ImagenDiapositivaPath, dvm.Diapositiva.Curso.EntityID, dvm.Diapositiva.EntityID, extensions[i]);
                                    if (System.IO.File.Exists(deletePath))
                                    {
                                        System.IO.File.Delete(deletePath);
                                    }
                                }

                                // -- Creo video
                                appPath += string.Format(ImagenDiapositivaPath, dvm.Diapositiva.Curso.EntityID, dvm.Diapositiva.EntityID, extension);
                                var file = new FileStream(appPath, FileMode.Create, FileAccess.Write);
                                file.Write(data, 0, length);
                                file.Close();

                                // -- Asigno video a diapositiva
                                dvm.Diapositiva.Video = string.Format(ImagenDiapositivaPath, dvm.Diapositiva.Curso.EntityID, dvm.Diapositiva.EntityID, extension);

                                //logic.Update(dvm.Diapositiva); -- Se guarda cuando sale del switch

                                TempData["SaveSuccess"] = "Se guardó diapositiva correctamente";
                            }
                        }
                        else
                        {
                            ModelState.AddModelError("VideoDiapositiva", "Debe cargar un video del tipo .mp4, .avi, .mpeg, .mpg o .wmv");
                        }
                    }
                    else if (dvm.Diapositiva.Video == null)
                    {
                        string[] extensions = { ".mp4", ".avi", ".mpeg", ".mpg", ".wmv" };
                        // -- Si existe el video lo borro
                        string appPath = HttpContext.Server.MapPath(VideosPath);
                        string deletePath;
                        for (int i = 0; i <= 3; i++)
                        {
                            deletePath = appPath + string.Format(ImagenDiapositivaPath, dvm.Diapositiva.Curso.EntityID, dvm.Diapositiva.EntityID, extensions[i]);
                            if (System.IO.File.Exists(deletePath))
                            {
                                System.IO.File.Delete(deletePath);
                            }
                        }
                    }
                    break;
                    #endregion
                }

                dvm.Diapositiva.TiempoTotal = duracionTotal;

                // -- Agrego o edito diapositiva
                if (dvm.Diapositiva.EntityID == 0)
                {
                    logic.Add(dvm.Diapositiva);
                    RenombrarAudios(dvm.Diapositiva.EntityID, ".mp3");
                }
                else
                {
                    logic.Update(dvm.Diapositiva);
                }

                #endregion

                #region Cargo Imagen de Diapositiva

                var imageFile = Request.Files["ImagenDiapositiva"];
                // -- Si tiene imagen
                if (imageFile != null && imageFile.ContentLength > 0 && !string.IsNullOrEmpty(imageFile.FileName))
                {
                    FileInfo fileInfo = new FileInfo(imageFile.FileName);
                    if (fileInfo.Extension.ToLower().Equals(".jpg") || fileInfo.Extension.ToLower().Equals(".jpeg") || fileInfo.Extension.ToLower().Equals(".gif") || fileInfo.Extension.ToLower().Equals(".png"))
                    {
                        // -- Puntero
                        if (ModelState.IsValid)
                        {
                            string appPath = HttpContext.Server.MapPath(ImagenesPath);

                            Stream fileStream = imageFile.InputStream;
                            string extension  = fileInfo.Extension;

                            var    length = Convert.ToInt32(fileStream.Length);
                            byte[] data   = null;

                            using (var reader = new BinaryReader(fileStream))
                            {
                                data = reader.ReadBytes(length);
                            }

                            string[] extensions = { ".jpg", ".jpeg", ".png", ".gif" };
                            string   deletePath;
                            // -- Si existe la imagen la borro
                            for (int i = 0; i <= 3; i++)
                            {
                                deletePath = appPath + string.Format(ImagenDiapositivaPath, dvm.Diapositiva.Curso.EntityID, dvm.Diapositiva.EntityID, extensions[i]);
                                if (System.IO.File.Exists(deletePath))
                                {
                                    System.IO.File.Delete(deletePath);
                                }
                            }

                            // -- Creo imagen
                            appPath += string.Format(ImagenDiapositivaPath, dvm.Diapositiva.Curso.EntityID, dvm.Diapositiva.EntityID, extension);
                            var file = new FileStream(appPath, FileMode.Create, FileAccess.Write);
                            file.Write(data, 0, length);
                            file.Close();

                            // -- Asigno imagen a diapositiva
                            dvm.Diapositiva.Imagen = string.Format(ImagenDiapositivaPath, dvm.Diapositiva.Curso.EntityID, dvm.Diapositiva.EntityID, extension);

                            logic.Update(dvm.Diapositiva);

                            TempData["SaveSuccess"] = "Se guardó diapositiva correctamente";
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("ImagenDiapositiva", "Debe cargar una imagen del tipo .jpg .jpeg .gif o .png");
                    }
                }
                else if (dvm.Diapositiva.Imagen == null)
                {
                    string[] extensions = { ".jpg", ".jpeg", ".png", "gif" };
                    // -- Si existe la imagen la borro
                    string appPath = HttpContext.Server.MapPath(ImagenesPath);
                    string deletePath;
                    for (int i = 0; i <= 3; i++)
                    {
                        deletePath = appPath + string.Format(ImagenDiapositivaPath, dvm.Diapositiva.Curso.EntityID, dvm.Diapositiva.EntityID, extensions[i]);
                        if (System.IO.File.Exists(deletePath))
                        {
                            System.IO.File.Delete(deletePath);
                        }
                    }
                }

                #endregion

                return(RedirectToAction("Index", "Diapositiva", new { cursoID = cursoID }));
            }
            // -- Recupero las diapositivas del curso
            var diapositivasCurso = logic.GetByCurso(cursoID);
            // -- Armo la lista
            ViewBag.DiapositivasID = new MultiSelectList(diapositivasCurso, "EntityID", "Titulo", DiapositivasID);
            // -- Se reestablece el curso
            dvm.Diapositiva.Curso = new Curso {
                EntityID = cursoID
            };

            // -- Seteo la plantilla seleccionada
            ViewBag.selectedddlPlantilla = ddlPlantilla;

            return(View(dvm));
        }
Exemplo n.º 28
0
 public void RemoveButton(Boton boton)
 {
     botones_.Remove(boton);
 }
Exemplo n.º 29
0
 private ModelElement GetParentForBoton(Boton elem)
 {
     return(elem.VentanaBoton);
 }
Exemplo n.º 30
0
 // Start is called before the first frame update
 void Start()
 {
     buttonAnim = GetComponent <Animator>();
     boton      = GameObject.Find("Database").GetComponent <Boton>();
 }