private void SetSelectedRow(ListIndex li) { selectedRow = li.getValue(); RefreshButton = true; BackgroundButton = true; //chargement des databases if (selectedRow != -1) { var thumb = Cuts.GetAt(selectedRow).Thumbnail; TeamOne = Cuts.GetAt(selectedRow).Thumbnail.TeamOne; TeamTwo = Cuts.GetAt(selectedRow).Thumbnail.TeamTwo; DbCharOne = Cuts.GetAt(selectedRow).Thumbnail.TeamOne.DataBase; DbCharTwo = Cuts.GetAt(selectedRow).Thumbnail.TeamTwo.DataBase; Debug.WriteLine(Cuts.GetAt(selectedRow).Thumbnail.TeamOne.DataBase[0].Name); Debug.WriteLine(Cuts.GetAt(selectedRow).Thumbnail.TeamOne.DataBase[0].IsPlayed); Background = new BitmapImage(thumb.Background); ResetPreview(); } }
private void ResetPreview() { // chargement de la miniature : on doit parcourir les 2 databases et afficher les perso checked Bitmap temp_image = new Bitmap(Cuts.GetAt(selectedRow).Thumbnail.Background.OriginalString); int width = temp_image.Width; int height = temp_image.Height; float sizeChar = width / 38.4F; Graphics g = Graphics.FromImage(temp_image); g.InterpolationMode = InterpolationMode.High; g.SmoothingMode = SmoothingMode.HighQuality; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; g.CompositingQuality = CompositingQuality.HighQuality; //create the outline of the text System.Drawing.FontFamily f = new System.Drawing.FontFamily("Arial"); SolidBrush drawBrush = new SolidBrush(System.Drawing.Color.White); System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Black, 5); PointF drawPoint = new PointF(width / 4 - (TeamOne.TeamName.Length * sizeChar) / 2, height * 3 / 4); GraphicsPath p = new GraphicsPath(); //write team name 1 p.AddString( TeamOne.TeamName, // text to draw f, // or any other font family (int)System.Drawing.FontStyle.Regular, g.DpiY * sizeChar / 72, // em size drawPoint, // location where to draw text new StringFormat()); // set options here (e.g. center alignment) g.DrawPath(pen, p); g.FillPath(drawBrush, p); //write team name 2 drawPoint.X = temp_image.Width - width / 4 - (TeamTwo.TeamName.Length * sizeChar) / 2; GraphicsPath p2 = new GraphicsPath(); //write team name 1 p2.AddString( TeamTwo.TeamName, // text to draw f, // or any other font family (int)System.Drawing.FontStyle.Regular, g.DpiY * sizeChar / 72, // em size drawPoint, // location where to draw text new StringFormat()); // set options here (e.g. center alignment) g.DrawPath(pen, p2); g.FillPath(drawBrush, p2); //multiplicateur de position List <int> posTab = new List <int>(); // on vérifie une fois le tableau pour savoir combien de cases sont cochées for (int i = 0; i < DbCharOne.Count; i++) { if (DbCharOne[i].IsPlayed) { posTab.Add(i); Debug.Write(Cuts.GetAt(selectedRow).Thumbnail.TeamOne.DataBase[i].Name + ": "); Debug.WriteLine(Cuts.GetAt(selectedRow).Thumbnail.TeamOne.DataBase[i].IsPlayed); } } // on parcours la liste des cases cochées for (int i = 0; i < posTab.Count; i++) { Character temp_char = DbCharOne[posTab[i]]; int nb_char = posTab.Count; //afficher la miniature a gauche Bitmap char_picture = new Bitmap(temp_char.PictureUri.OriginalString); //mise a echelle int newWidth = (int)((char_picture.Width / (nb_char + 1)) * ((float)width / 1920)); int newHeight = (int)((char_picture.Height / (nb_char + 1)) * ((float)width / 1920)); Bitmap Smaller_char = new Bitmap(char_picture, new System.Drawing.Size(newWidth, newHeight)); //Smaller_char.MakeTransparent(); Rectangle rect = new Rectangle(width * (i + 1) / (2 + 2 * nb_char) - Smaller_char.Width / 2, height / 2 - (Smaller_char.Height) * 2 / 3, Smaller_char.Width, Smaller_char.Height); //image.WritePixels(rect, Data.Scan0, Data.Stride,100000); g.DrawImage(Smaller_char, rect); } posTab.Clear(); // on vérifie une fois le tableau pour savoir combien de cases sont cochées for (int i = 0; i < DbCharTwo.Count; i++) { if (DbCharTwo[i].IsPlayed) { posTab.Add(i); } } // on parcours la liste des cases cochées for (int i = 0; i < posTab.Count; i++) { Character temp_char = DbCharOne[posTab[i]]; int nb_char = posTab.Count; //afficher la miniature a gauche Bitmap char_picture = new Bitmap(temp_char.PictureUri.OriginalString); int newWidth = (int)((char_picture.Width / (nb_char + 1)) * ((float)width / 1920)); int newHeight = (int)((char_picture.Height / (nb_char + 1)) * ((float)width / 1920)); Bitmap Smaller_char = new Bitmap(char_picture, new System.Drawing.Size(newWidth, newHeight)); //Smaller_char.MakeTransparent(); Smaller_char.RotateFlip(RotateFlipType.RotateNoneFlipX); Rectangle rect = new Rectangle(width - (width * (i + 1) / (2 + 2 * nb_char)) - Smaller_char.Width / 2, height / 2 - (Smaller_char.Height) * 2 / 3, Smaller_char.Width, Smaller_char.Height); //image.WritePixels(rect, Data.Scan0, Data.Stride,100000); g.DrawImage(Smaller_char, rect); } //change pas grand chose g.Dispose(); IntPtr hBitmap = temp_image.GetHbitmap(); try { var img_src = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( hBitmap, IntPtr.Zero, Int32Rect.Empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions()); WriteableBitmap wb = new WriteableBitmap(img_src); var imgs = new ImageSend(wb); Messenger.Default.Send(imgs); } finally { DeleteObject(hBitmap); } //change pas grand chose temp_image.Dispose(); }
private void Export() { if (!Cuts.IsEmpty()) { // check all the cuts /* for (int i = 0; i < Cuts.Count(); i++) * { * if(Cuts.GetAt(i).Begin. > Cuts.GetAt(i).End) * { * * } * * * } */ /* * Create the split command with ffmpeg */ string resourcesFolderPath = Path.Combine(Directory.GetParent(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)).Parent.Parent.FullName, "Assets"); string videoName = Cuts.VideoPath.ToString().Split('/').Last().Split('.').First(); //creation of the folder var process_cmd = new System.Diagnostics.Process(); var startInfo_cmd = new System.Diagnostics.ProcessStartInfo { WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal, FileName = "cmd.exe", RedirectStandardInput = true, UseShellExecute = false }; process_cmd.StartInfo = startInfo_cmd; process_cmd.Start(); string video_path = Cuts.VideoPath.LocalPath.Replace('\\', '/').Substring(0, Cuts.VideoPath.LocalPath.Replace('\\', '/').LastIndexOf('/') + 1); process_cmd.StandardInput.WriteLine("mkdir " + "\"" + video_path + videoName + "\""); process_cmd.WaitForExit(1000); process_cmd.Kill(); for (int i = 0; i < Cuts.Count(); i++) { //boucle d'export une itération par vidéo var process = new System.Diagnostics.Process(); var startInfo = new System.Diagnostics.ProcessStartInfo { WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal, Arguments = "-ss " + Cuts.GetAt(i).Begin.ToString().Substring(0, 8) + " -to " + Cuts.GetAt(i).End.ToString().Substring(0, 8) + " -i " + Cuts.VideoPath.LocalPath.Replace('\\', '/') + " -c copy " + video_path + videoName + "/" + Cuts.GetAt(i).Name + ".mp4", FileName = resourcesFolderPath + "\\" + "ffmpeg.exe", RedirectStandardInput = false, UseShellExecute = true }; /*process.StartInfo = startInfo; * process.Start();*/ System.Diagnostics.Debug.WriteLine(resourcesFolderPath + "\\" + "ffmpeg.exe"); process = Process.Start(startInfo); //System.Diagnostics.Debug.WriteLine("ffmpeg -ss " + Cuts.GetAt(i).Begin.ToString() + " -to " + Cuts.GetAt(i).End.ToString() + " -i " + Cuts.VideoPath.LocalPath + " -c copy " + " D:/Utilisateurs/Raphael/Vidéos/" + videoName + "/" + Cuts.GetAt(i).Name+".mp4"); // await Task.Delay(1000); // process.StandardInput.WriteLine("cls"); // process.StandardInput.WriteLine("cd " +"\""+ resourcesFolderPath + "\"" ); // string command = "ffmpeg -ss " + Cuts.GetAt(i).Begin.ToString().Substring(0, 8) + " -to " + Cuts.GetAt(i).End.ToString().Substring(0, 8) + " -i " + Cuts.VideoPath.LocalPath.Replace('\\', '/') + " -c copy " + video_path + videoName + "/" + Cuts.GetAt(i).Name + ".mp4"; process.WaitForExit(); //export thumbnail var thumb_location = video_path + videoName + "/" + Cuts.GetAt(i).Name + ".png"; //creation de la thumbnail Bitmap image = GenerateThumb(i); image.Save(thumb_location); image.Dispose(); } /* * process.StandardInput.WriteLine("d:"); * process.StandardInput.WriteLine("mkdir \"D:/Utilisateurs/Raphael/AppData/Local/ffmpeg/" + videoName + "\""); * process.StandardInput.WriteLine("cd D:/Program Files/ffmpeg-4.0-win64-static/bin"); */ } }