правочки

This commit is contained in:
Максим Яковлев 2024-10-06 13:20:30 +04:00
parent c0526f74fd
commit 237a12901e
9 changed files with 3 additions and 387 deletions

View File

@ -5,6 +5,7 @@
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>

View File

@ -1,36 +0,0 @@
namespace ComponentProgramming
{
partial class testComp
{
/// <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()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}

View File

@ -1,67 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComponentProgramming
{
public partial class testComp : Component
{
private string _fileName;
public string FileName
{
set
{
if (string.IsNullOrEmpty(value)) return;
if (!value.EndsWith(".txt"))
{
throw new ArgumentException("No txt file");
}
_fileName = value;
}
}
public testComp()
{
InitializeComponent();
_fileName = string.Empty;
}
public testComp(IContainer container)
{
container.Add(this);
InitializeComponent();
_fileName = string.Empty;
}
public bool saveToFile(string[] texts)
{
CheckFileExist();
using var writer = new StreamWriter(_fileName, true);
foreach (var text in texts)
{
writer.WriteLine(text);
}
writer.Flush();
return true;
}
private void CheckFileExist()
{
if (string.IsNullOrEmpty(_fileName))
{
throw new ArgumentNullException(_fileName);
}
if(!File.Exists("../"+_fileName))
{
throw new FileNotFoundException(_fileName);
}
}
}
}

View File

@ -1,72 +0,0 @@
namespace ComponentProgramming
{
partial class ControlImage
{
/// <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()
{
pictureBoxAvatar = new PictureBox();
buttonLoad = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxAvatar).BeginInit();
SuspendLayout();
//
// pictureBoxAvatar
//
pictureBoxAvatar.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
pictureBoxAvatar.Location = new Point(3, 3);
pictureBoxAvatar.Name = "pictureBoxAvatar";
pictureBoxAvatar.Size = new Size(144, 115);
pictureBoxAvatar.TabIndex = 0;
pictureBoxAvatar.TabStop = false;
//
// buttonLoad
//
buttonLoad.Anchor = AnchorStyles.Bottom;
buttonLoad.Location = new Point(35, 124);
buttonLoad.Name = "buttonLoad";
buttonLoad.Size = new Size(75, 23);
buttonLoad.TabIndex = 1;
buttonLoad.Text = "Загрузить";
buttonLoad.UseVisualStyleBackColor = true;
buttonLoad.Click += buttonLoad_Click;
//
// Control
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(buttonLoad);
Controls.Add(pictureBoxAvatar);
Name = "Control";
((System.ComponentModel.ISupportInitialize)pictureBoxAvatar).EndInit();
ResumeLayout(false);
}
#endregion
private PictureBox pictureBoxAvatar;
private Button buttonLoad;
}
}

View File

@ -1,67 +0,0 @@
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 ComponentProgramming
{
public partial class ControlImage : UserControl
{
private event EventHandler? _avatarChanged;
private event Action? _errorOccured;
public string Error { get; private set; }
public Image Avatar
{
get
{
return pictureBoxAvatar.Image;
}
set
{
pictureBoxAvatar.Image = value;
}
}
public event EventHandler AvatarChanged
{
add { _avatarChanged += value; }
remove { _avatarChanged -= value; }
}
public event Action AnErrorOccured
{
add { _errorOccured += value; }
remove { _errorOccured -= value; }
}
public ControlImage()
{
InitializeComponent();
Error = string.Empty;
}
private void buttonLoad_Click(object sender, EventArgs e)
{
var ofd = new OpenFileDialog();
if(ofd.ShowDialog() == DialogResult.OK)
{
try
{
pictureBoxAvatar.Image = Image.FromFile(ofd.FileName);
pictureBoxAvatar.Width = pictureBoxAvatar.Image.Width;
_avatarChanged?.Invoke(this, e);
}
catch( Exception ex)
{
Error = ex.Message;
_errorOccured?.Invoke();
}
}
}
}
}

View File

@ -1,120 +0,0 @@
<?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>

View File

@ -1,24 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComponentProgramming.Control
{
public class Person
{
public int Id { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
public Person() { }
public Person(int id, string name, string surname)
{
Name = name;
Id = id;
Surname = surname;
}
}
}

View File

@ -106,7 +106,6 @@
#endregion
private ComponentProgramming.ControlImage control;
private ComponentProgramming.ControlComboBox controlComboBox;
private ComponentProgramming.ControlTextBox controlTextBox;
private Button buttonGetObj;

View File

@ -9,6 +9,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ComponentsLibraryNet60" Version="1.0.0" />
<PackageReference Include="ControlsLibraryNet60" Version="1.0.0" />
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="6.1.1" />
</ItemGroup>