Добавлено контекстное меню к панели автомобилей

This commit is contained in:
2024-10-08 14:41:32 +03:00
parent 3e04430a86
commit a7e5c55a5d
13 changed files with 648 additions and 58 deletions

View File

@@ -36,15 +36,15 @@
this.MoneyTextBox = new System.Windows.Forms.TextBox();
this.MoneyLabel = new System.Windows.Forms.Label();
this.ClassPanel = new System.Windows.Forms.Panel();
this.ClassTextBox = new System.Windows.Forms.TextBox();
this.ClassLabel = new System.Windows.Forms.Label();
this.NamePanel = new System.Windows.Forms.Panel();
this.ManufacturerLabel = new System.Windows.Forms.Label();
this.NameLabel = new System.Windows.Forms.Label();
this.ModelPanel = new System.Windows.Forms.Panel();
this.ModelTextBox = new System.Windows.Forms.TextBox();
this.ModelLabel = new System.Windows.Forms.Label();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.ModelTextBox = new System.Windows.Forms.TextBox();
this.ClassTextBox = new System.Windows.Forms.TextBox();
this.MainPanel.SuspendLayout();
this.PhotoPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.PhotoBox)).BeginInit();
@@ -136,6 +136,18 @@
this.ClassPanel.Size = new System.Drawing.Size(210, 17);
this.ClassPanel.TabIndex = 2;
//
// ClassTextBox
//
this.ClassTextBox.BackColor = System.Drawing.Color.White;
this.ClassTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.ClassTextBox.Dock = System.Windows.Forms.DockStyle.Top;
this.ClassTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.ClassTextBox.Location = new System.Drawing.Point(48, 0);
this.ClassTextBox.Name = "ClassTextBox";
this.ClassTextBox.ReadOnly = true;
this.ClassTextBox.Size = new System.Drawing.Size(160, 15);
this.ClassTextBox.TabIndex = 3;
//
// ClassLabel
//
this.ClassLabel.AutoSize = true;
@@ -195,6 +207,18 @@
this.ModelPanel.Size = new System.Drawing.Size(210, 17);
this.ModelPanel.TabIndex = 0;
//
// ModelTextBox
//
this.ModelTextBox.BackColor = System.Drawing.Color.White;
this.ModelTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.ModelTextBox.Dock = System.Windows.Forms.DockStyle.Top;
this.ModelTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.ModelTextBox.Location = new System.Drawing.Point(60, 0);
this.ModelTextBox.Name = "ModelTextBox";
this.ModelTextBox.ReadOnly = true;
this.ModelTextBox.Size = new System.Drawing.Size(148, 15);
this.ModelTextBox.TabIndex = 2;
//
// ModelLabel
//
this.ModelLabel.AutoSize = true;
@@ -211,30 +235,6 @@
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(61, 4);
//
// ModelTextBox
//
this.ModelTextBox.BackColor = System.Drawing.Color.White;
this.ModelTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.ModelTextBox.Dock = System.Windows.Forms.DockStyle.Top;
this.ModelTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.ModelTextBox.Location = new System.Drawing.Point(60, 0);
this.ModelTextBox.Name = "ModelTextBox";
this.ModelTextBox.ReadOnly = true;
this.ModelTextBox.Size = new System.Drawing.Size(148, 15);
this.ModelTextBox.TabIndex = 2;
//
// ClassTextBox
//
this.ClassTextBox.BackColor = System.Drawing.Color.White;
this.ClassTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.ClassTextBox.Dock = System.Windows.Forms.DockStyle.Top;
this.ClassTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.ClassTextBox.Location = new System.Drawing.Point(48, 0);
this.ClassTextBox.Name = "ClassTextBox";
this.ClassTextBox.ReadOnly = true;
this.ClassTextBox.Size = new System.Drawing.Size(160, 15);
this.ClassTextBox.TabIndex = 3;
//
// CarItem
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

View File

