private PhotoPanel MakePhotoPanel(int photoId) { //Photo photo = DBPhotosWebServices.GetPhoto(photoId); Photo photo = PhotoPool.Where(p => p.Id == photoId).First <Photo>(); if (photo != null) { // Boîte d'image PictureBox pbx = new PictureBox(); pbx.Size = new Size(80, 80); pbx.BackgroundImageLayout = ImageLayout.Zoom; pbx.BackgroundImage = photo.GetThumbnailImage(); pbx.Location = new Point(10, 10); pbx.Click += PBX_Click; // panneaux de photo sélectionnable PhotoPanel photoPanel = new PhotoPanel(); photoPanel.Size = new Size(100, 100); // Définir son nom en incluant le id de la photo ma // permettant ainsi de retrouver la photo concernée par un clic photoPanel.Name = "PN_" + photoId.ToString(); photoPanel.Click += Photo_Click; photoPanel.Selected = InSlideShow(photoId); photoPanel.Controls.Add(pbx); return(photoPanel); } return(null); }
// Gestionnaire est utile dans le cas ou le clic aurait lieu à l'extérieur de la boîte de photo // mais à l'intérieur de son panneau private void Photo_Click(object sender, EventArgs e) { PhotoPanel PPN = (PhotoPanel)sender; // Extraire le id de la photo concernée string stringId = PPN.Name.Substring(PPN.Name.IndexOf("_") + 1); int photoId = int.Parse(stringId); AddRemove_SlideShow(photoId); PPN.Selected = InSlideShow(photoId); PPN.Refresh(); }
/// <summary> /// Начинает отрисовку записи /// </summary> /// <param name="repUser">Пользователь, у которого сделали репост (null, если нет)</param> private void BeginLayoutDesign(User repUser, bool rep) { if (Copied_Post != null) { repost.Children.Add(new ctrPost(Copied_Post, repUser, true)); } if (!rep) { BitmapImage bilikes = new BitmapImage(); bilikes.BeginInit(); var streamlike = File.OpenRead(Environment.CurrentDirectory + @"\like.png"); bilikes.StreamSource = streamlike; bilikes.EndInit(); likesImage.Source = bilikes; BitmapImage bireps = new BitmapImage(); bireps.BeginInit(); var streamrep = File.OpenRead(Environment.CurrentDirectory + @"\rep.png"); bireps.StreamSource = streamrep; bireps.EndInit(); repImage.Source = bireps; } else { foot.Height = 0; user_ico.Width = 40; user_ico.Height = 40; user_ico_circle.RadiusX = 20; user_ico_circle.RadiusY = 20; user_ico_circle.Rect = new Rect(0, 0, 40, 40); } if (Videos != null) { videos.Margin = new Thickness(5, 0, 5, 5); //-------------adding-videos-------------\\ foreach (Video vid in Videos) { VideoPanel.Add(new ctrVideo(vid)); } } if (Photos != null) { photos.Margin = new Thickness(5, 0, 5, 5); //------------adding-photos--------------\\ foreach (Photo phot in Photos) { PhotoPanel.Add(new ctrPhoto(phot)); } } if (Poll != null) { polls.Margin = new Thickness(5, 0, 5, 5); //----------------add-poll---------------\\ PollPanel.Add(new ctrPoll(Poll)); } if (Audios != null) { foreach (Media.Audio aud in Audios) { AudioPanel.Add(new Audio(aud)); } } if (Links != null) { links.Margin = new Thickness(5, 0, 5, 5); //----------------add-link---------------\\ links.Children.Add(new ctrLink(Links[0])); } }
private void Awake() { Instance = this; }