diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2b53b5..868d947 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,5 +25,5 @@ jobs: run: For /R %%I in (*.sln) do dotnet build %%I shell: cmd - name: test - run: For /R %%I in (*.sln) do dotnet build %%I + run: For /R %%I in (*.sln) do dotnet test %%I shell: cmd diff --git a/C#/forSpbu/RunningButton/Program.cs b/C#/forSpbu/RunningButton/Program.cs new file mode 100644 index 0000000..d65e4e0 --- /dev/null +++ b/C#/forSpbu/RunningButton/Program.cs @@ -0,0 +1,14 @@ +namespace RunningButton; + +static class Program +{ + /// + /// The main entry point for the application. + /// + [STAThread] + private static void Main() + { + ApplicationConfiguration.Initialize(); + Application.Run(new RunningButtonForm()); + } +} \ No newline at end of file diff --git a/C#/forSpbu/RunningButton/RunningButton.csproj b/C#/forSpbu/RunningButton/RunningButton.csproj new file mode 100644 index 0000000..d36079d --- /dev/null +++ b/C#/forSpbu/RunningButton/RunningButton.csproj @@ -0,0 +1,12 @@ + + + + WinExe + net7.0-windows + enable + true + enable + true + + + \ No newline at end of file diff --git a/C#/forSpbu/RunningButton/RunningButton.csproj.user b/C#/forSpbu/RunningButton/RunningButton.csproj.user new file mode 100644 index 0000000..3a34caa --- /dev/null +++ b/C#/forSpbu/RunningButton/RunningButton.csproj.user @@ -0,0 +1,8 @@ + + + + + Form + + + \ No newline at end of file diff --git a/C#/forSpbu/RunningButton/RunningButtonForm.Designer.cs b/C#/forSpbu/RunningButton/RunningButtonForm.Designer.cs new file mode 100644 index 0000000..cd59dce --- /dev/null +++ b/C#/forSpbu/RunningButton/RunningButtonForm.Designer.cs @@ -0,0 +1,53 @@ +namespace RunningButton; + +partial class RunningButtonForm +{ + /// + /// 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); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.Size = new Size(400, 400); + this.MinimumSize = new Size(300, 400); + this.Text = "RunningButton"; + this.Controls.Add(_runningButton); + + _runningButton.BackColor = Color.Gray; + _runningButton.TextAlign = ContentAlignment.MiddleCenter; + _runningButton.Text = "Button"; + _runningButton.ForeColor = Color.Azure; + _runningButton.Font = new Font("Segoe UI", 15F, FontStyle.Regular, GraphicsUnit.Pixel); + _runningButton.MouseEnter += OnEnter; + _runningButton.Click += OnClick; + _runningButton.Location = new Point(0, 0); + _runningButton.Anchor = AnchorStyles.Top | AnchorStyles.Left; + _runningButton.Size = new Size(100, 100); + } + + #endregion + + private Button _runningButton = new Button(); + private Position _buttonPosition = Position.TopLeft; +} \ No newline at end of file diff --git a/C#/forSpbu/RunningButton/RunningButtonForm.cs b/C#/forSpbu/RunningButton/RunningButtonForm.cs new file mode 100644 index 0000000..042837c --- /dev/null +++ b/C#/forSpbu/RunningButton/RunningButtonForm.cs @@ -0,0 +1,65 @@ +namespace RunningButton; + +/// +/// Form class for the running button game +/// +public partial class RunningButtonForm : Form +{ + /// + /// Creates form and initializes the button + /// + public RunningButtonForm() + { + InitializeComponent(); + } + + private enum Position + { + TopLeft, + TopRight, + BottomRight, + BottomLeft + } + + private void OnEnter(object? sender, EventArgs eventArgs) + { + if (sender is not Button senderButton) + { + return; + } + + switch (_buttonPosition) + { + case Position.TopLeft: + _buttonPosition += 1; + senderButton.Anchor = AnchorStyles.Top | AnchorStyles.Right; + senderButton.Location = new Point(Size.Width - senderButton.Size.Width, 0); + break; + case Position.TopRight: + _buttonPosition += 1; + senderButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + senderButton.Location = new Point(Size.Width - senderButton.Size.Width, Size.Height - senderButton.Size.Height); + break; + case Position.BottomRight: + _buttonPosition += 1; + senderButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + senderButton.Location = new Point(0, Size.Height - senderButton.Size.Height); + break; + case Position.BottomLeft: + _buttonPosition = 0; + senderButton.Anchor = AnchorStyles.Top | AnchorStyles.Left; + senderButton.Location = new Point(0, 0); + break; + } + } + + private void OnClick(object? sender, EventArgs eventArgs) + { + if (sender is not Button) + { + return; + } + + Close(); + } +} \ No newline at end of file diff --git a/C#/forSpbu/forSpbu.sln b/C#/forSpbu/forSpbu.sln index 527f400..f3d01e6 100644 --- a/C#/forSpbu/forSpbu.sln +++ b/C#/forSpbu/forSpbu.sln @@ -10,6 +10,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "03.03", "03.03", "{882A9B9C EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "10.03", "10.03", "{EA6FC7D9-BDFB-49CD-AC00-FC5DDC5274B0}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Exam2", "Exam2", "{187107A9-2FE0-4E91-AFE3-7F088370560A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RunningButton", "RunningButton\RunningButton.csproj", "{80CE2F13-4CBF-4AF2-81E4-8809FF8E5BB6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,12 +25,17 @@ Global {E007586F-9760-4744-BB25-EDEFD6BA860C}.Release|Any CPU.ActiveCfg = Release|Any CPU {E007586F-9760-4744-BB25-EDEFD6BA860C}.Release|Any CPU.Build.0 = Release|Any CPU {A4F6ADD5-85FD-4F67-8B29-549DDDF6F82E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A4F6ADD5-85FD-4F67-8B29-549DDDF6F82E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A4F6ADD5-85FD-4F67-8B29-549DDDF6F82E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A4F6ADD5-85FD-4F67-8B29-549DDDF6F82E}.Release|Any CPU.Build.0 = Release|Any CPU + {A4F6ADD5-85FD-4F67-8B29-549DDDF6F82E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4F6ADD5-85FD-4F67-8B29-549DDDF6F82E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4F6ADD5-85FD-4F67-8B29-549DDDF6F82E}.Release|Any CPU.Build.0 = Release|Any CPU + {80CE2F13-4CBF-4AF2-81E4-8809FF8E5BB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {80CE2F13-4CBF-4AF2-81E4-8809FF8E5BB6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {80CE2F13-4CBF-4AF2-81E4-8809FF8E5BB6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {80CE2F13-4CBF-4AF2-81E4-8809FF8E5BB6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution - {E007586F-9760-4744-BB25-EDEFD6BA860C} = {D3FCB669-E93F-4F0B-B9C5-6592CE93AC7F} + {E007586F-9760-4744-BB25-EDEFD6BA860C} = {D3FCB669-E93F-4F0B-B9C5-6592CE93AC7F} {A4F6ADD5-85FD-4F67-8B29-549DDDF6F82E} = {D3FCB669-E93F-4F0B-B9C5-6592CE93AC7F} + {80CE2F13-4CBF-4AF2-81E4-8809FF8E5BB6} = {187107A9-2FE0-4E91-AFE3-7F088370560A} EndGlobalSection EndGlobal