ПИбд-23_Кондратьев_Никита_Lab1 #1

Closed
Itos wants to merge 7 commits from Lab1 into main
14 changed files with 686 additions and 7 deletions

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GasolineTanker
{
public enum Direction
{
Up = 1,
Down = 2,
Left = 3,
Right = 4
}
}

View File

@ -0,0 +1,163 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GasolineTanker
{
public class DrawningGasolineTanker
{
public EntityGasolineTanker? EntityGasolineTanker { get; private set; }
public int _pictureWidth;
public int _pictureHeight;
private int _startPosX = 0;
private int _startPosY = 0;
//Ширина грузовика
private readonly int _gasolineTankerWidth = 200;
//Высота грузовика
private readonly int _gasolineTankerHeight = 100;
//Инициализация свойств
public bool Init(int speed, double weight, Color bodyColor, bool tank, bool signalBeacon, Color additionalColor, int width, int height)
{
if (width <= _gasolineTankerWidth || height <= _gasolineTankerHeight)
{
return false;
}
_pictureWidth = width;
_pictureHeight = height;
EntityGasolineTanker = new EntityGasolineTanker();
EntityGasolineTanker.Init(speed, weight, bodyColor, tank, signalBeacon, additionalColor);
return true;
}
public void SetPosition(int x, int y)
{
if (EntityGasolineTanker == null)
{
return;
}
_startPosX = x;
_startPosY = y;
if(x + _gasolineTankerWidth >= _pictureWidth || y + _gasolineTankerHeight >= _pictureHeight)
Review

Не учтены все условия, при которых объект может выйти за границы

Не учтены все условия, при которых объект может выйти за границы
{
_startPosX = 1;
_startPosY = 1;
}
}
public void MoveTransport(Direction direction)
{
if (EntityGasolineTanker == null)
{
return;
}
switch (direction)
{
case Direction.Left:
if (_startPosX - EntityGasolineTanker.Step >= 0)
{
_startPosX -= (int)EntityGasolineTanker.Step;
}
else
{
_startPosX = 0;
}
break;
case Direction.Up:
if (_startPosY - EntityGasolineTanker.Step > 0)
{
_startPosY -= (int)EntityGasolineTanker.Step;
}
else
{
_startPosY = 0;
}
break;
case Direction.Right:
if (_startPosX + EntityGasolineTanker.Step + _gasolineTankerWidth < _pictureWidth)
{
_startPosX += (int)EntityGasolineTanker.Step;
}
else
{
_startPosX = _pictureWidth - _gasolineTankerWidth;
}
break;
case Direction.Down:
if (_startPosY + EntityGasolineTanker.Step + _gasolineTankerHeight < _pictureHeight)
{
_startPosY += (int)EntityGasolineTanker.Step;
}
else
{
_startPosY = _pictureHeight - _gasolineTankerHeight;
}
break;
}
}
public void DrawTransport(Graphics g)
{
if (EntityGasolineTanker == null)
{
return;
}
Pen pen = new(Color.Black);
Brush bodyBrush = new SolidBrush(EntityGasolineTanker.BodyColor);
Brush additionalBrush = new SolidBrush(EntityGasolineTanker.AdditionalColor);
Brush wheelBrush = new SolidBrush(Color.Black);
//Дополнительные элементы
if (EntityGasolineTanker.Tank)
{
//Цистерна
g.FillEllipse(additionalBrush, _startPosX + _gasolineTankerWidth / 20 * 0, _startPosY + _gasolineTankerHeight / 10 * 1, _gasolineTankerWidth / 20 * 5, _gasolineTankerHeight / 10 * 5);
g.FillEllipse(additionalBrush, _startPosX + _gasolineTankerWidth / 20 * 7, _startPosY + _gasolineTankerHeight / 10 * 1, _gasolineTankerWidth / 20 * 5, _gasolineTankerHeight / 10 * 5);
Point[] pointsTunk =
{
new Point(_startPosX + _gasolineTankerWidth / 20 * 2, _startPosY + _gasolineTankerHeight / 10 * 1),
new Point(_startPosX + _gasolineTankerWidth / 20 * 9, _startPosY + _gasolineTankerHeight / 10 * 1),
new Point(_startPosX + _gasolineTankerWidth / 20 * 9, _startPosY + _gasolineTankerHeight / 10 * 6),
new Point(_startPosX + _gasolineTankerWidth / 20 * 2, _startPosY + _gasolineTankerHeight / 10 * 6),
};
g.FillPolygon(additionalBrush, pointsTunk);
}
if (EntityGasolineTanker.SignalBeacon)
{
//Маячок
Point[] pointsBeacon =
{
new Point(_startPosX + _gasolineTankerWidth / 20 * 13, _startPosY + _gasolineTankerHeight / 10 * 1),
new Point(_startPosX + _gasolineTankerWidth / 20 * 13, _startPosY + _gasolineTankerHeight / 10 * 0),
new Point(_startPosX + _gasolineTankerWidth / 20 * 14, _startPosY + _gasolineTankerHeight / 10 * 0),
new Point(_startPosX + _gasolineTankerWidth / 20 * 14, _startPosY + _gasolineTankerHeight / 10 * 1),
};
g.FillPolygon(additionalBrush, pointsBeacon);
//g.DrawPolygon(pen, pointsBeacon);
}
/*
//Граница отрисовки объекта(для безопасности при редактировании)
Point[] pointsBorder = { new Point(_startPosX, _startPosY),
new Point(_startPosX, _startPosY + _gasolineTankerHeight),
new Point(_startPosX + _gasolineTankerWidth, _startPosY + _gasolineTankerHeight),
new Point(_startPosX + _gasolineTankerWidth, _startPosY)};
g.DrawPolygon(pen, pointsBorder);
*/
Point[] pointsFrame = {
new Point(_startPosX + _gasolineTankerWidth / 20 * 0, _startPosY + _gasolineTankerHeight / 10 * 6),
new Point(_startPosX + _gasolineTankerWidth / 20 * 12, _startPosY + _gasolineTankerHeight / 10 * 6),
new Point(_startPosX + _gasolineTankerWidth / 20 * 12, _startPosY + _gasolineTankerHeight / 10 * 1),
new Point(_startPosX + _gasolineTankerWidth / 20 * 15, _startPosY + _gasolineTankerHeight / 10 * 1),
new Point(_startPosX + _gasolineTankerWidth / 20 * 16, _startPosY + _gasolineTankerHeight / 10 * 4),
new Point(_startPosX + _gasolineTankerWidth / 20 * 20, _startPosY + _gasolineTankerHeight / 10 * 5),
new Point(_startPosX + _gasolineTankerWidth / 20 * 20, _startPosY + _gasolineTankerHeight / 10 * 8),
new Point(_startPosX + _gasolineTankerWidth / 20 * 0, _startPosY + _gasolineTankerHeight / 10 * 8),};
g.FillPolygon(bodyBrush, pointsFrame);
g.DrawPolygon(pen, pointsFrame);
//Колёса
g.FillEllipse(wheelBrush, _startPosX + _gasolineTankerWidth / 20 * 1, _startPosY + _gasolineTankerHeight / 10 * 7, _gasolineTankerWidth / 20 * 3, _gasolineTankerHeight / 10 * 3);
g.FillEllipse(wheelBrush, _startPosX + _gasolineTankerWidth / 20 * 5, _startPosY + _gasolineTankerHeight / 10 * 7, _gasolineTankerWidth / 20 * 3, _gasolineTankerHeight / 10 * 3);
g.FillEllipse(wheelBrush, _startPosX + _gasolineTankerWidth / 20 * 16, _startPosY + _gasolineTankerHeight / 10 * 7, _gasolineTankerWidth / 20 * 3, _gasolineTankerHeight / 10 * 3);
}
}
}

