public void Dessine(Graphics g, RectangleF rect) { float imageRatio = (float)(16 / 9); if (Codec == "dvsd") { imageRatio = (float)(4 / 3); } RectangleF r = new RectangleF(rect.Left, rect.Top, Math.Min(rect.Width, rect.Height * imageRatio), rect.Height); using (MemoryStream mes = new MemoryStream(Image)) { Image image = System.Drawing.Image.FromStream(mes); g.DrawImage(image, r); image.Dispose(); } float x = rect.Left; float y = rect.Top; float w = rect.Width; float h = rect.Height; if (Selected) { g.DrawRectangle(new Pen(Brushes.Red, 1), x, y, w, h); } else { g.DrawRectangle(Pens.Black, x, y, w, h); } if (Current) { g.DrawRectangle(new Pen(Brushes.Red, 5), x, y, w - 2, h); } g.DrawString(Videos.DuréeClip((int)EndFrame).ToString(), new Font("Arial", 5), Brushes.Orange, x + w, y + h); }
private void TimeLine_Paint(object sender, PaintEventArgs e) { if (shots == null) { return; } PointF débutVignette = new PointF(débutDessin, topTrack); #region Encadrement e.Graphics.DrawRectangle(Pens.Black, new Rectangle(0, topTrack, Width, trackHeight)); #endregion int totalFrame = 0; #region Affichage shots foreach (Shots s in shots) { float largeurClipCourant = (int)s.FrameCount / pixelsParSecondes; RectangleF rect = new RectangleF(débutVignette, new System.Drawing.SizeF(largeurClipCourant, trackHeight)); if (rect.Contains(new PointF(débutVignette.X + 1, topTrack + 5))) { s.Dessine(e.Graphics, rect); if (s.Current) { toolStripStatusLabel1.Text = s.Fichier + " " + s.DateShot.ToString() + " " + Videos.DuréeClip((int)s.FrameCount) + " " + s.FrameCount.ToString(); } débutVignette.X += largeurClipCourant; if (débutVignette.X > Width /*LongueurTimeline / pixelsParSecondes*/) { break; } } totalFrame += (int)s.FrameCount; } #endregion e.Graphics.DrawLine(Pens.Black, new PointF(CurrentPosition * pixelsParSecondes, topTrack), new PointF(CurrentPosition * pixelsParSecondes, topTrack + trackHeight + 35)); string temps = (CurrentTime / 60).ToString("d2") + ":" + (CurrentTime % 60).ToString("d2"); e.Graphics.DrawString(temps, new Font("Arial", 8), Brushes.Black, new PointF(CurrentPosition * pixelsParSecondes, topTrack + trackHeight + 35)); #region Graduation ligneGraduation = topTrack + trackHeight + 35; e.Graphics.DrawLine(Pens.Black, 0, ligneGraduation, Width, ligneGraduation); int x = 0; int heures = 0; int minutes = 0; int dizaines = 0; TimeSpan ts = Videos.DuréeClip(LongueurTimeline); //while (x < LongueurTimeline) //{ // int j = (x + (int)débutDessin); // if (x % (int)(60 * pixelsParSecondes) == 0) //minutes // { // e.Graphics.DrawLine(Pens.Black, j, ligneGraduation, j, ligneGraduation - mn); // e.Graphics.DrawString(minutes.ToString() + " '", new Font("Arial", 8), Brushes.Blue, new Point(j - 4, ligneGraduation - 20 - 10)); // minutes++; // dizaines = 0; // } // else if (x % (int)(10 * pixelsParSecondes) == 0) // dizaines de secondes // { // dizaines += 10; // e.Graphics.DrawLine(Pens.Black, j, ligneGraduation, j, ligneGraduation - sec); // e.Graphics.DrawString(dizaines.ToString() + " \"", new Font("Arial", 6), Brushes.Red, new Point(j - 4, ligneGraduation - sec - 10)); // } // else // e.Graphics.DrawLine(Pens.Black, j, ligneGraduation, j, ligneGraduation - sec); // x += (int)(10 * pixelsParSecondes); // if ((x + (int)débutDessin) > Width) // break; // if (heures > ts.Hours) // return; // if ((minutes - 1) * 60 + dizaines > ts.TotalSeconds) // return; //} while (x < LongueurTimeline) { int j = (int)((x * 25) / pixelsParSecondes) + (int)débutDessin; if (x % 60 == 0) //minutes { e.Graphics.DrawLine(Pens.Black, j, ligneGraduation, j, ligneGraduation - mn); e.Graphics.DrawString(minutes.ToString() + " '", new Font("Arial", 8), Brushes.Blue, new Point(j - 4, ligneGraduation - 20 - 10)); minutes++; dizaines = 0; } else if (x % 10 == 0) // dizaines de secondes { dizaines += 10; e.Graphics.DrawLine(Pens.Black, j, ligneGraduation, j, ligneGraduation - sec); e.Graphics.DrawString(dizaines.ToString() + " \"", new Font("Arial", 6), Brushes.Red, new Point(j - 4, ligneGraduation - sec - 10)); } else { e.Graphics.DrawLine(Pens.Black, j, ligneGraduation, j, ligneGraduation - sec); } x += 10; if ((x + (int)débutDessin) > Width) { break; } if (heures > ts.Hours) { return; } if ((minutes - 1) * 60 + dizaines > ts.TotalSeconds) { return; } } #endregion }