diff --git a/RunningButton/RunningButton.sln b/RunningButton/RunningButton.sln new file mode 100644 index 0000000..490c092 --- /dev/null +++ b/RunningButton/RunningButton.sln @@ -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 diff --git a/RunningButton/RunningButton/Program.cs b/RunningButton/RunningButton/Program.cs new file mode 100644 index 0000000..0eee87b --- /dev/null +++ b/RunningButton/RunningButton/Program.cs @@ -0,0 +1,15 @@ +namespace RunningButton +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + ApplicationConfiguration.Initialize(); + Application.Run(new RunningButtonForm()); + } + } +} \ No newline at end of file diff --git a/RunningButton/RunningButton/RunningButton.csproj b/RunningButton/RunningButton/RunningButton.csproj new file mode 100644 index 0000000..4161552 --- /dev/null +++ b/RunningButton/RunningButton/RunningButton.csproj @@ -0,0 +1,11 @@ + + + + WinExe + net8.0-windows + enable + true + enable + + + \ No newline at end of file diff --git a/RunningButton/RunningButton/RunningButtonForm.cs b/RunningButton/RunningButton/RunningButtonForm.cs new file mode 100644 index 0000000..dd60b3f --- /dev/null +++ b/RunningButton/RunningButton/RunningButtonForm.cs @@ -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); + button.Click += new System.EventHandler(this.Mouse_Click); + random = new Random(); + this.MinimumSize = new Size(500, 500); + } + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer? components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + /// + /// Event that happens when user hovers on the button + /// + /// parameter that contains a reference to the control that raised the event + /// parameter that contains the event data + 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)); + } + + /// + /// Event that happens when user successfully clicks the button + /// + /// parameter that contains a reference to the control that raised the event + /// parameter that contains the event data + private void Mouse_Click(object sender, EventArgs e) + { + System.Windows.Forms.Application.Exit(); + } + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + + } +}