-
Notifications
You must be signed in to change notification settings - Fork 0
Добавьте файлы проекта. #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: temp
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| | ||
| Microsoft Visual Studio Solution File, Format Version 12.00 | ||
| # Visual Studio Version 17 | ||
| VisualStudioVersion = 17.14.36202.13 d17.14 | ||
| MinimumVisualStudioVersion = 10.0.40219.1 | ||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PetProjectDog", "PetProjectDog\PetProjectDog.csproj", "{5528D01A-B792-4076-B8D0-D8F8D812FCAC}" | ||
| EndProject | ||
| Global | ||
| GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
| Debug|Any CPU = Debug|Any CPU | ||
| Release|Any CPU = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
| {5528D01A-B792-4076-B8D0-D8F8D812FCAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {5528D01A-B792-4076-B8D0-D8F8D812FCAC}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {5528D01A-B792-4076-B8D0-D8F8D812FCAC}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| {5528D01A-B792-4076-B8D0-D8F8D812FCAC}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(SolutionProperties) = preSolution | ||
| HideSolutionNode = FALSE | ||
| EndGlobalSection | ||
| GlobalSection(ExtensibilityGlobals) = postSolution | ||
| SolutionGuid = {B520792F-6A33-4531-BC98-82FCA29ED32E} | ||
| EndGlobalSection | ||
| EndGlobal |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| 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 PetProjectDog | ||
| { | ||
| public partial class AddNoteForm : Form | ||
| { | ||
|
|
||
| public string NoteText { get; private set; } | ||
|
|
||
| public AddNoteForm() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
|
|
||
| private void AddNoteForm_Load(object sender, EventArgs e) | ||
| { | ||
|
|
||
| } | ||
|
|
||
| private void textBox1_TextChanged(object sender, EventArgs e) | ||
| { | ||
|
|
||
| } | ||
|
|
||
| private void btnSave_Click(object sender, EventArgs e) | ||
| { | ||
| if(!string.IsNullOrWhiteSpace(txtNote.Text)) | ||
| { | ||
| NoteText = txtNote.Text.Trim(); | ||
| DialogResult = DialogResult.OK; | ||
| Close(); | ||
| } | ||
| else | ||
| { | ||
| MessageBox.Show("Введите текст примечания.", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Text.Json; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace PetProjectDog | ||
| { | ||
| public static class DataStorage | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Лучше конечно это все переписать на структуру классов, не хорошо делать статические классы-хранилки. А также хорошо бы разные коллекции разбивать по разным классам, условно Если всё что происходит, это запись и чтение из файла, то можно сделать базовый класс Также напрягает логика с тем, что нужно знать, что нужно модифицировать коллекцию, а потом вызвать записывающий метод. Лучше всего тут бы подошло -
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. А по поводу статики дополнение - в винформах конечно вполне нормально, когда форма взаимодействует через какой-то статический контекст. Но условно без DI, как самое простое и относительно чистое решение можно сделать так |
||
| { | ||
| public static List<Dog> Dogs { get; private set; } = new List<Dog>(); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Стандартный принятый порядок Поля Ну либо другой другой, но отступы между строками лучше соблюдать, и избегать пустых строк как в конце. |
||
| public static List<Owner> Owners { get; private set; } = new List<Owner>(); | ||
| private static string FilePath => "dogs.json"; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Тут лучше бы подошла константа private const string ... |
||
| public static void SaveDogsToFile() | ||
| { | ||
| string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "dogs.json"); | ||
|
|
||
| var options = new JsonSerializerOptions { WriteIndented = true }; | ||
| string json = JsonSerializer.Serialize(Dogs, options); | ||
|
|
||
| File.WriteAllText(path, json); | ||
|
|
||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ещё пустая строка :) |
||
| } | ||
|
|
||
| public static void LoadDogsFromFile() | ||
| { | ||
| if (!File.Exists(FilePath)) return; | ||
|
|
||
| string json = File.ReadAllText(FilePath); | ||
| try | ||
| { | ||
| Dogs = JsonSerializer.Deserialize<List<Dog>>(json) ?? new List<Dog>(); | ||
| } | ||
| catch | ||
| { | ||
| Dogs = new List<Dog>(); | ||
| } | ||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Diagnostics.Eventing.Reader; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace PetProjectDog | ||
| { | ||
| public class Dog | ||
| { | ||
| public string Name { get; set; } // имя пса | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Бесмыссленные комментарии лучше избегать. А если хочется красивые подсказки, то такое можно выносить в Тогда они в подсказках появляются, вроде студия тоже умеет сама их генерировать. |
||
| public string Age { get; set; } // возраст | ||
| public double Weight { get; set; } // вес | ||
|
|
||
| public string Colour { get; set; } // Цвет | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. В коде принят американский английский, т.е. Color |
||
|
|
||
| public bool IsFriendly { get; set; } // дружелюбна? | ||
|
|
||
| public string Breed { get; set; } // порода | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Если хочется подумать над моделью данных, то стоит сразу нормализовывать данные - |
||
|
|
||
| public string SpecialFeatures { get; set; } // особые приметы | ||
|
|
||
| public List<string> Notes { get; set; } = new List<string>(); // список примечаний | ||
|
|
||
| public bool IsVaccinated { get; set; } | ||
| public DateTime LastVaccination { get; set; } // дата последней вакцины | ||
|
|
||
| public DateTime NextVaccination { get; set; } // дата следуюущей вакцины | ||
|
|
||
| public DateTime LastWalk { get; set; } // | ||
| public DateTime NextWalk { get; set; } // | ||
| public DateTime DateLastUpdate { get; set; } // Дата последнего обновления карточки | ||
|
|
||
| public string PhotoPath { get; set; } // Путь к фотографии | ||
|
|
||
| public Owner Owner { get; set; } = new Owner(); // поле для владельца | ||
|
|
||
| public Dog(string name, string age, double weight, string color, string breed, bool isFriendly, bool isVaccinated) | ||
| { | ||
| Name = name; | ||
| Age = age; | ||
| Weight = weight; | ||
| Colour = color; | ||
| Breed = breed; | ||
| IsFriendly = isFriendly; | ||
| IsVaccinated = isVaccinated; | ||
| } | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Тоже отступы
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Больше про них писать не буду, но надо привыкнуть следить за ними :) |
||
| public Dog() | ||
| { | ||
| } | ||
|
|
||
|
|
||
| public void ShowMainInfo() | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Выглядит как дебажный метод. +можно ещё и над использованием логгеров подумать :) |
||
| { | ||
| Console.WriteLine($"Имя: {Name}\nВозраст: {Age}\nПорода: {Breed}\n" + | ||
| $"Дружелюбна: {IsFriendly}\nВакцинирована: {IsVaccinated}"); | ||
| } | ||
| public override string ToString() | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Использование ToString() полезно, только когда это используется где-то в логгерах. Для выведения на экран лучше заводить отдельные методы GetFormattedMainInfo(), как выше у тебя было. |
||
| { | ||
| return $"Имя питомца: {Name}, Порода: {Breed},Возраст: {Age} лет, Дата регистрации: {DateTime.Now.ToString("yyyy-MM-dd")}"; | ||
| } | ||
|
|
||
| public void AddNote(string note) | ||
| { | ||
| Notes.Add(note); | ||
| } | ||
| public void MarkAsWalked() | ||
| { | ||
| LastWalk = DateTime.Now; | ||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше стараться избегать пустых методов, да, случайно кликаются, понимаю)