/// <summary> /// Muestra la ventana detalle en modo edit /// </summary> /// <history> /// [emoguel] 15/04/2016 Created /// </history> private void Cell_DoubleClick(object sender, RoutedEventArgs e) { Region region = (Region)dgrRegions.SelectedItem; frmRegionDetail frmRegionDetail = new frmRegionDetail(); frmRegionDetail.Owner = this; frmRegionDetail.enumMode = (_blnEdit) ? EnumMode.Edit : EnumMode.ReadOnly; frmRegionDetail.oldRegion = region; if (frmRegionDetail.ShowDialog() == true) { int nIndex = 0; List <Region> lstRegions = (List <Region>)dgrRegions.ItemsSource; if (ValidateFilter(frmRegionDetail.region)) { ObjectHelper.CopyProperties(region, frmRegionDetail.region); //Actualizamos los datos lstRegions.Sort((x, y) => string.Compare(x.rgN, y.rgN)); //ordenamos la lista nIndex = lstRegions.IndexOf(region); //obtenemos la posicion del registro } else { lstRegions.Remove(region); //Quitamos el registro de la lista } dgrRegions.Items.Refresh(); //Actualizamos la lista GridHelper.SelectRow(dgrRegions, nIndex); //Seleccionamos el registro StatusBarReg.Content = lstRegions.Count + " Regions."; //Actualizamos el contador } }
/// <summary> /// Abre la ventana detalle en modo Add /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [emoguel] created 15/04/2016 /// </history> private void btnAdd_Click(object sender, RoutedEventArgs e) { frmRegionDetail frmRegionDetail = new frmRegionDetail(); frmRegionDetail.Owner = this; frmRegionDetail.enumMode = EnumMode.Add; if (frmRegionDetail.ShowDialog() == true) { Region region = frmRegionDetail.region; if (ValidateFilter(region)) { List <Region> lstRegions = (List <Region>)dgrRegions.ItemsSource; lstRegions.Add(region); //Agregamos el nuevo registro lstRegions.Sort((x, y) => string.Compare(x.rgN, y.rgN)); //Ordenamos la lista int nIndex = lstRegions.IndexOf(region); //Obtenemos la posiciĆ³n del nuevo registro dgrRegions.Items.Refresh(); //Actualizamos la vista GridHelper.SelectRow(dgrRegions, nIndex); //Seleccionamos el nuevo registro StatusBarReg.Content = lstRegions.Count + " Regions."; //Actualizamos el contador } } }