View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace GasolineTanker
{
public class EntityGasolineTanker
{
public int Speed { get; private set; }
public double Weight { get; private set; }
// Основной цвет
public Color BodyColor { get; private set; }
//Наличие цистерны
public bool Tank { get; private set; }
//Наличие сигнального маяка
public bool SignalBeacon { get; private set; }
//Дополнительный цвет
public Color AdditionalColor { get; private set; }
//Шаг перемещения
public double Step => (double)Speed * 100 / Weight;
//Инициализация полей Грузовика
public void Init(int speed, double weight, Color bodyColor, bool tank, bool signalBeacon, Color additionalColor)
{
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
Tank = tank;
SignalBeacon = signalBeacon;
AdditionalColor = additionalColor;
}
}
}

View File

@ -1,6 +1,6 @@
namespace GasolineTanker
{
partial class Form1
partial class GasolineTanker
{
/// <summary>
/// Required designer variable.
@ -28,12 +28,111 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.PictureBoxGasolineTanker = new System.Windows.Forms.PictureBox();
this.ButtonCreate = new System.Windows.Forms.Button();
this.ButtonRight = new System.Windows.Forms.Button();
this.ButtonDown = new System.Windows.Forms.Button();
this.ButtonLeft = new System.Windows.Forms.Button();
this.ButtonUp = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.PictureBoxGasolineTanker)).BeginInit();
this.SuspendLayout();
//
// PictureBoxGasolineTanker
//
this.PictureBoxGasolineTanker.Dock = System.Windows.Forms.DockStyle.Fill;
this.PictureBoxGasolineTanker.Location = new System.Drawing.Point(0, 0);
this.PictureBoxGasolineTanker.Name = "PictureBoxGasolineTanker";
this.PictureBoxGasolineTanker.Size = new System.Drawing.Size(884, 461);
this.PictureBoxGasolineTanker.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.PictureBoxGasolineTanker.TabIndex = 0;
this.PictureBoxGasolineTanker.TabStop = false;
//
// ButtonCreate
//
this.ButtonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.ButtonCreate.Location = new System.Drawing.Point(12, 426);
this.ButtonCreate.Name = "ButtonCreate";
this.ButtonCreate.Size = new System.Drawing.Size(75, 23);
this.ButtonCreate.TabIndex = 1;
this.ButtonCreate.Text = "Создать";
this.ButtonCreate.UseVisualStyleBackColor = true;
this.ButtonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
//
// ButtonRight
//
this.ButtonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.ButtonRight.BackgroundImage = global::GasolineTanker.Properties.Resources.right;
this.ButtonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.ButtonRight.Location = new System.Drawing.Point(842, 419);
this.ButtonRight.Name = "ButtonRight";
this.ButtonRight.Size = new System.Drawing.Size(30, 30);
this.ButtonRight.TabIndex = 2;
this.ButtonRight.UseVisualStyleBackColor = true;
this.ButtonRight.Click += new System.EventHandler(this.ButtonMove_Click);
//
// ButtonDown
//
this.ButtonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.ButtonDown.BackgroundImage = global::GasolineTanker.Properties.Resources.down;
this.ButtonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.ButtonDown.Location = new System.Drawing.Point(806, 419);
this.ButtonDown.Name = "ButtonDown";
this.ButtonDown.Size = new System.Drawing.Size(30, 30);
this.ButtonDown.TabIndex = 3;
this.ButtonDown.UseVisualStyleBackColor = true;
this.ButtonDown.Click += new System.EventHandler(this.ButtonMove_Click);
//
// ButtonLeft
//
this.ButtonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.ButtonLeft.BackgroundImage = global::GasolineTanker.Properties.Resources.left;
this.ButtonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.ButtonLeft.Location = new System.Drawing.Point(770, 419);
this.ButtonLeft.Name = "ButtonLeft";
this.ButtonLeft.Size = new System.Drawing.Size(30, 30);
this.ButtonLeft.TabIndex = 4;
this.ButtonLeft.UseVisualStyleBackColor = true;
this.ButtonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
//
// ButtonUp
//
this.ButtonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.ButtonUp.BackgroundImage = global::GasolineTanker.Properties.Resources.up;
this.ButtonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.ButtonUp.Location = new System.Drawing.Point(806, 383);
this.ButtonUp.Name = "ButtonUp";
this.ButtonUp.Size = new System.Drawing.Size(30, 30);
this.ButtonUp.TabIndex = 5;
this.ButtonUp.UseVisualStyleBackColor = true;
this.ButtonUp.Click += new System.EventHandler(this.ButtonMove_Click);
//
// GasolineTanker
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
this.ClientSize = new System.Drawing.Size(884, 461);
this.Controls.Add(this.ButtonUp);
this.Controls.Add(this.ButtonLeft);
this.Controls.Add(this.ButtonDown);
this.Controls.Add(this.ButtonRight);
this.Controls.Add(this.ButtonCreate);
this.Controls.Add(this.PictureBoxGasolineTanker);
this.Name = "GasolineTanker";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "GasolineTanker";
((System.ComponentModel.ISupportInitialize)(this.PictureBoxGasolineTanker)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private PictureBox PictureBoxGasolineTanker;
private Button ButtonCreate;
private Button ButtonRight;
private Button ButtonDown;
private Button ButtonLeft;
private Button ButtonUp;
}
}

