-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStickyNote.vb
More file actions
186 lines (151 loc) · 5.16 KB
/
StickyNote.vb
File metadata and controls
186 lines (151 loc) · 5.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
Public Class StickyNote
Public items As List(Of Produce) = New List(Of Produce) 'items in the list as an array of produce
'Dim shopper As Shopper uncomment when shopper class is made
Dim listPurpose As String 'purpose of the list
Dim listFrequency As Integer 'number of days before list repeats set to -1 to indicate non routine list
Dim listDate As Date = Nothing 'date the list needs to be shopped for
Dim listName As String ' name of the list
Dim shopper As String ' name of the assigned shopper
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
'Add your custom paint code here
End Sub
Public Sub New(Optional name1 As String = "List Title", Optional purpose1 As String = "Nothing", Optional items1 As List(Of Produce) = Nothing,
Optional shopper1 As String = "Not Assigned", Optional date1 As Date = Nothing, Optional frequency1 As Integer = 7)
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
'pass mouse events to parent
For Each control In Controls
If TypeOf control Is Button Then Continue For
Dim c As Control = control
AddHandler c.MouseDown, AddressOf ItemMouseDown
AddHandler c.MouseUp, AddressOf ItemMouseUp
AddHandler c.MouseMove, AddressOf ItemMouseMove
Next
If items1 Is Nothing Then
Me.items = New List(Of Produce)
Else
Me.items = items1
End If
Purpose = purpose1
Frequency = frequency1
ShoppingDate = date1
ShoppingListName = name1
AssignedShopper = shopper1
DateInfoLabel.Text = FrequencyWord(listFrequency)
End Sub
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
'pass mouse events to parent
For Each control In Controls
If TypeOf control Is Button Then Continue For
Dim c As Control = control
AddHandler c.MouseDown, AddressOf ItemMouseDown
AddHandler c.MouseUp, AddressOf ItemMouseUp
AddHandler c.MouseMove, AddressOf ItemMouseMove
Next
Me.items = New List(Of Produce)
Purpose = "Nothing"
Frequency = 7
ShoppingDate = Date.Now
ShoppingListName = "List Title"
AssignedShopper = "Shopper"
End Sub
Public Function FrequencyWord(num As Integer) As String
Select Case num
Case -1
Return "One-Time"
Case 1
Return "Daily"
Case 7
Return "Weekly"
Case 30
Return "Monthly"
End Select
Return Nothing
End Function
Property Purpose As String
Get
Return listPurpose
End Get
Set(value As String)
listPurpose = value
End Set
End Property
Property ShoppingDate As Date
Get
Return listDate
End Get
Set(value As Date)
listDate = value
End Set
End Property
Property ShoppingListName As String
Get
Return ListTitle.Text
End Get
Set(value As String)
listName = value
ListTitle.Text = listName
End Set
End Property
Property AssignedShopper As String
Get
Return shopper
End Get
Set(value As String)
shopper = value
ShopperNameLabel.Text = value
End Set
End Property
Property Frequency
Get
Return listFrequency
End Get
Set(value)
listFrequency = value
If listFrequency < 0 Then
hideRoutine()
Else
showRoutine()
End If
End Set
End Property
Public Shadows Sub DraggedUnder(ByRef sender As Draggable)
MsgBox("draggable")
End Sub
Public Shadows Sub DraggedUnder(ByRef sender As StickyNote)
'MsgBox(items.)
End Sub
'pass mouse events to parent
Private Sub ItemMouseDown(sender As Object, e As MouseEventArgs)
OnMouseDown(e)
End Sub
Private Sub ItemMouseUp(sender As Object, e As MouseEventArgs)
OnMouseUp(e)
End Sub
Private Sub ItemMouseMove(sender As Object, e As MouseEventArgs)
OnMouseMove(e)
End Sub
Private Sub editList(sender As Object, e As EventArgs) Handles EditButton.Click
Dim a = New ShoppingListEdit(Me)
a.Show()
Form1.Hide()
End Sub
Private Sub ViewDetails(sender As Object, e As EventArgs) Handles ViewButton.Click
Dim a = New ShoppingListView(Me)
a.Show()
Form1.Hide()
End Sub
Private Sub hideRoutine()
TypeLabel.Text = "Shop Date:"
DateInfoLabel.Text = Me.ShoppingDate.ToString("yy-MM-dd")
End Sub
Private Sub ShowRoutine()
TypeLabel.Text = "Frequency:"
DateInfoLabel.Text = FrequencyWord(Frequency)
End Sub
End Class