Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 5.18 KB | None | 0 0
  1.  Private Sub displayTask(task As Task, modifiable As Boolean)
  2.         'add a border to the displayed task in the list of tasks
  3.         CType(task.controls(0), Panel).BorderStyle = BorderStyle.FixedSingle
  4.         'remove the controls that are already contained in the display area
  5.         grpTask.Controls.Clear()
  6.         'index allowing to compute the vertical position of the controls
  7.         Dim indexY = 0
  8.         'creation of a Panel in which to add the controls
  9.         Dim pnlTask As New Panel
  10.         pnlTask.AutoSize = True
  11.         pnlTask.Anchor = AnchorStyles.Left & AnchorStyles.Bottom & AnchorStyles.Right & AnchorStyles.Top
  12.  
  13.         If Not modifiable Then
  14.             'WRITE HERE THE CODE FOR CREATING THE CONTROLS NEEDED FOR DISPLAYING A TASK THAT CANNOT BE MODIFIED
  15.             '=> LABELS
  16.             Dim lblTitle As New Label
  17.             Dim lblDescription As New Label
  18.             Dim lblCategory As New Label
  19.             Dim lblDeadline As New Label
  20.  
  21.             Dim cat As String
  22.  
  23.             Select Case task.category
  24.                 Case Category.family
  25.                     cat = "family"
  26.                 Case Category.home
  27.                     cat = "home"
  28.                 Case Category.home
  29.                     cat = "homework"
  30.                 Case Category.leisure
  31.                     cat = "leisure"
  32.                 Case Else
  33.                     cat = "homework"
  34.             End Select
  35.  
  36.             'Initializing lblTitle
  37.             lblTitle.Text = "Title : " + task.title
  38.             lblTitle.MaximumSize = New Size(190, 0)
  39.             lblTitle.AutoSize = True
  40.             lblTitle.Location = New Point(10, 0)
  41.  
  42.             'Initializing lblDescription
  43.             lblDescription.Text = "Description : " + task.description
  44.             lblDescription.AutoSize = True
  45.             lblDescription.MaximumSize = New Size(190, 100)
  46.             lblDescription.Location = New Point(10, 15)
  47.  
  48.             'Initializing lblCategory
  49.             lblCategory.Text = "Category : " + cat
  50.             lblCategory.AutoSize = True
  51.             lblCategory.Location = New Point(10, 120)
  52.  
  53.             'Initializing lblDeadline
  54.             lblDeadline.Text = "Deadline : " + task.deadline.Day.ToString + "/" + task.deadline.Month.ToString + "/" + task.deadline.Year.ToString
  55.             lblDeadline.AutoSize = True
  56.             lblDeadline.Location = New Point(10, 135)
  57.  
  58.             With pnlTask
  59.                 .Controls.Add(lblTitle)
  60.                 .Controls.Add(lblDescription)
  61.                 .Controls.Add(lblCategory)
  62.                 .Controls.Add(lblDeadline)
  63.             End With
  64.         Else
  65.             'WRITE HERE THE CODE FOR CREATING THE CONTROLS NEEDED FOR DISPLAYING A TASK THAT CAN BE MODIFIED
  66.             '=> TEXTBOX, COMBOBOX, CHECKBOX AD  DATETIMEPICKER
  67.             '=> OK AND CANCEL BUTTONS
  68.             'references to controls that will be used to modify a task
  69.             txtModifTitle = New TextBox
  70.             txtModifDescr = New TextBox
  71.             cboModifCat = New ComboBox
  72.             chkModifDate = New CheckBox
  73.             dateModif = New DateTimePicker
  74.             Dim btnOk As New Button
  75.             Dim btnCancel As New Button
  76.  
  77.             'Initializing txtModifTitle
  78.             txtModifTitle.Text = task.title
  79.             txtModifTitle.Width = 150
  80.  
  81.             'Initializing txtModifDescr
  82.             With txtModifDescr
  83.                 .Text = task.description
  84.                 .Height = 90
  85.                 .Width = 190
  86.                 .Multiline = True
  87.                 .Top = txtModifTitle.Top + txtModifTitle.Height + 5
  88.             End With
  89.  
  90.             'Initializing cboModifCat
  91.             cboModifCat.Top = txtModifDescr.Top + txtModifDescr.Height + 5
  92.             Dim cats As Array
  93.             cats = System.Enum.GetValues(GetType(Category))
  94.             For Each cat In cats
  95.                 cboModifCat.Items.Add(cat)
  96.             Next
  97.             cboModifCat.SelectedIndex = task.category
  98.  
  99.  
  100.             'Initializing chkModifDate
  101.             chkModifDate.Text = "Deadline"
  102.             chkModifDate.Top = cboModifCat.Top + cboModifCat.Height + 5
  103.  
  104.             'Initializing dateModif
  105.             dateModif.Top = chkModifDate.Top + chkModifDate.Height + 5
  106.             dateModif.Width = 180
  107.  
  108.             'Initializing btnOk
  109.             btnOk.Text = "Ok"
  110.             btnOk.Top = dateModif.Top + dateModif.Height + 5
  111.             AddHandler btnOk.Click, AddressOf clickOk
  112.  
  113.             'Initializing btnCancel
  114.             btnCancel.Text = "Cancel"
  115.             btnCancel.Top = btnOk.Top
  116.             btnCancel.Left = btnOk.Left + btnOk.Width + 5
  117.             AddHandler btnCancel.Click, AddressOf clickCancel
  118.  
  119.             With pnlTask
  120.                 .Controls.Add(txtModifTitle)
  121.                 .Controls.Add(txtModifDescr)
  122.                 .Controls.Add(cboModifCat)
  123.                 .Controls.Add(chkModifDate)
  124.                 .Controls.Add(dateModif)
  125.                 .Controls.Add(btnOk)
  126.                 .Controls.Add(btnCancel)
  127.             End With
  128.  
  129.         End If
  130.             'add the panel containing the controls to the display area.
  131.             pnlTask.Location = New Point(5, 20)
  132.         grpTask.Controls.Add(pnlTask)
  133.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement