Accueil > > > AVIPREVIEW GUI POUR EMULE ET EDONKEY
AVIPREVIEW GUI POUR EMULE ET EDONKEY
Information sur la source
Description
Mon programme (et à l'aide du fichier AviPreviewC.exe disponible sur le site http://www.funkster.org) permet de créer un fichier qui reprend toutes les frames déjà téléchargé avec eMule ou eDonkey2000. Explication : Il crée une liste des fichiers .part et vérifie indique si ce sont des fichiers vidéo (avi), il permet ensuite de spécifier la résolution et la taille du fichier et créera ensuite le fichier de prévisualisation dans un répertoire donné et de le lancer par après;
Source
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Data;
- using System.IO;
- using System.Diagnostics;
- using System.Runtime.InteropServices;
-
- namespace AviPreview_Emule
- {
-
-
- /// <summary>
- /// Description résumée de Form1.
- /// </summary>
- public class Form1 : System.Windows.Forms.Form
- {
- private System.Windows.Forms.ListBox listBox1;
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.TextBox txtWidth;
- private System.Windows.Forms.TextBox txtHeight;
- private System.Windows.Forms.CheckBox chkresolution;
- private System.Windows.Forms.GroupBox groupBox2;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.Label label5;
-
- private System.Windows.Forms.Button button1;
- private System.ComponentModel.Container components = null;
- /// </summary>
- public const string WIDTH_RESOLUTION = "-h ";
- public const string HEIGHT_RESOLUTION = "-v ";
- public const string FORCE_DETECTION = "-f";
- public const string OUTPUT_SIZE = "-s ";
- private System.Windows.Forms.TextBox txtSize;
-
- public string commandline = "";
-
- public enum ERROR_MESSAGES
- {
- Width,
- Height,
- Selection,
- Not_Number,
- Avipreview,
- Emule,
- Avi,
- Creation,
- Fichier
- }
-
- public Form1()
- {
- //
- // Requis pour la prise en charge du Concepteur Windows Forms
- //
- InitializeComponent();
-
- //
- // TODO : ajoutez le code du constructeur après l'appel à InitializeComponent
- //
- }
-
- /// <summary>
- /// Nettoyage des ressources utilisées.
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if (components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
-
- #region Code généré par le Concepteur Windows Form
- /// <summary>
- /// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
- /// le contenu de cette méthode avec l'éditeur de code.
- /// </summary>
- private void InitializeComponent()
- {
- System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
- this.listBox1 = new System.Windows.Forms.ListBox();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.label2 = new System.Windows.Forms.Label();
- this.label1 = new System.Windows.Forms.Label();
- this.txtHeight = new System.Windows.Forms.TextBox();
- this.txtWidth = new System.Windows.Forms.TextBox();
- this.chkresolution = new System.Windows.Forms.CheckBox();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.label5 = new System.Windows.Forms.Label();
- this.label4 = new System.Windows.Forms.Label();
- this.txtSize = new System.Windows.Forms.TextBox();
- this.label3 = new System.Windows.Forms.Label();
- this.button1 = new System.Windows.Forms.Button();
- this.groupBox1.SuspendLayout();
- this.groupBox2.SuspendLayout();
- this.SuspendLayout();
- //
- // listBox1
- //
- this.listBox1.Location = new System.Drawing.Point(15, 10);
- this.listBox1.Name = "listBox1";
- this.listBox1.ScrollAlwaysVisible = true;
- this.listBox1.Size = new System.Drawing.Size(140, 108);
- this.listBox1.TabIndex = 0;
- //
- // groupBox1
- //
- this.groupBox1.Controls.Add(this.label2);
- this.groupBox1.Controls.Add(this.label1);
- this.groupBox1.Controls.Add(this.txtHeight);
- this.groupBox1.Controls.Add(this.txtWidth);
- this.groupBox1.Enabled = false;
- this.groupBox1.Location = new System.Drawing.Point(29, 146);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(131, 89);
- this.groupBox1.TabIndex = 1;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "Résolution";
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(11, 56);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(49, 16);
- this.label2.TabIndex = 3;
- this.label2.Text = "hauteur :";
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(11, 29);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(49, 16);
- this.label1.TabIndex = 2;
- this.label1.Text = "Largeur :";
- //
- // txtHeight
- //
- this.txtHeight.Location = new System.Drawing.Point(64, 54);
- this.txtHeight.Name = "txtHeight";
- this.txtHeight.Size = new System.Drawing.Size(47, 20);
- this.txtHeight.TabIndex = 1;
- this.txtHeight.Text = "";
- //
- // txtWidth
- //
- this.txtWidth.Location = new System.Drawing.Point(64, 23);
- this.txtWidth.Name = "txtWidth";
- this.txtWidth.Size = new System.Drawing.Size(47, 20);
- this.txtWidth.TabIndex = 0;
- this.txtWidth.Text = "";
- //
- // chkresolution
- //
- this.chkresolution.Location = new System.Drawing.Point(9, 129);
- this.chkresolution.Name = "chkresolution";
- this.chkresolution.Size = new System.Drawing.Size(126, 16);
- this.chkresolution.TabIndex = 4;
- this.chkresolution.Text = "Spécifier résolution";
- this.chkresolution.CheckedChanged += new System.EventHandler(this.chkresolution_CheckedChanged);
- //
- // groupBox2
- //
- this.groupBox2.Controls.Add(this.label5);
- this.groupBox2.Controls.Add(this.label4);
- this.groupBox2.Controls.Add(this.txtSize);
- this.groupBox2.Controls.Add(this.label3);
- this.groupBox2.Location = new System.Drawing.Point(179, 146);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(145, 64);
- this.groupBox2.TabIndex = 5;
- this.groupBox2.TabStop = false;
- this.groupBox2.Text = "Taille du fichier de sortie";
- //
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(18, 44);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(108, 16);
- this.label5.TabIndex = 3;
- this.label5.Text = "vide = tout récupérer";
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(98, 22);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(20, 16);
- this.label4.TabIndex = 2;
- this.label4.Text = "Mo";
- //
- // txtSize
- //
- this.txtSize.Location = new System.Drawing.Point(53, 19);
- this.txtSize.Name = "txtSize";
- this.txtSize.Size = new System.Drawing.Size(41, 20);
- this.txtSize.TabIndex = 1;
- this.txtSize.Text = "";
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(11, 21);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(38, 16);
- this.label3.TabIndex = 0;
- this.label3.Text = "Taille :";
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(197, 43);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(112, 47);
- this.button1.TabIndex = 6;
- this.button1.Text = "Récupérer";
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // Form1
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
- this.ClientSize = new System.Drawing.Size(344, 245);
- this.Controls.Add(this.button1);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.groupBox1);
- this.Controls.Add(this.listBox1);
- this.Controls.Add(this.chkresolution);
- this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
- this.Name = "Form1";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "AviPreview GUI";
- this.Load += new System.EventHandler(this.Form1_Load);
- this.groupBox1.ResumeLayout(false);
- this.groupBox2.ResumeLayout(false);
- this.ResumeLayout(false);
-
- }
- #endregion
-
- /// <summary>
- /// Point d'entrée principal de l'application.
- /// </summary>
- [STAThread]
- static void Main()
- {
- Application.Run(new Form1());
- }
-
- private void Form1_Load(object sender, System.EventArgs e)
- {
- string[] files = new string[] {};
- byte[] byte_header = new byte[4];
- string strheader="";
- if(Directory.Exists("temp") && File.Exists("emule.exe"))
- {
- files = Directory.GetFiles("temp", "*.part");
- if(files.Length != 0)
- {
- for(int i=0;i<files.Length;i++)
- {
- FileStream stream = new FileStream(files[i], FileMode.Open);
-
- stream.Read(byte_header, 0, 4);
- strheader = System.Text.Encoding.ASCII.GetString(byte_header);
- if(strheader == "RIFF") files[i] += " (avi)";
- else files[i] += " (???)";
- }
- listBox1.DataSource = files;
- }
- }
- else
- {
- Erreur(ERROR_MESSAGES.Emule);
- Close();
- }
- }
-
- private void chkresolution_CheckedChanged(object sender, System.EventArgs e)
- {
- if(chkresolution.Checked == true)
- {
- groupBox1.Enabled = true;
- }
- else
- {
- groupBox1.Enabled = false;
- }
- }
-
- private void button1_Click(object sender, System.EventArgs e)
- {
- if(!VerifyAviPreview()) {}
- else if(!VerifyResolution()) {}
- else if(!VerifyNumber()) {}
- else if(!VerifyAVI()) {}
- else PrepareForLaunching();
- }
-
- public bool VerifyAviPreview()
- {
- if(!File.Exists("AviPreviewC.exe"))
- {
- Erreur(ERROR_MESSAGES.Avipreview);
- return false;
- }
- return true;
- }
-
- public bool VerifyResolution()
- {
- if(chkresolution.Checked)
- {
- if(txtWidth.Text == "")
- {
- Erreur(ERROR_MESSAGES.Width);
- return false;
- }
- else if(txtHeight.Text == "")
- {
- Erreur(ERROR_MESSAGES.Height);
- return false;
- }
- }
- return true;
- }
-
- public bool VerifyNumber()
- {
- foreach (char c in txtWidth.Text)
- {
- if(c < 48 || c > 57)
- {
- Erreur(ERROR_MESSAGES.Not_Number);
- return false;
- }
- }
- foreach (char c in txtHeight.Text)
- {
- if(c < 48 || c > 57)
- {
- Erreur(ERROR_MESSAGES.Not_Number);
- return false;
- }
- }
- foreach (char c in txtSize.Text)
- {
- if(c < 48 || c > 57)
- {
- Erreur(ERROR_MESSAGES.Not_Number);
- return false;
- }
- }
-
- return true;
- }
-
- public bool VerifyAVI()
- {
- if(listBox1.SelectedIndex == -1)
- {
- Erreur(ERROR_MESSAGES.Selection);
- return false;
- }
- if(listBox1.SelectedItem.ToString().IndexOf("avi") == -1)
- {
- Erreur(ERROR_MESSAGES.Avi);
- return false;
- }
- else return true;
- }
-
- public void PrepareForLaunching()
- {
- bool resolution=false;
- bool size=false;
-
- if(txtWidth.Text != "" && txtHeight.Text != "") resolution = true;
- if(txtSize.Text != "") size = true;
-
- ExecuteAviPreview(resolution, size);
- }
-
- public void ExecuteAviPreview(bool resolution, bool size)
- {
- string commandline;
- string[] jetons;
-
- SaveFileDialog sfd = new SaveFileDialog();
- sfd.InitialDirectory = @"%USERPROFILE%\Bureau";
- sfd.Filter = "Fichier vidéo|*.avi";
- sfd.RestoreDirectory = true;
- if(sfd.ShowDialog() != DialogResult.Cancel)
- {
-
- jetons = listBox1.SelectedItem.ToString().Split(new char[] {' '});
- commandline = jetons[0] + " \u0022" + sfd.FileName + "\u0022";
- if(resolution)
- {
- commandline += " -h " + txtWidth.Text;
- commandline += " -v " + txtHeight.Text;
- }
- if(size) commandline += " -s " + txtSize.Text + "M";
-
- Process myprocess = new Process();
- myprocess.StartInfo.FileName = "AviPreviewC.exe";
- myprocess.StartInfo.Arguments = commandline;
- myprocess.Start();
- myprocess.WaitForExit();
- if(!File.Exists(sfd.FileName)) Erreur(ERROR_MESSAGES.Creation);
- else
- {
- DialogResult result = MessageBox.Show("Tout s'est bien déroulé. voulez-vous lancer la vidéo ?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
- if(result == DialogResult.Yes) ExecutePreview(sfd.FileName);
- }
- }
- }
-
- public void ExecutePreview(string filename)
- {
- Process myprocess = new Process();
- myprocess.StartInfo.FileName = filename;
- myprocess.Start();
- myprocess.WaitForExit();
- }
-
- public void Erreur(AviPreview_Emule.Form1.ERROR_MESSAGES erreur)
- {
- string msg = "";
-
- switch(erreur)
- {
- case ERROR_MESSAGES.Width: msg = "La largeur n'est pas spécifiée !"; break;
- case ERROR_MESSAGES.Height: msg = "La hauteur n'est pas spécifiée !"; break;
- case ERROR_MESSAGES.Not_Number: msg = "Une valeur spécifié n'est pas un nombre !"; break;
- case ERROR_MESSAGES.Selection: msg = "Aucun fichier sélectionner !"; break;
- case ERROR_MESSAGES.Avipreview: msg = "AviPreviewC.exe doit se trouver dans le dossier de emule !"; break;
- case ERROR_MESSAGES.Emule: msg = "Ce programme doit être placer dans le répertoire d'eMule !"; break;
- case ERROR_MESSAGES.Avi: msg = "Le fichier sélectionner n'est pas une video au format AVI standard !"; break;
- case ERROR_MESSAGES.Creation: msg = "Erreur inconnue lors de la création du fichier !"; break;
- case ERROR_MESSAGES.Fichier: msg = "Vous devez donner l'emplacement du fichier dé prévisualisation !"; break;
- }
-
- MessageBox.Show(msg, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace AviPreview_Emule
{
/// <summary>
/// Description résumée de Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtWidth;
private System.Windows.Forms.TextBox txtHeight;
private System.Windows.Forms.CheckBox chkresolution;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Button button1;
private System.ComponentModel.Container components = null;
/// </summary>
public const string WIDTH_RESOLUTION = "-h ";
public const string HEIGHT_RESOLUTION = "-v ";
public const string FORCE_DETECTION = "-f";
public const string OUTPUT_SIZE = "-s ";
private System.Windows.Forms.TextBox txtSize;
public string commandline = "";
public enum ERROR_MESSAGES
{
Width,
Height,
Selection,
Not_Number,
Avipreview,
Emule,
Avi,
Creation,
Fichier
}
public Form1()
{
//
// Requis pour la prise en charge du Concepteur Windows Forms
//
InitializeComponent();
//
// TODO : ajoutez le code du constructeur après l'appel à InitializeComponent
//
}
/// <summary>
/// Nettoyage des ressources utilisées.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Code généré par le Concepteur Windows Form
/// <summary>
/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
/// le contenu de cette méthode avec l'éditeur de code.
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.listBox1 = new System.Windows.Forms.ListBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.txtHeight = new System.Windows.Forms.TextBox();
this.txtWidth = new System.Windows.Forms.TextBox();
this.chkresolution = new System.Windows.Forms.CheckBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.txtSize = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// listBox1
//
this.listBox1.Location = new System.Drawing.Point(15, 10);
this.listBox1.Name = "listBox1";
this.listBox1.ScrollAlwaysVisible = true;
this.listBox1.Size = new System.Drawing.Size(140, 108);
this.listBox1.TabIndex = 0;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.txtHeight);
this.groupBox1.Controls.Add(this.txtWidth);
this.groupBox1.Enabled = false;
this.groupBox1.Location = new System.Drawing.Point(29, 146);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(131, 89);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Résolution";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(11, 56);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(49, 16);
this.label2.TabIndex = 3;
this.label2.Text = "hauteur :";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(11, 29);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(49, 16);
this.label1.TabIndex = 2;
this.label1.Text = "Largeur :";
//
// txtHeight
//
this.txtHeight.Location = new System.Drawing.Point(64, 54);
this.txtHeight.Name = "txtHeight";
this.txtHeight.Size = new System.Drawing.Size(47, 20);
this.txtHeight.TabIndex = 1;
this.txtHeight.Text = "";
//
// txtWidth
//
this.txtWidth.Location = new System.Drawing.Point(64, 23);
this.txtWidth.Name = "txtWidth";
this.txtWidth.Size = new System.Drawing.Size(47, 20);
this.txtWidth.TabIndex = 0;
this.txtWidth.Text = "";
//
// chkresolution
//
this.chkresolution.Location = new System.Drawing.Point(9, 129);
this.chkresolution.Name = "chkresolution";
this.chkresolution.Size = new System.Drawing.Size(126, 16);
this.chkresolution.TabIndex = 4;
this.chkresolution.Text = "Spécifier résolution";
this.chkresolution.CheckedChanged += new System.EventHandler(this.chkresolution_CheckedChanged);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.label5);
this.groupBox2.Controls.Add(this.label4);
this.groupBox2.Controls.Add(this.txtSize);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Location = new System.Drawing.Point(179, 146);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(145, 64);
this.groupBox2.TabIndex = 5;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Taille du fichier de sortie";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(18, 44);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(108, 16);
this.label5.TabIndex = 3;
this.label5.Text = "vide = tout récupérer";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(98, 22);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(20, 16);
this.label4.TabIndex = 2;
this.label4.Text = "Mo";
//
// txtSize
//
this.txtSize.Location = new System.Drawing.Point(53, 19);
this.txtSize.Name = "txtSize";
this.txtSize.Size = new System.Drawing.Size(41, 20);
this.txtSize.TabIndex = 1;
this.txtSize.Text = "";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(11, 21);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(38, 16);
this.label3.TabIndex = 0;
this.label3.Text = "Taille :";
//
// button1
//
this.button1.Location = new System.Drawing.Point(197, 43);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(112, 47);
this.button1.TabIndex = 6;
this.button1.Text = "Récupérer";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(344, 245);
this.Controls.Add(this.button1);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.chkresolution);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "AviPreview GUI";
this.Load += new System.EventHandler(this.Form1_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// Point d'entrée principal de l'application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
string[] files = new string[] {};
byte[] byte_header = new byte[4];
string strheader="";
if(Directory.Exists("temp") && File.Exists("emule.exe"))
{
files = Directory.GetFiles("temp", "*.part");
if(files.Length != 0)
{
for(int i=0;i<files.Length;i++)
{
FileStream stream = new FileStream(files[i], FileMode.Open);
stream.Read(byte_header, 0, 4);
strheader = System.Text.Encoding.ASCII.GetString(byte_header);
if(strheader == "RIFF") files[i] += " (avi)";
else files[i] += " (???)";
}
listBox1.DataSource = files;
}
}
else
{
Erreur(ERROR_MESSAGES.Emule);
Close();
}
}
private void chkresolution_CheckedChanged(object sender, System.EventArgs e)
{
if(chkresolution.Checked == true)
{
groupBox1.Enabled = true;
}
else
{
groupBox1.Enabled = false;
}
}
private void button1_Click(object sender, System.EventArgs e)
{
if(!VerifyAviPreview()) {}
else if(!VerifyResolution()) {}
else if(!VerifyNumber()) {}
else if(!VerifyAVI()) {}
else PrepareForLaunching();
}
public bool VerifyAviPreview()
{
if(!File.Exists("AviPreviewC.exe"))
{
Erreur(ERROR_MESSAGES.Avipreview);
return false;
}
return true;
}
public bool VerifyResolution()
{
if(chkresolution.Checked)
{
if(txtWidth.Text == "")
{
Erreur(ERROR_MESSAGES.Width);
return false;
}
else if(txtHeight.Text == "")
{
Erreur(ERROR_MESSAGES.Height);
return false;
}
}
return true;
}
public bool VerifyNumber()
{
foreach (char c in txtWidth.Text)
{
if(c < 48 || c > 57)
{
Erreur(ERROR_MESSAGES.Not_Number);
return false;
}
}
foreach (char c in txtHeight.Text)
{
if(c < 48 || c > 57)
{
Erreur(ERROR_MESSAGES.Not_Number);
return false;
}
}
foreach (char c in txtSize.Text)
{
if(c < 48 || c > 57)
{
Erreur(ERROR_MESSAGES.Not_Number);
return false;
}
}
return true;
}
public bool VerifyAVI()
{
if(listBox1.SelectedIndex == -1)
{
Erreur(ERROR_MESSAGES.Selection);
return false;
}
if(listBox1.SelectedItem.ToString().IndexOf("avi") == -1)
{
Erreur(ERROR_MESSAGES.Avi);
return false;
}
else return true;
}
public void PrepareForLaunching()
{
bool resolution=false;
bool size=false;
if(txtWidth.Text != "" && txtHeight.Text != "") resolution = true;
if(txtSize.Text != "") size = true;
ExecuteAviPreview(resolution, size);
}
public void ExecuteAviPreview(bool resolution, bool size)
{
string commandline;
string[] jetons;
SaveFileDialog sfd = new SaveFileDialog();
sfd.InitialDirectory = @"%USERPROFILE%\Bureau";
sfd.Filter = "Fichier vidéo|*.avi";
sfd.RestoreDirectory = true;
if(sfd.ShowDialog() != DialogResult.Cancel)
{
jetons = listBox1.SelectedItem.ToString().Split(new char[] {' '});
commandline = jetons[0] + " \u0022" + sfd.FileName + "\u0022";
if(resolution)
{
commandline += " -h " + txtWidth.Text;
commandline += " -v " + txtHeight.Text;
}
if(size) commandline += " -s " + txtSize.Text + "M";
Process myprocess = new Process();
myprocess.StartInfo.FileName = "AviPreviewC.exe";
myprocess.StartInfo.Arguments = commandline;
myprocess.Start();
myprocess.WaitForExit();
if(!File.Exists(sfd.FileName)) Erreur(ERROR_MESSAGES.Creation);
else
{
DialogResult result = MessageBox.Show("Tout s'est bien déroulé. voulez-vous lancer la vidéo ?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if(result == DialogResult.Yes) ExecutePreview(sfd.FileName);
}
}
}
public void ExecutePreview(string filename)
{
Process myprocess = new Process();
myprocess.StartInfo.FileName = filename;
myprocess.Start();
myprocess.WaitForExit();
}
public void Erreur(AviPreview_Emule.Form1.ERROR_MESSAGES erreur)
{
string msg = "";
switch(erreur)
{
case ERROR_MESSAGES.Width: msg = "La largeur n'est pas spécifiée !"; break;
case ERROR_MESSAGES.Height: msg = "La hauteur n'est pas spécifiée !"; break;
case ERROR_MESSAGES.Not_Number: msg = "Une valeur spécifié n'est pas un nombre !"; break;
case ERROR_MESSAGES.Selection: msg = "Aucun fichier sélectionner !"; break;
case ERROR_MESSAGES.Avipreview: msg = "AviPreviewC.exe doit se trouver dans le dossier de emule !"; break;
case ERROR_MESSAGES.Emule: msg = "Ce programme doit être placer dans le répertoire d'eMule !"; break;
case ERROR_MESSAGES.Avi: msg = "Le fichier sélectionner n'est pas une video au format AVI standard !"; break;
case ERROR_MESSAGES.Creation: msg = "Erreur inconnue lors de la création du fichier !"; break;
case ERROR_MESSAGES.Fichier: msg = "Vous devez donner l'emplacement du fichier dé prévisualisation !"; break;
}
MessageBox.Show(msg, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
Conclusion
Je remercie Olivier Stephenson sans qui ce projet n'aurait jamais su être réalisable !
J'ai encore une mise à jour à faire : Faire une fenêtre de visualisation en temps réel de l'opération de AviPreviewC.exe (pas la console quoi)
Je mettrais à jour le code source dès que je l'aurais fait.
Si vous avez des suggestions, faites le moi savoir je verrais ce que je peux faire
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
faire un GUI [ par raver2046 ]
Bon voila, sa fais un moment que je me creuse la tête pour essayer de faire une GUI ( comprenez par la une appli WIN32 avec des fenêtres et tout) qui
Problème de cross threading avec un DataGridView [ par defcode ]
J'essaye d'ajouter une nouvelle ligne à un datagridview depuis un autre thread sur une autre Class. Si je ne suis pas sur un thread pour lan
Pb avec ressource commune et multilangues [ par fregolo52 ]
Bonjour,Je développe avec VS2003.J'ai ce message qui est apparu soudainement (sans raison) :Impossible de trouver des ressources appropriées pour la c
gui demo + look&feel mac [ par sprooz ]
Bonjour, je recherche un lien sur une demo de gui en c# représentative de tout ce qu'on peut faire en la matiere. De plus est ce qu'il existe un look
GUI en C# embarqué [ par wille12 ]
Bonjour, Je dois développer un logiciel embarqué sur PDA en C# avec Visual Studio. Il me faudrait quelques infos sur les éléments graphiques de bases
Dépendance Circulaire [ par Redfire ]
Bonjour, je débute en C# et je me retrouve face à un problème.Je m'essaie au développement en couche, je dispose d'une classe library qui contient tou
|
Derniers Blogs
UNE JOLIE-HORLOGE ET PAS QU'UN PEU !UNE JOLIE-HORLOGE ET PAS QU'UN PEU ! par neodante
Pour les possesseurs d'iPhone, ça y est Bijin Tokei - qui se traduit littéralement en Français par " Jolie Horloge " - est arrivé et GRATUITEMENT s'il vous plaît ! Après la version Tokyo, Hokkaido, night club, racing, Gal, "pour les mademoiselles'", . voi...
Cliquez pour lire la suite de l'article par neodante TECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICESTECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICES par ROMELARD Fabrice
Animé par: Gaetan Bouveret et Julien Chomarat Business Connectivity Services (BCS) est dans SharePoint 2010 la version 2 de Business Data Catalog (BDC dans SharePoint 2007). Il s'agit de la solution permettant de visualiser des données provenan...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE[DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE par orion
Comme de nombreux geek, je suis un grand amateur de série TV et je rate régulièrement des épisodes de mes séries préférés. Une solution s'offre à vous avec ce merveilleux site : Tv Gorge - www.tvgorge.com Moteur de recherche à l'appui, vous pouvez ...
Cliquez pour lire la suite de l'article par orion TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|