diff --git a/BinarySearch/.vs/BinarySearch/DesignTimeBuild/.dtbcache.v2 b/BinarySearch/.vs/BinarySearch/DesignTimeBuild/.dtbcache.v2 index 6f50050..5d37f89 100644 Binary files a/BinarySearch/.vs/BinarySearch/DesignTimeBuild/.dtbcache.v2 and b/BinarySearch/.vs/BinarySearch/DesignTimeBuild/.dtbcache.v2 differ diff --git a/BinarySearch/.vs/BinarySearch/FileContentIndex/72f28def-d73b-4087-b337-6ce47809aee8.vsidx b/BinarySearch/.vs/BinarySearch/FileContentIndex/72f28def-d73b-4087-b337-6ce47809aee8.vsidx deleted file mode 100644 index de5b211..0000000 Binary files a/BinarySearch/.vs/BinarySearch/FileContentIndex/72f28def-d73b-4087-b337-6ce47809aee8.vsidx and /dev/null differ diff --git a/BinarySearch/.vs/BinarySearch/FileContentIndex/7d08648c-81d9-433b-8410-d42939db9db1.vsidx b/BinarySearch/.vs/BinarySearch/FileContentIndex/7d08648c-81d9-433b-8410-d42939db9db1.vsidx deleted file mode 100644 index 4d223b1..0000000 Binary files a/BinarySearch/.vs/BinarySearch/FileContentIndex/7d08648c-81d9-433b-8410-d42939db9db1.vsidx and /dev/null differ diff --git a/BinarySearch/.vs/BinarySearch/FileContentIndex/8b925210-29a6-4142-986f-231e070f47d3.vsidx b/BinarySearch/.vs/BinarySearch/FileContentIndex/8b925210-29a6-4142-986f-231e070f47d3.vsidx new file mode 100644 index 0000000..29f2fa2 Binary files /dev/null and b/BinarySearch/.vs/BinarySearch/FileContentIndex/8b925210-29a6-4142-986f-231e070f47d3.vsidx differ diff --git a/BinarySearch/.vs/BinarySearch/FileContentIndex/ad03122e-14d2-48be-a1dd-57c0a29de8b6.vsidx b/BinarySearch/.vs/BinarySearch/FileContentIndex/ad03122e-14d2-48be-a1dd-57c0a29de8b6.vsidx deleted file mode 100644 index a1827b9..0000000 Binary files a/BinarySearch/.vs/BinarySearch/FileContentIndex/ad03122e-14d2-48be-a1dd-57c0a29de8b6.vsidx and /dev/null differ diff --git a/BinarySearch/.vs/BinarySearch/FileContentIndex/be38e04a-fc3f-4c7d-babb-e57cdd1d0573.vsidx b/BinarySearch/.vs/BinarySearch/FileContentIndex/be38e04a-fc3f-4c7d-babb-e57cdd1d0573.vsidx new file mode 100644 index 0000000..3051887 Binary files /dev/null and b/BinarySearch/.vs/BinarySearch/FileContentIndex/be38e04a-fc3f-4c7d-babb-e57cdd1d0573.vsidx differ diff --git a/BinarySearch/.vs/BinarySearch/FileContentIndex/daf1f328-584f-4f02-a6ef-a1704a115b78.vsidx b/BinarySearch/.vs/BinarySearch/FileContentIndex/daf1f328-584f-4f02-a6ef-a1704a115b78.vsidx new file mode 100644 index 0000000..2de7f92 Binary files /dev/null and b/BinarySearch/.vs/BinarySearch/FileContentIndex/daf1f328-584f-4f02-a6ef-a1704a115b78.vsidx differ diff --git a/BinarySearch/.vs/BinarySearch/v17/.futdcache.v2 b/BinarySearch/.vs/BinarySearch/v17/.futdcache.v2 index b745ec3..5e487e7 100644 Binary files a/BinarySearch/.vs/BinarySearch/v17/.futdcache.v2 and b/BinarySearch/.vs/BinarySearch/v17/.futdcache.v2 differ diff --git a/BinarySearch/.vs/BinarySearch/v17/.suo b/BinarySearch/.vs/BinarySearch/v17/.suo index bad8fdf..d531bcb 100644 Binary files a/BinarySearch/.vs/BinarySearch/v17/.suo and b/BinarySearch/.vs/BinarySearch/v17/.suo differ diff --git a/BinarySearch/.vs/ProjectEvaluation/binarysearch.metadata.v7.bin b/BinarySearch/.vs/ProjectEvaluation/binarysearch.metadata.v7.bin index d533a40..d29407c 100644 Binary files a/BinarySearch/.vs/ProjectEvaluation/binarysearch.metadata.v7.bin and b/BinarySearch/.vs/ProjectEvaluation/binarysearch.metadata.v7.bin differ diff --git a/BinarySearch/.vs/ProjectEvaluation/binarysearch.projects.v7.bin b/BinarySearch/.vs/ProjectEvaluation/binarysearch.projects.v7.bin index 637442a..7c9aa58 100644 Binary files a/BinarySearch/.vs/ProjectEvaluation/binarysearch.projects.v7.bin and b/BinarySearch/.vs/ProjectEvaluation/binarysearch.projects.v7.bin differ diff --git a/BinarySearch/BinarySearch/Forms/InfoForm.resx b/BinarySearch/BinarySearch/Forms/InfoForm.resx index 26691b7..0b4cb35 100644 --- a/BinarySearch/BinarySearch/Forms/InfoForm.resx +++ b/BinarySearch/BinarySearch/Forms/InfoForm.resx @@ -127,7 +127,7 @@ 3. Сравниваем срединный элемент с заданным искомым элементом. 4. Если искомое число больше среднего — продолжаем поиск в правой части массива (если он отсортирован по возрастанию): делим ее пополам, повторяя пункт 3. Если же заданное число меньше — алгоритм продолжит поиск в левой части массива, снова возвращаясь к пункту 3. - +Сложность: O(logN) 17, 17 @@ -136,7 +136,7 @@ iVBORw0KGgoAAAANSUhEUgAABF4AAASFCAYAAACWvRgTAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL - EQAACxEBf2RfkQAApzZJREFUeF7s/U+PHOeBLnoefYEW9QHaLa+PZVDb/gPIO0tqwPRKts6C9KIJqzeU + DgAACw4BQL7hQQAApzZJREFUeF7s/U+PHOeBLnoefYEW9QHaLa+PZVDb/gPIO0tqwPRKts6C9KIJqzeU AWkk3DtzxZGOdHcWJVizG5OGvT2i0Z7VTNuEe+uG1V5d2AbEXlzg+khukqJsWrLUlZNPVr3Ft4JvZmVW 5Z+IzN8PeEBWZmREZFZWVsRTb0T8lxEAAAAAq7CneAEAAABYDcULAAAAwIooXgAAAABWRPECAAAAsCKK FwAAAIAVUbwAAAAArIjiBQAAAGBFFC8AAAAAK6J4AQAAAFgRxQsAAADAiiheAAAAAFZE8QIAAACwIooX @@ -855,7 +855,7 @@ Данная программа позволяет вам посмотреть на графическую демонастрацию работы алгоритма "Бинарный поиск". -Для этого вам потребуется создать базовый целочисленный массив и указать какой элемент вы хотите найти. Так же если у вас есть сохраненный .bin файл с сохраненным состоянием там, то можете выгрузить его (CTRL+L). +Для этого вам потребуется создать базовый целочисленный массив и указать какой элемент вы хотите найти. Так же если у вас есть сохраненный .bin или .json файл с состоянием, то можете загрузить его (CTRL+L). После того как у вас появится в главной форме массив нажмите на кнопку запуска алгоритма. Теперь вы можете пройтись вперед и просмотреть шаги выполнения алгоритма. Так же можно сохранить данный массив (CTRL+S). Желаю вам успехов в изучении алгоритмов! diff --git a/BinarySearch/BinarySearch/Forms/MainForm.Designer.cs b/BinarySearch/BinarySearch/Forms/MainForm.Designer.cs index d20fe09..aef2f48 100644 --- a/BinarySearch/BinarySearch/Forms/MainForm.Designer.cs +++ b/BinarySearch/BinarySearch/Forms/MainForm.Designer.cs @@ -45,15 +45,26 @@ saveFileDialog = new SaveFileDialog(); openFileDialog = new OpenFileDialog(); labelMid = new Label(); - progressBarSteps = new ProgressBar(); groupBox1 = new GroupBox(); - groupBox2 = new GroupBox(); textBoxSteps = new TextBox(); + groupBox2 = new GroupBox(); textBoxStep = new TextBox(); + groupBox3 = new GroupBox(); + labelResult = new Label(); + labelConditional = new Label(); + textBoxTarget = new TextBox(); + textBoxCurrent = new TextBox(); + statusStrip1 = new StatusStrip(); + toolStripStatusLabel1 = new ToolStripStatusLabel(); + toolStripStatusLabelElems = new ToolStripStatusLabel(); + toolStripStatusLabel2 = new ToolStripStatusLabel(); + toolStripProgressBarSteps = new ToolStripProgressBar(); groupBoxTools.SuspendLayout(); menuStrip1.SuspendLayout(); groupBox1.SuspendLayout(); groupBox2.SuspendLayout(); + groupBox3.SuspendLayout(); + statusStrip1.SuspendLayout(); SuspendLayout(); // // groupBoxTools @@ -65,9 +76,9 @@ groupBoxTools.Controls.Add(buttonStepForward); groupBoxTools.Controls.Add(buttonInfo); groupBoxTools.Controls.Add(buttonAddData); - groupBoxTools.Location = new Point(788, 27); + groupBoxTools.Location = new Point(797, 27); groupBoxTools.Name = "groupBoxTools"; - groupBoxTools.Size = new Size(200, 384); + groupBoxTools.Size = new Size(200, 255); groupBoxTools.TabIndex = 0; groupBoxTools.TabStop = false; groupBoxTools.Text = "Инструменты"; @@ -124,9 +135,10 @@ // // flowLayoutPanelArray // - flowLayoutPanelArray.Location = new Point(12, 96); + flowLayoutPanelArray.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + flowLayoutPanelArray.Location = new Point(12, 101); flowLayoutPanelArray.Name = "flowLayoutPanelArray"; - flowLayoutPanelArray.Size = new Size(757, 36); + flowLayoutPanelArray.Size = new Size(779, 36); flowLayoutPanelArray.TabIndex = 3; // // labelIsTarget @@ -149,9 +161,10 @@ // // flowLayoutPanelIndex // - flowLayoutPanelIndex.Location = new Point(12, 56); + flowLayoutPanelIndex.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + flowLayoutPanelIndex.Location = new Point(12, 61); flowLayoutPanelIndex.Name = "flowLayoutPanelIndex"; - flowLayoutPanelIndex.Size = new Size(757, 36); + flowLayoutPanelIndex.Size = new Size(779, 36); flowLayoutPanelIndex.TabIndex = 4; // // menuStrip1 @@ -159,7 +172,7 @@ menuStrip1.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem }); menuStrip1.Location = new Point(0, 0); menuStrip1.Name = "menuStrip1"; - menuStrip1.Size = new Size(988, 24); + menuStrip1.Size = new Size(997, 24); menuStrip1.TabIndex = 6; menuStrip1.Text = "menuStrip1"; // @@ -189,12 +202,12 @@ // // saveFileDialog // - saveFileDialog.Filter = "bin file | *.bin"; + saveFileDialog.Filter = "bin file (*.bin)|*.bin|json file (*.json)|*.json"; // // openFileDialog // openFileDialog.FileName = "openFileDialog1"; - openFileDialog.Filter = "bin file | *.bin"; + openFileDialog.Filter = "All files (*.bin, *.json)|*.bin;*.json|Binary files (*.bin)|*.bin|JSON files (*.json)|*.json"; // // labelMid // @@ -204,59 +217,143 @@ labelMid.Size = new Size(0, 15); labelMid.TabIndex = 7; // - // progressBarSteps - // - progressBarSteps.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; - progressBarSteps.Location = new Point(12, 377); - progressBarSteps.Name = "progressBarSteps"; - progressBarSteps.Size = new Size(770, 23); - progressBarSteps.TabIndex = 8; - // // groupBox1 // + groupBox1.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; groupBox1.Controls.Add(textBoxSteps); - groupBox1.Location = new Point(12, 310); + groupBox1.Location = new Point(11, 182); groupBox1.Name = "groupBox1"; groupBox1.Size = new Size(133, 61); groupBox1.TabIndex = 9; groupBox1.TabStop = false; groupBox1.Text = "Количество шагов"; // + // textBoxSteps + // + textBoxSteps.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + textBoxSteps.Enabled = false; + textBoxSteps.Location = new Point(6, 25); + textBoxSteps.Name = "textBoxSteps"; + textBoxSteps.Size = new Size(110, 23); + textBoxSteps.TabIndex = 0; + textBoxSteps.Text = "0"; + // // groupBox2 // + groupBox2.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; groupBox2.Controls.Add(textBoxStep); - groupBox2.Location = new Point(151, 310); + groupBox2.Location = new Point(150, 182); groupBox2.Name = "groupBox2"; groupBox2.Size = new Size(131, 61); groupBox2.TabIndex = 10; groupBox2.TabStop = false; groupBox2.Text = "Актуальный шаг"; // - // textBoxSteps - // - textBoxSteps.Enabled = false; - textBoxSteps.Location = new Point(6, 22); - textBoxSteps.Name = "textBoxSteps"; - textBoxSteps.Size = new Size(121, 23); - textBoxSteps.TabIndex = 0; - // // textBoxStep // + textBoxStep.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; textBoxStep.Enabled = false; - textBoxStep.Location = new Point(4, 22); + textBoxStep.Location = new Point(6, 25); textBoxStep.Name = "textBoxStep"; - textBoxStep.Size = new Size(121, 23); + textBoxStep.Size = new Size(110, 23); textBoxStep.TabIndex = 1; + textBoxStep.Text = "0"; + // + // groupBox3 + // + groupBox3.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + groupBox3.Controls.Add(labelResult); + groupBox3.Controls.Add(labelConditional); + groupBox3.Controls.Add(textBoxTarget); + groupBox3.Controls.Add(textBoxCurrent); + groupBox3.Location = new Point(287, 182); + groupBox3.Name = "groupBox3"; + groupBox3.Size = new Size(313, 61); + groupBox3.TabIndex = 11; + groupBox3.TabStop = false; + groupBox3.Text = "Рассчеты"; + // + // labelResult + // + labelResult.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + labelResult.AutoSize = true; + labelResult.Location = new Point(152, 32); + labelResult.Name = "labelResult"; + labelResult.Size = new Size(0, 15); + labelResult.TabIndex = 3; + // + // labelConditional + // + labelConditional.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + labelConditional.AutoSize = true; + labelConditional.Location = new Point(52, 32); + labelConditional.Name = "labelConditional"; + labelConditional.Size = new Size(0, 15); + labelConditional.TabIndex = 2; + // + // textBoxTarget + // + textBoxTarget.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + textBoxTarget.Enabled = false; + textBoxTarget.Location = new Point(105, 25); + textBoxTarget.Name = "textBoxTarget"; + textBoxTarget.Size = new Size(40, 23); + textBoxTarget.TabIndex = 1; + // + // textBoxCurrent + // + textBoxCurrent.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + textBoxCurrent.Enabled = false; + textBoxCurrent.Location = new Point(6, 25); + textBoxCurrent.Name = "textBoxCurrent"; + textBoxCurrent.Size = new Size(40, 23); + textBoxCurrent.TabIndex = 0; + // + // statusStrip1 + // + statusStrip1.Items.AddRange(new ToolStripItem[] { toolStripStatusLabel1, toolStripStatusLabelElems, toolStripStatusLabel2, toolStripProgressBarSteps }); + statusStrip1.Location = new Point(0, 261); + statusStrip1.Name = "statusStrip1"; + statusStrip1.Size = new Size(997, 22); + statusStrip1.TabIndex = 12; + statusStrip1.Text = "statusStrip1"; + // + // toolStripStatusLabel1 + // + toolStripStatusLabel1.BackColor = SystemColors.Control; + toolStripStatusLabel1.Name = "toolStripStatusLabel1"; + toolStripStatusLabel1.Size = new Size(137, 17); + toolStripStatusLabel1.Text = "Количество элементов:"; + // + // toolStripStatusLabelElems + // + toolStripStatusLabelElems.BackColor = SystemColors.Control; + toolStripStatusLabelElems.Name = "toolStripStatusLabelElems"; + toolStripStatusLabelElems.Size = new Size(13, 17); + toolStripStatusLabelElems.Text = "0"; + // + // toolStripStatusLabel2 + // + toolStripStatusLabel2.BackColor = SystemColors.Control; + toolStripStatusLabel2.Name = "toolStripStatusLabel2"; + toolStripStatusLabel2.Size = new Size(197, 17); + toolStripStatusLabel2.Text = "Прогресс выполнения алгоритма:"; + // + // toolStripProgressBarSteps + // + toolStripProgressBarSteps.Name = "toolStripProgressBarSteps"; + toolStripProgressBarSteps.Size = new Size(100, 16); // // MainForm // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; BackColor = Color.Moccasin; - ClientSize = new Size(988, 412); + ClientSize = new Size(997, 283); + Controls.Add(statusStrip1); + Controls.Add(groupBox3); Controls.Add(groupBox2); Controls.Add(groupBox1); - Controls.Add(progressBarSteps); Controls.Add(labelMid); Controls.Add(flowLayoutPanelIndex); Controls.Add(labelTarget); @@ -274,6 +371,10 @@ groupBox1.PerformLayout(); groupBox2.ResumeLayout(false); groupBox2.PerformLayout(); + groupBox3.ResumeLayout(false); + groupBox3.PerformLayout(); + statusStrip1.ResumeLayout(false); + statusStrip1.PerformLayout(); ResumeLayout(false); PerformLayout(); } @@ -302,5 +403,15 @@ private GroupBox groupBox2; private TextBox textBoxSteps; private TextBox textBoxStep; + private GroupBox groupBox3; + private Label labelResult; + private Label labelConditional; + private TextBox textBoxTarget; + private TextBox textBoxCurrent; + private StatusStrip statusStrip1; + private ToolStripProgressBar toolStripProgressBarSteps; + private ToolStripStatusLabel toolStripStatusLabel1; + private ToolStripStatusLabel toolStripStatusLabelElems; + private ToolStripStatusLabel toolStripStatusLabel2; } } \ No newline at end of file diff --git a/BinarySearch/BinarySearch/Forms/MainForm.cs b/BinarySearch/BinarySearch/Forms/MainForm.cs index 788b9ba..77e1fea 100644 --- a/BinarySearch/BinarySearch/Forms/MainForm.cs +++ b/BinarySearch/BinarySearch/Forms/MainForm.cs @@ -63,9 +63,10 @@ public partial class MainForm : Form _stateStorage.Reset(); _visualizer.UpdateFlowLayoutPanel(); _manager.ExecuteBinarySearch(_parameters); - progressBarSteps.Maximum = _stateStorage.GetStatesCount(); + toolStripStatusLabelElems.Text = _parameters?.Array?.Count.ToString(); + toolStripProgressBarSteps.Maximum = _stateStorage.GetStatesCount(); textBoxSteps.Text = _stateStorage.GetStatesCount().ToString(); - progressBarSteps.Value = 0; + toolStripProgressBarSteps.Value = 0; textBoxStep.Text = 0.ToString(); toolStripMenuItemSave.Enabled = true; buttonStepForward.Enabled = true; @@ -80,7 +81,7 @@ public partial class MainForm : Form private void buttonStepForward_Click(object sender, EventArgs e) { SearchState? searchState = _stateStorage.GetNextState(); - progressBarSteps.Value = _stateStorage.GetCurrentIndex()+1; + toolStripProgressBarSteps.Value = _stateStorage.GetCurrentIndex()+1; textBoxStep.Text = (_stateStorage.GetCurrentIndex() + 1).ToString(); SearchState? searchStateCheck = _stateStorage.GetNextState(); if (searchStateCheck == null && searchState != null) @@ -101,6 +102,7 @@ public partial class MainForm : Form { return; } + calculateInfo(searchState); _visualizer.Visualize(searchState); buttonStepForward.Enabled = true; buttonStepBack.Enabled = true; @@ -118,13 +120,35 @@ public partial class MainForm : Form { return; } - progressBarSteps.Value = _stateStorage.GetCurrentIndex()+1; + toolStripProgressBarSteps.Value = _stateStorage.GetCurrentIndex()+1; textBoxStep.Text = (_stateStorage.GetCurrentIndex() + 1).ToString(); + calculateInfo(searchState); _visualizer.Visualize(searchState); buttonStepForward.Enabled = true; buttonStepBack.Enabled = true; } + private void calculateInfo(SearchState state) + { + int currentNumber = state.Array[state.Mid]; + int target = state.Target; + textBoxCurrent.Text = currentNumber.ToString(); + textBoxTarget.Text = target.ToString(); + if (target < currentNumber) + { + labelConditional.Text = "больше"; + labelResult.Text = "берём левый подмассив"; + } else if (target > currentNumber) + { + labelConditional.Text = "меньше"; + labelResult.Text = "берём правый подмассив"; + } else + { + labelConditional.Text = "равно"; + labelResult.Text = "берём это значение"; + } + } + /// /// Обработчик события открытия формы информации /// diff --git a/BinarySearch/BinarySearch/Forms/MainForm.resx b/BinarySearch/BinarySearch/Forms/MainForm.resx index 8214e5c..6c3205d 100644 --- a/BinarySearch/BinarySearch/Forms/MainForm.resx +++ b/BinarySearch/BinarySearch/Forms/MainForm.resx @@ -126,4 +126,7 @@ 267, 17 + + 400, 17 + \ No newline at end of file diff --git a/BinarySearch/BinarySearch/State/StateStorage.cs b/BinarySearch/BinarySearch/State/StateStorage.cs index f167e2e..53d99d4 100644 --- a/BinarySearch/BinarySearch/State/StateStorage.cs +++ b/BinarySearch/BinarySearch/State/StateStorage.cs @@ -1,4 +1,5 @@ using System.Runtime.Serialization.Formatters.Binary; +using System.Text.Json; namespace BinarySearch.State; @@ -101,7 +102,7 @@ public class StateStorage } /// - /// Сохранение хранилища в бинарный файл + /// Сохранение хранилища в бинарный файл или JSON файл /// /// /// @@ -109,11 +110,30 @@ public class StateStorage { try { - BinaryFormatter formatter = new BinaryFormatter(); - using FileStream fs = new FileStream(filename, FileMode.Create); - #pragma warning disable SYSLIB0011 - formatter.Serialize(fs, states); - #pragma warning restore SYSLIB0011 + string extension = Path.GetExtension(filename).ToLower(); + + if (extension == ".bin") + { + // Сохранение в бинарный формат + BinaryFormatter formatter = new BinaryFormatter(); + using FileStream fs = new FileStream(filename, FileMode.Create); + #pragma warning disable SYSLIB0011 + formatter.Serialize(fs, states); + #pragma warning restore SYSLIB0011 + } + else if (extension == ".json") + { + // Сохранение в формат JSON + string json = JsonSerializer.Serialize(states); + File.WriteAllText(filename, json); + } + else + { + // Неподдерживаемое расширение файла + Console.WriteLine("Unsupported file extension"); + return false; + } + return true; } catch (Exception ex) @@ -124,7 +144,7 @@ public class StateStorage } /// - /// Загрузка хранилища из бинарного файла + /// Загрузка хранилища из бинарного файла или JSON файла /// /// /// @@ -132,11 +152,30 @@ public class StateStorage { try { - BinaryFormatter formatter = new BinaryFormatter(); - using FileStream fs = new FileStream(filename, FileMode.Open); - #pragma warning disable SYSLIB0011 - states = (List)formatter.Deserialize(fs); - #pragma warning restore SYSLIB0011 + string extension = Path.GetExtension(filename).ToLower(); + + if (extension == ".bin") + { + // Загрузка из бинарного файла + BinaryFormatter formatter = new BinaryFormatter(); + using FileStream fs = new FileStream(filename, FileMode.Open); + #pragma warning disable SYSLIB0011 + states = (List)formatter.Deserialize(fs); + #pragma warning restore SYSLIB0011 + } + else if (extension == ".json") + { + // Загрузка из файла в формате JSON + string json = File.ReadAllText(filename); + states = JsonSerializer.Deserialize>(json); + } + else + { + // Неподдерживаемое расширение файла + Console.WriteLine("Unsupported file extension"); + return false; + } + return true; } catch (Exception ex) diff --git a/BinarySearch/BinarySearch/bin/Debug/net7.0-windows/BinarySearch.dll b/BinarySearch/BinarySearch/bin/Debug/net7.0-windows/BinarySearch.dll index aa96c92..b2f6627 100644 Binary files a/BinarySearch/BinarySearch/bin/Debug/net7.0-windows/BinarySearch.dll and b/BinarySearch/BinarySearch/bin/Debug/net7.0-windows/BinarySearch.dll differ diff --git a/BinarySearch/BinarySearch/bin/Debug/net7.0-windows/BinarySearch.exe b/BinarySearch/BinarySearch/bin/Debug/net7.0-windows/BinarySearch.exe index a5c5141..7f97d54 100644 Binary files a/BinarySearch/BinarySearch/bin/Debug/net7.0-windows/BinarySearch.exe and b/BinarySearch/BinarySearch/bin/Debug/net7.0-windows/BinarySearch.exe differ diff --git a/BinarySearch/BinarySearch/bin/Debug/net7.0-windows/BinarySearch.pdb b/BinarySearch/BinarySearch/bin/Debug/net7.0-windows/BinarySearch.pdb index 4859466..5f28da2 100644 Binary files a/BinarySearch/BinarySearch/bin/Debug/net7.0-windows/BinarySearch.pdb and b/BinarySearch/BinarySearch/bin/Debug/net7.0-windows/BinarySearch.pdb differ diff --git a/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/BinarySearch.AssemblyInfo.cs b/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/BinarySearch.AssemblyInfo.cs index f9ba2f8..07771f1 100644 --- a/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/BinarySearch.AssemblyInfo.cs +++ b/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/BinarySearch.AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("BinarySearch")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+bcd334d0311ab8e6c59928bb18adb95b23630025")] [assembly: System.Reflection.AssemblyProductAttribute("BinarySearch")] [assembly: System.Reflection.AssemblyTitleAttribute("BinarySearch")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/BinarySearch.AssemblyInfoInputs.cache b/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/BinarySearch.AssemblyInfoInputs.cache index b9ff95c..542c874 100644 --- a/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/BinarySearch.AssemblyInfoInputs.cache +++ b/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/BinarySearch.AssemblyInfoInputs.cache @@ -1 +1 @@ -1d747fb8a31ff8aaece430d2476a61103b8e3209701086c3b8734998b4b745be +695aa2c69608c0253b250b29a1ce56a3094f8fd99413ff79c586e97848417cf0 diff --git a/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/BinarySearch.InfoForm.resources b/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/BinarySearch.InfoForm.resources index b90cdec..5878d52 100644 Binary files a/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/BinarySearch.InfoForm.resources and b/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/BinarySearch.InfoForm.resources differ diff --git a/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/BinarySearch.csproj.GenerateResource.cache b/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/BinarySearch.csproj.GenerateResource.cache index 27cf8c6..9b46757 100644 Binary files a/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/BinarySearch.csproj.GenerateResource.cache and b/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/BinarySearch.csproj.GenerateResource.cache differ diff --git a/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/BinarySearch.dll b/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/BinarySearch.dll index aa96c92..b2f6627 100644 Binary files a/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/BinarySearch.dll and b/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/BinarySearch.dll differ diff --git a/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/BinarySearch.pdb b/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/BinarySearch.pdb index 4859466..5f28da2 100644 Binary files a/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/BinarySearch.pdb and b/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/BinarySearch.pdb differ diff --git a/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/apphost.exe b/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/apphost.exe index a5c5141..7f97d54 100644 Binary files a/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/apphost.exe and b/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/apphost.exe differ diff --git a/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/ref/BinarySearch.dll b/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/ref/BinarySearch.dll index 8054b19..c391ed0 100644 Binary files a/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/ref/BinarySearch.dll and b/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/ref/BinarySearch.dll differ diff --git a/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/refint/BinarySearch.dll b/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/refint/BinarySearch.dll index 8054b19..c391ed0 100644 Binary files a/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/refint/BinarySearch.dll and b/BinarySearch/BinarySearch/obj/Debug/net7.0-windows/refint/BinarySearch.dll differ