-
Notifications
You must be signed in to change notification settings - Fork 0
Hw7 clock #15
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: master
Are you sure you want to change the base?
Hw7 clock #15
Conversation
yurii-litvinov
left a comment
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.
Hw7Clock/Hw7Clock/Form1.cs
Outdated
| { | ||
| public partial class Form1 : Form | ||
| { | ||
| Timer timer = new Timer(); |
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.
private
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.
А ещё в современном C# можно писать Timer timer = new ();
Hw7Clock/Hw7Clock/Form1.cs
Outdated
|
|
||
| namespace Hw7Clock | ||
| { | ||
| public partial class Form1 : Form |
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.
Не, Form1 как имя класса (и как заголовок окна) очень не очень.
Hw7Clock/Hw7Clock/Form1.cs
Outdated
| graphics.DrawString("1", new Font("Elephant", 12), Brushes.Black, new PointF(210, 25)); | ||
| graphics.DrawString("2", new Font("Elephant", 12), Brushes.Black, new PointF(260, 70)); | ||
| graphics.DrawString("3", new Font("Elephant", 12), Brushes.Black, new PointF(280, 142)); | ||
| graphics.DrawString("4", new Font("Elephant", 12), Brushes.Black, new PointF(260, 200)); | ||
| graphics.DrawString("5", new Font("Elephant", 12), Brushes.Black, new PointF(210, 255)); | ||
| graphics.DrawString("6", new Font("Elephant", 12), Brushes.Black, new PointF(142, 276)); | ||
| graphics.DrawString("7", new Font("Elephant", 12), Brushes.Black, new PointF(70, 255)); | ||
| graphics.DrawString("8", new Font("Elephant", 12), Brushes.Black, new PointF(25, 200)); | ||
| graphics.DrawString("9", new Font("Elephant", 12), Brushes.Black, new PointF(0, 140)); | ||
| graphics.DrawString("10", new Font("Elephant", 12), Brushes.Black, new PointF(25, 70)); | ||
| graphics.DrawString("11", new Font("Elephant", 12), Brushes.Black, new PointF(70, 25)); | ||
| graphics.DrawString("12", new Font("Elephant", 12), Brushes.Black, new PointF(140, 2)); |
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.
Какой ужас :) Наверняка можно как-то проще. Посмотрите на graphics.RotateTransform и graphics.TranslateTransform
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.
Ну хорошо, не надо Transform-ов, но хоть копипаст-то убрать надо. Шрифт, например, один раз создать и везде его использовать. Сам graphics.DrawString обернуть в функцию, которая бы принимала текст и координаты.
Hw7Clock/Hw7Clock/Form1.cs
Outdated
| int ss = DateTime.Now.Second; | ||
| int mm = DateTime.Now.Minute; | ||
| int hh = DateTime.Now.Hour; | ||
| int[] coord = new int[2]; |
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.
Массив, а не кортеж?
Hw7Clock/Hw7Clock/Form1.cs
Outdated
| { | ||
| coordinates[0] = coordX - (int)(hLen * -Math.Sin(Math.PI * value / 180)); | ||
| coordinates[1] = coordY - (int)(hLen * Math.Cos(Math.PI * value / 180)); | ||
| } |
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.
Тоже что-то копипаст какой-то
Hw7Clock/Hw7Clock/Form1.cs
Outdated
| int mm = DateTime.Now.Minute; | ||
| int hh = DateTime.Now.Hour; | ||
| int[] coord = new int[2]; | ||
| (int, int) coord; |
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.
Лучше (int x, int y) coord;. Тогда вместо страшного coord.Item1, coord.Item2 можно будет писать coord.x, coord.y
Hw7Clock/Hw7Clock/Form1.cs
Outdated
| graphics.DrawString("1", new Font("Elephant", 12), Brushes.Black, new PointF(210, 25)); | ||
| graphics.DrawString("2", new Font("Elephant", 12), Brushes.Black, new PointF(260, 70)); | ||
| graphics.DrawString("3", new Font("Elephant", 12), Brushes.Black, new PointF(280, 142)); | ||
| graphics.DrawString("4", new Font("Elephant", 12), Brushes.Black, new PointF(260, 200)); | ||
| graphics.DrawString("5", new Font("Elephant", 12), Brushes.Black, new PointF(210, 255)); | ||
| graphics.DrawString("6", new Font("Elephant", 12), Brushes.Black, new PointF(142, 276)); | ||
| graphics.DrawString("7", new Font("Elephant", 12), Brushes.Black, new PointF(70, 255)); | ||
| graphics.DrawString("8", new Font("Elephant", 12), Brushes.Black, new PointF(25, 200)); | ||
| graphics.DrawString("9", new Font("Elephant", 12), Brushes.Black, new PointF(0, 140)); | ||
| graphics.DrawString("10", new Font("Elephant", 12), Brushes.Black, new PointF(25, 70)); | ||
| graphics.DrawString("11", new Font("Elephant", 12), Brushes.Black, new PointF(70, 25)); | ||
| graphics.DrawString("12", new Font("Elephant", 12), Brushes.Black, new PointF(140, 2)); |
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.
Ну хорошо, не надо Transform-ов, но хоть копипаст-то убрать надо. Шрифт, например, один раз создать и везде его использовать. Сам graphics.DrawString обернуть в функцию, которая бы принимала текст и координаты.
yurii-litvinov
left a comment
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.
👍

No description provided.