Skip to content

Commit

Permalink
Running Button
Browse files Browse the repository at this point in the history
  • Loading branch information
kamendov-maxim committed May 23, 2024
1 parent 2e7b4c9 commit 8f96ced
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 0 deletions.
25 changes: 25 additions & 0 deletions RunningButton/RunningButton.sln
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
15 changes: 15 additions & 0 deletions RunningButton/RunningButton/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace RunningButton
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
ApplicationConfiguration.Initialize();
Application.Run(new RunningButtonForm());
}
}
}
11 changes: 11 additions & 0 deletions RunningButton/RunningButton/RunningButton.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

</Project>
67 changes: 67 additions & 0 deletions RunningButton/RunningButton/RunningButtonForm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
namespace RunningButton
{
public class RunningButtonForm: Form
{
private Button button;
Random random;
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

View workflow job for this annotation

GitHub Actions / build-Windows

Nullability of reference types in type of parameter 'sender' of 'void RunningButtonForm.Mouse_Hover(object sender, EventArgs e)' doesn't match the target delegate 'EventHandler' (possibly because of nullability attributes).

Check warning on line 18 in RunningButton/RunningButton/RunningButtonForm.cs

View workflow job for this annotation

GitHub Actions / build-Windows

Nullability of reference types in type of parameter 'sender' of 'void RunningButtonForm.Mouse_Hover(object sender, EventArgs e)' doesn't match the target delegate 'EventHandler' (possibly because of nullability attributes).

Check warning on line 18 in RunningButton/RunningButton/RunningButtonForm.cs

View workflow job for this annotation

GitHub Actions / build-Windows

Nullability of reference types in type of parameter 'sender' of 'void RunningButtonForm.Mouse_Hover(object sender, EventArgs e)' doesn't match the target delegate 'EventHandler' (possibly because of nullability attributes).

Check warning on line 18 in RunningButton/RunningButton/RunningButtonForm.cs

View workflow job for this annotation

GitHub Actions / build-Windows

Nullability of reference types in type of parameter 'sender' of 'void RunningButtonForm.Mouse_Hover(object sender, EventArgs e)' doesn't match the target delegate 'EventHandler' (possibly because of nullability attributes).
button.Click += new System.EventHandler(this.Mouse_Click);

Check warning on line 19 in RunningButton/RunningButton/RunningButtonForm.cs

View workflow job for this annotation

GitHub Actions / build-Windows

Nullability of reference types in type of parameter 'sender' of 'void RunningButtonForm.Mouse_Click(object sender, EventArgs e)' doesn't match the target delegate 'EventHandler' (possibly because of nullability attributes).

Check warning on line 19 in RunningButton/RunningButton/RunningButtonForm.cs

View workflow job for this annotation

GitHub Actions / build-Windows

Nullability of reference types in type of parameter 'sender' of 'void RunningButtonForm.Mouse_Click(object sender, EventArgs e)' doesn't match the target delegate 'EventHandler' (possibly because of nullability attributes).

Check warning on line 19 in RunningButton/RunningButton/RunningButtonForm.cs

View workflow job for this annotation

GitHub Actions / build-Windows

Nullability of reference types in type of parameter 'sender' of 'void RunningButtonForm.Mouse_Click(object sender, EventArgs e)' doesn't match the target delegate 'EventHandler' (possibly because of nullability attributes).

Check warning on line 19 in RunningButton/RunningButton/RunningButtonForm.cs

View workflow job for this annotation

GitHub Actions / build-Windows

Nullability of reference types in type of parameter 'sender' of 'void RunningButtonForm.Mouse_Click(object sender, EventArgs e)' doesn't match the target delegate 'EventHandler' (possibly because of nullability attributes).
random = new Random();
this.MinimumSize = new Size(500, 500);
}
/// <summary>
/// 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));
}

/// <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>

}
}

0 comments on commit 8f96ced

Please sign in to comment.