private void setpnlContent(UserControlAnimalRecord test) { if (pnlAnimalInfo.InvokeRequired) { pnlAnimalInfo.Invoke(new MethodInvoker(() => { pnlAnimalInfo.Controls.Clear(); pnlAnimalInfo.Controls.Add(test); })); } else { pnlAnimalInfo.Controls.Clear(); pnlAnimalInfo.Controls.Add(test); } }
private void setAnimalInfo() { UserControlAnimalRecord animalRecord = new UserControlAnimalRecord(_animal); animalRecord.setAdoptButtonVis(false); setpnlContent(animalRecord); try { if (_animal.isAdopted) { Image playbutton; try { playbutton = (Image)AdoptAPet.Properties.Resources.adopted; } catch (Exception ex) { return; } Image Frame; try { Frame = ImageGoBetween.imageFromAid(_animal.aid); } catch (Exception ex) { return; } using (Frame) { int height = pbPicture.Height; int width = pbPicture.Width; using (var bitmap = new Bitmap(width, height)) { using (var canvas = Graphics.FromImage(bitmap)) { canvas.InterpolationMode = InterpolationMode.HighQualityBicubic; canvas.DrawImage(Frame, new Rectangle(0, 0, width, height), new Rectangle(0, 0, Frame.Width, Frame.Height), GraphicsUnit.Pixel); canvas.DrawImage(playbutton, (bitmap.Width / 2) - (playbutton.Width / 2 + 5), (bitmap.Height / 2) - (playbutton.Height / 2 + 5)); canvas.Save(); } try { pbPicture.Image = new Bitmap(bitmap); } catch (Exception ex) { } } } } else { setpbPictureImage(ImageGoBetween.imageFromAid(_animal.aid)); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }