diff --git a/CourseWorkEreda копия/App.config b/CourseWorkEreda копия/App.config
new file mode 100644
index 0000000..56efbc7
--- /dev/null
+++ b/CourseWorkEreda копия/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CourseWorkEreda копия/ArrayDeque.cs b/CourseWorkEreda копия/ArrayDeque.cs
new file mode 100644
index 0000000..d0476d8
--- /dev/null
+++ b/CourseWorkEreda копия/ArrayDeque.cs
@@ -0,0 +1,103 @@
+using CourseWork_EredavkinRA;
+using System;
+namespace CourseWork_EredavkinRA;
+public class ArrayDeque
+{
+ public int[] array;
+ public int Count;
+ public int maxCount = 10;
+ private int top;
+
+
+
+ public ArrayDeque(int size)
+ {
+ array = new int[size];
+ top = -1;
+ }
+
+
+ public void PushBack(int element)
+ {
+ if (top >= array.Length - 1)
+ {
+ MessageBox.Show("Дек переполнен. Невозможно добавить элемент.");
+ return;
+ }
+
+ top++;
+ array[top] = element;
+ }
+ public int PopBack()
+ {
+ if (top == -1)
+ {
+ MessageBox.Show("Дек пуст. Отсутствует элемент для удаления.");
+ return -1;
+ }
+
+ int poppedElement = array[top];
+ array[top] = 0;
+ top--;
+
+ return poppedElement;
+ }
+ public void PushFront(int element)
+ {
+
+
+ for (int i = top; i >= 0; i--)
+ {
+ array[i + 1] = array[i];
+ }
+ array[0] = element;
+ top++;
+ }
+
+ public int PopFront()
+ {
+ if (top == -1)
+ {
+ MessageBox.Show("Дек пуст. Отсутствует элемент для удаления.");
+ return -1;
+ }
+
+ int poppedElement = array[0];
+
+ for (int i = 0; i < top; i++)
+ {
+ array[i] = array[i + 1];
+ }
+
+ array[top] = 0;
+ top--;
+
+ return poppedElement;
+ }
+ public bool IsEmpty()
+ {
+ return top == -1;
+ }
+ public int[] GetArray()
+ {
+ return array;
+ }
+ public ArrayDequeState CreateMemento()
+ {
+ return new ArrayDequeState((int[])array.Clone(), top);
+ }
+ public ArrayDequeState GetState(ArrayDequeParameters parameter)
+ {
+ return new ArrayDequeState(array, Count);
+ }
+ public bool InBound(int index)
+ {
+ return index >= 0 && index < maxCount;
+ }
+ public void SetMemento(ArrayDequeState memento)
+ {
+ array = (int[])memento.Array.Clone();
+ top = memento.Top;
+ }
+
+}
\ No newline at end of file
diff --git a/CourseWorkEreda копия/ArrayDequeParameters.cs b/CourseWorkEreda копия/ArrayDequeParameters.cs
new file mode 100644
index 0000000..6cea4ad
--- /dev/null
+++ b/CourseWorkEreda копия/ArrayDequeParameters.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CourseWork_EredavkinRA
+{
+ public class ArrayDequeParameters
+ {
+ public int Number { get; set; }
+
+ public ArrayDequeParameters(int number)
+ {
+ Number = number;
+ }
+ }
+
+}
diff --git a/CourseWorkEreda копия/ArrayDequeState.cs b/CourseWorkEreda копия/ArrayDequeState.cs
new file mode 100644
index 0000000..0abdf73
--- /dev/null
+++ b/CourseWorkEreda копия/ArrayDequeState.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CourseWork_EredavkinRA
+{
+ public enum Operation
+ {
+ pushBack, pushFront, popBack, popFront, None = -1
+ }
+ public class ArrayDequeState
+ {
+ public Operation operation;
+ public int[] Array { get; }
+ public int Top;
+ public int Size;
+
+
+ public ArrayDequeState(int[] array, int top, Operation oper = Operation.None)
+ {
+ operation = oper;
+ Array = array;
+ Top = top;
+ Size = array.Length;
+ }
+ }
+
+}
diff --git a/CourseWorkEreda копия/ArrayManager.cs b/CourseWorkEreda копия/ArrayManager.cs
new file mode 100644
index 0000000..d960487
--- /dev/null
+++ b/CourseWorkEreda копия/ArrayManager.cs
@@ -0,0 +1,107 @@
+using CourseWork_EredavkinRA;
+using System.Xml.Linq;
+
+
+namespace CourseWorkEreda;
+
+public class ArrayManager
+{
+
+ public StateStorage storage;
+ private ArrayDeque? stack;
+
+ public ArrayManager(ArrayDequeParameters parameters)
+ {
+ stack = new ArrayDeque(parameters.Number);
+ storage = new StateStorage();
+
+ }
+
+ public IEnumerable GetStates()
+ {
+ return storage.GetStates();
+ }
+ public void ClearStates()
+ {
+ storage.ClearStates();
+ }
+ public void SetCurrentStateToLast()
+ {
+ var lastState = storage.GetLastState();
+ if (lastState != null)
+ {
+ stack = new ArrayDeque(10);
+ foreach (var item in lastState.Array)
+ {
+ stack.PushFront(item);
+ }
+ }
+ }
+ public StateStorage GetStorage()
+ {
+ return storage;
+ }
+ public void SetState(ArrayDequeState state)
+ {
+ stack.SetMemento(state);
+ }
+
+ public void FrontPush(int element)
+ {
+ stack.PushFront(element);
+ ArrayDequeState state = stack.CreateMemento();
+ state.operation = Operation.pushFront;
+ storage.AddState(state);
+
+ state = stack.CreateMemento();
+ storage.AddState(stack.CreateMemento(), false);
+ }
+ public void BackPush(int element)
+ {
+ stack.PushBack(element);
+ ArrayDequeState state = stack.CreateMemento();
+ state.operation = Operation.pushBack;
+ storage.AddState(state);
+
+ state = stack.CreateMemento();
+ storage.AddState(stack.CreateMemento(), false);
+ }
+
+ public void PopBack()
+ {
+ stack.PopBack();
+ ArrayDequeState state = stack.CreateMemento();
+ state.operation = Operation.popBack;
+ storage.AddState(state);
+
+ state = stack.CreateMemento();
+ storage.AddState(stack.CreateMemento(), false);
+ }
+ public void PopFront()
+ {
+ stack.PopFront();
+ ArrayDequeState state = stack.CreateMemento();
+ state.operation = Operation.popFront;
+ storage.AddState(state);
+
+ state = stack.CreateMemento();
+ storage.AddState(stack.CreateMemento(), false);
+ }
+ public bool IsEmpty()
+ {
+ return stack.IsEmpty();
+ }
+ public StateStorage StepForward()
+ {
+ storage.StepForward();
+ return storage;
+ }
+
+ public StateStorage StepBackward()
+ {
+ storage.StepBackward();
+ return storage;
+ }
+
+
+}
diff --git a/CourseWorkEreda копия/CourseWorkEreda.csproj b/CourseWorkEreda копия/CourseWorkEreda.csproj
new file mode 100644
index 0000000..663fdb8
--- /dev/null
+++ b/CourseWorkEreda копия/CourseWorkEreda.csproj
@@ -0,0 +1,11 @@
+
+
+
+ WinExe
+ net8.0-windows
+ enable
+ true
+ enable
+
+
+
\ No newline at end of file
diff --git a/CourseWorkEreda копия/CourseWorkEreda.sln b/CourseWorkEreda копия/CourseWorkEreda.sln
new file mode 100644
index 0000000..b51f66f
--- /dev/null
+++ b/CourseWorkEreda копия/CourseWorkEreda.sln
@@ -0,0 +1,32 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.9.34607.119
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseWorkEreda", "CourseWorkEreda.csproj", "{55B3C967-1007-4AEE-8254-B934DF3AFCFB}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Элементы решения", "Элементы решения", "{E57086F2-9FE9-4275-B931-EB5C86B531F8}"
+ ProjectSection(SolutionItems) = preProject
+ ..\CourseWork_EredavkinRA\ArrayDequeParameters.cs = ..\CourseWork_EredavkinRA\ArrayDequeParameters.cs
+ EndProjectSection
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Resources", "Resources", "{A5D59235-7511-46C2-B531-57BF6E672C5F}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {55B3C967-1007-4AEE-8254-B934DF3AFCFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {55B3C967-1007-4AEE-8254-B934DF3AFCFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {55B3C967-1007-4AEE-8254-B934DF3AFCFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {55B3C967-1007-4AEE-8254-B934DF3AFCFB}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {1B76AA47-1FCE-4D57-ADE4-85C7C7288F2C}
+ EndGlobalSection
+EndGlobal
diff --git a/CourseWorkEreda копия/FormInfo.Designer.cs b/CourseWorkEreda копия/FormInfo.Designer.cs
new file mode 100644
index 0000000..54029cf
--- /dev/null
+++ b/CourseWorkEreda копия/FormInfo.Designer.cs
@@ -0,0 +1,71 @@
+namespace CourseWorkEreda
+{
+ partial class FormInfo
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormInfo));
+ richTextBox1 = new RichTextBox();
+ buttonCloseInfoForm = new Button();
+ SuspendLayout();
+ //
+ // richTextBox1
+ //
+ richTextBox1.Location = new Point(12, 12);
+ richTextBox1.Name = "richTextBox1";
+ richTextBox1.Size = new Size(694, 138);
+ richTextBox1.TabIndex = 0;
+ richTextBox1.Text = resources.GetString("richTextBox1.Text");
+ //
+ // buttonCloseInfoForm
+ //
+ buttonCloseInfoForm.Location = new Point(631, 178);
+ buttonCloseInfoForm.Name = "buttonCloseInfoForm";
+ buttonCloseInfoForm.Size = new Size(75, 23);
+ buttonCloseInfoForm.TabIndex = 2;
+ buttonCloseInfoForm.Text = "Закрыть";
+ buttonCloseInfoForm.UseVisualStyleBackColor = true;
+ buttonCloseInfoForm.Click += buttonCloseInfoForm_Click;
+ //
+ // FormInfo
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(739, 213);
+ Controls.Add(buttonCloseInfoForm);
+ Controls.Add(richTextBox1);
+ Name = "FormInfo";
+ Text = "FormInfo";
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private RichTextBox richTextBox1;
+ private Button buttonCloseInfoForm;
+ }
+}
\ No newline at end of file
diff --git a/CourseWorkEreda копия/FormInfo.cs b/CourseWorkEreda копия/FormInfo.cs
new file mode 100644
index 0000000..9c267ba
--- /dev/null
+++ b/CourseWorkEreda копия/FormInfo.cs
@@ -0,0 +1,25 @@
+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 CourseWorkEreda
+{
+ public partial class FormInfo : Form
+ {
+ public FormInfo()
+ {
+ InitializeComponent();
+ }
+
+ private void buttonCloseInfoForm_Click(object sender, EventArgs e)
+ {
+ Close();
+ }
+ }
+}
diff --git a/CourseWorkEreda копия/FormInfo.resx b/CourseWorkEreda копия/FormInfo.resx
new file mode 100644
index 0000000..71f9d75
--- /dev/null
+++ b/CourseWorkEreda копия/FormInfo.resx
@@ -0,0 +1,126 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Дек (deque, double-ended queue) — универсальная структура данных, которая представляет собой последовательность элементов, у которой есть два конца. Причём добавление и удаление элементов может происходить как в начало, так и в конец структуры.
+Абстрактный тип данных (АТД) — это математическая модель для типов данных, где тип данных определяется поведением (семантикой) с точки зрения пользователя данных.
+АТД определяет набор функций, независимых от конкретной реализации типа, для оперирования его значениями.
+В программировании абстрактные типы данных обычно представляются в виде интерфейсов, которые скрывают соответствующие реализации типов.
+
+
\ No newline at end of file
diff --git a/CourseWorkEreda копия/FormInput.Designer.cs b/CourseWorkEreda копия/FormInput.Designer.cs
new file mode 100644
index 0000000..1877b8b
--- /dev/null
+++ b/CourseWorkEreda копия/FormInput.Designer.cs
@@ -0,0 +1,86 @@
+namespace CourseWorkEreda
+{
+ partial class FormInput
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ labelAbout = new Label();
+ numElement = new NumericUpDown();
+ buttonAdd = new Button();
+ ((System.ComponentModel.ISupportInitialize)numElement).BeginInit();
+ SuspendLayout();
+ //
+ // labelAbout
+ //
+ labelAbout.AutoSize = true;
+ labelAbout.Location = new Point(50, 21);
+ labelAbout.Name = "labelAbout";
+ labelAbout.Size = new Size(94, 15);
+ labelAbout.TabIndex = 0;
+ labelAbout.Text = "Введите данные";
+ labelAbout.Click += label1_Click;
+ //
+ // numElement
+ //
+ numElement.Location = new Point(23, 39);
+ numElement.Name = "numElement";
+ numElement.Size = new Size(162, 23);
+ numElement.TabIndex = 1;
+ numElement.ValueChanged += numElement_ValueChanged;
+ //
+ // buttonAdd
+ //
+ buttonAdd.Location = new Point(23, 79);
+ buttonAdd.Name = "buttonAdd";
+ buttonAdd.Size = new Size(151, 65);
+ buttonAdd.TabIndex = 2;
+ buttonAdd.Text = "Вставка нового Элемента";
+ buttonAdd.UseVisualStyleBackColor = true;
+ buttonAdd.Click += buttonAdd_Click;
+ //
+ // FormInput
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(214, 184);
+ Controls.Add(buttonAdd);
+ Controls.Add(numElement);
+ Controls.Add(labelAbout);
+ Name = "FormInput";
+ Text = "FormInput";
+ ((System.ComponentModel.ISupportInitialize)numElement).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelAbout;
+ private NumericUpDown numElement;
+ private Button buttonAdd;
+ }
+}
\ No newline at end of file
diff --git a/CourseWorkEreda копия/FormInput.cs b/CourseWorkEreda копия/FormInput.cs
new file mode 100644
index 0000000..37b8a16
--- /dev/null
+++ b/CourseWorkEreda копия/FormInput.cs
@@ -0,0 +1,38 @@
+using CourseWork_EredavkinRA;
+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 CourseWorkEreda;
+
+public partial class FormInput : Form
+{
+ public event Action? PushClicked;
+ public FormInput()
+ {
+ InitializeComponent();
+ }
+
+ private void label1_Click(object sender, EventArgs e)
+ {
+
+ }
+
+ private void buttonAdd_Click(object sender, EventArgs e)
+ {
+ int element = (int)numElement.Value;
+ PushClicked?.Invoke(element);
+ Close();
+ }
+
+ private void numElement_ValueChanged(object sender, EventArgs e)
+ {
+
+ }
+}
diff --git a/CourseWorkEreda копия/FormInput.resx b/CourseWorkEreda копия/FormInput.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/CourseWorkEreda копия/FormInput.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/CourseWorkEreda копия/FormMain.Designer.cs b/CourseWorkEreda копия/FormMain.Designer.cs
new file mode 100644
index 0000000..c3e897b
--- /dev/null
+++ b/CourseWorkEreda копия/FormMain.Designer.cs
@@ -0,0 +1,240 @@
+namespace CourseWorkEreda
+{
+ partial class FormMain
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ pictureBox1 = new PictureBox();
+ buttonPushFront = new Button();
+ buttonpushBack = new Button();
+ buttonpopFront = new Button();
+ buttonpopBack = new Button();
+ buttonEmpty = new Button();
+ buttonInfo = new Button();
+ buttonSave = new Button();
+ buttonLoad = new Button();
+ lstStackStates = new ListBox();
+ buttonStepForward = new Button();
+ buttonStepBack = new Button();
+ button1 = new Button();
+ splitter1 = new Splitter();
+ label1 = new Label();
+ ((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
+ SuspendLayout();
+ //
+ // pictureBox1
+ //
+ pictureBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ pictureBox1.BorderStyle = BorderStyle.FixedSingle;
+ pictureBox1.Location = new Point(34, 12);
+ pictureBox1.Name = "pictureBox1";
+ pictureBox1.Size = new Size(742, 544);
+ pictureBox1.TabIndex = 0;
+ pictureBox1.TabStop = false;
+ //
+ // buttonPushFront
+ //
+ buttonPushFront.Location = new Point(799, 41);
+ buttonPushFront.Name = "buttonPushFront";
+ buttonPushFront.Size = new Size(226, 23);
+ buttonPushFront.TabIndex = 2;
+ buttonPushFront.Text = "pushFront";
+ buttonPushFront.UseVisualStyleBackColor = true;
+ buttonPushFront.Click += buttonPushFront_Click;
+ //
+ // buttonpushBack
+ //
+ buttonpushBack.Location = new Point(801, 69);
+ buttonpushBack.Name = "buttonpushBack";
+ buttonpushBack.Size = new Size(226, 23);
+ buttonpushBack.TabIndex = 3;
+ buttonpushBack.Text = "pushBack";
+ buttonpushBack.UseVisualStyleBackColor = true;
+ buttonpushBack.Click += buttonpushBack_Click;
+ //
+ // buttonpopFront
+ //
+ buttonpopFront.Location = new Point(799, 99);
+ buttonpopFront.Name = "buttonpopFront";
+ buttonpopFront.Size = new Size(226, 23);
+ buttonpopFront.TabIndex = 4;
+ buttonpopFront.Text = "popFront";
+ buttonpopFront.UseVisualStyleBackColor = true;
+ buttonpopFront.Click += buttonpopFront_Click;
+ //
+ // buttonpopBack
+ //
+ buttonpopBack.Location = new Point(799, 128);
+ buttonpopBack.Name = "buttonpopBack";
+ buttonpopBack.Size = new Size(226, 23);
+ buttonpopBack.TabIndex = 5;
+ buttonpopBack.Text = "popBack";
+ buttonpopBack.UseVisualStyleBackColor = true;
+ buttonpopBack.Click += buttonpopBack_Click;
+ //
+ // buttonEmpty
+ //
+ buttonEmpty.Location = new Point(799, 157);
+ buttonEmpty.Name = "buttonEmpty";
+ buttonEmpty.Size = new Size(226, 23);
+ buttonEmpty.TabIndex = 6;
+ buttonEmpty.Text = "Empty";
+ buttonEmpty.UseVisualStyleBackColor = true;
+ buttonEmpty.Click += buttonEmpty_Click;
+ //
+ // buttonInfo
+ //
+ buttonInfo.Location = new Point(799, 186);
+ buttonInfo.Name = "buttonInfo";
+ buttonInfo.Size = new Size(226, 23);
+ buttonInfo.TabIndex = 7;
+ buttonInfo.Text = "Информация";
+ buttonInfo.UseVisualStyleBackColor = true;
+ buttonInfo.Click += buttonInfo_Click;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(799, 215);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(226, 23);
+ buttonSave.TabIndex = 8;
+ buttonSave.Text = "Сохранение ";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += buttonSave_Click;
+ //
+ // buttonLoad
+ //
+ buttonLoad.Location = new Point(799, 244);
+ buttonLoad.Name = "buttonLoad";
+ buttonLoad.Size = new Size(226, 23);
+ buttonLoad.TabIndex = 9;
+ buttonLoad.Text = "Загрузка";
+ buttonLoad.UseVisualStyleBackColor = true;
+ buttonLoad.Click += buttonLoad_Click;
+ //
+ // lstStackStates
+ //
+ lstStackStates.FormattingEnabled = true;
+ lstStackStates.ItemHeight = 15;
+ lstStackStates.Location = new Point(828, 273);
+ lstStackStates.Name = "lstStackStates";
+ lstStackStates.Size = new Size(176, 139);
+ lstStackStates.TabIndex = 10;
+ //
+ // buttonStepForward
+ //
+ buttonStepForward.Location = new Point(799, 456);
+ buttonStepForward.Name = "buttonStepForward";
+ buttonStepForward.Size = new Size(100, 27);
+ buttonStepForward.TabIndex = 11;
+ buttonStepForward.Text = "Вперед";
+ buttonStepForward.UseVisualStyleBackColor = true;
+ buttonStepForward.Click += buttonStepForward_Click;
+ //
+ // buttonStepBack
+ //
+ buttonStepBack.Location = new Point(925, 456);
+ buttonStepBack.Name = "buttonStepBack";
+ buttonStepBack.Size = new Size(100, 27);
+ buttonStepBack.TabIndex = 12;
+ buttonStepBack.Text = "Назад";
+ buttonStepBack.UseVisualStyleBackColor = true;
+ buttonStepBack.Click += buttonStepBack_Click;
+ //
+ // button1
+ //
+ button1.Location = new Point(850, 502);
+ button1.Name = "button1";
+ button1.Size = new Size(125, 23);
+ button1.TabIndex = 13;
+ button1.Text = "Обновить";
+ button1.UseVisualStyleBackColor = true;
+ button1.Click += button1_Click;
+ //
+ // splitter1
+ //
+ splitter1.Location = new Point(0, 0);
+ splitter1.Name = "splitter1";
+ splitter1.Size = new Size(3, 577);
+ splitter1.TabIndex = 14;
+ splitter1.TabStop = false;
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(870, 23);
+ label1.Name = "label1";
+ label1.Size = new Size(86, 15);
+ label1.TabIndex = 15;
+ label1.Text = "Инструменты:";
+ //
+ // FormMain
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1070, 577);
+ Controls.Add(label1);
+ Controls.Add(splitter1);
+ Controls.Add(button1);
+ Controls.Add(buttonStepBack);
+ Controls.Add(buttonStepForward);
+ Controls.Add(lstStackStates);
+ Controls.Add(buttonLoad);
+ Controls.Add(buttonSave);
+ Controls.Add(buttonInfo);
+ Controls.Add(buttonEmpty);
+ Controls.Add(buttonpopBack);
+ Controls.Add(buttonpopFront);
+ Controls.Add(buttonpushBack);
+ Controls.Add(buttonPushFront);
+ Controls.Add(pictureBox1);
+ Name = "FormMain";
+ Text = "FormMain";
+ ((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private PictureBox pictureBox1;
+ private Button buttonPushFront;
+ private Button buttonpushBack;
+ private Button buttonpopFront;
+ private Button buttonpopBack;
+ private Button buttonEmpty;
+ private Button buttonInfo;
+ private Button buttonSave;
+ private Button buttonLoad;
+ private ListBox lstStackStates;
+ private Button buttonStepForward;
+ private Button buttonStepBack;
+ private Button button1;
+ private Splitter splitter1;
+ private Label label1;
+ }
+}
diff --git a/CourseWorkEreda копия/FormMain.cs b/CourseWorkEreda копия/FormMain.cs
new file mode 100644
index 0000000..48f0d73
--- /dev/null
+++ b/CourseWorkEreda копия/FormMain.cs
@@ -0,0 +1,182 @@
+using CourseWork_EredavkinRA;
+using System.Windows.Forms;
+
+namespace CourseWorkEreda
+{
+
+ public partial class FormMain : Form
+ {
+ private ArrayManager stackManager;
+ private Visualizator _Visualizer;
+ public FormMain()
+ {
+ InitializeComponent();
+ _Visualizer = new Visualizator();
+ stackManager = new ArrayManager(new ArrayDequeParameters(10));
+
+
+ }
+
+ public void ExecuteOperation(Operation operation, int? element = null)
+ {
+ if (operation == Operation.pushFront && element.HasValue)
+ {
+
+ FormInput pushForm = new FormInput();
+ pushForm.PushClicked += HandlePushClicked;
+ pushForm.Show();
+ }
+ else if (operation == Operation.popFront)
+ {
+ stackManager.PopFront();
+ }
+ else if (operation == Operation.pushBack && element.HasValue)
+ {
+ FormInput pushForm = new FormInput();
+ pushForm.PushClicked += HandleBackPushClicked;
+ pushForm.Show();
+
+ }
+ else if (operation == Operation.popBack)
+ {
+ stackManager.PopBack();
+ }
+ UpdateStackView(stackManager.GetStorage());
+ }
+
+ public void HandlePushClicked(int element)
+ {
+ stackManager.FrontPush(element);
+ UpdateStackView(stackManager.GetStorage());
+ }
+
+ public void HandleBackPushClicked(int element)
+ {
+ stackManager.BackPush(element);
+ UpdateStackView(stackManager.GetStorage());
+ }
+
+ private void buttonPushFront_Click(object sender, EventArgs e)
+ {
+ int element = 0;
+
+ Action pushAction = (element) => ExecuteOperation(Operation.pushFront, element);
+ pushAction(element);
+ _Visualizer.SetAddRectangleUp(true);
+ }
+
+
+ private void buttonpushBack_Click(object sender, EventArgs e)
+ {
+ int element = 0; //
+ Action pushAction = (element) => ExecuteOperation(Operation.pushBack, element);
+ pushAction(element);
+ _Visualizer.SetAddRectangleUp(false);
+
+ }
+
+ private void buttonpopFront_Click(object sender, EventArgs e)
+ {
+ ExecuteOperation(Operation.popFront);
+ UpdateStackView(stackManager.GetStorage());
+ }
+
+ private void buttonpopBack_Click(object sender, EventArgs e)
+ {
+ ExecuteOperation(Operation.popBack);
+ UpdateStackView(stackManager.GetStorage());
+ }
+
+ private void buttonEmpty_Click(object sender, EventArgs e)
+ {
+ if (stackManager.IsEmpty())
+ {
+ MessageBox.Show(" !");
+ }
+ else
+ {
+ MessageBox.Show(" .");
+ }
+ }
+
+ private void buttonInfo_Click(object sender, EventArgs e)
+ {
+ FormInfo informationForm = new FormInfo();
+ informationForm.Show();
+ UpdateStackView(stackManager.GetStorage());
+ }
+
+ private void buttonSave_Click(object sender, EventArgs e)
+ {
+ SaveFileDialog saveFileDialog = new SaveFileDialog();
+ saveFileDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
+ if (saveFileDialog.ShowDialog() == DialogResult.OK)
+ {
+ stackManager.storage.SaveToFile(saveFileDialog.FileName);
+ MessageBox.Show(" !");
+ }
+ }
+
+ private void buttonLoad_Click(object sender, EventArgs e)
+ {
+ OpenFileDialog openFileDialog = new OpenFileDialog();
+ openFileDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
+ if (openFileDialog.ShowDialog() == DialogResult.OK)
+ {
+ stackManager.ClearStates();
+ stackManager.storage.LoadFromFile(openFileDialog.FileName);
+
+ //
+ ArrayDequeState? lastState = stackManager.storage.GetLastState();
+ if (lastState != null)
+ {
+ //stackManager.SetState(lastState);
+ //UpdateStackView();
+ }
+
+ MessageBox.Show(" !");
+ }
+ }
+ public void UpdateStackView(StateStorage stateStorage)
+ {
+ ArrayDequeState? currentState = stackManager.GetStates().LastOrDefault();
+ if (currentState != null)
+ {
+ _Visualizer.Visualize(currentState, this);
+ UpdateStateList();
+ }
+ }
+ private void UpdateStateList()
+ {
+ lstStackStates.Items.Clear();
+ foreach (var state in stackManager.GetStates())
+ {
+ lstStackStates.Items.Add(string.Join(",", state.Array));
+
+ }
+ }
+
+ private void button1_Click(object sender, EventArgs e)
+ {
+ ArrayDequeState? currentState = stackManager.GetStates().LastOrDefault();
+ if (currentState != null)
+ {
+
+ _Visualizer.Visualize(currentState, this);
+ }
+ }
+
+ private void buttonStepForward_Click(object sender, EventArgs e)
+ {
+ var storage = stackManager.StepForward();
+ UpdateStackView(storage);
+ }
+
+ private void buttonStepBack_Click(object sender, EventArgs e)
+ {
+ var storage = stackManager.StepBackward();
+ UpdateStackView(storage);
+ }
+
+ }
+}
diff --git a/CourseWorkEreda копия/FormMain.resx b/CourseWorkEreda копия/FormMain.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/CourseWorkEreda копия/FormMain.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/CourseWorkEreda копия/Program.cs b/CourseWorkEreda копия/Program.cs
new file mode 100644
index 0000000..1a5a81c
--- /dev/null
+++ b/CourseWorkEreda копия/Program.cs
@@ -0,0 +1,17 @@
+namespace CourseWorkEreda
+{
+ internal static class Program
+ {
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ // To customize application configuration such as set high DPI settings or default font,
+ // see https://aka.ms/applicationconfiguration.
+ ApplicationConfiguration.Initialize();
+ Application.Run(new FormMain());
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseWorkEreda копия/Properties/AssemblyInfo.cs b/CourseWorkEreda копия/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..9a3e263
--- /dev/null
+++ b/CourseWorkEreda копия/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Общие сведения об этой сборке предоставляются следующим набором
+// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
+// связанных со сборкой.
+[assembly: AssemblyTitle("CourseWorkEreda")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("CourseWorkEreda")]
+[assembly: AssemblyCopyright("Copyright © 2024")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
+// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
+// COM, следует установить атрибут ComVisible в TRUE для этого типа.
+[assembly: ComVisible(false)]
+
+// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
+[assembly: Guid("95dbc5de-0360-4961-b637-5021c9f271a6")]
+
+// Сведения о версии сборки состоят из указанных ниже четырех значений:
+//
+// Основной номер версии
+// Дополнительный номер версии
+// Номер сборки
+// Редакция
+//
+// Можно задать все значения или принять номера сборки и редакции по умолчанию
+// используя "*", как показано ниже:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/CourseWorkEreda копия/Properties/Resources.Designer.cs b/CourseWorkEreda копия/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..c207664
--- /dev/null
+++ b/CourseWorkEreda копия/Properties/Resources.Designer.cs
@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+//
+// Этот код создан программным средством.
+// Версия среды выполнения: 4.0.30319.42000
+//
+// Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если
+// код создан повторно.
+//
+//------------------------------------------------------------------------------
+
+namespace CourseWorkEreda.Properties
+{
+
+
+ ///
+ /// Класс ресурсов со строгим типом для поиска локализованных строк и пр.
+ ///
+ // Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder
+ // класс с помощью таких средств, как ResGen или Visual Studio.
+ // Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen
+ // с параметром /str или заново постройте свой VS-проект.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// Возврат кэшированного экземпляра ResourceManager, используемого этим классом.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CourseWorkEreda.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Переопределяет свойство CurrentUICulture текущего потока для всех
+ /// подстановки ресурсов с помощью этого класса ресурсов со строгим типом.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/CourseWorkEreda копия/Properties/Resources.resx b/CourseWorkEreda копия/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/CourseWorkEreda копия/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/CourseWorkEreda копия/Properties/Settings.Designer.cs b/CourseWorkEreda копия/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..feded8a
--- /dev/null
+++ b/CourseWorkEreda копия/Properties/Settings.Designer.cs
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace CourseWorkEreda.Properties
+{
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/CourseWorkEreda копия/Properties/Settings.settings b/CourseWorkEreda копия/Properties/Settings.settings
new file mode 100644
index 0000000..3964565
--- /dev/null
+++ b/CourseWorkEreda копия/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/CourseWorkEreda копия/Resources/Down.jpg b/CourseWorkEreda копия/Resources/Down.jpg
new file mode 100644
index 0000000..d548b17
Binary files /dev/null and b/CourseWorkEreda копия/Resources/Down.jpg differ
diff --git a/CourseWorkEreda копия/Resources/Up.jpg b/CourseWorkEreda копия/Resources/Up.jpg
new file mode 100644
index 0000000..ccc2510
Binary files /dev/null and b/CourseWorkEreda копия/Resources/Up.jpg differ
diff --git a/CourseWorkEreda копия/StateStorage.cs b/CourseWorkEreda копия/StateStorage.cs
new file mode 100644
index 0000000..8a27736
--- /dev/null
+++ b/CourseWorkEreda копия/StateStorage.cs
@@ -0,0 +1,131 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using System.Runtime.Serialization.Formatters.Binary;
+
+
+namespace CourseWork_EredavkinRA
+{
+ public class StateStorage
+ {
+ private List states;
+ public int CurrentStateIndex;
+ public int Count => states.Count;
+ public StateStorage()
+ {
+ states = new List();
+ CurrentStateIndex = 0;
+ }
+ public void AddState(ArrayDequeState state, bool nextState = true)
+ {
+
+ if (nextState)
+ {
+ CurrentStateIndex++;
+ }
+ MessageBox.Show(CurrentStateIndex.ToString());
+ states.Add(state);
+ }
+ public void ClearStates()
+ {
+ CurrentStateIndex--;
+ states.Clear();
+ }
+ public IEnumerable GetStates()
+ {
+
+ return states;
+ }
+ public void SaveToFile(string filePath)
+ {
+ using (StreamWriter writer = new StreamWriter(filePath))
+ {
+ foreach (var state in states)
+ {
+ string line = string.Join(",", state.Array) + ";" + state.Top;
+ writer.WriteLine(line);
+ }
+ }
+ }
+ public void LoadFromFile(string filePath)
+ {
+ states.Clear();
+ using (StreamReader reader = new StreamReader(filePath))
+ {
+ string line;
+ while ((line = reader.ReadLine()) != null)
+ {
+ if (string.IsNullOrWhiteSpace(line))
+ {
+ continue;
+ }
+ try
+ {
+ var parts = line.Split(';');
+ int[] array = parts[0].Split(',').Select(int.Parse).ToArray();
+ int top = int.Parse(parts[1]);
+ ArrayDequeState state = new ArrayDequeState(array, top);
+ states.Add(state);
+ }
+ catch (FormatException ex)
+ {
+ System.Diagnostics.Debug.WriteLine($"Error parsing line: {line}. Exception: {ex.Message}");
+ }
+ }
+ }
+ CurrentStateIndex = states.Count > 0 ? states.Count - 1 : -1;
+ }
+ public ArrayDequeState? GetLastState()
+ {
+ return states.LastOrDefault();
+ }
+ public ArrayDequeState? GetCurrentState()
+ {
+ if (CurrentStateIndex >= 0 && CurrentStateIndex < states.Count)
+ {
+ return states[CurrentStateIndex];
+ }
+ return null;
+ }
+ public ArrayDequeState GetNextState()
+ {
+ MessageBox.Show(CurrentStateIndex + " " + (states.Count - 1));
+ if (CurrentStateIndex < states.Count - 1)
+ {
+ CurrentStateIndex++;
+ MessageBox.Show(CurrentStateIndex.ToString());
+ return states[CurrentStateIndex];
+ }
+ return null;
+ }
+ public ArrayDequeState? GetPreviousState()
+ {
+ if (CurrentStateIndex > 0)
+ {
+ CurrentStateIndex--;
+ MessageBox.Show(CurrentStateIndex.ToString());
+
+ return states[CurrentStateIndex];
+ }
+ return null;
+ }
+
+ public int GetCurrentStateIndex()
+ {
+ return CurrentStateIndex;
+ }
+ public void StepForward()
+ {
+ if (CurrentStateIndex + 1 >= Count) return;
+ CurrentStateIndex++;
+ }
+
+ public void StepBackward()
+ {
+ if (CurrentStateIndex == 0) return;
+ CurrentStateIndex--;
+ }
+
+ }
+}
diff --git a/CourseWorkEreda копия/Visualizator.cs b/CourseWorkEreda копия/Visualizator.cs
new file mode 100644
index 0000000..af4f334
--- /dev/null
+++ b/CourseWorkEreda копия/Visualizator.cs
@@ -0,0 +1,117 @@
+using CourseWork_EredavkinRA;
+using System;
+using System.Collections.Generic;
+using System.Drawing.Drawing2D;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using static System.Windows.Forms.AxHost;
+
+namespace CourseWorkEreda;
+
+public class Visualizator
+
+{
+ private bool addRectangleUp = false;
+ public void Visualize(ArrayDequeState state, FormMain form)
+ {
+
+ Pen penArrow = new(Color.Black, 2f);
+
+ PictureBox? pictureBox = form.Controls["pictureBox1"] as PictureBox;
+
+ if (pictureBox == null) return;
+
+ Bitmap bitmap = new Bitmap(pictureBox.Width, pictureBox.Height);
+
+ using (Graphics graphics = Graphics.FromImage(bitmap))
+ {
+ graphics.Clear(Color.White);
+
+ int[] stackArray = state.Array;
+ int stackSize = state.Top + 1;
+ int rectangleWidth = 100;
+ int rectangleHeight = 50;
+ const int distanceBetweenElements = 10;
+ int x = 300;
+ int startY = 100;
+ if (state.operation != Operation.None)
+ {
+ graphics.FillRectangle(Brushes.Turquoise, 50, 50, rectangleWidth, rectangleHeight);
+ graphics.DrawRectangle(Pens.Black, 50, 50, rectangleWidth, rectangleHeight);
+ graphics.FillRectangle(Brushes.Turquoise, pictureBox.Width - 200, 50, rectangleWidth, rectangleHeight);
+ graphics.DrawRectangle(Pens.Black, pictureBox.Width - 200, 50, rectangleWidth, rectangleHeight);
+
+ int lastRectangleY = startY + (stackSize - 1) * (rectangleHeight + distanceBetweenElements);
+
+
+
+ graphics.FillRectangle(Brushes.Turquoise, 50, lastRectangleY + 100, rectangleWidth, rectangleHeight);
+ graphics.DrawRectangle(Pens.Black, 50, lastRectangleY + 100, rectangleWidth, rectangleHeight);
+
+ graphics.FillRectangle(Brushes.Turquoise, pictureBox.Width - 200, lastRectangleY + 100, rectangleWidth, rectangleHeight);
+ graphics.DrawRectangle(Pens.Black, pictureBox.Width - 200, lastRectangleY + 100, rectangleWidth, rectangleHeight);
+
+
+ for (int i = 0; i < stackSize; i++)
+ {
+
+ int y = startY + i * (rectangleHeight + distanceBetweenElements);
+
+ graphics.FillRectangle(Brushes.Turquoise, x, y, rectangleWidth, rectangleHeight);
+ graphics.DrawRectangle(Pens.Black, x, y, rectangleWidth, rectangleHeight);
+
+ string text = stackArray[i].ToString();
+ using (Font font = new Font("Arial", 10))
+ {
+ SizeF textSize = graphics.MeasureString(text, font);
+ float textX = x + (rectangleWidth - textSize.Width) / 2;
+ float textY = y + (rectangleHeight - textSize.Height) / 2;
+ graphics.DrawString(text, font, Brushes.Black, textX, textY);
+ }
+ }
+ }
+ else
+ {
+ graphics.FillRectangle(Brushes.Turquoise, 50, 50, rectangleWidth, rectangleHeight);
+ graphics.DrawRectangle(Pens.Black, 50, 50, rectangleWidth, rectangleHeight);
+ graphics.FillRectangle(Brushes.Turquoise, pictureBox.Width - 200, 50, rectangleWidth, rectangleHeight);
+ graphics.DrawRectangle(Pens.Black, pictureBox.Width - 200, 50, rectangleWidth, rectangleHeight);
+
+ int lastRectangleY = startY + (stackSize - 1) * (rectangleHeight + distanceBetweenElements);
+
+ graphics.FillRectangle(Brushes.Turquoise, 50, lastRectangleY + 100, rectangleWidth, rectangleHeight);
+ graphics.DrawRectangle(Pens.Black, 50, lastRectangleY + 100, rectangleWidth, rectangleHeight);
+
+ graphics.FillRectangle(Brushes.Turquoise, pictureBox.Width - 200, lastRectangleY + 100, rectangleWidth, rectangleHeight);
+ graphics.DrawRectangle(Pens.Black, pictureBox.Width - 200, lastRectangleY + 100, rectangleWidth, rectangleHeight);
+
+ for (int i = 0; i < stackSize; i++)
+ {
+ int y = startY + i * (rectangleHeight + distanceBetweenElements);
+
+ graphics.FillRectangle(Brushes.Turquoise, x, y, rectangleWidth, rectangleHeight);
+ graphics.DrawRectangle(Pens.Black, x, y, rectangleWidth, rectangleHeight);
+
+ string text = stackArray[i].ToString();
+ using (Font font = new Font("Arial", 10))
+ {
+ SizeF textSize = graphics.MeasureString(text, font);
+ float textX = x + (rectangleWidth - textSize.Width) / 2;
+ float textY = y + (rectangleHeight - textSize.Height) / 2;
+ graphics.DrawString(text, font, Brushes.Black, textX, textY);
+ }
+ }
+ }
+
+
+ }
+
+ pictureBox.Image = bitmap;
+ }
+ public void SetAddRectangleUp(bool value)
+ {
+ addRectangleUp = value;
+ }
+}