2
This commit is contained in:
parent
760763c667
commit
30ee797f0a
Binary file not shown.
@ -4,6 +4,6 @@
|
||||
"\\KursiveWork",
|
||||
"\\KursiveWork\\KursiveWork"
|
||||
],
|
||||
"SelectedNode": "\\KursiveWork\\KursiveWork\\infoform.cs",
|
||||
"SelectedNode": "\\KursiveWork\\KursiveWork\\MainForm.cs",
|
||||
"PreviewInSolutionExplorer": false
|
||||
}
|
BIN
.vs/slnx.sqlite
BIN
.vs/slnx.sqlite
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -102,7 +102,7 @@ public class LinkedListStorage
|
||||
}
|
||||
public List<LinkedListState> Load(string filename)
|
||||
{
|
||||
states.Clear();
|
||||
//states.Clear();
|
||||
currentIndex = 0;
|
||||
|
||||
using (BinaryReader reader = new BinaryReader(File.Open(filename, FileMode.Open)))
|
||||
|
@ -22,10 +22,18 @@ public class LinkedListVisualizer
|
||||
{
|
||||
// Заливка фона
|
||||
g.Clear(Color.White);
|
||||
|
||||
//Отрисовка головы
|
||||
g.DrawString("Head", new Font("Arial", 12), Brushes.Black, new Point(10, 15));
|
||||
g.DrawLine(Pens.Black, 55, 25, 20 + NodeWidth + NodeSpacing, 25);
|
||||
g.DrawPolygon(Pens.Black, new Point[] {
|
||||
new Point(28 + NodeWidth + NodeSpacing, 25),
|
||||
new Point(28 + NodeWidth + NodeSpacing - 5, 20),
|
||||
new Point(28 + NodeWidth + NodeSpacing - 5, 30)
|
||||
});
|
||||
// Рисование узлов
|
||||
Node current = state.Head;
|
||||
int x = NodeSpacing;
|
||||
int x = 70 + NodeSpacing;
|
||||
|
||||
while (current != null)
|
||||
{
|
||||
// Рисование узла
|
||||
@ -35,17 +43,36 @@ public class LinkedListVisualizer
|
||||
// Рисование стрелки
|
||||
if (current.Next != null)
|
||||
{
|
||||
g.DrawLine(Pens.Black, x + NodeWidth, 25, x + NodeWidth + NodeSpacing, 25);
|
||||
g.DrawLine(Pens.Black, x + NodeWidth, 25, x + NodeWidth + NodeSpacing - 7, 25);
|
||||
g.DrawPolygon(Pens.Black, new Point[] {
|
||||
new Point(x + NodeWidth + NodeSpacing, 25),
|
||||
new Point(x + NodeWidth + NodeSpacing + 5, 20),
|
||||
new Point(x + NodeWidth + NodeSpacing + 5, 30)
|
||||
new Point(x + NodeWidth + NodeSpacing - 5, 20),
|
||||
new Point(x + NodeWidth + NodeSpacing - 5, 30)
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
g.DrawLine(Pens.Black, x + NodeWidth, 25, x + NodeWidth + NodeSpacing - 7, 25);
|
||||
g.DrawPolygon(Pens.Black, new Point[] {
|
||||
new Point(x + NodeWidth + NodeSpacing, 25),
|
||||
new Point(x + NodeWidth + NodeSpacing - 5, 20),
|
||||
new Point(x + NodeWidth + NodeSpacing - 5, 30)
|
||||
});
|
||||
}
|
||||
|
||||
x += NodeWidth + NodeSpacing;
|
||||
current = current.Next;
|
||||
}
|
||||
if (current == null)
|
||||
{
|
||||
//g.DrawLine(Pens.Black, x + NodeWidth - 50, 25, x + NodeWidth + NodeSpacing - 50, 25);
|
||||
//g.DrawPolygon(Pens.Black, new Point[] {
|
||||
// new Point(x + NodeWidth + NodeSpacing - 50, 25),
|
||||
// new Point(x + NodeWidth + NodeSpacing - 55, 20),
|
||||
// new Point(x + NodeWidth + NodeSpacing - 55, 30)
|
||||
// });
|
||||
g.DrawString("NULL", new Font("Arial", 12), Brushes.Black, new Point(x + NodeWidth / 2 - 15, 15));
|
||||
}
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ namespace KursiveWork
|
||||
manager = new LinkedListManager(parameters);
|
||||
Controls.Add(pictureBox);
|
||||
pictureBox.Image = visualizer.Visualize(list.CreateState());
|
||||
manager.storage.AddState(list.CreateState());
|
||||
}
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
@ -123,7 +124,9 @@ namespace KursiveWork
|
||||
if (saveFileDialog.FileName != "")
|
||||
{
|
||||
manager.storage.Save(saveFileDialog.FileName); // Сохраняем в текстовый файл
|
||||
MessageBox.Show("Файл сохранен");
|
||||
}
|
||||
else MessageBox.Show("Ошибка сохранения");
|
||||
}
|
||||
|
||||
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user