Petit calendrier avec annotations.
Pratique pour des RDV ou autres évenements.
Utilise un MounthCalendar
Source / Exemple :
Public Class Form1
Public rb1 As String
Public protect As Boolean = False
Function PrevInstance() As Boolean
If UBound(Diagnostics.Process.GetProcessesByName _
(Diagnostics.Process.GetCurrentProcess.ProcessName)) _
> 0 Then
Return True '' Le programme n'est pas déjà executé
Else
Return False '' Le programme est déjà executé !!
End If
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If PrevInstance() Then
MessageBox.Show("JaCalendar est déjà en cours d'exécution.", "JaCalendar (raffika)", MessageBoxButtons.OK, MessageBoxIcon.Information)
End
End If
Dim infos
Dim datedufichiercorrespondant As String
Dim sansextention As String
For Each foundFile As String In My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.CurrentDirectory & "\Notes\", FileIO.SearchOption.SearchAllSubDirectories, "*.TXT")
infos = My.Computer.FileSystem.GetFileInfo(foundFile) '' pour obtenir des infos sur le fichier trouvé
datedufichiercorrespondant = infos.Name '' obtient le nom du fichier seul
sansextention = datedufichiercorrespondant.Substring(0, datedufichiercorrespondant.Length - 4) '' Fait une manipulation pour obtenir juste le nom du fichier en enlevant les 4 derniers caratères qui correspondent à .TXT
MonthCalendar1.AddBoldedDate(sansextention) ''On ajoute une date en gras
ListBox1.Items.Add(sansextention) '' et aussi on la met dans le listbox1
''pour savoir les fichiers présents ps : la listbox1 n'est pas visible
Next
''MonthCalendar1.MonthlyBoldedDates = MonthCalendar1.MonthlyBoldedDates ''On met à jour
MonthCalendar1.UpdateBoldedDates()
''la liste des dates en gras ...
''Ici on verifie si la date du jour contient une note
If ListBox1.Items.Contains(Today.ToLongDateString) Then
''Si la listbox1 contient la date du jour
''afficher le contenu du fichier dans le richtextbox :
rb1 = miseenformedate(Today.ToLongDateString) & Environment.NewLine
rb1 &= System.IO.File.ReadAllText(My.Computer.FileSystem.CurrentDirectory & "\Notes\" & Today.ToLongDateString & ".TXT", System.Text.Encoding.Default)
Else ''sinon, on affiche la date dans le richtextbox et on met en dessous 'pas de notes'
rb1 = miseenformedate(Today.ToLongDateString) & Environment.NewLine
rb1 &= "Pas de notes"
End If
protect = True
RichTextBox1.Text = rb1
protect = False
Timer1_Tick(Me, System.EventArgs.Empty)
End Sub
Private Sub MonthCalendar1_DateChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateChanged
''La date sélectionné a changée, mettre à jour le richtextbox :
If ListBox1.Items.Contains(e.Start.ToLongDateString) Then
rb1 = miseenformedate(e.Start.ToLongDateString) & Environment.NewLine
rb1 &= System.IO.File.ReadAllText(My.Computer.FileSystem.CurrentDirectory & "\Notes\" & e.Start.ToLongDateString & ".TXT", System.Text.Encoding.Default)
Else ''sinon, on affiche la date dans le richtextbox et on met en dessous 'pas de notes'
rb1 = miseenformedate(e.Start.ToLongDateString) & Environment.NewLine
rb1 &= "Pas de notes"
End If
protect = True
RichTextBox1.Text = rb1
protect = False
End Sub
Function miseenformedate(ByVal longuedate As String) As String
''Cette fonction met en forme la date, par exemple
''si on envoie à cette fonction :
''mercredi 13 octobre 2010
''elle renverra :
''Mercredi 13 Octobre 2010
Dim table() As String
table = Split(longuedate, " ")
Dim result As String = ""
result &= UCase(table(0).Substring(0, 1))
result &= table(0).Substring(1, table(0).Length - 1)
result &= " " & table(1) & " "
result &= UCase(table(2).Substring(0, 1))
result &= table(2).Substring(1, table(2).Length - 1)
result &= " " & table(3)
Return result '' C'est juste pour faire un peu mieux...
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
''On clique sur créer/modifier une note, donc
''demander si on souhaite la modifier
If ListBox1.Items.Contains(MonthCalendar1.SelectionStart.ToLongDateString) Then
If MessageBox.Show("Une note est déjà présente pour le " & MonthCalendar1.SelectionStart & Environment.NewLine & "Souhaitez-vous là modifier ?", Me.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.No Then
Exit Sub
End If
End If
''sinon afficher form2
Form2.ShowDialog()
End Sub
Private Sub RichTextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles RichTextBox1.KeyPress
e.Handled = True '' Annule la touche pressée pour interdire la modification du Richtextbox1
Beep() ''Emet un son windows
End Sub
Private Sub Form1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
If e.Button = Windows.Forms.MouseButtons.Right Then
ContextMenuStrip1.Show(MousePosition.X, MousePosition.Y)
End If
End Sub
Private Sub ExplorerLesNotesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExplorerLesNotesToolStripMenuItem.Click
System.Diagnostics.Process.Start(My.Computer.FileSystem.CurrentDirectory & "\Notes\")
End Sub
Private Sub AideToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AideToolStripMenuItem.Click
MessageBox.Show("JaCalendar" & vbCrLf & vbCrLf & "Pour ajouter une note, cliquez sur la date voulue," & vbCrLf & "puis cliquez sur le bouton Ajouter ou modifier une note, tout en bas." & vbCrLf & "Pour supprimer une note, cliquez sur ce même bouton," & vbCrLf & "pour l'éditer, puis cliquez avec le bouton droit de la souris" & vbCrLf & "sur Enregistrer, puis cliquez sur Supprimer la note.", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub AProposToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AProposToolStripMenuItem.Click
MessageBox.Show("JaCalendar" & vbCrLf & vbCrLf & "Petit calendrier avec annotations." & vbCrLf & vbCrLf & "Réalisé avec Visual Basic 2008 Express" & vbCrLf & "Auteur : raffika" & vbCrLf & "License : Freeware", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Dim binary As String = "0"
Dim ii As Boolean
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ii = Not ii
Label1.Text = "Aujourd'hui : " & miseenformedate(Today.ToLongDateString) & " - " & miseenformeheure(ii)
End Sub
Function miseenformeheure(ByVal i As Boolean)
Dim s As String = DateAndTime.Now.Hour
If s.Length = 1 Then s = "0" & TimeOfDay.Hour
Dim mm As String = DateAndTime.Now.Minute
If mm.Length = 1 Then mm = "0" & TimeOfDay.Minute
If i Then
Return s & ":" & mm
Else
Return s & " " & mm
End If
'resultat &= "H" '& If(mm.Length <> 1, "0" & mm, mm)
'Dim HAZARD As Double = Rnd(Rnd(1))
'wl(HAZARD)
'Dim binary As String = ""
'If HAZARD < 0.5 Then
'binary = 0
'Else
' binary = 1
'End If
'wl(binary)
'MessageBox.Show("HAZARD = " & Rnd(Rnd(1)))
'Dim unoudiff As Integer = HAZARD
'Console.WriteLine("HAZARD.length = ")
'Console.WriteLine("(if(randomtest.lenght=1,Nothing,False)) " & (If(randomtest.Length = 1, "0" & "9", "10")))
'Console.WriteLine(If(mm.Length = 1, "0" & mm, mm))
'renvoyer nothing, object !!
'''''''''''''''''''''''''''''''''''''''
' firstChoice is a nullable value type.
' Dim firstChoice? As Integer = Nothing
'Dim secondChoice As Integer = 1128
' If expression with three arguments.
'Console.WriteLine(If(firstChoice IsNot Nothing, firstChoice, secondChoice))
' If expression with two arguments.
'Console.WriteLine(If(firstChoice, secondChoice))
End Function
Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
If protect = False Then
RichTextBox1.Text = rb1
End If
End Sub
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
PictureBox1.Image = My.Resources.FD ''
MonthCalendar1.SelectionStart = MonthCalendar1.SelectionStart.AddDays(1)
fd.Start()
End Sub
Private Sub PictureBox1_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseEnter
PictureBox1.Image = My.Resources.FDc
End Sub
Private Sub PictureBox1_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseLeave
PictureBox1.Image = My.Resources.FDn
End Sub
Private Sub PictureBox2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseDown
PictureBox2.Image = My.Resources.FG ''
MonthCalendar1.SelectionStart = MonthCalendar1.SelectionStart.AddDays(-1)
fg.Start()
End Sub
Private Sub PictureBox2_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.MouseEnter
PictureBox2.Image = My.Resources.FGc
End Sub
Private Sub PictureBox2_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox2.MouseLeave
PictureBox2.Image = My.Resources.FGn
End Sub
Private Sub PictureBox2_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseUp
PictureBox2.Image = My.Resources.FGc
fg.Stop()
End Sub
Private Sub fg_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles fg.Tick
MonthCalendar1.SelectionStart = MonthCalendar1.SelectionStart.AddDays(-1)
End Sub
Private Sub fd_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles fd.Tick
MonthCalendar1.SelectionStart = MonthCalendar1.SelectionStart.AddDays(1)
End Sub
Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
PictureBox1.Image = My.Resources.FDc
fd.Stop()
End Sub
End Class
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.