Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members

Form1.cs

Go to the documentation of this file.
00001 /*
00002 SimImmuno version 1.0
00003 Copyright (C) 2005 sebeuh.ajsinfo.net
00004 
00005 SimImmuno est libre, vous pouvez le redistribuer et/ou le modifier
00006 selon les termes de la Licence Publique Générale GNU publiée par la
00007 Free Software Foundation (version 2).
00008 
00009 SimImmuno est distribué car potentiellement utile, mais SANS AUCUNE GARANTIE,
00010 ni explicite ni implicite, y compris les garanties de commercialisation
00011 ou d'adaptation dans un but spécifique. Reportez-vous à la
00012 Licence Publique Générale GNU pour plus de détails.
00013 
00014 Texte de la license officielle (anglais) :
00015 http://simimmuno.ajsinfo.net/text.aspx?code=no&txt_file=GPL.txt
00016 Traduction francaise (non-officielle) :
00017 http://simimmuno.ajsinfo.net/text.aspx?code=no&txt_file=GPL-fr.txt
00018 */
00019 using System;
00020 using System.Drawing;
00021 using System.Drawing.Imaging;
00022 using System.Collections;
00023 using System.ComponentModel;
00024 using System.Windows.Forms;
00025 using System.Data;
00026 using System.IO;
00027 using System.Reflection;
00028 
00029 namespace SimImmuno
00030 {
00031         public class frmMain : System.Windows.Forms.Form
00032         {
00033                 #region Declarations & Constructeur
00034                 private System.ComponentModel.Container components = null;
00035                 public static CellulesCollection ccol;
00036                 public bool LoopOn;
00037                 private bool InitOn;
00038                 public static bool LoadOn;
00039                 public static frmLog log;
00040                 public static frmControl control;
00041                 public frmBrowser browser;
00042                 public frmOptions opts;
00043                 private int fps;
00044                 private long LastFPS;
00045                 private Random rnd_pos;
00046                 private Random rnd_value;
00047                 public static bool log_debug;
00048                 public static bool log_limit;
00049                 public static int log_limit_size;
00050                 public static string titre_sim;
00051                 public static DateTime dtChrono;
00052                 public static DateTime dtLastChrono;
00053                 public static int boucle_count;
00054                 public static int boucle_per_seconde;
00055                 private int last_choix;
00056 
00057                 private int nb_normal;
00058                 private int nb_cellinfect;
00059                 private int nb_anticorp;
00060                 private int nb_antigen;
00061                 private int nb_CI;
00062                 private int nb_debris;
00063                 private int nb_LB;
00064                 private int nb_LBm;
00065                 private int nb_LT4;
00066                 private int nb_LT4m;
00067                 private int nb_LT8m;
00068                 private int nb_LT8;
00069                 private int nb_LTc;
00070                 private int nb_phago;
00071                 private int nb_plasmo;
00072                 private int nb_vih;
00073                 private int nb_infectvih;
00074                 
00075                 public static bool af_normal;
00076                 public static bool af_cellinfect;
00077                 public static bool af_anticorp;
00078                 public static bool af_antigen;
00079                 public static bool af_CI;
00080                 public static bool af_debris;
00081                 public static bool af_LB;
00082                 public static bool af_LBm;
00083                 public static bool af_LT4;
00084                 public static bool af_LT4m;
00085                 public static bool af_LT8m;
00086                 public static bool af_LT8;
00087                 public static bool af_LTc;
00088                 public static bool af_phago;
00089                 public static bool af_plasmo;
00090                 public static bool af_vih;
00091                 public static bool af_infectvih;
00092 
00093                 private System.Windows.Forms.MainMenu mainMenu;
00094                 private System.Windows.Forms.MenuItem menuItem1;
00095                 private System.Windows.Forms.MenuItem menuItem2;
00096                 private System.Windows.Forms.MenuItem menuItem3;
00097                 private System.Windows.Forms.MenuItem menuItem4;
00098                 private System.Windows.Forms.MenuItem menuItem5;
00099                 private System.Windows.Forms.MenuItem menuItem6;
00100                 private System.Windows.Forms.MenuItem menuItem7;
00101                 private System.Windows.Forms.MenuItem menuItem8;
00102                 private System.Windows.Forms.MenuItem menuItem9;
00103                 private System.Windows.Forms.MenuItem menuItem10;
00104                 private System.Windows.Forms.MenuItem menuItem11;
00105                 private System.Windows.Forms.MenuItem menuItem12;
00106                 private System.Windows.Forms.MenuItem menuItem13;
00107                 private System.Windows.Forms.MenuItem menuItem14;
00108                 private System.Windows.Forms.OpenFileDialog openFileDialog1;
00109                 private System.Windows.Forms.SaveFileDialog saveFileDialog1;
00110                 private System.Windows.Forms.MenuItem menuItem16;
00111                 private System.Windows.Forms.MenuItem menuItem17;
00112                 private System.Windows.Forms.MenuItem menuItem18;
00113                 private System.Windows.Forms.MenuItem menuItem20;
00114                 private System.Windows.Forms.MenuItem menuItem21;
00115                 private System.Windows.Forms.MenuItem menuItem22;
00116                 private System.Windows.Forms.MenuItem menuItem23;
00117                 private System.Windows.Forms.HelpProvider helpProvider1;
00118                 private System.Windows.Forms.MenuItem menuItem19;
00119                 private System.Windows.Forms.MenuItem menuItem24;
00120                 private System.Windows.Forms.MenuItem menuItem25;
00121                 private System.Windows.Forms.MenuItem menuItem26;
00122                 private System.Windows.Forms.MenuItem menuItem27;
00123                 private System.Windows.Forms.MenuItem menuItem15;
00124 
00125                 public frmMain()
00126                 {
00127                         InitializeComponent();
00128                         components = null;
00129                         ccol = new CellulesCollection();
00130                         Cellule.rnd = new Random();
00131                         this.rnd_pos = new Random();
00132                         ImageList.LoadImgs();
00133                 }
00134                 #endregion
00135 
00136                 #region Fonctions Simulateur
00137                 private void MoelleOsseuse_Thymus()
00138                 {
00139                         rnd_value = new Random();
00140                         if(rnd_value.Next(500) == 1)
00141                         {
00142                                 int spe = rnd_value.Next(1,6);
00143                                 int xx = rnd_pos.Next(800);
00144                                 int yy = rnd_pos.Next(600);
00145                                 int choix = rnd_value.Next(1,4);
00146                                 if(choix != last_choix)
00147                                 {
00148                                         last_choix = choix;
00149                                         switch(choix)
00150                                         {
00151                                                 case 1:
00152                                                         // LT8
00153                                                         LT8 lt8_1 = new LT8(xx,yy,spe);
00154                                                         ccol.Add(lt8_1);
00155                                                         log.NewEvent("Thymus: Ajout d'un LT8 de spé : " + spe.ToString());
00156                                                         break;
00157                                                 case 2:
00158                                                         // LT4
00159                                                         LT4 lt4_1 = new LT4(xx,yy,spe);
00160                                                         ccol.Add(lt4_1);
00161                                                         log.NewEvent("Thymus: Ajout d'un LT4 de spé : " + spe.ToString());
00162                                                         break;
00163                                                 case 3:
00164                                                         //LB
00165                                                         LB lb_1 = new LB(xx,yy,spe);
00166                                                         ccol.Add(lb_1);
00167                                                         log.NewEvent("Moelle Osseuse: Ajout d'un LB de spé : " + spe.ToString());
00168                                                         break;
00169                                         }
00170                                 }
00171                                 spe = 0;
00172                                 choix = 0;
00173                                 xx = 0;
00174                                 yy = 0;
00175                         }
00176                 }
00177                 #endregion
00178 
00179                 #region Fonctions diverses
00180                 private void RestartSim(string titre)
00181                 {
00182                         // Nouvelle simulation
00183                         titre_sim = titre;
00184                         LoopOn = false;
00185                         frmMain.ccol.Clear();
00186                         ClearTab();
00187                         boucle_count = 0;
00188                         boucle_per_seconde = 0;
00189                         ResetTimer();
00190                         log.clear();
00191                         this.Text = "SimImmuno by SeBeuH";
00192                         log.NewEvent("SimImmuno prêt");
00193                 }
00194 
00195                 public static void ResetTimer()
00196                 {
00197                         frmMain.dtChrono = DateTime.FromOADate(0);
00198                         frmMain.dtLastChrono = DateTime.FromOADate(0);
00199                 }
00200 
00201                 public static void SetLog(bool debug,bool limit,int size)
00202                 {
00203                         // cf frmOptions
00204                         log_debug = debug;
00205                         log_limit = limit;
00206                         log_limit_size = size;
00207                 }
00208 
00209                 public static void SetLoadOn(bool loading)
00210                 {
00211                         LoadOn = loading;
00212                 }
00213                 #endregion
00214 
00215                 #region Fonctions graphique
00216 
00217                 private void RenderPaint(object sender, System.Windows.Forms.PaintEventArgs e)
00218                 {
00219                         // Rendu graphique - gestion des cycles
00220                         log.NewEvent("------------------------- CYCLE N°" + boucle_count.ToString() + " -------------------------");
00221                         CellulesCollection ccol_copy = (CellulesCollection)ccol.Clone();
00222                         //
00223                         Graphics g = e.Graphics;
00224                         Font police = new Font("Arial",10,FontStyle.Bold);
00225                         SolidBrush stylo = new SolidBrush(Color.Black);
00226                         SolidBrush stylo_blanc = new SolidBrush(Color.White);
00227                         //Compteur
00228                         nb_anticorp = 0;
00229                         nb_antigen = 0;
00230                         nb_cellinfect = 0;
00231                         nb_CI = 0;
00232                         nb_debris = 0;
00233                         nb_LB = 0;
00234                         nb_LBm = 0;
00235                         nb_LT4 = 0;
00236                         nb_LT4m = 0;
00237                         nb_LT8m = 0;
00238                         nb_LT8 = 0;
00239                         nb_LTc = 0;
00240                         nb_phago = 0;
00241                         nb_normal = 0;
00242                         nb_plasmo = 0;
00243                         nb_vih = 0;
00244                         nb_infectvih = 0;
00245                         //
00246                         if(ccol_copy.Count >= 0)
00247                         {
00248                                 foreach(Cellule cell in ccol_copy)
00249                                 {
00250                                         //Vie
00251                                         cell.Life--;
00252                                         if(cell.Life<=0)
00253                                         {
00254                                                 try
00255                                                 {
00256                                                         ccol.RemoveAt(cell.index);
00257                                                 }
00258                                                 catch (Exception)
00259                                                 {
00260                                                         if(log_debug)
00261                                                         {
00262                                                                 if(cell is Antigen)
00263                                                                         log.NewEvent("!Erreur type=ANTIGEN index=" + cell.index.ToString());
00264                                                                 else if(cell is LB)
00265                                                                         log.NewEvent("!Erreur type=LB index=" + cell.index.ToString());
00266                                                                 else if(cell is CellInfect)
00267                                                                         log.NewEvent("!Erreur type=CELLINFECT index=" + cell.index.ToString());
00268                                                                 else if(cell is Anticorp)
00269                                                                         log.NewEvent("!Erreur type=ANTICORP index=" + cell.index.ToString());
00270                                                                 else if(cell is CI)
00271                                                                         log.NewEvent("!Erreur type=CI index=" + cell.index.ToString());
00272                                                                 else if(cell is Plasmocyte)
00273                                                                         log.NewEvent("!Erreur type=PLASMO index=" + cell.index.ToString());
00274                                                                 else if(cell is Phagocyte)
00275                                                                         log.NewEvent("!Erreur type=PHAGO index=" + cell.index.ToString());
00276                                                                 else if(cell is LT8)
00277                                                                         log.NewEvent("!Erreur type=LT8 index=" + cell.index.ToString());
00278                                                                 else if(cell is LTc)
00279                                                                         log.NewEvent("!Erreur type=LTc index=" + cell.index.ToString());
00280                                                                 else if(cell is Debris)
00281                                                                         log.NewEvent("!Erreur type=DEBRIS index=" + cell.index.ToString());
00282                                                                 else if(cell is LT4)
00283                                                                         log.NewEvent("!Erreur type=LT4 index=" + cell.index.ToString());
00284                                                                 else if(cell is LT4m)
00285                                                                         log.NewEvent("!Erreur type=LT4m index=" + cell.index.ToString());
00286                                                                 else if(cell is LT8m)
00287                                                                         log.NewEvent("!Erreur type=LT8m index=" + cell.index.ToString());
00288                                                                 else if(cell is LBm)
00289                                                                         log.NewEvent("!Erreur type=LBm index=" + cell.index.ToString());
00290                                                                 else if(cell is InfectVIH)
00291                                                                         log.NewEvent("!Erreur type=CELLINFECTVIH index=" + cell.index.ToString());
00292                                                                 else if(cell is VIH)
00293                                                                         log.NewEvent("!Erreur type=VIH index=" + cell.index.ToString());
00294                                                                 else
00295                                                                         log.NewEvent("!Erreur type=CELLNORMAL index=" + cell.index.ToString());
00296                                                         }
00297                                                 }
00298                                         }
00299                                         // Bordure                              
00300                                         if(cell.Location.X<6) cell.Location.X=5;
00301                                         if(cell.Location.X>this.Width-23) cell.Location.X=this.Width-23;
00302                                         if(cell.Location.Y<6) cell.Location.Y=5;
00303                                         if(cell.Location.Y>this.Height-53) cell.Location.Y=this.Height-53;
00304                                         // - ACTION des acteurs -
00305                                         try
00306                                         {
00307                                                 cell.Action();
00308                                                 MoelleOsseuse_Thymus();
00309                                         }
00310                                         catch(Exception exx)
00311                                         {
00312                                                 if(log_debug)
00313                             log.NewEvent("Erreur: " + exx.Message);
00314                                         }
00315 
00316                                         // - Rendu graphique - 
00317                                         Image img;
00318                                         Image imgResize;
00319                                         Size moy_taille = new Size(20,20);
00320                                         Size grande_taille = new Size(24,24);
00321                                         if(cell is Antigen)
00322                                         {
00323                                                 if(af_antigen)
00324                                                 {
00325                                                         img = ImageList.Antigen;
00326                                                         g.DrawImage(img,PositionToDisplay("petit",cell.Location));
00327                                                 }
00328                                                 nb_antigen++;
00329                                         }
00330                                         else if(cell is Anticorp)
00331                                         {
00332                                                 if(af_anticorp)
00333                                                 {
00334                                                         img = ImageList.Anticorp;
00335                                                         int temp_ac = rnd_value.Next(1,4);
00336                                                         RotateFlipType rotate = RotateFlipType.RotateNoneFlipNone;
00337                                                         switch(temp_ac)
00338                                                         {
00339                                                                 case 1:
00340                                                                         rotate = RotateFlipType.Rotate90FlipNone;
00341                                                                         break;
00342                                                                 case 2:
00343                                                                         rotate = RotateFlipType.Rotate90FlipX;
00344                                                                         break;
00345                                                                 case 3:
00346                                                                         rotate = RotateFlipType.Rotate90FlipXY;
00347                                                                         break;
00348                                                                 case 4:
00349                                                                         rotate = RotateFlipType.Rotate90FlipY;
00350                                                                         break;
00351                                                         }
00352                                                         img.RotateFlip(rotate);
00353                                                         g.DrawImage(img,PositionToDisplay("petit",cell.Location));
00354                                                 }
00355                                                 nb_anticorp++;
00356                                         }
00357                                         else if(cell is LB)
00358                                         {
00359                                                 if(af_LB)
00360                                                 {
00361                                                         img = ImageList.LB;                                                     
00362                                                         imgResize = new Bitmap(img,moy_taille);
00363                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00364                                                 }
00365                                                 nb_LB++;
00366                                         }
00367                                         else if(cell is Phagocyte)
00368                                         {
00369                                                 if(af_phago)
00370                                                 {
00371                                                         img = ImageList.Phagocyte;                              
00372                                                         imgResize = new Bitmap(img,grande_taille);
00373                                                         g.DrawImage(imgResize,PositionToDisplay("grand",cell.Location));
00374                                                 }
00375                                                 nb_phago++;
00376                                         }
00377                                         else if(cell is Plasmocyte)
00378                                         {
00379                                                 if(af_plasmo)
00380                                                 {
00381                                                         img = ImageList.Plasmocyte;                                             
00382                                                         imgResize = new Bitmap(img,moy_taille);
00383                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00384                                                 }
00385                                                 nb_plasmo++;
00386                                         }
00387                                         else if(cell is CellInfect)
00388                                         {
00389                                                 if(af_cellinfect)
00390                                                 {
00391                                                         img = ImageList.CellInfect;
00392                                                         imgResize = new Bitmap(img,moy_taille);
00393                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00394                                                 }
00395                                                 nb_cellinfect++;
00396                                         }
00397                                         else if(cell is CI)
00398                                         {
00399                                                 if(af_CI)
00400                                                 {
00401                                                         img = ImageList.CI;
00402                                                         imgResize = new Bitmap(img,moy_taille);
00403                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00404                                                 }
00405                                                 nb_CI++;
00406                                         }
00407                                         else if(cell is LT8)
00408                                         {
00409                                                 if(af_LT8)
00410                                                 {
00411                                                         img = ImageList.LT8;
00412                                                         imgResize = new Bitmap(img,moy_taille);
00413                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00414                                                 }
00415                                                 nb_LT8++;
00416                                         }
00417                                         else if(cell is LTc)
00418                                         {
00419                                                 if(af_LTc)
00420                                                 {
00421                                                         img = ImageList.LTc;
00422                                                         imgResize = new Bitmap(img,moy_taille);
00423                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00424                                                 }
00425                                                 nb_LTc++;
00426                                         }
00427                                         else if(cell is Debris)
00428                                         {
00429                                                 if(af_debris)
00430                                                 {
00431                                                         img = ImageList.Debris;
00432                                                         imgResize = new Bitmap(img,moy_taille);
00433                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00434                                                 }
00435                                                 nb_debris++;
00436                                         }
00437                                         else if(cell is LT4)
00438                                         {
00439                                                 if(af_LT4)
00440                                                 {
00441                                                         img = ImageList.LT4;
00442                                                         imgResize = new Bitmap(img,moy_taille);
00443                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00444                                                 }
00445                                                 nb_LT4++;
00446                                         }
00447                                         else if(cell is LT4m)
00448                                         {
00449                                                 if(af_LT4m)
00450                                                 {
00451                                                         img = ImageList.LT4m;
00452                                                         imgResize = new Bitmap(img,moy_taille);
00453                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00454                                                 }
00455                                                 nb_LT4m++;
00456                                         }
00457                                         else if(cell is LT8m)
00458                                         {
00459                                                 if(af_LT8m)
00460                                                 {
00461                                                         img = ImageList.LT8m;
00462                                                         imgResize = new Bitmap(img,moy_taille);
00463                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00464                                                 }
00465                                                 nb_LT8m++;
00466                                         }
00467                                         else if(cell is LBm)
00468                                         {
00469                                                 if(af_LBm)
00470                                                 {
00471                                                         img = ImageList.LBm;
00472                                                         imgResize = new Bitmap(img,moy_taille);
00473                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00474                                                 }
00475                                                 nb_LBm++;
00476                                         }
00477                                         else if(cell is InfectVIH)
00478                                         {
00479                                                 if(af_infectvih)
00480                                                 {
00481                                                         img = ImageList.InfectVIH;
00482                                                         imgResize = new Bitmap(img,moy_taille);
00483                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00484                                                 }
00485                                                 nb_infectvih++;
00486                                         }
00487                                         else if(cell is VIH)
00488                                         {
00489                                                 if(af_vih)
00490                                                 {
00491                                                         img = ImageList.VIH;
00492                                                         g.DrawImage(img,PositionToDisplay("petit",cell.Location));
00493                                                 }
00494                                                 nb_vih++;
00495                                         }
00496                                         else
00497                                         {
00498                                                 if(af_normal)
00499                                                 {
00500                                                         img = ImageList.CellNormal;
00501                                                         imgResize = new Bitmap(img,moy_taille);
00502                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00503                                                 }
00504                                                 nb_normal++;
00505                                         }
00506                                 }
00507                         }
00508                         g.FillRectangle(stylo_blanc,2,2,(titre_sim.Length * 7),18);
00509                         g.DrawString(titre_sim,police,stylo,3,3);
00510             
00511                         // Compteur - timer
00512                         DateTime tmp_chrono;
00513                         if(LoopOn)
00514                 tmp_chrono = dtLastChrono.Add((TimeSpan)DateTime.Now.Subtract(dtChrono));
00515                         else
00516                                 tmp_chrono = dtLastChrono;
00517                         control.SetCompteur(nb_anticorp,nb_antigen,nb_cellinfect,nb_CI,nb_debris,nb_LB,nb_LT8,nb_LTc,nb_normal,nb_phago,nb_plasmo,nb_LT4,nb_LBm,nb_LT4m,nb_LT8m,nb_vih,nb_infectvih,tmp_chrono);
00518                         browser.update();
00519                         boucle_count++;
00520                         boucle_per_seconde++;
00521                         if(!LoopOn) return;
00522                         fps++;
00523                         if(LastFPS != DateTime.Now.Second)
00524                         {
00525                                 this.Text="SimImmuno by SeBeuH - Population : "+ccol.Count.ToString() + " - Cycle n° " + boucle_count.ToString() + " - Cycle(s)/sec : " + boucle_per_seconde.ToString();
00526                                 fps=0;
00527                                 LastFPS = DateTime.Now.Second;
00528                                 boucle_per_seconde = 0;
00529                         }
00530                         // Si fin de la simulation
00531                         if(ccol.Count == 0)
00532                         {
00533                                 LoopOn = false;
00534                                 log.NewEvent("Population = 0");
00535                                 log.NewEvent("Fin de la simulation");                   
00536                         }
00537                         // Fin !
00538                         Application.DoEvents();
00539                         this.Invalidate();
00540                 }
00541 
00542                 private Image MakeScreenShot()
00543                 {
00544                         // Rendu graphique seulement
00545                         Image out_img = new Bitmap(850,680);
00546                         Graphics g = null;
00547                         g = Graphics.FromImage(out_img);
00548                         Font police = new Font("Arial",10,FontStyle.Bold);
00549                         Font police_copyright = new Font("Arial",8,FontStyle.Italic);
00550                         SolidBrush stylo = new SolidBrush(Color.Black);
00551                         SolidBrush stylo_blanc = new SolidBrush(Color.White);
00552                         CellulesCollection ccol_copy = (CellulesCollection)ccol.Clone();
00553 
00554                         if(ccol_copy.Count >= 0)
00555                         {
00556                                 foreach(Cellule cell in ccol_copy)
00557                                 {
00558                                         Image img;
00559                                         Image imgResize;
00560                                         Size moy_taille = new Size(20,20);
00561                                         Size grande_taille = new Size(24,24);
00562 
00563                                         if(cell is Antigen)
00564                                         {
00565                                                 if(af_antigen)
00566                                                 {
00567                                                         img = ImageList.Antigen;
00568                                                         g.DrawImage(img,PositionToDisplay("petit",cell.Location));
00569                                                 }
00570                                         }
00571                                         else if(cell is Anticorp)
00572                                         {
00573                                                 if(af_anticorp)
00574                                                 {
00575                                                         img = ImageList.Anticorp;
00576                                                         int temp_ac = rnd_value.Next(1,4);
00577                                                         RotateFlipType rotate = RotateFlipType.RotateNoneFlipNone;
00578                                                         switch(temp_ac)
00579                                                         {
00580                                                                 case 1:
00581                                                                         rotate = RotateFlipType.Rotate90FlipNone;
00582                                                                         break;
00583                                                                 case 2:
00584                                                                         rotate = RotateFlipType.Rotate90FlipX;
00585                                                                         break;
00586                                                                 case 3:
00587                                                                         rotate = RotateFlipType.Rotate90FlipXY;
00588                                                                         break;
00589                                                                 case 4:
00590                                                                         rotate = RotateFlipType.Rotate90FlipY;
00591                                                                         break;
00592                                                         }
00593                                                         img.RotateFlip(rotate);
00594                                                         g.DrawImage(img,PositionToDisplay("petit",cell.Location));
00595                                                 }
00596                                         }
00597                                         else if(cell is LB)
00598                                         {
00599                                                 if(af_LB)
00600                                                 {
00601                                                         img = ImageList.LB;                                                     
00602                                                         imgResize = new Bitmap(img,moy_taille);
00603                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00604                                                 }
00605                                         }
00606                                         else if(cell is Phagocyte)
00607                                         {
00608                                                 if(af_phago)
00609                                                 {
00610                                                         img = ImageList.Phagocyte;                                                      
00611                                                         imgResize = new Bitmap(img,grande_taille);
00612                                                         g.DrawImage(imgResize,PositionToDisplay("grand",cell.Location));
00613                                                 }
00614                                         }
00615                                         else if(cell is Plasmocyte)
00616                                         {
00617                                                 if(af_plasmo)
00618                                                 {
00619                                                         img = ImageList.Plasmocyte;                                             
00620                                                         imgResize = new Bitmap(img,moy_taille);
00621                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00622                                                 }
00623                                         }
00624                                         else if(cell is CellInfect)
00625                                         {
00626                                                 if(af_cellinfect)
00627                                                 {
00628                                                         img = ImageList.CellInfect;
00629                                                         imgResize = new Bitmap(img,moy_taille);
00630                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00631                                                 }
00632                                         }
00633                                         else if(cell is CI)
00634                                         {
00635                                                 if(af_CI)
00636                                                 {
00637                                                         img = ImageList.CI;
00638                                                         imgResize = new Bitmap(img,moy_taille);
00639                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00640                                                 }
00641                                         }
00642                                         else if(cell is LT8)
00643                                         {
00644                                                 if(af_LT8)
00645                                                 {
00646                                                         img = ImageList.LT8;
00647                                                         imgResize = new Bitmap(img,moy_taille);
00648                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00649                                                 }
00650                                         }
00651                                         else if(cell is LTc)
00652                                         {
00653                                                 if(af_LTc)
00654                                                 {
00655                                                         img = ImageList.LTc;
00656                                                         imgResize = new Bitmap(img,moy_taille);
00657                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00658                                                 }
00659                                         }
00660                                         else if(cell is Debris)
00661                                         {
00662                                                 if(af_debris)
00663                                                 {
00664                                                         img = ImageList.Debris;
00665                                                         imgResize = new Bitmap(img,moy_taille);
00666                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00667                                                 }
00668                                         }
00669                                         else if(cell is LT4)
00670                                         {
00671                                                 if(af_LT4)
00672                                                 {
00673                                                         img = ImageList.LT4;
00674                                                         imgResize = new Bitmap(img,moy_taille);
00675                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00676                                                 }
00677                                         }
00678                                         else if(cell is LT4m)
00679                                         {
00680                                                 if(af_LT4m)
00681                                                 {
00682                                                         img = ImageList.LT4m;
00683                                                         imgResize = new Bitmap(img,moy_taille);
00684                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00685                                                 }
00686                                         }
00687                                         else if(cell is LT8m)
00688                                         {
00689                                                 if(af_LT8m)
00690                                                 {
00691                                                         img = ImageList.LT8m;
00692                                                         imgResize = new Bitmap(img,moy_taille);
00693                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00694                                                 }
00695                                         }
00696                                         else if(cell is LBm)
00697                                         {
00698                                                 if(af_LBm)
00699                                                 {
00700                                                         img = ImageList.LBm;
00701                                                         imgResize = new Bitmap(img,moy_taille);
00702                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00703                                                 }
00704                                         }
00705                                         else if(cell is InfectVIH)
00706                                         {
00707                                                 if(af_infectvih)
00708                                                 {
00709                                                         img = ImageList.InfectVIH;
00710                                                         imgResize = new Bitmap(img,moy_taille);
00711                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00712                                                 }
00713                                         }
00714                                         else if(cell is VIH)
00715                                         {
00716                                                 if(af_vih)
00717                                                 {
00718                                                         img = ImageList.VIH;
00719                                                         g.DrawImage(img,PositionToDisplay("petit",cell.Location));
00720                                                 }
00721                                         }
00722                                         else
00723                                         {
00724                                                 if(af_normal)
00725                                                 {
00726                                                         img = ImageList.CellNormal;
00727                                                         imgResize = new Bitmap(img,moy_taille);
00728                                                         g.DrawImage(imgResize,PositionToDisplay("moyen",cell.Location));
00729                                                 }
00730                                         }
00731                                 }
00732                         }
00733                         //titre
00734                         g.FillRectangle(stylo_blanc,2,2,(titre_sim.Length * 7),18);
00735                         g.DrawString(titre_sim,police,stylo,3,3);
00736                         //copyright
00737                         g.DrawString(@"(c) 2005 - SimImmuno by SeBeuH - http://sebeuh.ajsnfo.net",police_copyright,stylo,550,665);
00738                         //finalisation et renvoi de l'image
00739                         g.Dispose();
00740                         return out_img;
00741                 }
00742 
00743                 private Point PositionToDisplay(string taille_icon,Point position)
00744                 {
00745                         // Defini la position exacte du centre en fct de sa taille
00746                         Point tmp = position;
00747                         switch(taille_icon)
00748                         {
00749                                 case "petit":
00750                                         tmp.X = tmp.X - 8;
00751                                         tmp.Y = tmp.Y - 8;
00752                                         break;
00753                                 case "moyen":
00754                                         tmp.X = tmp.X - 10;
00755                                         tmp.Y = tmp.Y - 10;
00756                                         break;
00757                                 case "grand":
00758                                         tmp.X = tmp.X - 12;
00759                                         tmp.Y = tmp.Y - 12;
00760                                         break;
00761                         }
00762                         return tmp;
00763                 }
00764 
00765                 public static void SetDisplay(string nom,bool valeur)
00766                 {
00767                         // Gestion de l'affichage (cf frmControl)
00768                         switch(nom)
00769                         {
00770                                 case "normal":
00771                                         af_normal = valeur;
00772                                         break;
00773                                 case "infect":
00774                                         af_cellinfect = valeur;
00775                                         break;
00776                                 case "anticorp":
00777                                         af_anticorp = valeur;
00778                                         break;
00779                                 case "antigen":
00780                                         af_antigen = valeur;
00781                                         break;
00782                                 case "ci":
00783                                         af_CI = valeur;
00784                                         break;
00785                                 case "debris":
00786                                         af_debris = valeur;
00787                                         break;
00788                                 case "lb":
00789                                         af_LB = valeur;
00790                                         break;
00791                                 case "lt4":
00792                                         af_LT4 = valeur;
00793                                         break;
00794                                 case "lbm":
00795                                         af_LBm = valeur;
00796                                         break;
00797                                 case "lt8m":
00798                                         af_LT8m = valeur;
00799                                         break;
00800                                 case "lt4m":
00801                                         af_LT4m = valeur;
00802                                         break;
00803                                 case "lt8":
00804                                         af_LT8 = valeur;
00805                                         break;
00806                                 case "ltc":
00807                                         af_LTc = valeur;
00808                                         break;
00809                                 case "phago":
00810                                         af_phago = valeur;
00811                                         break;
00812                                 case "plasmo":
00813                                         af_plasmo = valeur;
00814                                         break;
00815                                 case "infectvih":
00816                                         af_infectvih = valeur;
00817                                         break;
00818                                 case "vih":
00819                                         af_vih = valeur;
00820                                         break;
00821                         }
00822                 }
00823                 #endregion
00824                 
00825                 #region Fonctions de base .NET
00826                 protected override void Dispose( bool disposing )
00827                 {
00828                         if( disposing )
00829                         {
00830                                 if (components != null) 
00831                                 {
00832                                         components.Dispose();
00833                                 }
00834                         }
00835                         base.Dispose( disposing );
00836                 }
00837 
00838                 #region Windows Form Designer generated code
00839                 private void InitializeComponent()
00840                 {
00841                         System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmMain));
00842                         this.mainMenu = new System.Windows.Forms.MainMenu();
00843                         this.menuItem1 = new System.Windows.Forms.MenuItem();
00844                         this.menuItem16 = new System.Windows.Forms.MenuItem();
00845                         this.menuItem7 = new System.Windows.Forms.MenuItem();
00846                         this.menuItem8 = new System.Windows.Forms.MenuItem();
00847                         this.menuItem24 = new System.Windows.Forms.MenuItem();
00848                         this.menuItem19 = new System.Windows.Forms.MenuItem();
00849                         this.menuItem9 = new System.Windows.Forms.MenuItem();
00850                         this.menuItem10 = new System.Windows.Forms.MenuItem();
00851                         this.menuItem2 = new System.Windows.Forms.MenuItem();
00852                         this.menuItem11 = new System.Windows.Forms.MenuItem();
00853                         this.menuItem15 = new System.Windows.Forms.MenuItem();
00854                         this.menuItem17 = new System.Windows.Forms.MenuItem();
00855                         this.menuItem18 = new System.Windows.Forms.MenuItem();
00856                         this.menuItem20 = new System.Windows.Forms.MenuItem();
00857                         this.menuItem21 = new System.Windows.Forms.MenuItem();
00858                         this.menuItem22 = new System.Windows.Forms.MenuItem();
00859                         this.menuItem23 = new System.Windows.Forms.MenuItem();
00860                         this.menuItem12 = new System.Windows.Forms.MenuItem();
00861                         this.menuItem3 = new System.Windows.Forms.MenuItem();
00862                         this.menuItem13 = new System.Windows.Forms.MenuItem();
00863                         this.menuItem14 = new System.Windows.Forms.MenuItem();
00864                         this.menuItem25 = new System.Windows.Forms.MenuItem();
00865                         this.menuItem26 = new System.Windows.Forms.MenuItem();
00866                         this.menuItem27 = new System.Windows.Forms.MenuItem();
00867                         this.menuItem4 = new System.Windows.Forms.MenuItem();
00868                         this.menuItem5 = new System.Windows.Forms.MenuItem();
00869                         this.menuItem6 = new System.Windows.Forms.MenuItem();
00870                         this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
00871                         this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
00872                         this.helpProvider1 = new System.Windows.Forms.HelpProvider();
00873                         // 
00874                         // mainMenu
00875                         // 
00876                         this.mainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00877                                                                                                                                                                          this.menuItem1,
00878                                                                                                                                                                          this.menuItem2,
00879                                                                                                                                                                          this.menuItem3,
00880                                                                                                                                                                          this.menuItem25,
00881                                                                                                                                                                          this.menuItem4});
00882                         // 
00883                         // menuItem1
00884                         // 
00885                         this.menuItem1.Index = 0;
00886                         this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00887                                                                                                                                                                           this.menuItem16,
00888                                                                                                                                                                           this.menuItem7,
00889                                                                                                                                                                           this.menuItem8,
00890                                                                                                                                                                           this.menuItem24,
00891                                                                                                                                                                           this.menuItem19,
00892                                                                                                                                                                           this.menuItem9,
00893                                                                                                                                                                           this.menuItem10});
00894                         this.menuItem1.Text = "&Fichier";
00895                         // 
00896                         // menuItem16
00897                         // 
00898                         this.menuItem16.Index = 0;
00899                         this.menuItem16.Text = "Nouvelle simulation";
00900                         this.menuItem16.Click += new System.EventHandler(this.menuItem16_Click);
00901                         // 
00902                         // menuItem7
00903                         // 
00904                         this.menuItem7.Index = 1;
00905                         this.menuItem7.Text = "&Charger";
00906                         this.menuItem7.Click += new System.EventHandler(this.menuItem7_Click);
00907                         // 
00908                         // menuItem8
00909                         // 
00910                         this.menuItem8.Index = 2;
00911                         this.menuItem8.Text = "&Enregistrer";
00912                         this.menuItem8.Click += new System.EventHandler(this.menuItem8_Click);
00913                         // 
00914                         // menuItem24
00915                         // 
00916                         this.menuItem24.Index = 3;
00917                         this.menuItem24.Text = "-";
00918                         // 
00919                         // menuItem19
00920                         // 
00921                         this.menuItem19.Index = 4;
00922                         this.menuItem19.Text = "&Capture d\'écran";
00923                         this.menuItem19.Click += new System.EventHandler(this.menuItem19_Click);
00924                         // 
00925                         // menuItem9
00926                         // 
00927                         this.menuItem9.Index = 5;
00928                         this.menuItem9.Text = "-";
00929                         // 
00930                         // menuItem10
00931                         // 
00932                         this.menuItem10.Index = 6;
00933                         this.menuItem10.Text = "&Quitter";
00934                         this.menuItem10.Click += new System.EventHandler(this.menuItem10_Click);
00935                         // 
00936                         // menuItem2
00937                         // 
00938                         this.menuItem2.Index = 1;
00939                         this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00940                                                                                                                                                                           this.menuItem11,
00941                                                                                                                                                                           this.menuItem15,
00942                                                                                                                                                                           this.menuItem17,
00943                                                                                                                                                                           this.menuItem12});
00944                         this.menuItem2.Text = "&Simulation";
00945                         // 
00946                         // menuItem11
00947                         // 
00948                         this.menuItem11.Index = 0;
00949                         this.menuItem11.Text = "&Démarrer/Pause";
00950                         this.menuItem11.Click += new System.EventHandler(this.menuItem11_Click);
00951                         // 
00952                         // menuItem15
00953                         // 
00954                         this.menuItem15.Index = 1;
00955                         this.menuItem15.Text = "&Acteurs de la simulation";
00956                         this.menuItem15.Click += new System.EventHandler(this.menuItem15_Click);
00957                         // 
00958                         // menuItem17
00959                         // 
00960                         this.menuItem17.Index = 2;
00961                         this.menuItem17.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
00962                                                                                                                                                                            this.menuItem18,
00963                                                                                                                                                                            this.menuItem20,
00964                                                                                                                                                                            this.menuItem21,
00965                                                                                                                                                                            this.menuItem22,
00966                                                                                                                                                                            this.menuItem23});
00967                         this.menuItem17.Text = "Modèles - Exemples";
00968                         // 
00969                         // menuItem18
00970                         // 
00971                         this.menuItem18.Index = 0;
00972                         this.menuItem18.Text = "Simulation complète";
00973                         this.menuItem18.Click += new System.EventHandler(this.menuItem18_Click);
00974                         // 
00975                         // menuItem20
00976                         // 
00977                         this.menuItem20.Index = 1;
00978                         this.menuItem20.Text = "Phagocytose";
00979                         this.menuItem20.Click += new System.EventHandler(this.menuItem20_Click);
00980                         // 
00981                         // menuItem21
00982                         // 
00983                         this.menuItem21.Index = 2;
00984                         this.menuItem21.Text = "Intégrité du milieu extra-cellulaire";
00985                         this.menuItem21.Click += new System.EventHandler(this.menuItem21_Click);
00986                         // 
00987                         // menuItem22
00988                         // 
00989                         this.menuItem22.Index = 3;
00990                         this.menuItem22.Text = "Intégrité des cellules";
00991                         this.menuItem22.Click += new System.EventHandler(this.menuItem22_Click);
00992                         // 
00993                         // menuItem23
00994                         // 
00995                         this.menuItem23.Index = 4;
00996                         this.menuItem23.Text = "Action du VIH";
00997                         this.menuItem23.Click += new System.EventHandler(this.menuItem23_Click);
00998                         // 
00999                         // menuItem12
01000                         // 
01001                         this.menuItem12.Index = 3;
01002                         this.menuItem12.Text = "Options";
01003                         this.menuItem12.Click += new System.EventHandler(this.menuItem12_Click);
01004                         // 
01005                         // menuItem3
01006                         // 
01007                         this.menuItem3.Index = 2;
01008                         this.menuItem3.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
01009                                                                                                                                                                           this.menuItem13,
01010                                                                                                                                                                           this.menuItem14});
01011                         this.menuItem3.Text = "&Affichage";
01012                         // 
01013                         // menuItem13
01014                         // 
01015                         this.menuItem13.Checked = true;
01016                         this.menuItem13.Index = 0;
01017                         this.menuItem13.Text = "&Fenêtre de contrôle";
01018                         this.menuItem13.Click += new System.EventHandler(this.menuItem13_Click);
01019                         // 
01020                         // menuItem14
01021                         // 
01022                         this.menuItem14.Checked = true;
01023                         this.menuItem14.Index = 1;
01024                         this.menuItem14.Text = "&Fenêtre d\'événements";
01025                         this.menuItem14.Click += new System.EventHandler(this.menuItem14_Click);
01026                         // 
01027                         // menuItem25
01028                         // 
01029                         this.menuItem25.Index = 3;
01030                         this.menuItem25.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
01031                                                                                                                                                                            this.menuItem6,
01032                                                                                                                                                                            this.menuItem26,
01033                                                                                                                                                                            this.menuItem27});
01034                         this.menuItem25.Text = "&Projet SimImmuno";
01035                         // 
01036                         // menuItem26
01037                         // 
01038                         this.menuItem26.Index = 1;
01039                         this.menuItem26.Text = "&Site Web du projet";
01040                         this.menuItem26.Click += new System.EventHandler(this.menuItem26_Click);
01041                         // 
01042                         // menuItem27
01043                         // 
01044                         this.menuItem27.Index = 2;
01045                         this.menuItem27.Text = "&Envoyer un commentaire";
01046                         this.menuItem27.Click += new System.EventHandler(this.menuItem27_Click);
01047                         // 
01048                         // menuItem4
01049                         // 
01050                         this.menuItem4.Index = 4;
01051                         this.menuItem4.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
01052                                                                                                                                                                           this.menuItem5});
01053                         this.menuItem4.Text = "&?";
01054                         // 
01055                         // menuItem5
01056                         // 
01057                         this.menuItem5.Index = 0;
01058                         this.menuItem5.Text = "&Aide";
01059                         this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
01060                         // 
01061                         // menuItem6
01062                         // 
01063                         this.menuItem6.Index = 0;
01064                         this.menuItem6.Text = "A &propos";
01065                         this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
01066                         // 
01067                         // frmMain
01068                         // 
01069                         this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
01070                         this.BackColor = System.Drawing.Color.White;
01071                         this.ClientSize = new System.Drawing.Size(848, 640);
01072                         this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
01073                         this.Menu = this.mainMenu;
01074                         this.Name = "frmMain";
01075                         this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
01076                         this.Text = "SimImmuno by SeBeuH";
01077                         this.Closing += new System.ComponentModel.CancelEventHandler(this.frmMain_Closing);
01078                         this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.frmMain_KeyPress);
01079                         this.Load += new System.EventHandler(this.frmMain_Load);
01080 
01081                 }
01082                 #endregion
01083 
01084                 [STAThread]
01085                 static void Main() 
01086                 {Application.Run(new frmMain());}
01087 
01088                 #endregion
01089 
01090                 #region Fonctions Windows
01091                 private void frmMain_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
01092                 {
01093                         // Rendu graphique - action
01094                         RenderPaint(sender,e);
01095                 }
01096                 private void frmMain_Closing(object sender, System.ComponentModel.CancelEventArgs e)
01097                 {
01098                         //Fermeture
01099                         LoopOn = false;
01100                 }
01101 
01102                 private void frmMain_Load(object sender, System.EventArgs e)
01103                 {
01104                         //Init. graphique
01105                         this.SetStyle(ControlStyles.DoubleBuffer,true);
01106                         this.SetStyle(ControlStyles.AllPaintingInWmPaint,true);
01107                         this.SetStyle(ControlStyles.UserPaint,true);
01108                         //Load form
01109                         browser = new frmBrowser();
01110                         opts = new frmOptions();
01111                         log = new frmLog();
01112                         log.Show();
01113                         control = new frmControl();
01114                         control.Show();
01115                         this.Focus();
01116                         //Init. variables
01117                         af_anticorp = true;
01118                         af_antigen = true;
01119                         af_cellinfect = true;
01120                         af_CI = true;
01121                         af_debris = true;
01122                         af_LB = true;
01123                         af_LT8 = true;
01124                         af_LTc = true;
01125                         af_plasmo = true;
01126                         af_normal = true;
01127                         af_phago = true;
01128                         af_LBm = true;
01129                         af_LT4 = true;
01130                         af_LT4m = true;
01131                         af_LT8m = true;
01132                         af_infectvih = true;
01133                         af_vih = true;
01134                         log_debug = false;
01135                         log_limit = false;
01136                         log_limit_size = 20;
01137                         boucle_count = 0;
01138                         boucle_per_seconde = 0;
01139                         last_choix = 1;
01140                         titre_sim = "";
01141                         // Chargé !
01142                         log.NewEvent("SimImmuno chargé");
01143                 }
01144 
01145                 private void frmMain_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
01146                 {
01147                         //Touche espace
01148                         if(e.KeyChar.ToString()==" ")
01149                         {
01150                                 Pause();
01151                         }
01152                 }
01153 
01154                 private void ClearTab()
01155                 {
01156                         // Vidage de l'ecran
01157                         LoopOn = true;
01158                         this.Invalidate();
01159                         LoopOn = false;
01160                 }
01161 
01162                 private void Pause()
01163                 {
01164                         // Demarrer-Arreter la simulation
01165                         if(ccol.Count > 0)
01166                         {
01167                                 if(!InitOn)
01168                                 {
01169                                         if(!LoopOn)
01170                                         {
01171                                                 LoopOn = true;
01172                                                 InitOn = true;
01173                                                 dtChrono = DateTime.Now;
01174                                                 this.Paint += new System.Windows.Forms.PaintEventHandler(this.frmMain_Paint);
01175                                                 this.Invalidate();
01176                                         }
01177                                         else
01178                                         {
01179                                                 LoopOn = false;
01180                                         }
01181                                 }
01182                                 else
01183                                 {
01184                                         if(!LoopOn)
01185                                         {
01186                                                 LoopOn = true;
01187                                                 dtChrono = DateTime.Now;
01188                                                 this.Invalidate();
01189                                         }
01190                                         else
01191                                         {
01192                                                 LoopOn = false;
01193                                                 dtLastChrono = dtLastChrono.Add((TimeSpan)DateTime.Now.Subtract(dtChrono));
01194                                         }
01195                                 }
01196                         }
01197                         else
01198                                 MessageBox.Show("Le simulateur est vide ! Veuillez le remplir via 'Acteurs de la simulation' du menu Simulation","SimImmuno",MessageBoxButtons.OK,MessageBoxIcon.Error);
01199                 }
01200 
01201                 #endregion
01202 
01203                 #region Menu
01204 
01205                 private void menuItem13_Click(object sender, System.EventArgs e)
01206                 {
01207                         //frmControl
01208                         if(menuItem13.Checked)
01209                         {
01210                                 menuItem13.Checked = false;
01211                                 control.Close();
01212                                 this.Focus();
01213                         }
01214                         else
01215                         {
01216                                 menuItem13.Checked = true;
01217                                 control = new frmControl();
01218                                 control.Show();
01219                                 this.Focus();
01220                         }
01221                 }
01222 
01223                 private void menuItem10_Click(object sender, System.EventArgs e)
01224                 {
01225                         //Quitter
01226                         if(LoopOn)
01227                                 Pause();
01228                         Application.Exit();
01229                 }
01230 
01231                 private void menuItem11_Click(object sender, System.EventArgs e)
01232                 {
01233                         //Start-Pause
01234                         Pause();
01235                 }
01236 
01237                 private void menuItem7_Click(object sender, System.EventArgs e)
01238                 {
01239                         //Charger
01240                         try
01241                         {
01242                                 openFileDialog1.Filter = "Fichiers SIM (*.sim)|*.sim|Tous fichiers (*.*)|*.*";
01243                                 openFileDialog1.FilterIndex = 1;
01244                                 openFileDialog1.RestoreDirectory = true;
01245                                 if(openFileDialog1.ShowDialog() == DialogResult.OK)
01246                                 {
01247                                         string file_env = openFileDialog1.FileName;
01248                                         RestartSim("Fichier : " + openFileDialog1.FileName.ToString());
01249                                         Stream str = File.Open(file_env,FileMode.Open);
01250                                         System.Runtime.Serialization.Formatters.Binary.BinaryFormatter binFormat=new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
01251                                         frmMain.ccol = (CellulesCollection)binFormat.Deserialize(str);
01252                                         str.Close();
01253                                         frmMain.SetLoadOn(true);
01254                                         Pause();Pause();
01255                                         MessageBox.Show("Environnement chargé","SimImmuno",MessageBoxButtons.OK,MessageBoxIcon.Information);
01256                                 }
01257                         }
01258                         catch(Exception exx)
01259                         {
01260                                 MessageBox.Show("Erreur : " + exx.Message.ToString(),"SimImmuno",MessageBoxButtons.OK,MessageBoxIcon.Error);
01261                         }
01262                 }
01263 
01264                 private void menuItem8_Click(object sender, System.EventArgs e)
01265                 {
01266                         //Enregistrer
01267                         try
01268                         {
01269                                 CellulesCollection ccol_copy = (CellulesCollection)frmMain.ccol.Clone();
01270 
01271                                 saveFileDialog1.Filter = "Fichiers SIM (*.sim)|*.sim|Tous fichiers (*.*)|*.*";
01272                                 saveFileDialog1.FilterIndex = 1;
01273                                 saveFileDialog1.RestoreDirectory = true;
01274 
01275                                 if(saveFileDialog1.ShowDialog() == DialogResult.OK)
01276                                 {
01277                                         Stream str = File.Create(saveFileDialog1.FileName.ToString());
01278                                         System.Runtime.Serialization.Formatters.Binary.BinaryFormatter binFormat = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
01279                                         binFormat.Serialize(str,ccol_copy);
01280                                         str.Close();
01281                                         MessageBox.Show("Environnement enregistré","SimImmuno",MessageBoxButtons.OK,MessageBoxIcon.Information);
01282                                 }
01283                         }
01284                         catch(Exception exx)
01285                         {
01286                                 MessageBox.Show("Erreur : " + exx.Message.ToString(),"SimImmuno",MessageBoxButtons.OK,MessageBoxIcon.Error);
01287                         }
01288                 }
01289 
01290                 private void menuItem12_Click(object sender, System.EventArgs e)
01291                 {
01292                         //frmOptions
01293                         opts.Show();
01294                         opts.Focus();
01295                 }
01296 
01297                 private void menuItem5_Click(object sender, System.EventArgs e)
01298                 {
01299                         //Aide
01300 //                      helpProvider1.HelpNamespace = Directory.GetCurrentDirectory() + "\\simimmuno.chm";
01301 //                      Help.ShowHelp(this,helpProvider1.HelpNamespace);
01302 //                      MessageBox.Show("Aide en construction...\nPas de temps, c'est le bac :-p\nSi quelqu'un veut s'en occuper, qu'il me contacte...","SimImmuno",MessageBoxButtons.OK,MessageBoxIcon.Information);
01303                         try
01304                         {
01305                                 System.Diagnostics.Process procIE= new System.Diagnostics.Process();
01306                                 procIE.StartInfo.FileName = @"iexplore.exe";
01307                                 procIE.StartInfo.Arguments = @"http://simimmuno.ajsinfo.net/Default.aspx?path=docs";
01308                                 procIE.Start();
01309                         }
01310                         catch(Exception exx)
01311                         {
01312                                 MessageBox.Show(@"Erreur lors de l'ouverture du site http://simimmuno.ajsinfo.net." + "\nDescription: " + exx.Message.ToString(),"SimImmuno",MessageBoxButtons.OK,MessageBoxIcon.Error);
01313                         }       
01314                 }
01315 
01316                 private void menuItem6_Click(object sender, System.EventArgs e)
01317                 {
01318                         //A propos
01319                         Assembly myAppVer = Assembly.Load("simimmuno");
01320                         string version = myAppVer.GetName().Version.Major.ToString() + "." + myAppVer.GetName().Version.Minor.ToString() + " Revision " + myAppVer.GetName().Version.Revision.ToString() + " (Build : " + myAppVer.GetName().Version.Build.ToString() + ")";
01321                         string message = @"SimImmuno version " + version + "\nEcrit par Sébastien WARIN (SeBeuH) en C#\nSimImmuno est un simulateur des défenses immunitaires du programme de TS.\nMerci à Mme DUPAS, professeur d'SVT au lycée Jean Perrin (Lambersart),\n pour son aide au niveau scientifique.\nSimImmuno est distribué sous license GPL\n(c) 2005 http://simimmuno.ajsinfo.net";
01322                         MessageBox.Show(message,"SimImmuno by SeBeuH",MessageBoxButtons.OK,MessageBoxIcon.Information);
01323                 }
01324 
01325                 private void menuItem14_Click(object sender, System.EventArgs e)
01326                 {
01327                         //frmLog
01328                         if(menuItem14.Checked)
01329                         {
01330                                 menuItem14.Checked = false;
01331                                 log.Close();
01332                                 this.Focus();
01333                         }
01334                         else
01335                         {
01336                                 menuItem14.Checked = true;
01337                                 log = new frmLog();
01338                                 log.Show();
01339                                 this.Focus();
01340                         }
01341                 }
01342 
01343                 private void menuItem15_Click(object sender, System.EventArgs e)
01344                 {
01345                         //frmBrowser
01346                         LoopOn = false; 
01347                         browser.Show();
01348                         browser.Focus();
01349                 }
01350 
01351                 private void menuItem16_Click(object sender, System.EventArgs e)
01352                 {
01353                         //nouvelle simulation
01354                         RestartSim("");
01355                 }
01356 
01357                 private void menuItem19_Click(object sender, System.EventArgs e)
01358                 {
01359                         //capture d'ecran
01360                         if(ccol.Count != 0)
01361                         {
01362                                 try
01363                                 {
01364                                         saveFileDialog1.Filter = "Images JPG (*.jpg)|*.jpg|Tous fichiers (*.*)|*.*";
01365                                         saveFileDialog1.FilterIndex = 1;
01366                                         saveFileDialog1.RestoreDirectory = true;
01367 
01368                                         if(saveFileDialog1.ShowDialog() == DialogResult.OK)
01369                                         {
01370                                                 Image img_tmp = MakeScreenShot();
01371                                                 img_tmp.Save(saveFileDialog1.FileName.ToString());
01372                                                 MessageBox.Show("Capture enregistrée","SimImmuno",MessageBoxButtons.OK,MessageBoxIcon.Information);
01373                                         }
01374                                 }
01375                                 catch(Exception exx)
01376                                 {
01377                                         MessageBox.Show("Erreur : " + exx.Message.ToString(),"SimImmuno",MessageBoxButtons.OK,MessageBoxIcon.Error);
01378                                 }
01379                         }
01380                         else
01381                                 MessageBox.Show("Erreur : le simulateur est vide !","SimImmuno",MessageBoxButtons.OK,MessageBoxIcon.Error);
01382                 }
01383 
01384                 private void menuItem26_Click(object sender, System.EventArgs e)
01385                 {
01386                         //site web simimmuno
01387                         try
01388                         {
01389                                 System.Diagnostics.Process procIE= new System.Diagnostics.Process();
01390                                 procIE.StartInfo.FileName = @"iexplore.exe";
01391                                 procIE.StartInfo.Arguments = @"http://simimmuno.ajsinfo.net/";
01392                                 procIE.Start();
01393                         }
01394                         catch(Exception exx)
01395                         {
01396                                 MessageBox.Show(@"Erreur lors de l'ouverture du site http://simimmuno.ajsinfo.net." + "\nDescription: " + exx.Message.ToString(),"SimImmuno",MessageBoxButtons.OK,MessageBoxIcon.Error);
01397                         }
01398                 }
01399 
01400                 private void menuItem27_Click(object sender, System.EventArgs e)
01401                 {
01402                         //envoyer commentaire
01403                         frmSendComm sendmail = new frmSendComm();
01404                         sendmail.Show();
01405                 }
01406 
01407                 #endregion
01408 
01409                 #region Exemples
01410                 private void menuItem18_Click(object sender, System.EventArgs e)
01411                 {
01412                         //complete
01413                         LoadExemple("complet","Simulation des défenses immunitaires");
01414                 }
01415 
01416                 private void menuItem23_Click(object sender, System.EventArgs e)
01417                 {
01418                         //test VIH
01419                         LoadExemple("VIH","Infection de l'organisme par le VIH");
01420                 }
01421 
01422                 private void menuItem20_Click(object sender, System.EventArgs e)
01423                 {
01424                         //phago
01425                         LoadExemple("phagocytose","La phagocytose des débris cellulaires et complexes immuns");
01426                 }
01427 
01428                 private void menuItem21_Click(object sender, System.EventArgs e)
01429                 {
01430                         //extra
01431                         LoadExemple("extracell","Intégrité du milieu extra-cellulaire par les LB");
01432                 }
01433 
01434                 private void menuItem22_Click(object sender, System.EventArgs e)
01435                 {
01436                         //integcell
01437                         LoadExemple("intercell","Intégrité des cellules par les LT8");
01438                 }
01439 
01440                 private void LoadExemple(string fichier,string titre)
01441                 {
01442                         //Charger un exepmle
01443                         try
01444                         {
01445                                 RestartSim(titre);
01446                                 Stream str = Assembly.GetExecutingAssembly().GetManifestResourceStream("SimImmuno.exemples." + fichier + ".sim");
01447                                 System.Runtime.Serialization.Formatters.Binary.BinaryFormatter binFormat=new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
01448                                 frmMain.ccol = (CellulesCollection)binFormat.Deserialize(str);
01449                                 str.Close();
01450                                 frmMain.SetLoadOn(true);
01451                                 Pause();Pause();
01452                                 MessageBox.Show("Exemple chargé","SimImmuno",MessageBoxButtons.OK,MessageBoxIcon.Information);
01453                         }
01454                         catch(Exception exx)
01455                         {
01456                                 MessageBox.Show("Erreur : " + exx.Message.ToString(),"SimImmuno",MessageBoxButtons.OK,MessageBoxIcon.Error);
01457                         }
01458                 }
01459                 #endregion
01460         }
01461 }

Generated on Sat Jun 4 15:03:40 2005 for SimImmuno by  doxygen 1.4.2