@@ -11,18 +11,46 @@ namespace GtaVUsersInfo.Controls
public partial class CarItem : UserControl
{
private static readonly HttpClient httpClient = new HttpClient();
private Car car;
public Car Car
{
get { return car; }
set { car = value; }
}
public ContextMenuStrip MenuStrip
{
get { return ContextMenuStrip; }
set { ContextMenuStrip = value; }
}
public CarItem(Car carItem)
{
InitializeComponent();
NameLabel.Text = carItem.Name;
ManufacturerLabel.Text = carItem.Manufacturer;
ClassTextBox.Text = carItem.Class;
ModelTextBox.Text = carItem.Model;
MoneyTextBox.Text = '$' + carItem.Price.ToString();
Car = carItem;
LoadImageAsync(carItem.Photo);
NameLabel.Text = Car.Name;
ManufacturerLabel.Text = Car.Manufacturer;
ClassTextBox.Text = Car.Class;
ModelTextBox.Text = Car.Model;
MoneyTextBox.Text = '$' + Car.Price.ToString();
LoadImageAsync(Car.Photo);
}
public void EditCar(Car car)
{
Car = car;
NameLabel.Text = Car.Name;
ManufacturerLabel.Text = Car.Manufacturer;
ClassTextBox.Text = Car.Class;
ModelTextBox.Text = Car.Model;
MoneyTextBox.Text = '$' + Car.Price.ToString();
LoadImageAsync(Car.Photo);
}
private async void LoadImageAsync(string imageUrl)
@@ -66,6 +94,7 @@ namespace GtaVUsersInfo.Controls
private void carPrice_Leave(object sender, EventArgs e)
{
Car.Price = int.Parse((sender as TextBox).Text);
(sender as TextBox).Text = '$' + (sender as TextBox).Text;
}

84
Controls/CarItemMenuStrip.Designer.cs generated Normal file
View File

@@ -0,0 +1,84 @@
namespace GtaVUsersInfo.Controls
{
partial class CarItemMenuStrip
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.myMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
this.addNewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.myMenuStrip.SuspendLayout();
this.SuspendLayout();
//
// myMenuStrip
//
this.myMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.addNewToolStripMenuItem,
this.editToolStripMenuItem,
this.deleteToolStripMenuItem});
this.myMenuStrip.Name = "contextMenuStrip";
this.myMenuStrip.Size = new System.Drawing.Size(181, 92);
//
// addNewToolStripMenuItem
//
this.addNewToolStripMenuItem.Name = "addNewToolStripMenuItem";
this.addNewToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.addNewToolStripMenuItem.Text = "Создать";
//
// editToolStripMenuItem
//
this.editToolStripMenuItem.Name = "editToolStripMenuItem";
this.editToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.editToolStripMenuItem.Text = "Изменить";
//
// deleteToolStripMenuItem
//
this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
this.deleteToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.deleteToolStripMenuItem.Text = "Удалить";
//
// CarMenuStrip
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Name = "CarMenuStrip";
this.Size = new System.Drawing.Size(158, 245);
this.myMenuStrip.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ContextMenuStrip myMenuStrip;
private System.Windows.Forms.ToolStripMenuItem addNewToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem;
}
}

View File

@@ -0,0 +1,37 @@
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;
namespace GtaVUsersInfo.Controls
{
public partial class CarItemMenuStrip : UserControl
{
public ContextMenuStrip Menu
{
get { return myMenuStrip; }
}
public CarItem Car;
public CarItemMenuStrip(EventHandler add, EventHandler edit, EventHandler delete, CarItem car)
{
InitializeComponent();
addNewToolStripMenuItem.Click += add;
editToolStripMenuItem.Click += edit;
deleteToolStripMenuItem.Click += delete;
Car = car;
addNewToolStripMenuItem.Tag = this;
editToolStripMenuItem.Tag = this;
deleteToolStripMenuItem.Tag = this;
}
}
}

View File

@@ -0,0 +1,123 @@
<?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>
<metadata name="myMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

65
Controls/CarPanelMenuStrip.Designer.cs generated Normal file
View File

@@ -0,0 +1,65 @@
namespace GtaVUsersInfo.Controls
{
partial class CarPanelMenuStrip
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.myMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
this.addNewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.myMenuStrip.SuspendLayout();
this.SuspendLayout();
//
// myMenuStrip
//
this.myMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.addNewToolStripMenuItem});
this.myMenuStrip.Name = "contextMenuStrip";
this.myMenuStrip.Size = new System.Drawing.Size(118, 26);
//
// addNewToolStripMenuItem
//
this.addNewToolStripMenuItem.Name = "addNewToolStripMenuItem";
this.addNewToolStripMenuItem.Size = new System.Drawing.Size(117, 22);
this.addNewToolStripMenuItem.Text = "Создать";
//
// CarPanelMenuStrip
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Name = "CarPanelMenuStrip";
this.myMenuStrip.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ContextMenuStrip myMenuStrip;
private System.Windows.Forms.ToolStripMenuItem addNewToolStripMenuItem;
}
}

View File

@@ -0,0 +1,27 @@
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;
namespace GtaVUsersInfo.Controls
{
public partial class CarPanelMenuStrip : UserControl
{
public ContextMenuStrip Menu
{
get { return myMenuStrip; }
}
public CarPanelMenuStrip(EventHandler add)
{
InitializeComponent();
addNewToolStripMenuItem.Click += add;
}
}
}

View File

@@ -0,0 +1,123 @@
<?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>
<metadata name="myMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>