Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub displayTask(task As Task, modifiable As Boolean)
- 'add a border to the displayed task in the list of tasks
- CType(task.controls(0), Panel).BorderStyle = BorderStyle.FixedSingle
- 'remove the controls that are already contained in the display area
- grpTask.Controls.Clear()
- 'index allowing to compute the vertical position of the controls
- Dim indexY = 0
- 'creation of a Panel in which to add the controls
- Dim pnlTask As New Panel
- pnlTask.AutoSize = True
- pnlTask.Anchor = AnchorStyles.Left & AnchorStyles.Bottom & AnchorStyles.Right & AnchorStyles.Top
- If Not modifiable Then
- 'WRITE HERE THE CODE FOR CREATING THE CONTROLS NEEDED FOR DISPLAYING A TASK THAT CANNOT BE MODIFIED
- '=> LABELS
- Dim lblTitle As New Label
- Dim lblDescription As New Label
- Dim lblCategory As New Label
- Dim lblDeadline As New Label
- Dim cat As String
- Select Case task.category
- Case Category.family
- cat = "family"
- Case Category.home
- cat = "home"
- Case Category.home
- cat = "homework"
- Case Category.leisure
- cat = "leisure"
- Case Else
- cat = "homework"
- End Select
- 'Initializing lblTitle
- lblTitle.Text = "Title : " + task.title
- lblTitle.MaximumSize = New Size(190, 0)
- lblTitle.AutoSize = True
- lblTitle.Location = New Point(10, 0)
- 'Initializing lblDescription
- lblDescription.Text = "Description : " + task.description
- lblDescription.AutoSize = True
- lblDescription.MaximumSize = New Size(190, 100)
- lblDescription.Location = New Point(10, 15)
- 'Initializing lblCategory
- lblCategory.Text = "Category : " + cat
- lblCategory.AutoSize = True
- lblCategory.Location = New Point(10, 120)
- 'Initializing lblDeadline
- lblDeadline.Text = "Deadline : " + task.deadline.Day.ToString + "/" + task.deadline.Month.ToString + "/" + task.deadline.Year.ToString
- lblDeadline.AutoSize = True
- lblDeadline.Location = New Point(10, 135)
- With pnlTask
- .Controls.Add(lblTitle)
- .Controls.Add(lblDescription)
- .Controls.Add(lblCategory)
- .Controls.Add(lblDeadline)
- End With
- Else
- 'WRITE HERE THE CODE FOR CREATING THE CONTROLS NEEDED FOR DISPLAYING A TASK THAT CAN BE MODIFIED
- '=> TEXTBOX, COMBOBOX, CHECKBOX AD DATETIMEPICKER
- '=> OK AND CANCEL BUTTONS
- 'references to controls that will be used to modify a task
- txtModifTitle = New TextBox
- txtModifDescr = New TextBox
- cboModifCat = New ComboBox
- chkModifDate = New CheckBox
- dateModif = New DateTimePicker
- Dim btnOk As New Button
- Dim btnCancel As New Button
- 'Initializing txtModifTitle
- txtModifTitle.Text = task.title
- txtModifTitle.Width = 150
- 'Initializing txtModifDescr
- With txtModifDescr
- .Text = task.description
- .Height = 90
- .Width = 190
- .Multiline = True
- .Top = txtModifTitle.Top + txtModifTitle.Height + 5
- End With
- 'Initializing cboModifCat
- cboModifCat.Top = txtModifDescr.Top + txtModifDescr.Height + 5
- Dim cats As Array
- cats = System.Enum.GetValues(GetType(Category))
- For Each cat In cats
- cboModifCat.Items.Add(cat)
- Next
- cboModifCat.SelectedIndex = task.category
- 'Initializing chkModifDate
- chkModifDate.Text = "Deadline"
- chkModifDate.Top = cboModifCat.Top + cboModifCat.Height + 5
- 'Initializing dateModif
- dateModif.Top = chkModifDate.Top + chkModifDate.Height + 5
- dateModif.Width = 180
- 'Initializing btnOk
- btnOk.Text = "Ok"
- btnOk.Top = dateModif.Top + dateModif.Height + 5
- AddHandler btnOk.Click, AddressOf clickOk
- 'Initializing btnCancel
- btnCancel.Text = "Cancel"
- btnCancel.Top = btnOk.Top
- btnCancel.Left = btnOk.Left + btnOk.Width + 5
- AddHandler btnCancel.Click, AddressOf clickCancel
- With pnlTask
- .Controls.Add(txtModifTitle)
- .Controls.Add(txtModifDescr)
- .Controls.Add(cboModifCat)
- .Controls.Add(chkModifDate)
- .Controls.Add(dateModif)
- .Controls.Add(btnOk)
- .Controls.Add(btnCancel)
- End With
- End If
- 'add the panel containing the controls to the display area.
- pnlTask.Location = New Point(5, 20)
- grpTask.Controls.Add(pnlTask)
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement