private void SelectImg_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { Image img = sender as Image; var groupBox = VisualTreeHelperExtension.GetParentObject <DevExpress.Xpf.LayoutControl.GroupBox>(img); ActivityPlaceLocationImageView gpv = groupBox.DataContext as ActivityPlaceLocationImageView; if (gpv.GUID == "add") { LocationImageDialog imgDialog = new LocationImageDialog(); if (imgDialog.ShowDialog(this) == true) { imgDialog.EditView.ACTIVITY_PLACE_LOCATION_GUID = locationGuid; viewList.Insert(viewList.Count - 1, imgDialog.EditView); ActivityPlaceLocationImage newitem = new ActivityPlaceLocationImage(); newitem.GUID = imgDialog.EditView.GUID; newitem.ImageName = imgDialog.EditView.ImageName; newitem.TYPE = imgDialog.EditView.TYPE; newitem.Image = imgDialog.EditView.Image; newitem.ACTIVITY_PLACE_LOCATION_GUID = imgDialog.EditView.ACTIVITY_PLACE_LOCATION_GUID; ActivityPlaceLocationImageList.Add(newitem); RefreshList(); } } }
private void btn_ModifyClick(object sender, MouseButtonEventArgs e) { e.Handled = true; Image btn = sender as Image; ActivityPlaceLocationImageView itemview = btn.DataContext as ActivityPlaceLocationImageView; if (itemview != null) { LocationImageDialog imgDialog = new LocationImageDialog(itemview); if (imgDialog.ShowDialog() == true) { for (int i = 0; i < viewList.Count; i++) { if (viewList[i].GUID == imgDialog.EditView.GUID) { viewList[i].ImageName = imgDialog.EditView.ImageName; viewList[i].Image = imgDialog.EditView.Image; viewList[i].TYPE = imgDialog.EditView.TYPE; break; } } RefreshList(); for (int i = 0; i < ActivityPlaceLocationImageList.Count; i++) { if (ActivityPlaceLocationImageList[i].GUID == imgDialog.EditView.GUID) { ActivityPlaceLocationImageList[i].ImageName = imgDialog.EditView.ImageName; ActivityPlaceLocationImageList[i].Image = imgDialog.EditView.Image; ActivityPlaceLocationImageList[i].TYPE = imgDialog.EditView.TYPE; break; } } } } }