private async void clickSwitch(Object obj) { var metro = Application.Current.Windows[0] as MetroWindow; switch (obj.ToString()) { case "menu_editar": if (_selectedItem != null) { IngredientesVisible = true; NuevaRecetaVisible = true; BotonesVisible = false; bandera_editar = true; FocusText = true; Cambio = _selectedItem.Username; GuardarMenuEnabled = true; AgregarMenuEnabled = false; EliminarMenuEnabled = false; EditarMenuEnabled = false; CancelarMenuEnabled = true; AyudaMenuEnabled = true; SalirMenuEnabled = true; ExportarMenuEnabled = true; ListItems2.Clear(); if (_selectedItem.Password == "12345") { ListItems2.Add(new Usuario() { Username = "******", Password = "******" }); ListItems2.Add(new Usuario() { Username = "******", Password = "******" }); } else { ListItems2.Add(new Usuario() { Username = "******", Password = "******" }); ListItems2.Add(new Usuario() { Username = "******", Password = "******" }); } } else { bandera_editar = false; await metro.ShowMessageAsync("Validación", "Debe seleccionar una opcion."); } break; case "menu_agregar": IngredientesVisible = false; NuevaRecetaVisible = true; BotonesVisible = true; bandera_editar = false; FocusText = true; Cambio = string.Empty; GuardarMenuEnabled = true; AgregarMenuEnabled = false; EliminarMenuEnabled = false; EditarMenuEnabled = false; CancelarMenuEnabled = true; AyudaMenuEnabled = true; SalirMenuEnabled = true; ExportarMenuEnabled = true; break; case "boton_aceptar_receta": if (_selectedReceta != null) { IngredientesVisible = false; NuevaRecetaVisible = false; bandera_editar = false; FocusText = false; GuardarMenuEnabled = false; AgregarMenuEnabled = true; EliminarMenuEnabled = false; EditarMenuEnabled = false; CancelarMenuEnabled = false; AyudaMenuEnabled = true; SalirMenuEnabled = true; ExportarMenuEnabled = true; } else { await metro.ShowMessageAsync("Validación", "Debe seleccionar una opcion."); } break; case "boton_cancelar_receta": IngredientesVisible = false; NuevaRecetaVisible = false; bandera_editar = false; FocusText = false; GuardarMenuEnabled = false; AgregarMenuEnabled = true; EliminarMenuEnabled = false; EditarMenuEnabled = false; CancelarMenuEnabled = false; AyudaMenuEnabled = true; SalirMenuEnabled = true; ExportarMenuEnabled = true; break; case "menu_guardar": if (bandera_editar == false) { _selectedItem = null; _selectedItem = new Usuario() { Username = Cambio, Password = "******" }; ListItems.Add(_selectedItem); IngredientesVisible = true; NuevaRecetaVisible = false; AgregarMenuEnabled = false; ListItems2.Clear(); if (_selectedItem.Password == "12345") { ListItems2.Add(new Usuario() { Username = "******", Password = "******" }); ListItems2.Add(new Usuario() { Username = "******", Password = "******" }); } else { ListItems2.Add(new Usuario() { Username = "******", Password = "******" }); ListItems2.Add(new Usuario() { Username = "******", Password = "******" }); } } else { SelectedItem.Username = Cambio; IngredientesVisible = false; NuevaRecetaVisible = false; } bandera_editar = false; FocusText = false; SelectedItem = null; SeleccionIndice = -1; Cambio = string.Empty; GuardarMenuEnabled = false; AgregarMenuEnabled = true; EliminarMenuEnabled = false; EditarMenuEnabled = false; CancelarMenuEnabled = false; AyudaMenuEnabled = true; SalirMenuEnabled = true; ExportarMenuEnabled = true; break; case "menu_cancelar": IngredientesVisible = false; NuevaRecetaVisible = false; bandera_editar = false; FocusText = false; SelectedItem = null; SeleccionIndice = -1; Cambio = string.Empty; GuardarMenuEnabled = false; AgregarMenuEnabled = true; EliminarMenuEnabled = false; EditarMenuEnabled = false; CancelarMenuEnabled = false; AyudaMenuEnabled = true; SalirMenuEnabled = true; ExportarMenuEnabled = true; break; case "menu_eliminar": if (_selectedItem != null) { var mySettings = new MetroDialogSettings() { AffirmativeButtonText = "Aceptar", NegativeButtonText = "Cancelar", AnimateShow = true, AnimateHide = false }; // SALTO DE LINEA // string.Format("\n") var result = await metro.ShowMessageAsync("Borrar", "¿Está seguro que desea borrar esto? [ " + SelectedItem.Username + " ]", MessageDialogStyle.AffirmativeAndNegative, mySettings); if (result == MessageDialogResult.Affirmative) { var i = ListItems.IndexOf(_selectedItem); if (i >= 0) { ListItems.RemoveAt(i); var dialog = (BaseMetroDialog)metro.Resources["ConfirmacionDialog"]; await metro.ShowMetroDialogAsync(dialog); await TaskEx.Delay(1500); await metro.HideMetroDialogAsync(dialog); //MENSAJE EXTERNO //dialog = dialog.ShowDialogExternally(); //await TaskEx.Delay(1500); //await dialog.RequestCloseAsync(); } } } else { await metro.ShowMessageAsync("Validación", "Debe seleccionar una opcion"); } SelectedItem = null; SeleccionIndice = -1; Cambio = string.Empty; GuardarMenuEnabled = false; AgregarMenuEnabled = true; EliminarMenuEnabled = false; EditarMenuEnabled = false; CancelarMenuEnabled = false; AyudaMenuEnabled = true; SalirMenuEnabled = true; ExportarMenuEnabled = true; break; case "menu_exportar": SelectedItem = null; SeleccionIndice = -1; Cambio = string.Empty; break; case "menu_ayuda": SelectedItem = null; SeleccionIndice = -1; Cambio = string.Empty; break; case "menu_salir": SelectedItem = null; SeleccionIndice = -1; Cambio = string.Empty; break; } }
private async void clickSwitch(Object obj) { var metro = Application.Current.Windows[0] as MetroWindow; switch (obj.ToString()) { case "menu_editar": if (_selectedItem != null) { IngredientesVisible = true; NuevaRecetaVisible = true; BotonesVisible = false; bandera_editar = true; FocusText = true; Cambio = _selectedItem.Username; GuardarMenuEnabled = true; AgregarMenuEnabled = false; EliminarMenuEnabled = false; EditarMenuEnabled = false; CancelarMenuEnabled = true; AyudaMenuEnabled = true; SalirMenuEnabled = true; ExportarMenuEnabled = true; CheckVisible = true; int i = 0; if (_selectedItem.Password == "12345") { foreach (var item in ListItems2) { if (i % 2 == 0) { item.IsSelected = true; } else { item.IsSelected = false; } i = i + 1; } } else { foreach (var item in ListItems2) { if (i % 2 == 0) { item.IsSelected = false; } else { item.IsSelected = true; } i = i + 1; } } } else { bandera_editar = false; await metro.ShowMessageAsync("Validación", "Debe seleccionar una opcion."); } break; case "menu_agregar": IngredientesVisible = false; NuevaRecetaVisible = true; BotonesVisible = true; bandera_editar = false; FocusText = true; Cambio = string.Empty; GuardarMenuEnabled = true; AgregarMenuEnabled = false; EliminarMenuEnabled = false; EditarMenuEnabled = false; CancelarMenuEnabled = true; AyudaMenuEnabled = true; SalirMenuEnabled = true; ExportarMenuEnabled = true; //CheckVisible = false; break; case "boton_agregar_ingrediente": if (_ingredienteSeleccionado != null) { IngredientesVisible = false; NuevaRecetaVisible = false; bandera_editar = false; FocusText = false; GuardarMenuEnabled = false; AgregarMenuEnabled = true; EliminarMenuEnabled = false; EditarMenuEnabled = false; CancelarMenuEnabled = false; AyudaMenuEnabled = true; SalirMenuEnabled = true; ExportarMenuEnabled = true; CheckVisible = false; _ingredienteSeleccionado.Cantidad = Cantidad; } else { await metro.ShowMessageAsync("Validación", "Debe seleccionar una opcion."); } break; case "boton_cancelar_ingrediente": IngredientesVisible = false; NuevaRecetaVisible = false; bandera_editar = false; FocusText = false; GuardarMenuEnabled = false; AgregarMenuEnabled = true; EliminarMenuEnabled = false; EditarMenuEnabled = false; CancelarMenuEnabled = false; AyudaMenuEnabled = true; SalirMenuEnabled = true; ExportarMenuEnabled = true; CheckVisible = false; break; case "menu_guardar": if (bandera_editar == false) { _selectedItem = null; _selectedItem = new Usuario() { Username = Cambio, Password = "******" }; ListItems.Add(_selectedItem); IngredientesVisible = true; NuevaRecetaVisible = false; AgregarMenuEnabled = false; ListItems2.Clear(); if (_selectedItem.Password == "12345") { ListItems2.Add(new DetalleTraspaso() { Cantidad = "3", IsSelected = true, UnidadMedida = "KILOS", Producto = "TOMATE" }); ListItems2.Add(new DetalleTraspaso() { Cantidad = "2", IsSelected = false, UnidadMedida = "KILOS", Producto = "CEBOLLA" }); ListItems2.Add(new DetalleTraspaso() { Cantidad = "5", IsSelected = true, UnidadMedida = "KILOS", Producto = "CHILE" }); } else { ListItems2.Add(new DetalleTraspaso() { Cantidad = "4", IsSelected = true, UnidadMedida = "KILOS", Producto = "CARNE MOLIDA" }); ListItems2.Add(new DetalleTraspaso() { Cantidad = "8", IsSelected = false, UnidadMedida = "KILOS", Producto = "TOMATE" }); ListItems2.Add(new DetalleTraspaso() { Cantidad = "6", IsSelected = false, UnidadMedida = "KILOS", Producto = "CEBOLLA" }); } } else { SelectedItem.Username = Cambio; IngredientesVisible = false; NuevaRecetaVisible = false; } bandera_editar = false; FocusText = false; SelectedItem = null; SeleccionIndice = -1; Cambio = string.Empty; GuardarMenuEnabled = false; AgregarMenuEnabled = true; EliminarMenuEnabled = false; EditarMenuEnabled = false; CancelarMenuEnabled = false; AyudaMenuEnabled = true; SalirMenuEnabled = true; ExportarMenuEnabled = true; //CheckVisible = false; break; case "menu_cancelar": IngredientesVisible = false; NuevaRecetaVisible = false; bandera_editar = false; FocusText = false; SelectedItem = null; SeleccionIndice = -1; Cambio = string.Empty; GuardarMenuEnabled = false; AgregarMenuEnabled = true; EliminarMenuEnabled = false; EditarMenuEnabled = false; CancelarMenuEnabled = false; AyudaMenuEnabled = true; SalirMenuEnabled = true; ExportarMenuEnabled = true; CheckVisible = false; break; case "menu_eliminar": if (_selectedItem != null) { var mySettings = new MetroDialogSettings() { AffirmativeButtonText = "Aceptar", NegativeButtonText = "Cancelar", AnimateShow = true, AnimateHide = false }; // SALTO DE LINEA // string.Format("\n") var result = await metro.ShowMessageAsync("Borrar", "¿Está seguro que desea borrar esto? [ " + SelectedItem.Username + " ]", MessageDialogStyle.AffirmativeAndNegative, mySettings); if (result == MessageDialogResult.Affirmative) { var i = ListItems.IndexOf(_selectedItem); if (i >= 0) { ListItems.RemoveAt(i); var dialog = (BaseMetroDialog)metro.Resources["ConfirmacionDialog"]; await metro.ShowMetroDialogAsync(dialog); await TaskEx.Delay(1500); await metro.HideMetroDialogAsync(dialog); //MENSAJE EXTERNO //dialog = dialog.ShowDialogExternally(); //await TaskEx.Delay(1500); //await dialog.RequestCloseAsync(); } } } else { await metro.ShowMessageAsync("Validación", "Debe seleccionar una opcion"); } SelectedItem = null; SeleccionIndice = -1; Cambio = string.Empty; GuardarMenuEnabled = false; AgregarMenuEnabled = true; EliminarMenuEnabled = false; EditarMenuEnabled = false; CancelarMenuEnabled = false; AyudaMenuEnabled = true; SalirMenuEnabled = true; ExportarMenuEnabled = true; CheckVisible = false; break; case "menu_exportar": SelectedItem = null; SeleccionIndice = -1; break; case "menu_ayuda": SelectedItem = null; SeleccionIndice = -1; break; case "menu_salir": SelectedItem = null; SeleccionIndice = -1; break; } }