-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEdgeDialog.cs
More file actions
63 lines (59 loc) · 1.98 KB
/
EdgeDialog.cs
File metadata and controls
63 lines (59 loc) · 1.98 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
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;
namespace VisualGraph
{
/// <summary>
/// Dialog to add an edge
/// </summary>
public partial class EdgeDialog : Form
{
Dijekstra dijekstra;
Insert insert;
Form1 form1;
char language;
public EdgeDialog(Dijekstra dij, Insert insert1, Form1 f1, char language1)
{
InitializeComponent();
dijekstra = dij;
insert = insert1;
form1 = f1;
language = language1;
if (language == 'D')
{
laInitialVertex.Text = "Startknoten";
laFinalVertex.Text = "Endknoten";
laWeight.Text = "Gewicht";
}
else
{
laInitialVertex.Text = "Initial vertex";
laFinalVertex.Text = "Final vertex";
laWeight.Text = "weight";
}
}
private void buOk_Click(object sender, EventArgs e)
{
if (dijekstra.vertexList.Where(x => x.name == tbStart.Text).ToList().Count != 0
&& dijekstra.vertexList.Where(x => x.name == tbEnd.Text).ToList().Count != 0
&& Double.TryParse(tbWeight.Text, out double d))
{
insert.insertEdge(tbStart.Text, tbEnd.Text, Convert.ToDouble(tbWeight.Text));
}
else
{
if (language == 'D') MessageBox.Show("Es ist ein Fehler aufgetreten!", "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
else MessageBox.Show("An error occured!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
dijekstra.createMatrix();
form1.Refresh();
this.Close();
}
}
}