Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Лабораторная работа №7 #9

Open
wants to merge 1 commit into
base: lab5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Laba5/Laba2/App.config

This file was deleted.

Binary file removed Laba5/Laba2/bin/Debug/Laba2.exe
Binary file not shown.
6 changes: 0 additions & 6 deletions Laba5/Laba2/bin/Debug/Laba2.exe.config

This file was deleted.

Binary file removed Laba5/Laba2/bin/Debug/Laba2.pdb
Binary file not shown.
6 changes: 0 additions & 6 deletions Laba5/Laba2/bin/Debug/Laba2.vshost.exe.config

This file was deleted.

Binary file removed Laba5/Laba2/obj/Debug/Laba2.exe
Binary file not shown.
Binary file removed Laba5/Laba2/obj/Debug/Laba2.pdb
Binary file not shown.
50 changes: 0 additions & 50 deletions Laba5/Laba2/obj/Debug/Laba3.csproj.FileListAbsolute.txt

This file was deleted.

Binary file not shown.
Binary file not shown.
18 changes: 18 additions & 0 deletions Laba6/Laba2/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>

<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
</configSections>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="logfile" xsi:type="File" fileName="C://Users//Admin//file.txt" />
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="logfile" />
</rules>
</nlog>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
6 changes: 3 additions & 3 deletions Laba5/Laba2/ClassArray.cs → Laba6/Laba2/ClassArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ClassArray<T> where T : ITransport

private Dictionary<int, T> places;
private int maxCount;
//private T[] places;

private T defaultValue;


Expand All @@ -28,7 +28,7 @@ public ClassArray(int sizes,T defVal)
{
if(p.places.Count==p.maxCount)
{
return -1;
throw new ParkingOverflowException();
}
for (int i=0;i<p.places.Count;i++)
{
Expand All @@ -50,7 +50,7 @@ public ClassArray(int sizes,T defVal)
p.places.Remove(index);
return car;
}
return p.defaultValue;
throw new ParkingIndexOutOfRangeException();
}
private bool CheckFreePlace(int index)
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 54 additions & 32 deletions Laba5/Laba2/Form2.cs → Laba6/Laba2/Form2.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using NLog;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
Expand All @@ -19,9 +20,12 @@ public partial class Form2 : Form
int placesSizeWidth = 250;
int placeSizeHight = 150;

private Logger log;

public Form2()
{
InitializeComponent();
log = LogManager.GetCurrentClassLogger();
parking = new Parking(5);
for (int i = 1; i < 6; i++)
{
Expand Down Expand Up @@ -51,47 +55,51 @@ private void button1_Click(object sender, EventArgs e) //down
{
parking.LevelDown();
listBox.SelectedIndex = parking.getCurrentLevel;
log.Info("Переход на уровень ниже. Текущий уровень: " + parking.getCurrentLevel);
Draw();
}

private void button2_Click(object sender, EventArgs e) //up
{
parking.LevelUp();
listBox.SelectedIndex = parking.getCurrentLevel;
log.Info("Переход на уровень выше. Текущий уровень: " + parking.getCurrentLevel);
Draw();
}


private void buttonSetCar_Click_1(object sender, EventArgs e)
{
/*ColorDialog dialog = new ColorDialog();
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
var car = new Car(100, 4, 10, 1600, dialog.Color);
int place = parking.PutCarInParking(car);
Draw();
MessageBox.Show("Ваше место: " + place);
}
*/

form = new FormDelectCar();
form.AddEvent(AddCar);
form.Show();

log.Info("Меню для выборки цвета для машины");

}

private void AddCar(ITransport car)
{
if (car != null)
{
int place = parking.PutCarInParking(car);
if (place > -1)

try
{
int place = parking.PutCarInParking(car);
Draw();
MessageBox.Show("Ваше место: " + place);
log.Info("Машина или внедорожник добавлены");
}
else
catch (ParkingOverflowException ex)
{
MessageBox.Show("Машину не удалось поставить");
MessageBox.Show(ex.Message, "Ошибка переполнения",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Общая ошибка ",
MessageBoxButtons.OK, MessageBoxIcon.Error);

}
}
}
Expand All @@ -109,9 +117,10 @@ private void buttonSetVnedorozhnik_Click(object sender, EventArgs e)
int place = parking.PutCarInParking(car);
Draw();
MessageBox.Show("Ваше место: " + place);
log.Info("Припаркован Внедорожник на место " + place);
}
}

}

private void buttonTakeCar_Click(object sender, EventArgs e)
Expand All @@ -121,24 +130,37 @@ private void buttonTakeCar_Click(object sender, EventArgs e)
string level = listBox.Items[listBox.SelectedIndex].ToString();

if (maskedTextBox1.Text != "")
{
ITransport car = parking.GetCarInParking(Convert.ToInt32(maskedTextBox1.Text));
if (car != null)
{//если удалось забрать, то отрисовываем
Bitmap bmp = new Bitmap(pictureBoxTakeCar.Width, pictureBoxTakeCar.Height);
Graphics gr = Graphics.FromImage(bmp);
car.setPosition(150, 5);
car.drawCar(gr);
pictureBoxTakeCar.Image = bmp;
Draw();
{
try
{
ITransport car = parking.GetCarInParking(Convert.ToInt32(maskedTextBox1.Text));
if (car != null)
{//если удалось забрать, то отрисовываем
Bitmap bmp = new Bitmap(pictureBoxTakeCar.Width, pictureBoxTakeCar.Height);
Graphics gr = Graphics.FromImage(bmp);
car.setPosition(150, 5);
car.drawCar(gr);
pictureBoxTakeCar.Image = bmp;
Draw();
}
log.Info("Машину или Внедорожник забрали");

}
else
{//иначе сообщаем об этом
MessageBox.Show("Извинте, на этом месте нет машины");
catch (ParkingIndexOutOfRangeException ex)
{
MessageBox.Show(ex.Message, "Неверный номер",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Общая ошибка ",
MessageBoxButtons.OK, MessageBoxIcon.Error);

}
}

}

}

private void сохранитьToolStripMenuItem_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -178,7 +200,7 @@ private void загрузитьToolStripMenuItem_Click(object sender, EventArgs

}


}

}
Expand Down
3 changes: 3 additions & 0 deletions Laba5/Laba2/Form2.resx → Laba6/Laba2/Form2.resx
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,7 @@
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>314, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>60</value>
</metadata>
</root>
Loading