-
Notifications
You must be signed in to change notification settings - Fork 1
/
RestaurantDescription.cs
154 lines (121 loc) · 4.22 KB
/
RestaurantDescription.cs
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
//using FoodClasses;
namespace RIT_Menu
{
public partial class RestaurantDescription : Form
{
public bool Favorites;
private Resturants rests;
private RestaurantList parentform;
public RestaurantDescription(Resturants rest, RestaurantList form)
{
InitializeComponent();
rests = rest;
descLB.Text = rest.Description;
parentform = form;
Show_Foods();
Show_Hours();
Favorites = rest.favorites;
if (Favorites)
{
favorite.Text = "Favorited";
}
else if (!Favorites)
{
favorite.Text = "Add To Favorites?";
}
this.ShowDialog();
}
/******************************************/
/* Creates Hour Labels */
/******************************************/
private void Show_Hours()
{
string[] types = { "Breakfast", "Lunch", "Dinner" };
int count = 0;
AddLabel(550, 240 + (count * 20), "Opens at " + rests.Change_Time(rests.HourOpen));
count++;
foreach (string meal in types)
{
if (rests.Type.Contains(meal))
{
AddLabel(550, 240 + (count * 20), rests.Time(meal));
count++;
}
}
AddLabel(550, 240 + (count * 20), "Closes at " + rests.Change_Time(rests.HourClose));
}
/**************************************************/
/* Creates all the food labels */
/**************************************************/
private void Show_Foods()
{
int count = 0;
foreach (Menus menu in rests.menus)
{
foreach (Foods food in menu.MenuItems)
{
AddLabel(200, 250 + (count * 20), "- " + food.Name + " : $" + food.Price);
count++;
}
}
}
/********************************/
/* Adds Labels */
/********************************/
private void AddLabel(int locx, int locy, string text)
{
Label newLabel = new System.Windows.Forms.Label();
this.Controls.Add(newLabel);
newLabel.AutoSize = true;
newLabel.Location = new System.Drawing.Point(locx, locy);
newLabel.Name = "label1";
newLabel.Size = new System.Drawing.Size(46, 17);
newLabel.TabIndex = 5;
newLabel.Text = text;
}
/*****************************************************/
/* Closes this form and enables parent */
/*****************************************************/
private void Exit_Click(object sender, EventArgs e)
{
parentform.Visible = true;
this.Close();
}
/*************************************/
/* Un-Used Method */
/*************************************/
private void button1_Click(object sender, EventArgs e)
{
AddingEvent ae = new AddingEvent(rests);
ae.Show();
}
/*****************************************************/
/* Changes favorites json to true */
/*****************************************************/
private void favorite_Click(object sender, EventArgs e)
{
if (Favorites)
{
favorite.Text = "Add To Favorites?";
rests.favorites = false;
Favorites = false;
}
else if (!Favorites)
{
favorite.Text = "Favorited";
rests.favorites = true;
Favorites = true;
}
parentform.InitializePanels();
}
}
}