-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
104 lines (89 loc) · 3.3 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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Logistica
{
/* TODO
* Bloccare il bottone genera valori e esegui metodi quando non c'è la tabella generata, una volta che viene generata sbloccali
*/
public partial class Form1 : Form
{
Tabella d;
public Form1()
{
InitializeComponent();
this.Resize += Form1_Resize;
RidimensionaComponentiForm();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void RidimensionaComponentiForm()
{
// riposiziona la tabella
if (d != null)
{
// d.Size = new Size(this.ContenitoreTabella.Width / 2, this.ContenitoreTabella.Height / 2);
int x = this.ContenitoreTabella.Width / 2 - d.Size.Width / 2;
int y = this.ContenitoreTabella.Height / 2 - d.Size.Height / 2;
d.Location = new Point(x, y);
}
}
private void Form1_Resize(object sender, EventArgs e)
{
RidimensionaComponentiForm();
}
private void generate_button_Click(object sender, EventArgs e)
{
if (d != null)
{
d.Dispose();
}
d = new Tabella((int)n_righe.Value, (int)n_colonne.Value);
this.ContenitoreTabella.TabPages[0].Controls.Add(d);
RidimensionaComponentiForm();
}
private void button1_Click(object sender, EventArgs e)
{
if (d != null)
d.RiempiRandom((int)costi_min.Value, (int)costi_max.Value, (int)prod_min.Value, (int)prod_max.Value);
}
private void prod_min_ValueChanged(object sender, EventArgs e)
{
if (((NumericUpDown)sender).Value >= prod_max.Value)
((NumericUpDown)sender).Value = prod_max.Value;
}
private void costi_min_ValueChanged(object sender, EventArgs e)
{
if (((NumericUpDown)sender).Value >= costi_max.Value)
((NumericUpDown)sender).Value = costi_max.Value;
}
private void prod_max_ValueChanged(object sender, EventArgs e)
{
if (((NumericUpDown)sender).Value < prod_min.Value)
((NumericUpDown)sender).Value = prod_min.Value;
}
private void costi_max_ValueChanged(object sender, EventArgs e)
{
if (((NumericUpDown)sender).Value < costi_min.Value)
((NumericUpDown)sender).Value = costi_min.Value;
}
private void esegui_metodi_Click(object sender, EventArgs e)
{
if (d != null)
if (d.SommaRiga(d.RowCount - 1) == d.SommaColonna(d.ColumnCount - 1))
this.ContenitoreTabella.TabPages[1].Controls["tableLayoutPanel"].Controls["panel_nord_ovest"].Controls["content_nord_ovest"].Text
= Metodi.NordOvest(d.ToArray());
else
MessageBox.Show("Attenzione! La somma della produzione e del fabbisogno non combacia!");
}
}
}