CourseWork01

This commit is contained in:
Roma 2024-05-27 17:45:42 +04:00
parent f0107d4840
commit c3f7749b3a
26 changed files with 1843 additions and 0 deletions

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

View File

@ -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;
}
}

View File

@ -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;
}
}
}

View File

@ -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;
}
}
}

View File

@ -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<ArrayDequeState> 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;
}
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>

View File

@ -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

View File

@ -0,0 +1,71 @@
namespace CourseWorkEreda
{
partial class FormInfo
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -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();
}
}
}

View File

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="richTextBox1.Text" xml:space="preserve">
<value>Дек (deque, double-ended queue) — универсальная структура данных, которая представляет собой последовательность элементов, у которой есть два конца. Причём добавление и удаление элементов может происходить как в начало, так и в конец структуры.
Абстрактный тип данных (АТД) — это математическая модель для типов данных, где тип данных определяется поведением (семантикой) с точки зрения пользователя данных.
АТД определяет набор функций, независимых от конкретной реализации типа, для оперирования его значениями.
В программировании абстрактные типы данных обычно представляются в виде интерфейсов, которые скрывают соответствующие реализации типов.</value>
</data>
</root>

View File

@ -0,0 +1,86 @@
namespace CourseWorkEreda
{
partial class FormInput
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -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<int>? 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)
{
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,240 @@
namespace CourseWorkEreda
{
partial class FormMain
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -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<int> pushAction = (element) => ExecuteOperation(Operation.pushFront, element);
pushAction(element);
_Visualizer.SetAddRectangleUp(true);
}
private void buttonpushBack_Click(object sender, EventArgs e)
{
int element = 0; // Çäåñü ìîæíî çàäàòü çíà÷åíèå ýëåìåíòà äëÿ äîáàâëåíèÿ â êîíåö ñòåêà
Action<int> 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);
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,17 @@
namespace CourseWorkEreda
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[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());
}
}
}

View File

@ -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")]

View File

@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программным средством.
// Версия среды выполнения: 4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если
// код создан повторно.
// </auto-generated>
//------------------------------------------------------------------------------
namespace CourseWorkEreda.Properties
{
/// <summary>
/// Класс ресурсов со строгим типом для поиска локализованных строк и пр.
/// </summary>
// Этот класс был автоматически создан при помощи 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()
{
}
/// <summary>
/// Возврат кэшированного экземпляра ResourceManager, используемого этим классом.
/// </summary>
[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;
}
}
/// <summary>
/// Переопределяет свойство CurrentUICulture текущего потока для всех
/// подстановки ресурсов с помощью этого класса ресурсов со строгим типом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

View File

@ -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<ArrayDequeState> states;
public int CurrentStateIndex;
public int Count => states.Count;
public StateStorage()
{
states = new List<ArrayDequeState>();
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<ArrayDequeState> 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--;
}
}
}

View File

@ -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;
}
}