private void Image_MouseClick(object sender, MouseEventArgs e) { if (ND.SelectedIndex == 0) { if (Add.SelectedIndex == 0) { if (GraphDraw.Empty(e.X, e.Y)) { InputForm input = new InputForm(); if (input.ShowDialog() == DialogResult.OK) { if (!string.IsNullOrWhiteSpace(input.Str)) { graph.AddNode(input.Str, e.X, e.Y); UpdateImage(); } else { MessageBox.Show("неккоректны ввод"); } } } } else { S = GraphDraw.GetNode(e.X, e.Y); graph.Remove(S); UpdateImage(); S = null; } } else { if (S == null) { S = GraphDraw.GetNode(e.X, e.Y); } else { Node SS = GraphDraw.GetNode(e.X, e.Y); if (Add.SelectedIndex == 0) { InputForm input = new InputForm(); if (input.ShowDialog() == DialogResult.OK) { if (!string.IsNullOrWhiteSpace(input.Str) && int.TryParse(input.Str, out int result)) { S.AddEdge(SS, result); UpdateImage(); } else { MessageBox.Show("неккоректны ввод"); } } } else { S.RemoveEdge(SS); UpdateImage(); } S = null; } } }
private void Image_MouseClick(object sender, MouseEventArgs e) { if (Oper.SelectedIndex == 2) { Selected = GraphDraw.GetNode(e.X, e.Y); SelectedOutput.Text = Selected.Name; Search.Enabled = true; } else if (NodeOrEdge.SelectedIndex == 0) { if (Oper.SelectedIndex == 0) { if (GraphDraw.Empty(e.X, e.Y)) { InputForm input = new InputForm("Name"); if (input.ShowDialog() == DialogResult.OK) { if (!string.IsNullOrWhiteSpace(input.Str)) { graph.AddNode(input.Str, e.X, e.Y); UpdateImage(); } else { MessageBox.Show("Wrong input"); } } } } else { Temp = GraphDraw.GetNode(e.X, e.Y); if (Selected == Temp) { Selected = null; SelectedOutput.Text = ""; Search.Enabled = false; } graph.Remove(Temp); UpdateImage(); Temp = null; } } else { if (Temp == null) { Temp = GraphDraw.GetNode(e.X, e.Y); } else { Node SS = GraphDraw.GetNode(e.X, e.Y); if (SS != null) { if (Oper.SelectedIndex == 0) { InputForm input = new InputForm("Length"); if (input.ShowDialog() == DialogResult.OK) { if (!string.IsNullOrWhiteSpace(input.Str) && int.TryParse(input.Str, out int result)) { Temp.AddEdge(SS, result); UpdateImage(); } else { MessageBox.Show("Wrong Input"); } } } else { Temp.RemoveEdge(SS); UpdateImage(); } } Temp = null; } } }