private void btnAjouter_Click(object sender, EventArgs e) { RendezVous monRdv = new RendezVous(); monRdv.Texte = txtText.Text; monRdv.Debut = mcDebut.SelectionStart.AddMinutes(editView1.DebutJour); monRdv.Duree = tbDuree.Value; monRdv.Couleur = txtColor.BackColor; editView1.Items.Add(monRdv); editView1.Invalidate(); clearFields(); }
public EditView() { this.NbJours = 5; this.DebutJour = 480; this.FinJour = 1140; this.PremierJour = DateTime.Today; this.Marge = new SizeF(48, 32); this.selection = null; this.Intervalle = 60; trackers = null; /*Penser à initialiser avec la liste de rendez-vous de la base*/ this.Items = new ArrayList(); SetStyle(ControlStyles.OptimizedDoubleBuffer, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); InitializeComponent(); }
private void editView1_DragOver(object sender, DragEventArgs e) { //récupère les coordonnées de la souris dans la fenêtre Point loc = PointToClient(new Point(e.X, e.Y)); // Si le tracker existe if (editView1.tracker != null) { //récupère le curseur de copie si la touche Control est appuyée ou //si l'objet en cours de mouvement n'est pas dans l’enploi du temps if (((e.KeyState & 8) == 8 || !editView1.Items.Contains(editView1.tracker.rdv))) e.Effect = DragDropEffects.Copy; else if (loc.X < editView1.Marge.Width || loc.Y < editView1.Marge.Height) e.Effect = DragDropEffects.None; else e.Effect = DragDropEffects.Move; // on déplace le tracker mais pas l'objet qu'il contient if (e.Effect == DragDropEffects.Move || e.Effect == DragDropEffects.Copy) { //gestion du chevauchement DateTime date = QuelleHeureEstIl(loc); int minute = ((date.Minute / editView1.Intervalle) * editView1.Intervalle) + 60 * date.Hour; if (minute > editView1.FinJour - editView1.tracker.rdv.Duree) { minute = editView1.FinJour - editView1.tracker.rdv.Duree; } date = date.Date.AddMinutes(minute); RendezVous aComparer = new RendezVous(editView1.Selection.Texte, date, editView1.Selection.Duree, editView1.Selection.Couleur); bool seChevauche = false; foreach (RendezVous rdv in editView1.Items) { if (rdv != editView1.Selection && rdv.SeChevauche(aComparer)) { seChevauche = true; break; } } if (!seChevauche) { editView1.tracker.Debut = date.Date; editView1.tracker.Debut = editView1.tracker.Debut.AddMinutes(minute); } else e.Effect = DragDropEffects.None; } editView1.Invalidate(); } }
private void AfficheRDVSelectione(RendezVous monRDV, Graphics g) { TimeSpan dateTemp = monRDV.Debut.Subtract(editView1.PremierJour); if (dateTemp.Days >= 0 && dateTemp.Hours >= 0 && dateTemp.Minutes >= 0) { float x = editView1.Marge.Width + (dateTemp.Days * editView1.LargeurJour); float y = editView1.Marge.Height + (((monRDV.Debut.Minute + (monRDV.Debut.Hour * 60) - editView1.DebutJour) * editView1.HauteurMinute)); RectangleF monRect = new RectangleF(new PointF(x, y), new SizeF(new PointF(editView1.LargeurJour, monRDV.Duree * editView1.HauteurMinute))); g.DrawRectangle(new Pen(Color.Red), monRect.X, monRect.Y, monRect.Width, monRect.Height); } }
private void AfficheRDV(RendezVous monRDV, Graphics g) { TimeSpan dateTemp = monRDV.Debut.Subtract(editView1.PremierJour); if (dateTemp.Days >= 0 && dateTemp.Hours >= 0 && dateTemp.Minutes >= 0) { float x = editView1.Marge.Width + (dateTemp.Days * editView1.LargeurJour); float y = editView1.Marge.Height + (((monRDV.Debut.Minute + (monRDV.Debut.Hour * 60) - editView1.DebutJour) * editView1.HauteurMinute)); RectangleF monRect = new RectangleF(new PointF(x, y), new SizeF(new PointF(editView1.LargeurJour, monRDV.Duree * editView1.HauteurMinute))); g.FillRectangle(new System.Drawing.Drawing2D.LinearGradientBrush( monRect, monRDV.Couleur, monRDV.Couleur, System.Drawing.Drawing2D.LinearGradientMode.ForwardDiagonal), monRect); g.DrawRectangle(new Pen(Color.Black), monRect.X, monRect.Y, monRect.Width, monRect.Height); g.DrawString(monRDV.ToString(), this.Font, new SolidBrush(Color.Black), new PointF(monRect.X, monRect.Y)); } }
public bool SeChevauche(RendezVous rdv) { return (Debut.CompareTo(rdv.Debut) <= 0 && Debut.AddMinutes(Duree).CompareTo(rdv.Debut) > 0) || (Debut.CompareTo(rdv.Debut) >= 0 && Debut.CompareTo(rdv.Debut.AddMinutes(rdv.Duree)) < 0); }
public static RendezVous FromDataObject(IDataObject obj) { RendezVous rdv = obj.GetData(DataFormats.Serializable) as RendezVous; if (rdv == null) { string str = obj.GetData(DataFormats.Text) as String; rdv = new RendezVous(str, DateTime.Now, 60, Color.Green); } return rdv; }
public RdvTracker(RendezVous rdv) { this.rdv = rdv; this.Debut = rdv.Debut; }