LabWork03 #3

Closed
Mongol wants to merge 11 commits from LabWork03 into main
31 changed files with 1006 additions and 710 deletions
Showing only changes of commit 9067a2b576 - Show all commits

337
.gitignore vendored
View File

@ -1,85 +1,31 @@
# ---> VisualStudio
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*_i.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
@ -89,41 +35,27 @@ StyleCopReport.xml
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
@ -133,268 +65,69 @@ _ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.Publish.xml
*.pubxml
*.publishproj
*.azurePubxml
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
packages/
## TODO: If the tool you use requires repositories.config, also uncomment the next line
!packages/repositories.config
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
# Windows Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
# Windows Store app package directory
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
![Ss]tyle[Cc]op.targets
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.[Pp]ublish.xml
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
App_Data/*.mdf
App_Data/*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# =========================
# Windows detritus
# =========================
# Microsoft Fakes
FakesAssemblies/
# Windows image file caches
Thumbs.db
ehthumbs.db
# GhostDoc plugin setting file
*.GhostDoc.xml
# Folder config file
Desktop.ini
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
*.vbp
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
*.dsw
*.dsp
# Visual Studio 6 technical files
*.ncb
*.aps
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# Visual Studio History (VSHistory) files
.vshistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp
# JetBrains Rider
*.sln.iml
# Mac desktop service store files
.DS_Store
_NCrunch*

View File

@ -1,82 +0,0 @@
using System.Drawing;
namespace ProjectLiner
{
internal class DrawingLiner
{
Liner aag;
private readonly int _width = 0;
private readonly int _height = 0;
public DrawingLiner(Liner aag)
{
this.aag = aag;
_height = 60 + ((int)(aag.NumOfBoxes / 8 + 0.5) * 15);
_width = 150;
}
public DrawingLiner()
{
aag = new Liner();
}
public void SetPos(Point pos)
{
aag.position.X = Math.Clamp(pos.X + aag.position.X, 0, Program.faag.ClientSize.Width-_width);
aag.position.Y = Math.Clamp(pos.Y + aag.position.Y, 0, Program.faag.ClientSize.Height-_height);
}
public void MoveTransport(Vector2 way)
{
if(way == null)
{
throw new NullReferenceException();
}
SetPos(new Point((int)(way.x*aag.Step), (int)(way.y*aag.Step)));
}
public void Draw(Graphics g)
{
Pen pen = new Pen(Color.Black);
Brush brush1 = new SolidBrush(aag.FirstColor);
Brush brush2 = new SolidBrush(aag.SecondColor);
//deck
g.DrawPolygon(pen, new Point[] {
new Point(0 + aag.position.X, 15 + aag.position.Y+((int)(aag.NumOfBoxes/8+0.5)*15)),
new Point(150 + aag.position.X, 15 + aag.position.Y+((int)(aag.NumOfBoxes/8+0.5)*15)),
new Point(120 + aag.position.X, 45 + aag.position.Y+((int)(aag.NumOfBoxes/8+0.5)*15)),
new Point(30 + aag.position.X, 45 + aag.position.Y +((int)(aag.NumOfBoxes / 8 + 0.5) * 15)),
new Point(0 + aag.position.X, 15 + aag.position.Y +((int)(aag.NumOfBoxes / 8 + 0.5) * 15))});
g.FillPolygon(brush1, new Point[] {
new Point(0 + aag.position.X, 15 + aag.position.Y+((int)(aag.NumOfBoxes/8+0.5)*15)),
new Point(150 + aag.position.X, 15 + aag.position.Y+((int)(aag.NumOfBoxes/8+0.5)*15)),
new Point(120 + aag.position.X, 45 + aag.position.Y+((int)(aag.NumOfBoxes/8+0.5)*15)),
new Point(30 + aag.position.X, 45 + aag.position.Y +((int)(aag.NumOfBoxes / 8 + 0.5) * 15)),
new Point(0 + aag.position.X, 15 + aag.position.Y +((int)(aag.NumOfBoxes / 8 + 0.5) * 15))});
//mark
if (aag.HasMark)
{
g.DrawLine(new Pen(aag.SecondColor),30+aag.position.X, 20 + aag.position.Y + ((int)(aag.NumOfBoxes / 8 + 0.5) * 15), 30 + aag.position.X, 35 + aag.position.Y + ((int)(aag.NumOfBoxes / 8 + 0.5) * 15));
g.DrawLine(new Pen(aag.SecondColor), 20+aag.position.X, 25 + aag.position.Y + ((int)(aag.NumOfBoxes / 8 + 0.5) * 15), 40 + aag.position.X, 25 + aag.position.Y + ((int)(aag.NumOfBoxes / 8 + 0.5) * 15));
}
//block
for (int j = 0; j <= (int)(aag.NumOfBoxes / 8 + 0.5); j++)
{
if(aag.NumOfBoxes - j * 8 >= 8)
for (int i = 0; i < 8; i++)
{
g.FillRectangle(brush2, 15 + aag.position.X + i * 15, aag.position.Y - j * 15+((int)(aag.NumOfBoxes / 8 + 0.5) * 15), 15, 15);
g.DrawRectangle(pen, 15 + aag.position.X + i * 15, aag.position.Y - j * 15 + ((int)(aag.NumOfBoxes / 8 + 0.5) * 15), 15, 15);
}
else
for (int i = 0; i < aag.NumOfBoxes%8; i++)
{
if(aag.NumOfBoxes % 8 == 1)
{
g.FillRectangle(brush2, 8 + 15 + aag.position.X + (90 / 2), aag.position.Y - j * 15 + ((int)(aag.NumOfBoxes / 8 + 0.5) * 15), 15, 15);
g.DrawRectangle(pen, 8 + 15 + aag.position.X + (90 / 2), aag.position.Y - j * 15 + ((int)(aag.NumOfBoxes / 8 + 0.5) * 15), 15, 15);
continue;
}
g.FillRectangle(brush2,8 +15 + aag.position.X + (90 / (aag.NumOfBoxes % 8 - 1)) * i, aag.position.Y - j * 15 + ((int)(aag.NumOfBoxes / 8 + 0.5) * 15), 15, 15);
g.DrawRectangle(pen,8 + 15 + aag.position.X + (90 / (aag.NumOfBoxes % 8 - 1)) * i, aag.position.Y - j * 15 + ((int)(aag.NumOfBoxes / 8 + 0.5) * 15), 15, 15);
}
}
}
}
}

View File

@ -1,129 +0,0 @@
namespace ProjectLiner
{
partial class FormLiner
{
/// <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()
{
pictureBoxLiner = new PictureBox();
CreateButton = new Button();
buttonRight = new Button();
buttonDown = new Button();
buttonLeft = new Button();
buttonUp = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxLiner).BeginInit();
SuspendLayout();
//
// pictureBoxLiner
//
pictureBoxLiner.Dock = DockStyle.Fill;
pictureBoxLiner.Location = new Point(0, 0);
pictureBoxLiner.Name = "pictureBoxLiner";
pictureBoxLiner.Size = new Size(800, 450);
pictureBoxLiner.TabIndex = 5;
pictureBoxLiner.TabStop = false;
//
// CreateButton
//
CreateButton.Location = new Point(12, 408);
CreateButton.Name = "CreateButton";
CreateButton.Size = new Size(90, 30);
CreateButton.TabIndex = 0;
CreateButton.Text = "Create";
CreateButton.UseVisualStyleBackColor = true;
CreateButton.Click += ButtonCreate_Click;
//
// buttonRight
//
buttonRight.Font = new Font("Segoe UI", 15F, FontStyle.Regular, GraphicsUnit.Point);
buttonRight.Location = new Point(748, 398);
buttonRight.Name = "buttonRight";
buttonRight.Size = new Size(40, 40);
buttonRight.TabIndex = 1;
buttonRight.Text = "⇒";
buttonRight.UseVisualStyleBackColor = true;
buttonRight.Click += ButtonMove_Click;
//
// buttonDown
//
buttonDown.Font = new Font("Segoe UI", 15F, FontStyle.Regular, GraphicsUnit.Point);
buttonDown.Location = new Point(702, 398);
buttonDown.Name = "buttonDown";
buttonDown.Size = new Size(40, 40);
buttonDown.TabIndex = 2;
buttonDown.Text = "⇓";
buttonDown.UseVisualStyleBackColor = true;
buttonDown.Click += ButtonMove_Click;
//
// buttonLeft
//
buttonLeft.Font = new Font("Segoe UI", 15F, FontStyle.Regular, GraphicsUnit.Point);
buttonLeft.Location = new Point(656, 398);
buttonLeft.Name = "buttonLeft";
buttonLeft.Size = new Size(40, 40);
buttonLeft.TabIndex = 3;
buttonLeft.Text = "⇐";
buttonLeft.UseVisualStyleBackColor = true;
buttonLeft.Click += ButtonMove_Click;
//
// buttonUp
//
buttonUp.Font = new Font("Segoe UI", 15F, FontStyle.Regular, GraphicsUnit.Point);
buttonUp.Location = new Point(702, 352);
buttonUp.Name = "buttonUp";
buttonUp.Size = new Size(40, 40);
buttonUp.TabIndex = 4;
buttonUp.Text = "⇑";
buttonUp.UseVisualStyleBackColor = true;
buttonUp.Click += ButtonMove_Click;
//
// FormAntiAircraftGun
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(buttonUp);
Controls.Add(buttonLeft);
Controls.Add(buttonDown);
Controls.Add(buttonRight);
Controls.Add(CreateButton);
Controls.Add(pictureBoxLiner);
Name = "FormLiner";
Text = "Liner";
((System.ComponentModel.ISupportInitialize)pictureBoxLiner).EndInit();
ResumeLayout(false);
}
#endregion
private PictureBox pictureBoxLiner;
private Button CreateButton;
private Button buttonRight;
private Button buttonDown;
private Button buttonLeft;
private Button buttonUp;
}
}

View File

@ -1,53 +0,0 @@
namespace ProjectLiner
{
public partial class FormLiner : Form
{
private DrawingLiner? _drawer;
public FormLiner()
{
InitializeComponent();
}
private void Draw()
{
if (_drawer == null)
return;
Bitmap bmp = new(pictureBoxLiner.Width, pictureBoxLiner.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawer.Draw(gr);
pictureBoxLiner.Image = bmp;
}
private void ButtonMove_Click(object sender, EventArgs e)
{
if (_drawer == null)
{
return;
}
switch (((Button)sender)?.Name ?? string.Empty)
{
case "buttonUp":
_drawer.MoveTransport(new Vector2(0, -1));
break;
case "buttonDown":
_drawer.MoveTransport(new Vector2(0, 1));
break;
case "buttonLeft":
_drawer.MoveTransport(new Vector2(-1, 0));
break;
case "buttonRight":
_drawer.MoveTransport(new Vector2(1, 0));
break;
}
Draw();
}
private void ButtonCreate_Click(object sender, EventArgs e)
{
Random rnd = new Random();
_drawer = new DrawingLiner(new Liner(rnd.Next(1,100),rnd.Next(1,10),
Color.FromArgb(rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255)),
Color.FromArgb(rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255)),
rnd.Next(2, 25), Convert.ToBoolean(rnd.Next(0,2))));
Draw();
}
}
}

View File

@ -1,11 +0,0 @@
namespace ProjectLiner
{
abstract public class GameObject
{
public Point position;
public GameObject()
{
position = new Point();
}
}
}

View File

@ -1,76 +0,0 @@
namespace ProjectLiner
{
public class Liner : GameObject
{
private int _speed;
private int _weight;
private Color _firstCol;
private Color _secondCol;
private int _numOfBoxes;
private bool _haveMark;
private int _step;
public int Speed { get => _speed;}
public int Weight { get => _weight;}
public Color FirstColor { get => _firstCol; }
public Color SecondColor { get => _secondCol; }
public int NumOfBoxes { get => _numOfBoxes; }
public int Step { get => _step>0?_step:1; }
public bool HasMark { get => _haveMark;}
public Liner()
{
_speed = 1;
_weight = 1;
_firstCol = Color.Magenta;
_secondCol = Color.Black;
_numOfBoxes = 6;
_haveMark = true;
try
{
_step = _speed / _weight;
}catch(Exception e) { throw new Exception("Дурашка, какой ноль в весе?"); }
}
/// <summary>
///
/// </summary>
/// <param name="speed"></param>
/// <param name="weight">(0,int.MaxValue]</param>
/// <param name="firstCol"></param>
/// <param name="secondCol"></param>
/// <param name="numOfBoxes">[2,6]</param>
/// <exception cref="Exception"></exception>
public Liner(int speed, int weight, Color firstCol, Color secondCol, int numOfBoxes,bool haveMark)
{
if (numOfBoxes > 24||numOfBoxes<2)
throw new ArgumentOutOfRangeException($"{nameof(numOfBoxes)} out of range [2,24]");
_speed = speed;
_weight = weight;
_firstCol = firstCol;
_secondCol = secondCol;
_numOfBoxes = numOfBoxes;
_haveMark = haveMark;
try
{
_step = _speed / _weight;
}
catch (Exception e) { throw new Exception("Дурашка, какой ноль в весе?"); }
}
/// <summary>
///
/// </summary>
/// <param name="speed"></param>
/// <param name="weight">(0,int.MaxValue]</param>
/// <param name="firstCol"></param>
public Liner(int speed, int weight, Color firstCol)
{
_speed = speed;
_weight = weight;
_firstCol = firstCol;
_numOfBoxes = 6;
try
{
_step = _speed / _weight;
}
catch (Exception e) { throw e; }
}
}
}

View File

@ -1,18 +0,0 @@
namespace ProjectLiner
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
public static FormLiner faag = new FormLiner();
[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(faag);
}
}
}

View File

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

View File

@ -1,19 +0,0 @@
namespace ProjectLiner
{
public class Vector2
{
public float x, y;
public float lenght => MathF.Sqrt(x * x + y * y);
public Vector2 normilized => new Vector2(x/lenght, y/lenght);
public Vector2(float x, float y)
{
this.x = x;
this.y = y;
}
public Vector2()
{
x = 0;
y = 0;
}
}
}

Binary file not shown.

View File

@ -0,0 +1,122 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\drawingliner.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\drawingliner.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\formliner.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\formliner.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\entityliner.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\entityliner.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\formliner.designer.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\formliner.designer.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|c:\\somegitstuff\\isebd-11_khatypov_k.r_fundamental\\projectliner\\projectliner\\directiontype.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{7FB62E78-175F-490A-B5F2-2FF676947033}|ProjectLiner\\ProjectLiner.csproj|solutionrelative:projectliner\\directiontype.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 4,
"Children": [
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "FormLiner.cs",
"DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\FormLiner.cs",
"RelativeDocumentMoniker": "ProjectLiner\\FormLiner.cs",
"ToolTip": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\FormLiner.cs",
"RelativeToolTip": "ProjectLiner\\FormLiner.cs",
"ViewState": "AQIAAA8AAAAAAAAAAIA0wBcAAAAHAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-04-20T11:09:29.961Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 4,
"Title": "FormLiner.Designer.cs",
"DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\FormLiner.Designer.cs",
"RelativeDocumentMoniker": "ProjectLiner\\FormLiner.Designer.cs",
"ToolTip": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\FormLiner.Designer.cs",
"RelativeToolTip": "ProjectLiner\\FormLiner.Designer.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-04-20T11:09:26.829Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 2,
"Title": "Program.cs",
"DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\Program.cs",
"RelativeDocumentMoniker": "ProjectLiner\\Program.cs",
"ToolTip": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\Program.cs",
"RelativeToolTip": "ProjectLiner\\Program.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-04-20T11:09:23.139Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 3,
"Title": "EntityLiner.cs",
"DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\EntityLiner.cs",
"RelativeDocumentMoniker": "ProjectLiner\\EntityLiner.cs",
"ToolTip": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\EntityLiner.cs",
"RelativeToolTip": "ProjectLiner\\EntityLiner.cs",
"ViewState": "AQIAACEAAAAAAAAAAAAowAAAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-04-20T11:09:21.909Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "DrawingLiner.cs",
"DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\DrawingLiner.cs",
"RelativeDocumentMoniker": "ProjectLiner\\DrawingLiner.cs",
"ToolTip": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\DrawingLiner.cs",
"RelativeToolTip": "ProjectLiner\\DrawingLiner.cs",
"ViewState": "AQIAAG8AAAAAAAAAAAAqwHoAAAAKAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-04-20T11:09:20.684Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 5,
"Title": "DirectionType.cs",
"DocumentMoniker": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\DirectionType.cs",
"RelativeDocumentMoniker": "ProjectLiner\\DirectionType.cs",
"ToolTip": "C:\\SomeGitStuff\\ISEbd-11_Khatypov_K.R_fundamental\\ProjectLiner\\ProjectLiner\\DirectionType.cs",
"RelativeToolTip": "ProjectLiner\\DirectionType.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-04-20T11:09:18.889Z",
"EditorCaption": ""
}
]
}
]
}
]
}

View File

@ -1,9 +1,9 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.6.33815.320
VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectLiner", "ProjectLiner.csproj", "{0C215558-2860-459F-A04D-5BCE3792F5CC}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectLiner", "ProjectLiner\ProjectLiner.csproj", "{7FB62E78-175F-490A-B5F2-2FF676947033}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -11,15 +11,15 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0C215558-2860-459F-A04D-5BCE3792F5CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0C215558-2860-459F-A04D-5BCE3792F5CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0C215558-2860-459F-A04D-5BCE3792F5CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0C215558-2860-459F-A04D-5BCE3792F5CC}.Release|Any CPU.Build.0 = Release|Any CPU
{7FB62E78-175F-490A-B5F2-2FF676947033}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7FB62E78-175F-490A-B5F2-2FF676947033}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7FB62E78-175F-490A-B5F2-2FF676947033}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7FB62E78-175F-490A-B5F2-2FF676947033}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2A46C0F6-1F06-4A83-A51A-7BC26DD276FF}
SolutionGuid = {78BFA3C9-3BCC-4037-9217-9197133D11B5}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,27 @@
namespace ProjectLiner;
/// <summary>
/// Направление перемещения
/// </summary>
public enum DirectionType
{
/// <summary>
/// Вверх
/// </summary>
Up = 1,
/// <summary>
/// Вниз
/// </summary>
Down = 2,
/// <summary>
/// Влево
/// </summary>
Left = 3,
/// <summary>
/// Вправо
/// </summary>
Right = 4
}

View File

@ -0,0 +1,247 @@
namespace ProjectLiner;
/// <summary>
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
/// </summary>
public class DrawningLiner
{
/// <summary>
/// Класс-сущность
/// </summary>
public EntityLiner? EntityLiner { get; private set; }
/// <summary>
/// Ширина окна
/// </summary>
private int? _pictureWidth;
/// <summary>
/// Высота окна
/// </summary>
private int? _pictureHeight;
/// <summary>
/// Левая координата прорисовки автомобиля
/// </summary>
private int? _startPosX;
/// <summary>
/// Верхняя кооридната прорисовки автомобиля
/// </summary>
private int? _startPosY;
/// <summary>
/// Ширина прорисовки автомобиля
/// </summary>
private readonly int _drawingLinerWidth = 80;
/// <summary>
/// Высота прорисовки автомобиля
/// </summary>
private readonly int _drawingLinerHeight = 60;
/// <summary>
/// Инициализация свойств
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес</param>
/// <param name="bodyColor">Основной цвет</param>
/// <param name="additionalColor">Дополнительный цвет</param>
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool hasMark, bool hasDecoratins)
{
EntityLiner = new EntityLiner();
EntityLiner.Init(speed, weight, bodyColor, additionalColor, hasMark, hasDecoratins);
_pictureWidth = null;
_pictureHeight = null;
_startPosX = null;
_startPosY = null;
}
/// <summary>
/// Установка границ поля
/// </summary>
/// <param name="width">Ширина поля</param>
/// <param name="height">Высота поля</param>
/// <returns>true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах</returns>
public bool SetPictureSize(int width, int height)
{
// TODO проверка, что объект "влезает" в размеры поля
// если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена
if (_drawingLinerWidth > width || _drawingLinerHeight > height)
return false;
_pictureWidth = width;
_pictureHeight = height;
if (_startPosX.HasValue && _startPosY.HasValue)
{
if (_pictureWidth - _drawingLinerWidth < _startPosX)
_startPosX = _pictureWidth - _drawingLinerWidth;
if (_pictureHeight - _drawingLinerHeight < _startPosY)
_startPosY = _pictureHeight - _drawingLinerHeight;
}
return true;
}
/// <summary>
/// Установка позиции
/// </summary>
/// <param name="x">Координата X</param>
/// <param name="y">Координата Y</param>
public void SetPosition(int x, int y)
{
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
{
return;
}
_startPosX = _pictureWidth - _drawingLinerWidth < x ? _pictureWidth - _drawingLinerWidth : x;
_startPosY = _pictureHeight - _drawingLinerHeight < y ? _pictureHeight - _drawingLinerHeight : y;
}
/// <summary>
/// Изменение направления перемещения
/// </summary>
/// <param name="direction">Направление</param>
/// <returns>true - перемещене выполнено, false - перемещение невозможно</returns>
public bool MoveTransport(DirectionType direction)
{
if (EntityLiner == null || !_startPosX.HasValue || !_startPosY.HasValue)
{
return false;
}
switch (direction)
{
//влево
case DirectionType.Left:
if (_startPosX.Value - EntityLiner.Step > 0)
{
_startPosX -= (int)EntityLiner.Step;
}
return true;
//вверх
case DirectionType.Up:
if (_startPosY.Value - EntityLiner.Step > 0)
{
_startPosY -= (int)EntityLiner.Step;
}
return true;
// вправо
case DirectionType.Right:
if(_startPosX.Value + EntityLiner.Step < _pictureWidth-_drawingLinerWidth)
{
_startPosX += (int)EntityLiner.Step;
}
return true;
//вниз
case DirectionType.Down:
if (_startPosY.Value + EntityLiner.Step < _pictureHeight-_drawingLinerHeight)
{
_startPosY += (int)EntityLiner.Step;
}
return true;
default:
return false;
}
}
public void FormChanged(object sender, EventArgs e)
{
_pictureWidth = (sender as FormLiner).Size.Width;
_pictureHeight = (sender as FormLiner).Size.Height;
if (_startPosX.HasValue && _startPosY.HasValue)
{
if (_pictureWidth - _drawingLinerWidth < _startPosX)
_startPosX = _pictureWidth - _drawingLinerWidth;
if (_pictureHeight - _drawingLinerHeight < _startPosY)
_startPosY = _pictureHeight - _drawingLinerHeight;
(sender as FormLiner).Draw();
}
}
/// <summary>
/// Прорисовка объекта
/// </summary>
/// <param name="g"></param>
public void DrawTransport(Graphics g)
{
if (EntityLiner == null || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
}
Pen pen = new Pen(Color.Black);
Brush mainBrush = new SolidBrush(EntityLiner.BodyColor);
Brush additionalBrush = new SolidBrush(EntityLiner.AdditionalColor);
g.DrawRectangle(pen, new(_startPosX.Value, _startPosY.Value, 80, 60));
//Рисуем тело
g.FillPolygon(mainBrush, new Point[] {
new(_startPosX.Value+0, _startPosY.Value + 30),
new(_startPosX.Value+15,_startPosY.Value+50),
new(_startPosX.Value+65,_startPosY.Value+50),
new(_startPosX.Value+80,_startPosY.Value+30),
new(_startPosX.Value+0,_startPosY.Value+30),
new(_startPosX.Value+0,_startPosY.Value+20),
new(_startPosX.Value+80, _startPosY.Value+20),
new(_startPosX.Value+80, _startPosY.Value+30)
});
g.DrawLines(pen, new Point[] {
new(_startPosX.Value+0, _startPosY.Value + 30),
new(_startPosX.Value+15,_startPosY.Value+50),
new(_startPosX.Value+65,_startPosY.Value+50),
new(_startPosX.Value+80,_startPosY.Value+30),
new(_startPosX.Value+0,_startPosY.Value+30),
new(_startPosX.Value+0,_startPosY.Value+20),
new(_startPosX.Value+80, _startPosY.Value+20),
new(_startPosX.Value+80, _startPosY.Value+30)
});
//Рисуем окна
g.FillRectangles(additionalBrush, new Rectangle[]{
new(_startPosX.Value+5,_startPosY.Value+22,10,6),
new(_startPosX.Value+20,_startPosY.Value+22,10,6),
new(_startPosX.Value+35,_startPosY.Value+22,10,6),
new(_startPosX.Value+50,_startPosY.Value+22,10,6),
new(_startPosX.Value+65,_startPosY.Value+22,10,6),
});
g.DrawRectangles(pen, new Rectangle[]{
new(_startPosX.Value+5,_startPosY.Value+22,10,6),
new(_startPosX.Value+20,_startPosY.Value+22,10,6),
new(_startPosX.Value+35,_startPosY.Value+22,10,6),
new(_startPosX.Value+50,_startPosY.Value+22,10,6),
new(_startPosX.Value+65,_startPosY.Value+22,10,6),
});
//Марка на борту
if (EntityLiner.HasMark)
{
g.FillRectangles(additionalBrush, new Rectangle[]
{
new(_startPosX.Value+15,_startPosY.Value+38,17,3),
new(_startPosX.Value+22,_startPosY.Value+32,3,16)
});
}
//Декорации
if (EntityLiner.HasDecoratins)
{
g.FillRectangles(additionalBrush, new Rectangle[]
{
new(_startPosX.Value+8,_startPosY.Value+0,10,20),
new(_startPosX.Value+26,_startPosY.Value+0,10,20),
new(_startPosX.Value+44,_startPosY.Value+0,10,20),
new(_startPosX.Value+62,_startPosY.Value+0,10,20),
});
g.DrawRectangles(pen, new Rectangle[]
{
new(_startPosX.Value+8,_startPosY.Value+0,10,20),
new(_startPosX.Value+26,_startPosY.Value+0,10,20),
new(_startPosX.Value+44,_startPosY.Value+0,10,20),
new(_startPosX.Value+62,_startPosY.Value+0,10,20),
});
}
}
}

View File

@ -0,0 +1,62 @@
namespace ProjectLiner;
/// <summary>
/// Класс-сущность "Спортивный автомобиль"
/// </summary>
public class EntityLiner
{
/// <summary>
/// Скорость
/// </summary>
public int Speed { get; private set; }
/// <summary>
/// Вес
/// </summary>
public double Weight { get; private set; }
/// <summary>
/// Основной цвет
/// </summary>
public Color BodyColor { get; private set; }
/// <summary>
/// Дополнительный цвет (для опциональных элементов)
/// </summary>
public Color AdditionalColor { get; private set; }
/// <summary>
/// Имеет марку на боку
/// </summary>
public bool HasMark { get; private set; }
/// <summary>
/// Имеет декорации сверху
/// </summary>
public bool HasDecoratins { get; private set; }
/// <summary>
/// Шаг перемещения автомобиля
/// </summary>
public double Step => Speed * 100 / Weight;
/// <summary>
/// Инициализация полей объекта-класса спортивного автомобиля
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес автомобиля</param>
/// <param name="bodyColor">Основной цвет</param>
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="hasMark">Имеет значёк на куове</param>
/// <param name="hasDecoratins">Имеет декорации сверху</param>
///
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool hasMark, bool hasDecoratins)
{
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
AdditionalColor = additionalColor;
HasMark = hasMark;
HasDecoratins = hasDecoratins;
}
}

View File

@ -0,0 +1,134 @@
namespace ProjectLiner
{
partial class FormLiner
{
/// <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()
{
pictureBoxLiner = new PictureBox();
buttonCreateLiner = new Button();
buttonLeft = new Button();
buttonUp = new Button();
buttonDown = new Button();
buttonRight = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxLiner).BeginInit();
SuspendLayout();
//
// pictureBoxLiner
//
pictureBoxLiner.Dock = DockStyle.Fill;
pictureBoxLiner.Location = new Point(0, 0);
pictureBoxLiner.Name = "pictureBoxLiner";
pictureBoxLiner.Size = new Size(923, 597);
pictureBoxLiner.TabIndex = 0;
pictureBoxLiner.TabStop = false;
//
// buttonCreateLiner
//
buttonCreateLiner.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCreateLiner.Location = new Point(12, 562);
buttonCreateLiner.Name = "buttonCreateLiner";
buttonCreateLiner.Size = new Size(75, 23);
buttonCreateLiner.TabIndex = 1;
buttonCreateLiner.Text = "Создать";
buttonCreateLiner.UseVisualStyleBackColor = true;
buttonCreateLiner.Click += ButtonCreateLiner_Click;
//
// buttonLeft
//
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonLeft.BackgroundImage = Properties.Resources.arrowLeft;
buttonLeft.BackgroundImageLayout = ImageLayout.Stretch;
buttonLeft.Location = new Point(787, 550);
buttonLeft.Name = "buttonLeft";
buttonLeft.Size = new Size(35, 35);
buttonLeft.TabIndex = 2;
buttonLeft.UseVisualStyleBackColor = true;
buttonLeft.Click += ButtonMove_Click;
//
// buttonUp
//
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonUp.BackgroundImage = Properties.Resources.arrowUp;
buttonUp.BackgroundImageLayout = ImageLayout.Stretch;
buttonUp.Location = new Point(828, 509);
buttonUp.Name = "buttonUp";
buttonUp.Size = new Size(35, 35);
buttonUp.TabIndex = 3;
buttonUp.UseVisualStyleBackColor = true;
buttonUp.Click += ButtonMove_Click;
//
// buttonDown
//
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonDown.BackgroundImage = Properties.Resources.arrowDown;
buttonDown.BackgroundImageLayout = ImageLayout.Stretch;
buttonDown.Location = new Point(828, 550);
buttonDown.Name = "buttonDown";
buttonDown.Size = new Size(35, 35);
buttonDown.TabIndex = 4;
buttonDown.UseVisualStyleBackColor = true;
buttonDown.Click += ButtonMove_Click;
//
// buttonRight
//
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonRight.BackgroundImage = Properties.Resources.arrowRight;
buttonRight.BackgroundImageLayout = ImageLayout.Stretch;
buttonRight.Location = new Point(869, 550);
buttonRight.Name = "buttonRight";
buttonRight.Size = new Size(35, 35);
buttonRight.TabIndex = 5;
buttonRight.UseVisualStyleBackColor = true;
buttonRight.Click += ButtonMove_Click;
//
// FormLiner
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(923, 597);
Controls.Add(buttonRight);
Controls.Add(buttonDown);
Controls.Add(buttonUp);
Controls.Add(buttonLeft);
Controls.Add(buttonCreateLiner);
Controls.Add(pictureBoxLiner);
Name = "FormLiner";
Text = "Пассажирский лайнер";
((System.ComponentModel.ISupportInitialize)pictureBoxLiner).EndInit();
ResumeLayout(false);
}
#endregion
private PictureBox pictureBoxLiner;
private Button buttonCreateLiner;
private Button buttonLeft;
private Button buttonUp;
private Button buttonDown;
private Button buttonRight;
}
}

View File

@ -0,0 +1,93 @@
namespace ProjectLiner;
/// <summary>
/// Форма работы с объектом "Спортивный автомобиль"
/// </summary>
public partial class FormLiner : Form
{
/// <summary>
/// Поле-объект для прорисовки объекта
/// </summary>
private DrawningLiner? _drawningLiner;
/// <summary>
/// Конструктор формы
/// </summary>
public FormLiner()
{
InitializeComponent();
}
/// <summary>
/// Метод прорисовки машины
/// </summary>
public void Draw()
{
if (_drawningLiner == null)
{
return;
}
Bitmap bmp = new(pictureBoxLiner.Width, pictureBoxLiner.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawningLiner.DrawTransport(gr);
pictureBoxLiner.Image = bmp;
}
/// <summary>
/// Обработка нажатия кнопки "Создать"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonCreateLiner_Click(object sender, EventArgs e)
{
if (_drawningLiner != null)
ResizeEnd -= _drawningLiner.FormChanged;
Random random = new();
_drawningLiner = new DrawningLiner();
_drawningLiner.Init(random.Next(100, 300), random.Next(1000, 3000),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
_drawningLiner.SetPictureSize(pictureBoxLiner.Width, pictureBoxLiner.Height);
_drawningLiner.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
ResizeEnd += _drawningLiner.FormChanged;
}
/// <summary>
/// Перемещение объекта по форме (нажатие кнопок навигации)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonMove_Click(object sender, EventArgs e)
{
if (_drawningLiner == null)
{
return;
}
string name = ((Button)sender)?.Name ?? string.Empty;
bool result = false;
switch (name)
{
case "buttonUp":
result = _drawningLiner.MoveTransport(DirectionType.Up);
break;
case "buttonDown":
result = _drawningLiner.MoveTransport(DirectionType.Down);
break;
case "buttonLeft":
result = _drawningLiner.MoveTransport(DirectionType.Left);
break;
case "buttonRight":
result = _drawningLiner.MoveTransport(DirectionType.Right);
break;
}
if (result)
{
Draw();
}
}
}

View File

@ -0,0 +1,17 @@
namespace ProjectLiner
{
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 FormLiner());
}
}
}

View File

@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>

View File

@ -0,0 +1,103 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ProjectLiner.Properties {
using System;
/// <summary>
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
/// </summary>
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
// с помощью такого средства, как ResGen или Visual Studio.
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
// с параметром /str или перестройте свой проект VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.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 (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProjectLiner.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;
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arrowDown {
get {
object obj = ResourceManager.GetObject("arrowDown", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arrowLeft {
get {
object obj = ResourceManager.GetObject("arrowLeft", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arrowRight {
get {
object obj = ResourceManager.GetObject("arrowRight", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arrowUp {
get {
object obj = ResourceManager.GetObject("arrowUp", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -0,0 +1,133 @@
<?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>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="arrowDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrowDown.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="arrowLeft" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrowLeft.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="arrowRight" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrowRight.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="arrowUp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrowUp.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

View File

@ -1,2 +0,0 @@
# ISEbd-11_Khatypov_K.R_fundamental