почти
This commit is contained in:
parent
3b3bdf8168
commit
0ac84cd6c7
@ -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>
|
102
Final/Final/Form1.Designer.cs
generated
102
Final/Final/Form1.Designer.cs
generated
@ -1,4 +1,6 @@
|
||||
namespace Final
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Final
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
@ -34,9 +36,19 @@
|
||||
button1 = new Button();
|
||||
listBox1 = new ListBox();
|
||||
tabPage2 = new TabPage();
|
||||
button5 = new Button();
|
||||
textBox1 = new TextBox();
|
||||
textBoxH = new TextBox();
|
||||
textBoxW = new TextBox();
|
||||
button4 = new Button();
|
||||
button3 = new Button();
|
||||
listBox2 = new ListBox();
|
||||
pictureBox1 = new PictureBox();
|
||||
tabPage3 = new TabPage();
|
||||
tabControl1.SuspendLayout();
|
||||
tabPage1.SuspendLayout();
|
||||
tabPage2.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// tabControl1
|
||||
@ -94,6 +106,14 @@
|
||||
//
|
||||
// tabPage2
|
||||
//
|
||||
tabPage2.Controls.Add(button5);
|
||||
tabPage2.Controls.Add(textBox1);
|
||||
tabPage2.Controls.Add(textBoxH);
|
||||
tabPage2.Controls.Add(textBoxW);
|
||||
tabPage2.Controls.Add(button4);
|
||||
tabPage2.Controls.Add(button3);
|
||||
tabPage2.Controls.Add(listBox2);
|
||||
tabPage2.Controls.Add(pictureBox1);
|
||||
tabPage2.Location = new Point(4, 34);
|
||||
tabPage2.Name = "tabPage2";
|
||||
tabPage2.Padding = new Padding(3);
|
||||
@ -102,6 +122,75 @@
|
||||
tabPage2.Text = "1 задание";
|
||||
tabPage2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// button5
|
||||
//
|
||||
button5.Location = new Point(918, 470);
|
||||
button5.Name = "button5";
|
||||
button5.Size = new Size(138, 62);
|
||||
button5.TabIndex = 9;
|
||||
button5.Text = "Квадрат с овалом";
|
||||
button5.UseVisualStyleBackColor = true;
|
||||
button5.Click += button5_Click;
|
||||
//
|
||||
// textBox1
|
||||
//
|
||||
textBox1.Location = new Point(168, 172);
|
||||
textBox1.Name = "textBox1";
|
||||
textBox1.Size = new Size(299, 31);
|
||||
textBox1.TabIndex = 8;
|
||||
//
|
||||
// textBoxH
|
||||
//
|
||||
textBoxH.Location = new Point(168, 101);
|
||||
textBoxH.Name = "textBoxH";
|
||||
textBoxH.Size = new Size(299, 31);
|
||||
textBoxH.TabIndex = 7;
|
||||
//
|
||||
// textBoxW
|
||||
//
|
||||
textBoxW.Location = new Point(168, 23);
|
||||
textBoxW.Name = "textBoxW";
|
||||
textBoxW.Size = new Size(299, 31);
|
||||
textBoxW.TabIndex = 6;
|
||||
//
|
||||
// button4
|
||||
//
|
||||
button4.Location = new Point(602, 470);
|
||||
button4.Name = "button4";
|
||||
button4.Size = new Size(112, 62);
|
||||
button4.TabIndex = 5;
|
||||
button4.Text = "Квадрат";
|
||||
button4.UseVisualStyleBackColor = true;
|
||||
button4.Click += button4_Click;
|
||||
//
|
||||
// button3
|
||||
//
|
||||
button3.Location = new Point(735, 470);
|
||||
button3.Name = "button3";
|
||||
button3.Size = new Size(138, 62);
|
||||
button3.TabIndex = 4;
|
||||
button3.Text = "Квадрат с овалом";
|
||||
button3.UseVisualStyleBackColor = true;
|
||||
button3.Click += button3_Click;
|
||||
//
|
||||
// listBox2
|
||||
//
|
||||
listBox2.FormattingEnabled = true;
|
||||
listBox2.ItemHeight = 25;
|
||||
listBox2.Location = new Point(9, 470);
|
||||
listBox2.Name = "listBox2";
|
||||
listBox2.Size = new Size(519, 129);
|
||||
listBox2.TabIndex = 1;
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
pictureBox1.BackColor = Color.DarkGray;
|
||||
pictureBox1.Location = new Point(521, 6);
|
||||
pictureBox1.Name = "pictureBox1";
|
||||
pictureBox1.Size = new Size(619, 428);
|
||||
pictureBox1.TabIndex = 0;
|
||||
pictureBox1.TabStop = false;
|
||||
//
|
||||
// tabPage3
|
||||
//
|
||||
tabPage3.Location = new Point(4, 34);
|
||||
@ -122,6 +211,9 @@
|
||||
Text = "Form1";
|
||||
tabControl1.ResumeLayout(false);
|
||||
tabPage1.ResumeLayout(false);
|
||||
tabPage2.ResumeLayout(false);
|
||||
tabPage2.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
@ -134,5 +226,13 @@
|
||||
private Button button2;
|
||||
private Button button1;
|
||||
private TabPage tabPage3;
|
||||
private ListBox listBox2;
|
||||
private PictureBox pictureBox1;
|
||||
private Button button3;
|
||||
private Button button4;
|
||||
private TextBox textBoxH;
|
||||
private TextBox textBoxW;
|
||||
private TextBox textBox1;
|
||||
private Button button5;
|
||||
}
|
||||
}
|
@ -1,16 +1,23 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Rebar;
|
||||
|
||||
namespace Final
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
|
||||
|
||||
List<One> ones;
|
||||
|
||||
private List<Rectangle> rectangles;
|
||||
private Random rand;
|
||||
private Color selectedColor = Color.Red;
|
||||
public Form1()
|
||||
{
|
||||
|
||||
ones = new List<One>();
|
||||
|
||||
rectangles = new List<Rectangle>();
|
||||
rand = new Random();
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
@ -36,5 +43,71 @@ namespace Final
|
||||
listBox1.Items.Add(ones[i].ToString());
|
||||
}
|
||||
}
|
||||
private void ChooseColor()
|
||||
{
|
||||
using (ColorDialog colorDialog = new ColorDialog())
|
||||
{
|
||||
if (colorDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
selectedColor = colorDialog.Color;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (int.TryParse(textBoxW.Text, out int width) && int.TryParse(textBoxH.Text, out int height))
|
||||
{
|
||||
Point position = new Point(rand.Next(0, pictureBox1.Width - width), rand.Next(0, pictureBox1.Height - height));
|
||||
RectangleWithOval rectangleWithOval = new RectangleWithOval(width, height, position, selectedColor);
|
||||
rectangles.Add(rectangleWithOval);
|
||||
listBox1.Items.Add(rectangleWithOval);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Ïîæàëóéñòà, ââåäèòå êîððåêòíûå ðàçìåðû.");
|
||||
}
|
||||
}
|
||||
|
||||
private void button4_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (int.TryParse(textBoxW.Text, out int width) && int.TryParse(textBoxH.Text, out int height))
|
||||
{
|
||||
Point position = new Point(rand.Next(0, pictureBox1.Width - width), rand.Next(0, pictureBox1.Height - height));
|
||||
Rectangle rectangle = new Rectangle(width, height, position);
|
||||
rectangles.Add(rectangle);
|
||||
listBox2.Items.Add(rectangle);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Ïîæàëóéñòà, ââåäèòå êîððåêòíûå ðàçìåðû.");
|
||||
}
|
||||
}
|
||||
|
||||
private void button5_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBox2.SelectedItem is Rectangle rectangle)
|
||||
{
|
||||
if (pictureBox1.Image != null)
|
||||
{
|
||||
pictureBox1.Image.Dispose();
|
||||
}
|
||||
|
||||
pictureBox1.Image = new Bitmap(pictureBox1.Width, pictureBox1.Height);
|
||||
using (Graphics g = Graphics.FromImage(pictureBox1.Image))
|
||||
{
|
||||
g.Clear(Color.White); // Î÷èñòêà ôîíà ïåðåä ðèñîâàíèåì
|
||||
rectangle.Draw(g);
|
||||
}
|
||||
|
||||
pictureBox1.Refresh(); // Îáíîâëåíèå PictureBox ÷òîáû îòîáðàçèòü íîâûå èçìåíåíèÿ
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Ïîæàëóéñòà, âûáåðèòå îáúåêò äëÿ ïðîðèñîâêè.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
63
Final/Final/Properties/Resources.Designer.cs
generated
Normal file
63
Final/Final/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Final.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("Final.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
Final/Final/Properties/Resources.resx
Normal file
120
Final/Final/Properties/Resources.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>
|
27
Final/Final/Rectangle.cs
Normal file
27
Final/Final/Rectangle.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Final
|
||||
{
|
||||
public class Rectangle
|
||||
{
|
||||
public int Width { get; set; }
|
||||
public int Height { get; set; }
|
||||
public Point Position { get; set; }
|
||||
|
||||
public Rectangle(int width, int height, Point position)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
Position = position;
|
||||
}
|
||||
|
||||
public virtual void Draw(Graphics g)
|
||||
{
|
||||
g.DrawRectangle(Pens.Black, Position.X, Position.Y, Width, Height);
|
||||
}
|
||||
}
|
||||
}
|
29
Final/Final/RectangleWithOval.cs
Normal file
29
Final/Final/RectangleWithOval.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Final
|
||||
{
|
||||
public class RectangleWithOval : Rectangle
|
||||
{
|
||||
public Color OvalColor { get; set; }
|
||||
|
||||
public RectangleWithOval(int width, int height, Point position, Color color)
|
||||
: base(width, height, position)
|
||||
{
|
||||
OvalColor = color;
|
||||
}
|
||||
|
||||
public override void Draw(Graphics g)
|
||||
{
|
||||
base.Draw(g);
|
||||
using (Brush brush = new SolidBrush(OvalColor))
|
||||
{
|
||||
g.FillEllipse(brush, Position.X, Position.Y, Width, Height);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user