View File

@ -1,10 +1,65 @@
namespace GasolineTanker
{
public partial class Form1 : Form
public partial class GasolineTanker : Form
Review

Имя файла не соответствует имени элемента проекта

Имя файла не соответствует имени элемента проекта
{
public Form1()
private DrawningGasolineTanker? _drawningGasolineTanker;
public GasolineTanker()
{
InitializeComponent();
}
private void Draw()
{
if (_drawningGasolineTanker == null)
return;
Bitmap bmp = new(PictureBoxGasolineTanker.Width, PictureBoxGasolineTanker.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawningGasolineTanker.DrawTransport(gr);
PictureBoxGasolineTanker.Image = bmp;
}
private void ButtonCreate_Click(object sender, EventArgs e)
{
Random random = new();
_drawningGasolineTanker = new DrawningGasolineTanker();
_drawningGasolineTanker.Init(
random.Next(100, 300),
random.Next(1000, 3000),
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)),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
PictureBoxGasolineTanker.Width, PictureBoxGasolineTanker.Height);
_drawningGasolineTanker.SetPosition(random.Next(10, 100),
random.Next(10, 100));
Draw();
}
private void ButtonMove_Click(object sender, EventArgs e)
{
if (_drawningGasolineTanker == null)
{
return;
}
string name = ((Button)sender)?.Name ?? string.Empty;
switch (name)
{
case "ButtonUp":
_drawningGasolineTanker.MoveTransport(Direction.Up);
break;
case "ButtonDown":
_drawningGasolineTanker.MoveTransport(Direction.Down);
break;
case "ButtonLeft":
_drawningGasolineTanker.MoveTransport(Direction.Left);
break;
case "ButtonRight":
_drawningGasolineTanker.MoveTransport(Direction.Right);
break;
}
Draw();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -8,4 +8,19 @@
<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

@ -11,7 +11,7 @@ namespace GasolineTanker
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
Application.Run(new GasolineTanker());
}
}
}

View File

@ -0,0 +1,103 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace GasolineTanker.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("GasolineTanker.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 {
get {
object obj = ResourceManager.GetObject("down", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap left {
get {
object obj = ResourceManager.GetObject("left", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap right {
get {
object obj = ResourceManager.GetObject("right", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap up {
get {
object obj = ResourceManager.GetObject("up", 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="down" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\down.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="left" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\left.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="right" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\right.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="up" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\up.png;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: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB