This repository has been archived by the owner on Dec 16, 2022. It is now read-only.
/
Form1.cs
156 lines (131 loc) · 4.36 KB
/
Form1.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
155
156
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
using ANDREICSLIB.Helpers;
using ANDREICSLIB.Licensing;
using Meal_Chooser.Controller;
using tree = ANDREICSLIB.Helpers.Btree<System.String>;
namespace Meal_Chooser
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
#region licensing
private const String HelpString = "";
private readonly String OtherText =
@"©" + DateTime.Now.Year +
@" Andrei Gec (http://www.andreigec.net)
Licensed under GNU LGPL (http://www.gnu.org/)
Zip Assets © SharpZipLib (http://www.sharpdevelop.net/OpenSource/SharpZipLib/)
";
#endregion
public Chart GetChart()
{
return comparechart;
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void Form1_Load(object sender, EventArgs e)
{
controller.baseform = this;
AsyncHelpers.RunSync(controller.initFiles);
Licensing.LicensingForm(this, menuStrip1, HelpString, OtherText);
}
public static void rb_Click(object sender, EventArgs e)
{
//copy changes to people structure
var rb = ((RadioButton)sender);
var option = rb.Text;
var ingr = rb.Name;
var p = rb.Tag as tree;
controller.editPeopleIngredient(p, ingr, option);
}
private void ingpedientlistbox_SelectedIndexChanged(object sender, EventArgs e)
{
if (ingredientlistbox.SelectedIndex == -1)
return;
// controller.initSubIngr();
}
private void comparebutton_Click(object sender, EventArgs e)
{
// controller.setChart();
}
private void peoplelist_SelectedIndexChanged(object sender, EventArgs e)
{
// controller.initSubIngr();
}
private void newbutton_Click(object sender, EventArgs e)
{
// controller.createNewPerson();
}
private void addingrbutton_Click(object sender, EventArgs e)
{
controller.addIngredient();
}
private void deleteselectedbutton_Click(object sender, EventArgs e)
{
if (editingrbox.SelectedItem == null)
return;
controller.editIngredient();
}
private void Editmeal_Click(object sender, EventArgs e)
{
if (editmeallbox.SelectedItem == null)
return;
var meal = editmeallbox.SelectedItem.ToString();
controller.editMeal(meal);
}
private void addmealbutton_Click(object sender, EventArgs e)
{
controller.addMeal();
}
private void comparechart_MouseMove(object sender, MouseEventArgs e)
{
var result = comparechart.HitTest(e.X, e.Y);
// Set default cursor
this.Cursor = Cursors.Default;
// If the mouse if over a data point
if (result.ChartElementType == ChartElementType.DataPoint)
{
// Find selected data point
var point = comparechart.Series[0].Points[result.PointIndex];
// Change the appearance of the data point
hatchChart(point, true);
}
else
{
if (comparechart.Series.Count == 0)
return;
foreach (var p in comparechart.Series[0].Points)
{
hatchChart(p, false);
}
}
}
private void hatchChart(DataPoint point, bool hatch)
{
if (hatch)
{
point.BackSecondaryColor = Color.White;
point.BackHatchStyle = ChartHatchStyle.Percent25;
point.BorderWidth = 2;
Cursor = Cursors.Hand;
}
else
{
point.BackSecondaryColor = Color.Transparent;
point.BackHatchStyle = ChartHatchStyle.None;
}
}
private void Editcategories_Click(object sender, EventArgs e)
{
controller.EditIngredientCategory();
}
}
}