public void createBlock(int x, int heureDebut, DateTime debut, DateTime fin) { string hDebut = heureDebut + ""; string hFin = (heureDebut + 1) + ""; CreationBloc creationbloc = new CreationBloc(hDebut, hFin); creationbloc.ShowDialog(); if (creationbloc.isValide()) { //Compute Nouvelle Date ** Ajouter validation ** int dateDebut = int.Parse(creationbloc.getHd()); int dateFin = int.Parse(creationbloc.getHf()); bool isPreset = creationbloc.getPreset(); DateTime tempDebut = new DateTime(debut.Year, debut.Month, debut.Day, dateDebut, debut.Minute, debut.Second); DateTime tempFin = new DateTime(fin.Year, fin.Month, fin.Day, dateFin, fin.Minute, fin.Second) - new TimeSpan(0, 0, 0, 1); //Affecte le bloc Bloc tempBloc = new Bloc(tempDebut, tempFin, 0, 0, isPreset); if (placementValide(tempBloc)) { if (profil != null) { if (loader == null && laGrille.isPref) { profil.addPref(tempBloc); } else if (loader == null && !laGrille.isPref) { profil.addDispo(tempBloc); } tempBloc.draw(width, grfx); } else { //Ajout du block valide tempBloc.draw(width, grfx); loader.bloc.Add(tempBloc); } } else { MessageBox.Show("Placement invalide"); } } creationbloc.Dispose(); }
public void createBlock(int x, int heureDebut, DateTime debut, DateTime fin) { string hDebut = heureDebut + ""; string hFin = (heureDebut + 1) + ""; CreationBloc creationbloc = new CreationBloc(hDebut, hFin); creationbloc.ShowDialog(); if (creationbloc.isValide()) { //Compute Nouvelle Date ** Ajouter validation ** int dateDebut = int.Parse(creationbloc.getHd()); int dateFin = int.Parse(creationbloc.getHf()); bool isPreset = creationbloc.getPreset(); DateTime tempDebut = new DateTime(debut.Year, debut.Month, debut.Day, dateDebut, debut.Minute, debut.Second); DateTime tempFin = new DateTime(fin.Year, fin.Month, fin.Day, dateFin, fin.Minute, fin.Second) - new TimeSpan(0, 0, 0, 1); //Affecte le bloc Bloc tempBloc = new Bloc(tempDebut, tempFin, 0, 0, isPreset); if (placementValide(tempBloc)) { if (profil != null) { if (loader == null && laGrille.isPref) profil.addPref(tempBloc); else if (loader == null && !laGrille.isPref) profil.addDispo(tempBloc); tempBloc.draw(width, grfx); } else { //Ajout du block valide tempBloc.draw(width, grfx); loader.bloc.Add(tempBloc); } } else MessageBox.Show("Placement invalide"); } creationbloc.Dispose(); }