-
Notifications
You must be signed in to change notification settings - Fork 0
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
Running Button #15
Running Button #15
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.9.34728.123 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RunningButton", "RunningButton\RunningButton.csproj", "{6DED2831-56E2-46F4-A1E4-DD55C9753BD4}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{6DED2831-56E2-46F4-A1E4-DD55C9753BD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{6DED2831-56E2-46F4-A1E4-DD55C9753BD4}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{6DED2831-56E2-46F4-A1E4-DD55C9753BD4}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{6DED2831-56E2-46F4-A1E4-DD55C9753BD4}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {E4705B43-4F95-4106-8FF0-4C71759317BC} | ||
EndGlobalSection | ||
EndGlobal |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace RunningButton | ||
{ | ||
internal static class Program | ||
{ | ||
/// <summary> | ||
/// The main entry point for the application. | ||
/// </summary> | ||
[STAThread] | ||
static void Main() | ||
{ | ||
if (!System.OperatingSystem.IsWindows()) | ||
{ | ||
Console.WriteLine("Program is only supported on Windows"); | ||
System.Environment.Exit(0); | ||
} | ||
ApplicationConfiguration.Initialize(); | ||
Application.Run(new RunningButtonForm()); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<TargetFramework>net8.0-windows</TargetFramework> | ||
<EnableWindowsTargeting>true</EnableWindowsTargeting> | ||
<Nullable>enable</Nullable> | ||
<UseWindowsForms>true</UseWindowsForms> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
namespace RunningButton | ||
{ | ||
public class RunningButtonForm: Form | ||
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 Button button; | ||
Random random; | ||
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 RunningButtonForm() | ||
{ | ||
this.components = new System.ComponentModel.Container(); | ||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; | ||
this.ClientSize = new System.Drawing.Size(1000, 600); | ||
this.Text = "Running Button"; | ||
this.button = new Button(); | ||
this.Controls.Add(button); | ||
button.Text = "Press me"; | ||
button.Location = new Point(450, 275); | ||
button.Size = new Size(100, 50); | ||
button.MouseEnter += new System.EventHandler(this.Mouse_Hover); | ||
Check warning on line 18 in RunningButton/RunningButton/RunningButtonForm.cs GitHub Actions / build-Windows
Check warning on line 18 in RunningButton/RunningButton/RunningButtonForm.cs GitHub Actions / build-Windows
Check warning on line 18 in RunningButton/RunningButton/RunningButtonForm.cs GitHub Actions / build-Windows
Check warning on line 18 in RunningButton/RunningButton/RunningButtonForm.cs GitHub Actions / build-Windows
|
||
button.Click += new System.EventHandler(this.Mouse_Click); | ||
Check warning on line 19 in RunningButton/RunningButton/RunningButtonForm.cs GitHub Actions / build-Windows
Check warning on line 19 in RunningButton/RunningButton/RunningButtonForm.cs GitHub Actions / build-Windows
Check warning on line 19 in RunningButton/RunningButton/RunningButtonForm.cs GitHub Actions / build-Windows
Check warning on line 19 in RunningButton/RunningButton/RunningButtonForm.cs GitHub Actions / build-Windows
|
||
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. nullability-анализ ругается, стоило бы поправить |
||
random = new Random(); | ||
this.MinimumSize = new Size(500, 500); | ||
} | ||
/// <summary> | ||
Comment on lines
+22
to
+23
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. Тут надо пустую строку |
||
/// Required designer variable. | ||
/// </summary> | ||
private System.ComponentModel.IContainer? components = null; | ||
|
||
/// <summary> | ||
/// Clean up any resources being used. | ||
/// </summary> | ||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> | ||
protected override void Dispose(bool disposing) | ||
{ | ||
if (disposing && (components != null)) | ||
{ | ||
components.Dispose(); | ||
} | ||
base.Dispose(disposing); | ||
} | ||
|
||
/// <summary> | ||
/// Event that happens when user hovers on the button | ||
/// </summary> | ||
/// <param name="sender">parameter that contains a reference to the control that raised the event</param> | ||
/// <param name="e">parameter that contains the event data</param> | ||
private void Mouse_Hover(object sender, EventArgs e) | ||
{ | ||
this.button.Location = new Point(random.Next(0, this.Width - 130), random.Next(0 , this.Height - 100)); | ||
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. Никак не проверяется, что кнопка не оказалась прямо под курсором, так что на неё всё-таки можно кликнуть |
||
} | ||
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. Используйте expression-bodied-методы везде, где только можно :) |
||
|
||
/// <summary> | ||
/// Event that happens when user successfully clicks the button | ||
/// </summary> | ||
/// <param name="sender">parameter that contains a reference to the control that raised the event</param> | ||
/// <param name="e">parameter that contains the event data</param> | ||
private void Mouse_Click(object sender, EventArgs e) | ||
{ | ||
System.Windows.Forms.Application.Exit(); | ||
} | ||
|
||
/// <summary> | ||
/// Required method for Designer support - do not modify | ||
/// the contents of this method with the code editor. | ||
/// </summary> | ||
Comment on lines
+61
to
+64
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. Это какой-то кусок из сгенерённого файла |
||
|
||
} | ||
} |
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.
Используйте file-scoped namespaces