Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
4c2d28dc7f | |||
d01d7cf012 | |||
3e17af2218 | |||
0897fa70ef | |||
90ce4321f0 | |||
6a4009d6ba |
25
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser.sln
Normal file
25
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.8.34525.116
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinF_Lab2_Cruiser", "WinF_Lab2_Cruiser\WinF_Lab2_Cruiser.csproj", "{D13E8CC0-46D6-4CB4-9DE1-E340C99B69FB}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D13E8CC0-46D6-4CB4-9DE1-E340C99B69FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D13E8CC0-46D6-4CB4-9DE1-E340C99B69FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D13E8CC0-46D6-4CB4-9DE1-E340C99B69FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D13E8CC0-46D6-4CB4-9DE1-E340C99B69FB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {23A421F3-C54C-4554-B468-133A363BD9CD}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
259
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.Designer.cs
generated
Normal file
259
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.Designer.cs
generated
Normal file
@ -0,0 +1,259 @@
|
||||
using System.Net.Http.Headers;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace WinF_Lab2_Cruiser
|
||||
{
|
||||
partial class CollectionForm
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
ToolBox = new GroupBox();
|
||||
StorageBox = new GroupBox();
|
||||
|
||||
// labelCollections = new Label();
|
||||
TextBoxC = new TextBox();
|
||||
ArrayRB = new RadioButton();
|
||||
ListRB = new RadioButton();
|
||||
ButtonAL = new Button();
|
||||
Elements = new ListBox();
|
||||
ButtonDelAL = new Button();
|
||||
CreateCompany = new Button();
|
||||
|
||||
Check = new Button();
|
||||
RandomGenerator = new Button();
|
||||
RemoveButton = new Button();
|
||||
maskedTextBox1 = new MaskedTextBox();
|
||||
Add2Button = new Button();
|
||||
AddButton = new Button();
|
||||
comboBox1 = new ComboBox();
|
||||
pictureBox1 = new PictureBox();
|
||||
ToolBox.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// ToolBox
|
||||
//
|
||||
|
||||
ToolBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
ToolBox.Controls.Add(Check);
|
||||
ToolBox.Controls.Add(RandomGenerator);
|
||||
ToolBox.Controls.Add(RemoveButton);
|
||||
ToolBox.Controls.Add(maskedTextBox1);
|
||||
ToolBox.Controls.Add(Add2Button);
|
||||
ToolBox.Controls.Add(AddButton);
|
||||
ToolBox.Controls.Add(comboBox1);
|
||||
|
||||
ToolBox.Controls.Add(StorageBox);
|
||||
ToolBox.Controls.Add(CreateCompany);
|
||||
|
||||
CreateCompany.Location = new Point(10, 540);
|
||||
CreateCompany.Size = new Size(190, 80);
|
||||
CreateCompany.Text = "Create company";
|
||||
CreateCompany.Click += ButtonCreateCompany_Click;
|
||||
|
||||
ToolBox.Location = new Point(1030, 12);
|
||||
ToolBox.Name = "ToolBox";
|
||||
ToolBox.Size = new Size(220, 900);
|
||||
ToolBox.TabIndex = 0;
|
||||
ToolBox.TabStop = false;
|
||||
ToolBox.Text = "Tools";
|
||||
|
||||
StorageBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
StorageBox.Location = new Point(8, 180);
|
||||
StorageBox.Size = new Size(204, 350);
|
||||
StorageBox.TabIndex = 1;
|
||||
StorageBox.Text = "Collections Name:";
|
||||
|
||||
StorageBox.Controls.Add(TextBoxC);
|
||||
TextBoxC.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
TextBoxC.Location = new Point(7, 70);
|
||||
TextBoxC.Size = new Size(180, 46);
|
||||
TextBoxC.TabIndex = 10;
|
||||
|
||||
StorageBox.Controls.Add(ArrayRB);
|
||||
ArrayRB.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
ArrayRB.Location = new Point(4, 118);
|
||||
ArrayRB.Size = new Size(100, 40);
|
||||
ArrayRB.TabIndex = 11;
|
||||
ArrayRB.Text = "Array";
|
||||
|
||||
StorageBox.Controls.Add(ListRB);
|
||||
ListRB.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
ListRB.Location = new Point(96, 118);
|
||||
ListRB.Size = new Size(80, 40);
|
||||
ListRB.TabIndex = 12;
|
||||
ListRB.Text = "List";
|
||||
|
||||
StorageBox.Controls.Add(ButtonAL);
|
||||
ButtonAL.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
ButtonAL.Location = new Point(6, 160);
|
||||
ButtonAL.Size = new Size(180, 40);
|
||||
ButtonAL.TabIndex = 13;
|
||||
ButtonAL.Text = "Add collection";
|
||||
ButtonAL.Click += ButtonCollectionAdd_Click;
|
||||
|
||||
StorageBox.Controls.Add(Elements);
|
||||
Elements.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
Elements.Location = new Point(6, 200);
|
||||
Elements.Size = new Size(180, 100);
|
||||
|
||||
StorageBox.Controls.Add(ButtonDelAL);
|
||||
ButtonDelAL.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
ButtonDelAL.Location = new Point(6, 300);
|
||||
ButtonDelAL.Size = new Size(180, 40);
|
||||
ButtonDelAL.TabIndex = 14;
|
||||
ButtonDelAL.Text = "Remove";
|
||||
ButtonDelAL.Click += ButtonCollectionDel_Click;
|
||||
|
||||
//
|
||||
// Check
|
||||
//
|
||||
Check.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
Check.Location = new Point(34, 824);
|
||||
Check.Name = "Check";
|
||||
Check.Size = new Size(150, 46);
|
||||
Check.TabIndex = 2;
|
||||
Check.Text = "Check";
|
||||
Check.UseVisualStyleBackColor = true;
|
||||
Check.Click += Check_Click;
|
||||
//
|
||||
// RandomGenerator
|
||||
//
|
||||
RandomGenerator.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
RandomGenerator.Location = new Point(34, 734);
|
||||
RandomGenerator.Name = "RandomGenerator";
|
||||
RandomGenerator.Size = new Size(150, 90);
|
||||
RandomGenerator.TabIndex = 3;
|
||||
RandomGenerator.Text = "Generator Random";
|
||||
RandomGenerator.UseVisualStyleBackColor = true;
|
||||
RandomGenerator.Click += RandomGenerator_Click;
|
||||
//
|
||||
// RemoveButton
|
||||
//
|
||||
RemoveButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
RemoveButton.Location = new Point(34, 694);
|
||||
RemoveButton.Name = "RemoveButton";
|
||||
RemoveButton.Size = new Size(150, 40);
|
||||
RemoveButton.TabIndex = 4;
|
||||
RemoveButton.Text = "Delete";
|
||||
RemoveButton.UseVisualStyleBackColor = true;
|
||||
RemoveButton.Click += RemoveButton_Click;
|
||||
//
|
||||
// maskedTextBox1
|
||||
//
|
||||
maskedTextBox1.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
maskedTextBox1.Location = new Point(6, 648);
|
||||
maskedTextBox1.Mask = "00";
|
||||
maskedTextBox1.Name = "maskedTextBox1";
|
||||
maskedTextBox1.Size = new Size(198, 35);
|
||||
maskedTextBox1.TabIndex = 5;
|
||||
maskedTextBox1.ValidatingType = typeof(int);
|
||||
|
||||
|
||||
//
|
||||
// Add2Button
|
||||
//
|
||||
Add2Button.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
Add2Button.Location = new Point(6, 126);
|
||||
Add2Button.Name = "Add2Button";
|
||||
Add2Button.Size = new Size(198, 40);
|
||||
Add2Button.TabIndex = 6;
|
||||
Add2Button.Text = "Advanced";
|
||||
Add2Button.UseVisualStyleBackColor = true;
|
||||
Add2Button.Click += Add2Button_Click;
|
||||
//
|
||||
// AddButton
|
||||
//
|
||||
AddButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
AddButton.Location = new Point(6, 84);
|
||||
AddButton.Name = "AddButton";
|
||||
AddButton.Size = new Size(198, 40);
|
||||
AddButton.TabIndex = 7;
|
||||
AddButton.Text = "Base";
|
||||
AddButton.UseVisualStyleBackColor = true;
|
||||
AddButton.Click += AddButton_Click;
|
||||
//
|
||||
// comboBox1
|
||||
//
|
||||
comboBox1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBox1.FormattingEnabled = true;
|
||||
comboBox1.Items.AddRange(new object[] { "Storage" });
|
||||
comboBox1.Location = new Point(6, 35);
|
||||
comboBox1.Name = "comboBox1";
|
||||
comboBox1.Size = new Size(198, 40);
|
||||
comboBox1.TabIndex = 8;
|
||||
comboBox1.SelectedIndexChanged += comboBox_SelectedIndexChanged;
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
pictureBox1.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
pictureBox1.Dock = DockStyle.Left;
|
||||
pictureBox1.Location = new Point(0, 0);
|
||||
pictureBox1.Name = "pictureBox1";
|
||||
pictureBox1.Size = new Size(1020, 860);
|
||||
pictureBox1.TabIndex = 9;
|
||||
pictureBox1.TabStop = false;
|
||||
//
|
||||
// CollectionForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(13F, 32F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1260, 920);
|
||||
Controls.Add(pictureBox1);
|
||||
Controls.Add(ToolBox);
|
||||
Name = "CollectionForm";
|
||||
Text = "CollectionForm";
|
||||
ToolBox.ResumeLayout(false);
|
||||
ToolBox.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox ToolBox;
|
||||
private GroupBox StorageBox;
|
||||
// private Label labelCollections;
|
||||
private TextBox TextBoxC;
|
||||
private RadioButton ArrayRB;
|
||||
private RadioButton ListRB;
|
||||
private Button ButtonAL;
|
||||
private ListBox Elements;
|
||||
private Button ButtonDelAL;
|
||||
private Button CreateCompany;
|
||||
|
||||
private ComboBox comboBox1;
|
||||
private Button AddButton;
|
||||
private Button Add2Button;
|
||||
private MaskedTextBox maskedTextBox1;
|
||||
private PictureBox pictureBox1;
|
||||
private Button RemoveButton;
|
||||
private Button RandomGenerator;
|
||||
private Button Check;
|
||||
}
|
||||
}
|
236
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.cs
Normal file
236
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.cs
Normal file
@ -0,0 +1,236 @@
|
||||
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;
|
||||
using WinF_Lab2_Cruiser.CollectionGenericObjects;
|
||||
using WinF_Lab2_Cruiser.Drawing_tools;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
using WinF_Lab2_Cruiser.Entity_Folder;
|
||||
|
||||
namespace WinF_Lab2_Cruiser
|
||||
{
|
||||
public partial class CollectionForm : Form
|
||||
{
|
||||
private readonly StorageCollection<DrawingBase> _storageCollection;
|
||||
|
||||
private AbstractCompany? _Company = null;
|
||||
public CollectionForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
_storageCollection = new();
|
||||
}
|
||||
|
||||
private void comboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
ToolBox.Enabled = true;
|
||||
|
||||
/*
|
||||
switch (comboBox1.Text)
|
||||
{
|
||||
case "Storage":
|
||||
_Company = new NewClassCollection(pictureBox1.Width, pictureBox1.Height, new ArrayAlg<DrawingBase>());
|
||||
break;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private static Color GetColor(Random r)
|
||||
{
|
||||
Color cl = Color.FromArgb(r.Next(0, 256), r.Next(0, 256), r.Next(0, 256));
|
||||
ColorDialog dialog = new();
|
||||
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{ cl = dialog.Color; }
|
||||
|
||||
return cl;
|
||||
}
|
||||
|
||||
private void CreateObject(string type)
|
||||
{
|
||||
if (_Company == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Random rn = new();
|
||||
DrawingBase Transport;
|
||||
switch (type)
|
||||
{
|
||||
case nameof(DrawingBase):
|
||||
Transport = new DrawingBase(rn.Next(100, 300), rn.Next(1000, 3000), GetColor(rn));
|
||||
break;
|
||||
case nameof(DrawingCruiser):
|
||||
Class_CruiserEntity Obj = new Class_CruiserEntity(rn.Next(100, 300), rn.Next(1000, 3000),
|
||||
GetColor(rn), GetColor(rn), Convert.ToBoolean(rn.Next(0, 2)),
|
||||
Convert.ToBoolean(rn.Next(0, 2)), rn.Next(1, 4), rn.Next(5, 10), rn.Next(1, 3));
|
||||
Transport = new DrawingCruiser(Obj);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (_Company + Transport >= 0)
|
||||
{
|
||||
MessageBox.Show("> Object was added");
|
||||
pictureBox1.Image = _Company.Show();
|
||||
}
|
||||
|
||||
else { MessageBox.Show("[!] Failed to add object"); }
|
||||
}
|
||||
|
||||
private void AddButton_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingBase));
|
||||
|
||||
private void Add2Button_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingCruiser));
|
||||
|
||||
private void RemoveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_Company == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(maskedTextBox1?.Text) || _Company == null) { return; }
|
||||
if (MessageBox.Show("[*] Remove object: Are you sure?", "Remove",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ((_Company - Convert.ToInt32(maskedTextBox1.Text)) != null)
|
||||
{
|
||||
MessageBox.Show("> Object was removed");
|
||||
pictureBox1.Image = _Company.Show();
|
||||
}
|
||||
else { MessageBox.Show("[!] No object to be removed"); }
|
||||
}
|
||||
|
||||
private void RandomGenerator_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_Company == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int counter = 100;
|
||||
DrawingBase? drBase = null;
|
||||
|
||||
while (drBase == null)
|
||||
{
|
||||
drBase = _Company.GetRandomObj();
|
||||
|
||||
counter--;
|
||||
|
||||
if (counter <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (drBase == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DrawingCanvas Form = new DrawingCanvas();
|
||||
|
||||
/*
|
||||
DrawingCanvas Form = new() { SetTransport = drBase };
|
||||
*/
|
||||
|
||||
Form.SetTransport = drBase;
|
||||
Form.ShowDialog();
|
||||
// ----------------------------------------------------------
|
||||
}
|
||||
|
||||
private void Check_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_Company == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBox1.Image = _Company.Show();
|
||||
}
|
||||
|
||||
private void ButtonCollectionAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(TextBoxC.Text) || (!ListRB.Checked && !ArrayRB.Checked))
|
||||
{
|
||||
MessageBox.Show("Enter correct data or choose an option", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
CollectionType collType = CollectionType.None;
|
||||
|
||||
if (ArrayRB.Checked)
|
||||
{
|
||||
collType = CollectionType.Array;
|
||||
}
|
||||
else if (ListRB.Checked)
|
||||
{
|
||||
collType = CollectionType.List;
|
||||
}
|
||||
|
||||
_storageCollection.AddCollection(TextBoxC.Text, collType);
|
||||
RefreshListBoxItems();
|
||||
}
|
||||
|
||||
private void RefreshListBoxItems()
|
||||
{
|
||||
Elements.Items.Clear();
|
||||
for (int i = 0; i < _storageCollection.Keys?.Count; ++i)
|
||||
{
|
||||
string? collName = _storageCollection.Keys?[i];
|
||||
if (!string.IsNullOrEmpty(collName))
|
||||
{
|
||||
Elements.Items.Add(collName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCollectionDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Elements.SelectedItem == null || Elements.SelectedIndex < 0)
|
||||
{
|
||||
MessageBox.Show("Collection was not choosed");
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Are you sure?", "Removing", MessageBoxButtons.OK, MessageBoxIcon.Question) != DialogResult.OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_storageCollection.DelCollection(Elements.SelectedItem.ToString());
|
||||
RefreshListBoxItems();
|
||||
}
|
||||
|
||||
private void ButtonCreateCompany_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Elements.SelectedIndex < 0 || Elements.SelectedItem == null)
|
||||
{
|
||||
MessageBox.Show("Collection was not choosed");
|
||||
return;
|
||||
}
|
||||
|
||||
ICGO<DrawingBase>? collection = _storageCollection[Elements.SelectedItem.ToString() ?? string.Empty];
|
||||
if (collection == null)
|
||||
{
|
||||
MessageBox.Show("Collection is not initialized");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (comboBox1.Text)
|
||||
{
|
||||
case "Storage":
|
||||
_Company = new NewClassCollection(pictureBox1.Width, pictureBox1.Height, collection);
|
||||
break;
|
||||
}
|
||||
|
||||
ToolBox.Enabled = true;
|
||||
RefreshListBoxItems();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
120
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.resx
Normal file
120
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.resx
Normal 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>
|
@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WinF_Lab2_Cruiser.Drawing_tools;
|
||||
|
||||
namespace WinF_Lab2_Cruiser.CollectionGenericObjects
|
||||
{
|
||||
public abstract class AbstractCompany
|
||||
{
|
||||
protected readonly int _placeSizeWidth = 302;
|
||||
protected readonly int _placeSizeHeight = 46;
|
||||
|
||||
protected readonly int _picW, _picH;
|
||||
|
||||
protected ICGO<DrawingBase>? _Array = null;
|
||||
|
||||
// max num of vehicles
|
||||
private int GetMaxCount => _picW * _picH / (_placeSizeWidth * _placeSizeHeight);
|
||||
|
||||
public AbstractCompany(int SizeWidth, int SizeHeight, ICGO<DrawingBase>? array)
|
||||
{
|
||||
_picW = SizeWidth;
|
||||
_picH = SizeHeight;
|
||||
_Array = array;
|
||||
_Array.SetMaxCount = GetMaxCount;
|
||||
}
|
||||
|
||||
// insted of bool:
|
||||
public static int operator +(AbstractCompany cmp,
|
||||
DrawingBase trasport) => (cmp._Array.Insert(trasport));
|
||||
|
||||
public static DrawingBase operator -(AbstractCompany cmp,
|
||||
int pos) => (cmp._Array.Remove(pos));
|
||||
|
||||
public DrawingBase? GetRandomObj()
|
||||
{
|
||||
Random r = new();
|
||||
return _Array?.GetItem(r.Next(GetMaxCount));
|
||||
}
|
||||
|
||||
public Bitmap? Show()
|
||||
{
|
||||
Bitmap bitmap = new(_picW, _picH);
|
||||
Graphics Gr = Graphics.FromImage(bitmap);
|
||||
|
||||
DrawBackgound(Gr);
|
||||
|
||||
SetObjectsPosition();
|
||||
|
||||
for (int i = 0; i < (_Array?.Count ?? 0); ++i)
|
||||
{
|
||||
DrawingBase? obj = _Array?.GetItem(i);
|
||||
obj?.DrawTransport(Gr);
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
protected abstract void DrawBackgound(Graphics g);
|
||||
protected abstract void SetObjectsPosition();
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,112 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinF_Lab2_Cruiser.CollectionGenericObjects
|
||||
{
|
||||
public class ArrayAlg<K> : ICGO<K>
|
||||
where K : class
|
||||
{
|
||||
private K?[] _Array;
|
||||
|
||||
public ArrayAlg()
|
||||
{
|
||||
_Array = Array.Empty<K?>();
|
||||
}
|
||||
|
||||
public int Count => _Array.Length;
|
||||
|
||||
public int SetMaxCount { set {
|
||||
if (value > 0)
|
||||
{
|
||||
if (_Array.Length > 0)
|
||||
{
|
||||
Array.Resize(ref _Array, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_Array = new K?[value];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public K? GetItem(int index)
|
||||
{
|
||||
if (index > Count || index < 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _Array[index];
|
||||
}
|
||||
|
||||
public int Insert(K item)
|
||||
{
|
||||
// any empty place
|
||||
for (int i = 0; i <= Count; i++)
|
||||
{
|
||||
if (_Array[i] == null)
|
||||
{
|
||||
_Array[i] = item;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int Insert(int index, K item)
|
||||
{
|
||||
if (_Array[index] == null)
|
||||
{
|
||||
_Array[index] = item;
|
||||
return index;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
int min_diff = 100, min_index = 100;
|
||||
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
if (_Array[i] == null && min_diff > Math.Abs(index - i))
|
||||
{
|
||||
min_diff = Math.Abs(index - i);
|
||||
min_index = i;
|
||||
}
|
||||
}
|
||||
_Array[min_index] = item;
|
||||
return min_index;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public K Remove(int index)
|
||||
{
|
||||
K item;
|
||||
if (index < Count && index >= 0)
|
||||
{
|
||||
item = _Array[index];
|
||||
_Array[index] = null;
|
||||
return item;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
public bool Remove(int index)
|
||||
{
|
||||
K item;
|
||||
if (index < Count)
|
||||
{
|
||||
item = _Array[index];
|
||||
_Array[index] = null;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinF_Lab2_Cruiser.CollectionGenericObjects
|
||||
{
|
||||
public enum CollectionType
|
||||
{
|
||||
None = 0,
|
||||
Array = 1,
|
||||
List = 2
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinF_Lab2_Cruiser.CollectionGenericObjects
|
||||
{
|
||||
public interface ICGO<K>
|
||||
where K : class // ссылочный тип
|
||||
{
|
||||
int Count { get; }
|
||||
int SetMaxCount { set; }
|
||||
|
||||
int Insert(K item);
|
||||
int Insert(int index, K item);
|
||||
|
||||
K? Remove(int index);
|
||||
//bool Remove(int index);
|
||||
K? GetItem(int index);
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinF_Lab2_Cruiser.CollectionGenericObjects
|
||||
{
|
||||
public class ListGenericObjects<K> : ICGO<K> where K : class
|
||||
{
|
||||
private readonly List<K?> _collection;
|
||||
private int _maxCount;
|
||||
public int Count => _collection.Count;
|
||||
|
||||
public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } }
|
||||
|
||||
public ListGenericObjects()
|
||||
{
|
||||
_collection = new();
|
||||
}
|
||||
|
||||
public K? GetItem(int index)
|
||||
{
|
||||
if (index >= Count || index < 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _collection[index];
|
||||
}
|
||||
|
||||
public int Insert(K item)
|
||||
{
|
||||
if (item == null) // unneccesary
|
||||
{
|
||||
return -1; // [!] not 0,
|
||||
// 'cause 0 can be an index of item
|
||||
}
|
||||
|
||||
_collection.Add(item);
|
||||
return _collection.Count;
|
||||
}
|
||||
|
||||
public int Insert(int index, K item)
|
||||
{
|
||||
if (index >= _maxCount || index < 0 || _collection[index] != null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
_collection.Insert(index, item);
|
||||
return index;
|
||||
}
|
||||
|
||||
public K? Remove(int index)
|
||||
{
|
||||
if (index >= Count || index < 0) // on the other positions item doesn't exist
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
K item = _collection[index];
|
||||
_collection.RemoveAt(index);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WinF_Lab2_Cruiser.Drawing_tools;
|
||||
|
||||
namespace WinF_Lab2_Cruiser.CollectionGenericObjects
|
||||
{
|
||||
internal class NewClassCollection : AbstractCompany // service
|
||||
{
|
||||
private int startCoordX = 10, startCoordY = 10, between = 30;
|
||||
|
||||
public int maxWkolvo { get; private set; }
|
||||
public int maxHkolvo { get; private set; }
|
||||
|
||||
public NewClassCollection(int SizeWidth, int SizeHeight, ICGO<DrawingBase>? array) : base(SizeWidth, SizeHeight, array)
|
||||
{
|
||||
maxWkolvo = _picW / (_placeSizeWidth + between);
|
||||
maxHkolvo = _picH / _placeSizeHeight;
|
||||
}
|
||||
|
||||
protected override void DrawBackgound(Graphics g)
|
||||
{
|
||||
Pen pen = new(Color.Black, 2);
|
||||
|
||||
int currentH = 10, currentW = 10;
|
||||
|
||||
for (int i = 0; i < maxWkolvo; i++)
|
||||
{
|
||||
currentH = 10;
|
||||
for (int j = 0; j < maxHkolvo; j++)
|
||||
{
|
||||
g.DrawLine(pen, currentW + 302, currentH - 1, currentW - 1, currentH - 1);
|
||||
g.DrawLine(pen, currentW - 1, currentH - 1, currentW - 1, currentH + 50);
|
||||
|
||||
currentH += _placeSizeHeight + 1; // + between;
|
||||
}
|
||||
currentW += _placeSizeWidth + between;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SetObjectsPosition()
|
||||
{
|
||||
int index_collection = 0;
|
||||
int newX = startCoordX, newY = startCoordY;
|
||||
|
||||
if (_Array != null)
|
||||
{
|
||||
for(int i = 0; i < maxHkolvo; ++i)
|
||||
{
|
||||
newX = startCoordX;
|
||||
for (int j = 0; j < maxWkolvo; ++j)
|
||||
{
|
||||
if (_Array.GetItem(index_collection) != null)
|
||||
{
|
||||
_Array.GetItem(index_collection).SetPicSize(_picW, _picH);
|
||||
_Array.GetItem(index_collection).SetPos(newX, newY);
|
||||
newX += _placeSizeWidth + between;
|
||||
index_collection++;
|
||||
}
|
||||
}
|
||||
newY += _placeSizeHeight + 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WinF_Lab2_Cruiser.Drawing_tools;
|
||||
|
||||
namespace WinF_Lab2_Cruiser.CollectionGenericObjects
|
||||
{
|
||||
public class StorageCollection<T> where T : class
|
||||
{
|
||||
private Dictionary<string, ICGO<T>> _storage;
|
||||
public List<string> Keys => _storage.Keys.ToList();
|
||||
public StorageCollection()
|
||||
{
|
||||
_storage = new Dictionary<string, ICGO<T>>();
|
||||
}
|
||||
|
||||
public void AddCollection(string name, CollectionType CollType)
|
||||
{
|
||||
if (name == null || _storage.ContainsKey(name) || CollType == CollectionType.None)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (CollType)
|
||||
{
|
||||
case CollectionType.Array : _storage.Add(name, new ArrayAlg<T>()); break; // ------------------------------------------------ [ !!! ]
|
||||
case CollectionType.List : _storage[name] = new ListGenericObjects<T>(); break;
|
||||
}
|
||||
}
|
||||
|
||||
public void DelCollection(string name)
|
||||
{
|
||||
if (_storage.ContainsKey(name)) _storage.Remove(name);
|
||||
return;
|
||||
}
|
||||
|
||||
public ICGO<T>? this[string name] // int i
|
||||
{
|
||||
get
|
||||
{
|
||||
/*
|
||||
int k = 0;
|
||||
foreach (string key in Keys)
|
||||
{
|
||||
if (k >= i)
|
||||
{
|
||||
if (_storage.ContainsKey(Keys[k])) return _storage[name];
|
||||
return null;
|
||||
}
|
||||
k++;
|
||||
}
|
||||
*/
|
||||
|
||||
if (_storage.ContainsKey(name)) return _storage[name];
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
201
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/DrawingCanvas.Designer.cs
generated
Normal file
201
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/DrawingCanvas.Designer.cs
generated
Normal file
@ -0,0 +1,201 @@
|
||||
|
||||
namespace WinF_Lab2_Cruiser
|
||||
{
|
||||
partial class DrawingCanvas
|
||||
{
|
||||
/// <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();
|
||||
//CreateButton = new Button();
|
||||
//CreateButton2 = new Button();
|
||||
buttonUp = new Button();
|
||||
buttonLeft = new Button();
|
||||
buttonDown = new Button();
|
||||
buttonRight = new Button();
|
||||
ButtonActivate = new Button();
|
||||
comboBox = new ComboBox();
|
||||
Activate = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
pictureBox1.Dock = DockStyle.Fill;
|
||||
pictureBox1.Location = new Point(0, 0);
|
||||
pictureBox1.Margin = new Padding(6);
|
||||
pictureBox1.Name = "pictureBox1";
|
||||
pictureBox1.Size = new Size(1018, 604);
|
||||
pictureBox1.TabIndex = 0;
|
||||
pictureBox1.TabStop = false;
|
||||
//
|
||||
// CreateButton
|
||||
//
|
||||
/*
|
||||
CreateButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
CreateButton.Location = new Point(22, 465);
|
||||
CreateButton.Margin = new Padding(6);
|
||||
CreateButton.Name = "CreateButton";
|
||||
CreateButton.Size = new Size(139, 113);
|
||||
CreateButton.TabIndex = 1;
|
||||
CreateButton.Text = "Create object";
|
||||
CreateButton.UseVisualStyleBackColor = true;
|
||||
CreateButton.Click += buttonCr_Click;
|
||||
//
|
||||
// CreateButton2
|
||||
//
|
||||
CreateButton2.Location = new Point(22, 26);
|
||||
CreateButton2.Margin = new Padding(6);
|
||||
CreateButton2.Name = "CreateButton2";
|
||||
CreateButton2.Size = new Size(139, 113);
|
||||
CreateButton2.TabIndex = 2;
|
||||
CreateButton2.Text = "Cr Updated Object";
|
||||
CreateButton2.UseVisualStyleBackColor = true;
|
||||
CreateButton2.Click += buttonCr2_Click;
|
||||
*/
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonUp.BackgroundImage = Properties.Resources.up_arrow_res;
|
||||
buttonUp.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonUp.Location = new Point(817, 371);
|
||||
buttonUp.Margin = new Padding(6);
|
||||
buttonUp.Name = "buttonUp";
|
||||
buttonUp.Size = new Size(84, 96);
|
||||
buttonUp.TabIndex = 3;
|
||||
buttonUp.UseVisualStyleBackColor = true;
|
||||
buttonUp.Click += ButtonMove_Click;
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonLeft.BackgroundImage = Properties.Resources.left_arrow_res;
|
||||
buttonLeft.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonLeft.Location = new Point(722, 480);
|
||||
buttonLeft.Margin = new Padding(6);
|
||||
buttonLeft.Name = "buttonLeft";
|
||||
buttonLeft.Size = new Size(84, 96);
|
||||
buttonLeft.TabIndex = 4;
|
||||
buttonLeft.UseVisualStyleBackColor = true;
|
||||
buttonLeft.Click += ButtonMove_Click;
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonDown.BackgroundImage = Properties.Resources.down_arrow_res;
|
||||
buttonDown.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonDown.Location = new Point(817, 480);
|
||||
buttonDown.Margin = new Padding(6);
|
||||
buttonDown.Name = "buttonDown";
|
||||
buttonDown.Size = new Size(84, 96);
|
||||
buttonDown.TabIndex = 5;
|
||||
buttonDown.UseVisualStyleBackColor = true;
|
||||
buttonDown.Click += ButtonMove_Click;
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonRight.BackgroundImage = Properties.Resources.right_arrow_res;
|
||||
buttonRight.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonRight.Location = new Point(912, 480);
|
||||
buttonRight.Margin = new Padding(6);
|
||||
buttonRight.Name = "buttonRight";
|
||||
buttonRight.Size = new Size(84, 96);
|
||||
buttonRight.TabIndex = 6;
|
||||
buttonRight.UseVisualStyleBackColor = true;
|
||||
buttonRight.Click += ButtonMove_Click;
|
||||
//
|
||||
// ListComboBox
|
||||
//
|
||||
//
|
||||
// ButtonActivate
|
||||
//
|
||||
ButtonActivate.Anchor = AnchorStyles.Right;
|
||||
ButtonActivate.Location = new Point(22, 149);
|
||||
ButtonActivate.Margin = new Padding(6);
|
||||
ButtonActivate.Name = "ButtonActivate";
|
||||
ButtonActivate.Size = new Size(84, 96);
|
||||
ButtonActivate.TabIndex = 8;
|
||||
ButtonActivate.UseVisualStyleBackColor = true;
|
||||
ButtonActivate.Click += comboBox_Activate;
|
||||
//
|
||||
// comboBox1
|
||||
//
|
||||
comboBox.FormattingEnabled = true;
|
||||
comboBox.Items.AddRange(new object[] { "Center", "Boarder" });
|
||||
comboBox.Location = new Point(188, 26);
|
||||
comboBox.Name = "Directions";
|
||||
comboBox.Size = new Size(203, 40);
|
||||
comboBox.TabIndex = 9;
|
||||
//
|
||||
// Activate
|
||||
//
|
||||
Activate.Location = new Point(188, 93);
|
||||
Activate.Name = "Activate";
|
||||
Activate.Size = new Size(203, 46);
|
||||
Activate.TabIndex = 10;
|
||||
Activate.Text = "ActivateStep";
|
||||
Activate.UseVisualStyleBackColor = true;
|
||||
Activate.Click += comboBox_Activate;
|
||||
//
|
||||
// DrawingCanvas
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(13F, 32F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
AutoValidate = AutoValidate.EnableAllowFocusChange;
|
||||
BackColor = Color.CornflowerBlue;
|
||||
ClientSize = new Size(1018, 604);
|
||||
Controls.Add(Activate);
|
||||
Controls.Add(comboBox);
|
||||
Controls.Add(buttonRight);
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonLeft);
|
||||
Controls.Add(buttonUp);
|
||||
//Controls.Add(CreateButton);
|
||||
//Controls.Add(CreateButton2);
|
||||
Controls.Add(pictureBox1);
|
||||
Controls.Add(ButtonActivate);
|
||||
Margin = new Padding(4, 2, 4, 2);
|
||||
Name = "DrawingCanvas";
|
||||
StartPosition = FormStartPosition.Manual;
|
||||
Text = "DrawingCanvas";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
#endregion
|
||||
private PictureBox pictureBox1;
|
||||
//private Button CreateButton;
|
||||
//private Button CreateButton2;
|
||||
private Button buttonUp;
|
||||
private Button buttonLeft;
|
||||
private Button buttonDown;
|
||||
private Button buttonRight;
|
||||
private Button ButtonActivate;
|
||||
private ComboBox comboBox;
|
||||
private Button Activate;
|
||||
}
|
||||
}
|
131
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/DrawingCanvas.cs
Normal file
131
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/DrawingCanvas.cs
Normal file
@ -0,0 +1,131 @@
|
||||
using WinF_Lab2_Cruiser.Drawing_tools;
|
||||
using WinF_Lab2_Cruiser.Entity_Folder;
|
||||
using WinF_Lab2_Cruiser.Move_Strategy;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WinF_Lab2_Cruiser
|
||||
{
|
||||
public partial class DrawingCanvas : Form
|
||||
{
|
||||
private DrawingBase? _DrCruiser;
|
||||
private AbstractStrategy? _strategy;
|
||||
|
||||
public DrawingBase SetTransport
|
||||
{
|
||||
set
|
||||
{
|
||||
_DrCruiser = value;
|
||||
_DrCruiser.SetPicSize(pictureBox1.Width, pictureBox1.Height);
|
||||
comboBox.Enabled = true;
|
||||
_strategy = null;
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
|
||||
public DrawingCanvas()
|
||||
{
|
||||
InitializeComponent();
|
||||
_strategy = null;
|
||||
// DrawBackgound(Gr);
|
||||
}
|
||||
//private DrawingCanvas_Load(object sender, EventArgs e);
|
||||
private void Draw()
|
||||
{
|
||||
if (_DrCruiser == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bmp = new(pictureBox1.Width, pictureBox1.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp); _DrCruiser.DrawTransport(gr);
|
||||
pictureBox1.Image = bmp;
|
||||
// DrawBackgound(gr);
|
||||
}
|
||||
|
||||
/*
|
||||
private void CreateObj(string type)
|
||||
{
|
||||
Random rn = new Random();
|
||||
switch (type)
|
||||
{
|
||||
case nameof(DrawingBase):
|
||||
_DrCruiser = new DrawingBase(rn.Next(100, 300), rn.Next(1000, 3000), Color.FromArgb(rn.Next(0, 256), rn.Next(0, 256), rn.Next(0, 256)));
|
||||
break;
|
||||
case nameof(DrawingCruiser):
|
||||
Class_CruiserEntity Obj = new Class_CruiserEntity(rn.Next(100, 300), rn.Next(1000, 3000),
|
||||
Color.FromArgb(rn.Next(0, 256), rn.Next(0, 256), rn.Next(0, 256)), Color.FromArgb(rn.Next(0, 256), rn.Next(0, 256), rn.Next(0, 256)),
|
||||
Convert.ToBoolean(rn.Next(0, 2)), Convert.ToBoolean(rn.Next(0, 2)), rn.Next(1, 4), rn.Next(5, 10), rn.Next(1, 3));
|
||||
_DrCruiser = new DrawingCruiser(Obj);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
_DrCruiser.SetPicSize(pictureBox1.Width, pictureBox1.Height);
|
||||
_DrCruiser.SetPos(rn.Next(pictureBox1.Width - 600, pictureBox1.Width - _DrCruiser._CruiserMaxW), rn.Next(0, 100)); _strategy = null;
|
||||
comboBox.Enabled = true;
|
||||
Draw();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void buttonCr2_Click(object sender, EventArgs e) => CreateObj(nameof(DrawingCruiser));
|
||||
private void buttonCr_Click(object sender, EventArgs e) => CreateObj(nameof(DrawingBase));
|
||||
*/
|
||||
|
||||
private void comboBox_Activate(object sender, EventArgs e)
|
||||
{
|
||||
if (_DrCruiser == null) return;
|
||||
|
||||
if (comboBox.Enabled)
|
||||
{
|
||||
_strategy = comboBox.SelectedIndex switch
|
||||
{
|
||||
0 => new Center(),
|
||||
1 => new Boarder()
|
||||
};
|
||||
|
||||
if (_strategy == null) return;
|
||||
_strategy.SetData(new MovableCruiser(_DrCruiser), pictureBox1.Width, pictureBox1.Height);
|
||||
}
|
||||
|
||||
if (_strategy == null) return;
|
||||
comboBox.Enabled = false;
|
||||
|
||||
_strategy.MakeStep();
|
||||
Draw();
|
||||
|
||||
if (_strategy.GetStatus() == Status.Finish)
|
||||
{
|
||||
comboBox.Enabled = true;
|
||||
_strategy = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_DrCruiser == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
bool result = false; switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
result = _DrCruiser.MoveTransport(DirectionType.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
result = _DrCruiser.MoveTransport(DirectionType.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
result = _DrCruiser.MoveTransport(DirectionType.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
result = _DrCruiser.MoveTransport(DirectionType.Right);
|
||||
break;
|
||||
}
|
||||
if (result)
|
||||
{
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/DrawingCanvas.resx
Normal file
120
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/DrawingCanvas.resx
Normal 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>
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinF_Lab2_Cruiser.Drawing_tools
|
||||
{
|
||||
public enum DirectionType
|
||||
{
|
||||
Unknown = -1,
|
||||
Up = 1,
|
||||
Down = 2,
|
||||
Left = 3,
|
||||
Right = 4
|
||||
}
|
||||
}
|
191
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Drawing_tools/DrawingBase.cs
Normal file
191
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Drawing_tools/DrawingBase.cs
Normal file
@ -0,0 +1,191 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WinF_Lab2_Cruiser.Entity_Folder;
|
||||
|
||||
namespace WinF_Lab2_Cruiser.Drawing_tools
|
||||
{
|
||||
public class DrawingBase
|
||||
{
|
||||
/// Инициализация свойств (все параметры класса (сущности))
|
||||
public Base_Class_Cruiser? BaseEntity { get; protected set; }
|
||||
|
||||
/// Передача размеров поля & объекта
|
||||
private int? _pictureWidth;
|
||||
private int? _pictureHeight;
|
||||
|
||||
public readonly int _CruiserMaxW = 302;
|
||||
public readonly int _CruiserMaxH = 72;
|
||||
|
||||
/// Установка позиции
|
||||
protected int? _startPosX;
|
||||
protected int? _startPosY;
|
||||
|
||||
// for relationship with Moves*
|
||||
|
||||
public int? GetPosX => _startPosX;
|
||||
public int? GetPosY => _startPosY;
|
||||
public int GetWidth => _CruiserMaxW;
|
||||
public int GetHeight => _CruiserMaxH;
|
||||
|
||||
private DrawingBase()
|
||||
{
|
||||
_pictureHeight = null;
|
||||
_pictureWidth = null;
|
||||
_startPosX = null;
|
||||
_startPosY = null;
|
||||
}
|
||||
|
||||
public DrawingBase(int speed, double weight, Color mainc) : this()
|
||||
{
|
||||
BaseEntity = new Base_Class_Cruiser(speed, weight, mainc);
|
||||
}
|
||||
|
||||
protected DrawingBase(int MaxW, int MaxH) : this()
|
||||
{
|
||||
_CruiserMaxW = MaxW;
|
||||
_CruiserMaxH = MaxH;
|
||||
}
|
||||
|
||||
|
||||
public bool SetPicSize(int w, int h)
|
||||
{
|
||||
if (w > _pictureWidth || h > _pictureHeight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_pictureWidth = w;
|
||||
_pictureHeight = h;
|
||||
|
||||
if (_startPosX != null || _startPosY != null)
|
||||
{
|
||||
SetPos(_startPosX.Value, _startPosY.Value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SetPos(int x, int y)
|
||||
{
|
||||
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (x > _pictureWidth - _CruiserMaxW) _startPosX = _pictureWidth - _CruiserMaxW;
|
||||
else if (x < 0) _startPosX = 0;
|
||||
else _startPosX = x;
|
||||
|
||||
if (y > _pictureHeight - _CruiserMaxH) _startPosY = _pictureHeight.Value - _CruiserMaxH;
|
||||
else if (y < 0) _startPosY = 0;
|
||||
else _startPosY = y;
|
||||
}
|
||||
|
||||
public bool MoveTransport(DirectionType direction) // public Direction (?)
|
||||
{
|
||||
if (BaseEntity == null || !_startPosX.HasValue ||
|
||||
!_startPosY.HasValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
//влево
|
||||
case DirectionType.Left:
|
||||
if (_startPosX.Value - BaseEntity.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)BaseEntity.Step;
|
||||
}
|
||||
return true;
|
||||
//вверх
|
||||
case DirectionType.Up:
|
||||
if (_startPosY.Value - BaseEntity.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)BaseEntity.Step;
|
||||
}
|
||||
return true;
|
||||
// вправо
|
||||
case DirectionType.Right:
|
||||
if (_startPosX.Value + _CruiserMaxW + BaseEntity.Step < _pictureWidth.Value)
|
||||
{
|
||||
_startPosX += (int)BaseEntity.Step;
|
||||
}
|
||||
return true;
|
||||
//вниз
|
||||
case DirectionType.Down:
|
||||
if (_startPosY.Value + _CruiserMaxH + BaseEntity.Step < _pictureHeight.Value)
|
||||
{
|
||||
_startPosY += (int)BaseEntity.Step;
|
||||
}
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
if (BaseEntity == null || !_startPosX.HasValue ||
|
||||
!_startPosY.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Pen pen = new(Color.Black, 2);
|
||||
Brush PadBrush = new HatchBrush(HatchStyle.DottedDiamond, Color.LightGray, Color.Black);
|
||||
// Brush additionalBrush = new SolidBrush(BaseEntity.AdditionalC);
|
||||
Brush mainBrush = new SolidBrush(BaseEntity.MainC);
|
||||
|
||||
Random random = new();
|
||||
|
||||
// границы cruiser
|
||||
|
||||
Point point0 = new Point(_startPosX.Value + 2, _startPosY.Value + 7);
|
||||
Point point1 = new Point(_startPosX.Value + 2, _startPosY.Value + 30);
|
||||
Point point2 = new Point(_startPosX.Value + 184, _startPosY.Value + 42);
|
||||
Point point3 = new Point(_startPosX.Value + 260, _startPosY.Value + 34);
|
||||
Point point4 = new Point(_startPosX.Value + 300, _startPosY.Value + 22);
|
||||
Point point5 = new Point(_startPosX.Value + 260, _startPosY.Value + 10);
|
||||
Point point6 = new Point(_startPosX.Value + 184, _startPosY.Value + 2);
|
||||
|
||||
Point[] boarders = {
|
||||
point0,
|
||||
point1,
|
||||
point2,
|
||||
point3,
|
||||
point4,
|
||||
point5,
|
||||
point6,
|
||||
};
|
||||
|
||||
g.DrawPolygon(pen, boarders);
|
||||
g.FillPolygon(mainBrush, boarders);
|
||||
|
||||
g.DrawRectangle(pen, _startPosX.Value + 100, _startPosY.Value + 7, 38, 24);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 110, _startPosY.Value + 7, 20, 12);
|
||||
g.FillRectangle(mainBrush, _startPosX.Value + 110, _startPosY.Value + 7, 20, 12);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 117, _startPosY.Value + 18, 6, 20);
|
||||
g.FillRectangle(mainBrush, _startPosX.Value + 117, _startPosY.Value + 18, 6, 20);
|
||||
|
||||
// салон на верхней палубе
|
||||
//if (BaseEntity.Deckhouse)
|
||||
//{
|
||||
// // random location
|
||||
// int y_h = BaseEntity.values[1];
|
||||
// g.DrawRectangle(pen, _startPosX.Value + 100, _startPosY.Value + y_h, 38, 24); // 40, 26
|
||||
//
|
||||
// g.DrawRectangle(pen, _startPosX.Value + 110, _startPosY.Value + y_h + 6, 20, 12);
|
||||
// g.FillRectangle(additionalBrush, _startPosX.Value + 110, _startPosY.Value + y_h + 6, 20, 12);
|
||||
// g.DrawRectangle(pen, _startPosX.Value + 117, _startPosY.Value + y_h + 18, 6, 20);
|
||||
// g.FillRectangle(additionalBrush, _startPosX.Value + 117, _startPosY.Value + y_h + 18, 6, 20);
|
||||
//}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WinF_Lab2_Cruiser.Entity_Folder;
|
||||
|
||||
namespace WinF_Lab2_Cruiser.Drawing_tools
|
||||
{
|
||||
internal class DrawingCruiser : DrawingBase
|
||||
{
|
||||
/// Инициализация свойств (все параметры класса (сущности))
|
||||
// public Class_CruiserEntity? CE { get; private set; }
|
||||
// CE = new Class_CruiserEntity( <...> );
|
||||
|
||||
// public DrawingCruiser(int speed, double weight,
|
||||
// Color mainc, Color addtc, bool pad,
|
||||
// bool hangar, int p, int d_coordinates, int h) : base(302, 72) // <...>
|
||||
//{
|
||||
// BaseEntity = new Class_CruiserEntity(speed, weight, mainc, addtc, pad, hangar, p, d_coordinates, h);
|
||||
//}
|
||||
|
||||
public DrawingCruiser(Class_CruiserEntity Obj) : base(302, 72)
|
||||
{
|
||||
BaseEntity = Obj;
|
||||
}
|
||||
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (BaseEntity is not Class_CruiserEntity cruiser || !_startPosX.HasValue ||
|
||||
!_startPosY.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
base.DrawTransport(g);
|
||||
|
||||
Pen pen = new(Color.Black, 2);
|
||||
Brush PadBrush = new HatchBrush(HatchStyle.DottedDiamond, Color.LightGray, Color.Black);
|
||||
Brush additionalBrush = new SolidBrush(cruiser.AdditionalC);
|
||||
Random random = new();
|
||||
|
||||
//границы cruiser <...>
|
||||
|
||||
if (cruiser.HelicopterPads)
|
||||
{
|
||||
g.DrawEllipse(pen, _startPosX.Value + 170, _startPosY.Value + 11, 20, 20);
|
||||
g.FillEllipse(PadBrush, _startPosX.Value + 170, _startPosY.Value + 11, 20, 20);
|
||||
}
|
||||
|
||||
// салон на верхней палубе - Deckhouse <...>
|
||||
if (cruiser.Hangar)
|
||||
{
|
||||
int n = cruiser.values[2];
|
||||
if (n == 1) g.FillRectangle(additionalBrush, _startPosX.Value + 250, _startPosY.Value + 20, 14, 7);
|
||||
|
||||
else
|
||||
{
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 80, _startPosY.Value + 10, 10, 20);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 70, _startPosY.Value + 12, 8, 12);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinF_Lab2_Cruiser.Entity_Folder
|
||||
{
|
||||
public class Base_Class_Cruiser
|
||||
{
|
||||
/// MAIN свойства
|
||||
public int Speed { get; private set; }
|
||||
public double Weight { get; private set; }
|
||||
public Color MainC { get; private set; }
|
||||
public double Step => Speed * 100 / Weight;
|
||||
|
||||
/// Конструктор
|
||||
public Base_Class_Cruiser(int speed, double weight,
|
||||
Color mainc)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
MainC = mainc;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace WinF_Lab2_Cruiser.Entity_Folder
|
||||
{
|
||||
internal class Class_CruiserEntity : Base_Class_Cruiser
|
||||
{
|
||||
/// ADDITIONAL свойства
|
||||
public Color AdditionalC { get; private set; }
|
||||
|
||||
/// признаки (наличия)
|
||||
public bool HelicopterPads { get; private set; } /// вертолетная площадка
|
||||
public bool Hangar { get; private set; } /// ангар
|
||||
public bool Deckhouse { get; private set; } /// салон на верхней палубе
|
||||
|
||||
public int[] values = { 0, 0, 0 };
|
||||
|
||||
public Class_CruiserEntity(int speed, double weight,
|
||||
Color mainc, Color addtc, bool pad,
|
||||
bool hangar, int p, int d_coordinates, int h) : base(speed, weight, mainc)
|
||||
{
|
||||
// NOT PUBLIC, so: -> impossible
|
||||
//base.Speed = speed;
|
||||
//base.Weight = weight;
|
||||
//base.MainC = mainc;
|
||||
|
||||
AdditionalC = addtc;
|
||||
HelicopterPads = pad;
|
||||
Hangar = hangar;
|
||||
values[0] = p;
|
||||
values[1] = d_coordinates;
|
||||
values[2] = h;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinF_Lab2_Cruiser.Move_Strategy
|
||||
{
|
||||
public abstract class AbstractStrategy
|
||||
{
|
||||
private IMO? _movableObj;
|
||||
|
||||
private Status _state = Status.NotInit;
|
||||
|
||||
protected int FieldHeight { get; private set; }
|
||||
protected int FieldWidth { get; private set; }
|
||||
|
||||
public Status GetStatus() { return _state; } // => _state;
|
||||
|
||||
public void SetData(IMO movableObj, int width, int height)
|
||||
{
|
||||
if (movableObj == null)
|
||||
{
|
||||
_state = Status.NotInit;
|
||||
return;
|
||||
}
|
||||
|
||||
_state = Status.InProgress;
|
||||
_movableObj = movableObj;
|
||||
FieldWidth = width;
|
||||
FieldHeight = height;
|
||||
}
|
||||
|
||||
public void MakeStep()
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsTargetDes())
|
||||
{
|
||||
_state = Status.Finish;
|
||||
return;
|
||||
}
|
||||
|
||||
MoveToTarget();
|
||||
}
|
||||
|
||||
protected bool MoveLeft() => MoveTo(Moves.Left);
|
||||
protected bool MoveRight() => MoveTo(Moves.Right);
|
||||
protected bool MoveUp() => MoveTo(Moves.Up);
|
||||
protected bool MoveDown() => MoveTo(Moves.Down);
|
||||
|
||||
protected ObjectParam? GetObjParam => _movableObj?.GetPos;
|
||||
|
||||
protected int? GetStep()
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return _movableObj?.GetStep;
|
||||
}
|
||||
|
||||
// protected virtual void AdditionalMethod() { }
|
||||
|
||||
protected virtual void MoveToTarget()
|
||||
{
|
||||
ObjectParam? objParams = GetObjParam;
|
||||
|
||||
if (objParams == null) { return; }
|
||||
|
||||
int diffx = objParams.MiddleHorizontal - FieldWidth / 2;
|
||||
|
||||
if (Math.Abs(diffx) > GetStep())
|
||||
{
|
||||
if (diffx > 0) MoveLeft();
|
||||
else MoveRight();
|
||||
}
|
||||
|
||||
int diffy = objParams.MiddleVertical - FieldHeight / 2;
|
||||
|
||||
if (Math.Abs(diffy) > GetStep())
|
||||
{
|
||||
if (diffy > 0) MoveUp();
|
||||
else MoveDown();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual bool IsTargetDes()
|
||||
{
|
||||
ObjectParam? objParams = GetObjParam;
|
||||
if (objParams == null) { return false; }
|
||||
|
||||
return objParams.MiddleHorizontal - GetStep() <= FieldWidth / 2 &&
|
||||
objParams.MiddleHorizontal + GetStep() + 1 >= FieldWidth / 2 &&
|
||||
objParams.MiddleVertical - GetStep() <= FieldHeight / 2 &&
|
||||
objParams.MiddleVertical + GetStep() >= FieldHeight / 2;
|
||||
}
|
||||
|
||||
private bool MoveTo(Moves moves)
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return _movableObj?.TryMoveObj(moves) ?? false;
|
||||
}
|
||||
}
|
||||
}
|
56
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/Boarder.cs
Normal file
56
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/Boarder.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinF_Lab2_Cruiser.Move_Strategy;
|
||||
|
||||
public class Boarder : AbstractStrategy
|
||||
{
|
||||
protected override bool IsTargetDes()
|
||||
{
|
||||
ObjectParam? objP = GetObjParam;
|
||||
if (objP == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return FieldWidth < objP.SecondCoordX
|
||||
&& FieldHeight < objP.SecondCoordY;
|
||||
}
|
||||
|
||||
protected override void MoveToTarget()
|
||||
{
|
||||
ObjectParam? objP = GetObjParam;
|
||||
if (objP == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int s = (int)GetStep();
|
||||
|
||||
int diffx = objP.SecondCoordX - (FieldWidth - s);
|
||||
if (Math.Abs(diffx) >= GetStep())
|
||||
{
|
||||
if (diffx > 0)
|
||||
{
|
||||
MoveLeft();
|
||||
|
||||
// MoveRight();
|
||||
}
|
||||
else { MoveRight(); }
|
||||
}
|
||||
|
||||
int diffy = objP.SecondCoordY - (FieldHeight - s);
|
||||
if (Math.Abs(diffy) >= GetStep())
|
||||
{
|
||||
if (diffy > 0)
|
||||
{
|
||||
MoveUp();
|
||||
// MoveDown();
|
||||
}
|
||||
else { MoveDown(); }
|
||||
}
|
||||
}
|
||||
}
|
51
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/Center.cs
Normal file
51
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/Center.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinF_Lab2_Cruiser.Move_Strategy;
|
||||
|
||||
public class Center : AbstractStrategy
|
||||
{
|
||||
protected override bool IsTargetDes()
|
||||
{
|
||||
ObjectParam? objP = GetObjParam;
|
||||
if (objP == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return objP.MiddleHorizontal - GetStep() <= FieldWidth / 2 && objP.MiddleHorizontal + GetStep() >= FieldWidth / 2
|
||||
&& objP.MiddleVertical - GetStep() <= FieldHeight / 2 && objP.MiddleVertical + GetStep() >= FieldHeight / 2;
|
||||
}
|
||||
|
||||
protected override void MoveToTarget()
|
||||
{
|
||||
ObjectParam? objP = GetObjParam;
|
||||
if (objP == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int diffx = objP.MiddleHorizontal - FieldWidth / 2;
|
||||
if (Math.Abs(diffx) > GetStep())
|
||||
{
|
||||
if (diffx > 0)
|
||||
{
|
||||
MoveLeft();
|
||||
}
|
||||
else { MoveRight(); }
|
||||
}
|
||||
|
||||
int diffy = objP.MiddleVertical - FieldHeight / 2;
|
||||
if (Math.Abs(diffy) > GetStep())
|
||||
{
|
||||
if (diffy > 0)
|
||||
{
|
||||
MoveUp();
|
||||
}
|
||||
else { MoveDown(); }
|
||||
}
|
||||
}
|
||||
}
|
21
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/IMO.cs
Normal file
21
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/IMO.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinF_Lab2_Cruiser.Move_Strategy
|
||||
{
|
||||
public interface IMO
|
||||
{
|
||||
// methods ! only
|
||||
|
||||
ObjectParam? GetPos { get; }
|
||||
|
||||
int GetStep { get; }
|
||||
|
||||
int AdditionalMethod { set; }
|
||||
|
||||
bool TryMoveObj(Moves direction);
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WinF_Lab2_Cruiser.Drawing_tools;
|
||||
|
||||
namespace WinF_Lab2_Cruiser.Move_Strategy
|
||||
{
|
||||
public class MovableCruiser : IMO
|
||||
{
|
||||
private readonly DrawingBase? _DrBase = null;
|
||||
|
||||
public MovableCruiser(DrawingBase drBase)
|
||||
{
|
||||
_DrBase = drBase;
|
||||
}
|
||||
|
||||
public ObjectParam? GetPos
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_DrBase == null || _DrBase.BaseEntity == null || !_DrBase.GetPosX.HasValue || !_DrBase.GetPosY.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ObjectParam(_DrBase.GetPosX.Value, _DrBase.GetPosY.Value, _DrBase.GetWidth, _DrBase.GetHeight);
|
||||
}
|
||||
}
|
||||
|
||||
public int GetStep => (int)(_DrBase?.BaseEntity?.Step ?? 0);
|
||||
|
||||
public int AdditionalMethod { set => throw new NotImplementedException(); }
|
||||
|
||||
public bool TryMoveObj(Moves direction)
|
||||
{
|
||||
if (_DrBase == null || _DrBase.BaseEntity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return _DrBase.MoveTransport(GetDirectionType(direction));
|
||||
}
|
||||
|
||||
private static DirectionType GetDirectionType(Moves direction)
|
||||
{
|
||||
return direction switch
|
||||
{
|
||||
Moves.Left => DirectionType.Left,
|
||||
Moves.Right => DirectionType.Right,
|
||||
Moves.Up => DirectionType.Up,
|
||||
Moves.Down => DirectionType.Down,
|
||||
_ => DirectionType.Unknown
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
17
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/Moves.cs
Normal file
17
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/Moves.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinF_Lab2_Cruiser.Move_Strategy
|
||||
{
|
||||
public enum Moves
|
||||
{
|
||||
Unknown = -1,
|
||||
Up = 1,
|
||||
Down = 2,
|
||||
Left = 3,
|
||||
Right = 4
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinF_Lab2_Cruiser.Move_Strategy
|
||||
{
|
||||
public class ObjectParam
|
||||
{
|
||||
private readonly int _x;
|
||||
private readonly int _y;
|
||||
|
||||
private readonly int _width;
|
||||
private readonly int _height;
|
||||
|
||||
public int LeftBorder => _x;
|
||||
public int RightBorder => _x + _width;
|
||||
|
||||
public int TopBorder => _y;
|
||||
public int BottomBorder => _y + _height;
|
||||
|
||||
|
||||
public int MiddleHorizontal => _x + _width / 2;
|
||||
public int MiddleVertical => _y + _height / 2;
|
||||
|
||||
|
||||
public int SecondCoordY => _y + _height;
|
||||
public int SecondCoordX => _x + _width;
|
||||
|
||||
public ObjectParam(int x, int y, int width, int height)
|
||||
{
|
||||
_x = x;
|
||||
_y = y;
|
||||
_width = width;
|
||||
_height = height;
|
||||
}
|
||||
}
|
||||
}
|
15
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/Status.cs
Normal file
15
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/Status.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WinF_Lab2_Cruiser.Move_Strategy
|
||||
{
|
||||
public enum Status
|
||||
{
|
||||
NotInit,
|
||||
InProgress,
|
||||
Finish
|
||||
}
|
||||
}
|
18
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Program.cs
Normal file
18
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Program.cs
Normal file
@ -0,0 +1,18 @@
|
||||
namespace WinF_Lab2_Cruiser
|
||||
{
|
||||
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 DrawingCanvas());
|
||||
Application.Run(new CollectionForm());
|
||||
}
|
||||
}
|
||||
}
|
103
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Properties/Resources.Designer.cs
generated
Normal file
103
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace WinF_Lab2_Cruiser.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("WinF_Lab2_Cruiser.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 down_arrow_res {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("down_arrow_res", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap left_arrow_res {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("left_arrow_res", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap right_arrow_res {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("right_arrow_res", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap up_arrow_res {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("up_arrow_res", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Properties/Resources.resx
Normal file
133
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Properties/Resources.resx
Normal 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="right_arrow_res" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\right_arrow_res.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="up_arrow_res" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\up_arrow_res.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="left_arrow_res" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\left_arrow_res.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="down_arrow_res" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\down_arrow_res.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Resources/down_arrow_res.png
Normal file
BIN
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Resources/down_arrow_res.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 940 B |
BIN
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Resources/left_arrow_res.png
Normal file
BIN
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Resources/left_arrow_res.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 905 B |
Binary file not shown.
After Width: | Height: | Size: 877 B |
BIN
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Resources/up_arrow_res.png
Normal file
BIN
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Resources/up_arrow_res.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 863 B |
11
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser.csproj
Normal file
11
WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser.csproj
Normal 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>
|
Loading…
Reference in New Issue
Block a user