From ff7afe01e13055d07674cc94215deea8e79cdd72 Mon Sep 17 00:00:00 2001 From: IgnatSergeev/laptop Date: Fri, 26 May 2023 14:18:31 +0300 Subject: [PATCH 1/5] Added realisation --- C#/forSpbu/RunningButton/Program.cs | 16 +++++ C#/forSpbu/RunningButton/RunningButton.csproj | 11 ++++ .../RunningButton/RunningButton.csproj.user | 8 +++ .../RunningButtonForm.Designer.cs | 53 +++++++++++++++++ C#/forSpbu/RunningButton/RunningButtonForm.cs | 59 +++++++++++++++++++ C#/forSpbu/forSpbu.sln | 17 ++++-- 6 files changed, 160 insertions(+), 4 deletions(-) create mode 100644 C#/forSpbu/RunningButton/Program.cs create mode 100644 C#/forSpbu/RunningButton/RunningButton.csproj create mode 100644 C#/forSpbu/RunningButton/RunningButton.csproj.user create mode 100644 C#/forSpbu/RunningButton/RunningButtonForm.Designer.cs create mode 100644 C#/forSpbu/RunningButton/RunningButtonForm.cs diff --git a/C#/forSpbu/RunningButton/Program.cs b/C#/forSpbu/RunningButton/Program.cs new file mode 100644 index 0000000..b030dc3 --- /dev/null +++ b/C#/forSpbu/RunningButton/Program.cs @@ -0,0 +1,16 @@ +namespace RunningButton; + +static class Program +{ + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + 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..638e474 --- /dev/null +++ b/C#/forSpbu/RunningButton/RunningButton.csproj @@ -0,0 +1,11 @@ + + + + WinExe + net7.0-windows + enable + true + enable + + + \ 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..1bcb75b --- /dev/null +++ b/C#/forSpbu/RunningButton/RunningButtonForm.cs @@ -0,0 +1,59 @@ +namespace RunningButton; + +public partial class RunningButtonForm : Form +{ + public RunningButtonForm() + { + InitializeComponent(); + } + + 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 senderButton) + { + 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 From f92a14ce999dc8a1d65d5e6de356b8975b51303b Mon Sep 17 00:00:00 2001 From: IgnatSergeev/laptop Date: Fri, 26 May 2023 14:18:47 +0300 Subject: [PATCH 2/5] Fixed ci --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 9b8d72525a65e8e4ea083f631fb341de5d8c7606 Mon Sep 17 00:00:00 2001 From: IgnatSergeev/laptop Date: Fri, 26 May 2023 14:24:52 +0300 Subject: [PATCH 3/5] Added comments --- C#/forSpbu/RunningButton/Program.cs | 4 +--- C#/forSpbu/RunningButton/RunningButtonForm.cs | 10 ++++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/C#/forSpbu/RunningButton/Program.cs b/C#/forSpbu/RunningButton/Program.cs index b030dc3..d65e4e0 100644 --- a/C#/forSpbu/RunningButton/Program.cs +++ b/C#/forSpbu/RunningButton/Program.cs @@ -6,10 +6,8 @@ static class Program /// The main entry point for the application. /// [STAThread] - static void Main() + private static void Main() { - // To customize application configuration such as set high DPI settings or default font, - // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); Application.Run(new RunningButtonForm()); } diff --git a/C#/forSpbu/RunningButton/RunningButtonForm.cs b/C#/forSpbu/RunningButton/RunningButtonForm.cs index 1bcb75b..042837c 100644 --- a/C#/forSpbu/RunningButton/RunningButtonForm.cs +++ b/C#/forSpbu/RunningButton/RunningButtonForm.cs @@ -1,13 +1,19 @@ namespace RunningButton; +/// +/// Form class for the running button game +/// public partial class RunningButtonForm : Form { + /// + /// Creates form and initializes the button + /// public RunningButtonForm() { InitializeComponent(); } - enum Position + private enum Position { TopLeft, TopRight, @@ -49,7 +55,7 @@ private void OnEnter(object? sender, EventArgs eventArgs) private void OnClick(object? sender, EventArgs eventArgs) { - if (sender is not Button senderButton) + if (sender is not Button) { return; } From bd354f751dc0842cb635de296a634dfe59e92458 Mon Sep 17 00:00:00 2001 From: IgnatSergeev/laptop Date: Fri, 26 May 2023 14:27:50 +0300 Subject: [PATCH 4/5] Fixed ci --- C#/forSpbu/RunningButton/RunningButton.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/C#/forSpbu/RunningButton/RunningButton.csproj b/C#/forSpbu/RunningButton/RunningButton.csproj index 638e474..d663c35 100644 --- a/C#/forSpbu/RunningButton/RunningButton.csproj +++ b/C#/forSpbu/RunningButton/RunningButton.csproj @@ -6,6 +6,7 @@ enable true enable + true \ No newline at end of file From 06c3339e8c2324c07d532d87db0ea1ae2b5ff78a Mon Sep 17 00:00:00 2001 From: IgnatSergeev/laptop Date: Fri, 26 May 2023 14:29:14 +0300 Subject: [PATCH 5/5] Fixed ci --- C#/forSpbu/RunningButton/RunningButton.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C#/forSpbu/RunningButton/RunningButton.csproj b/C#/forSpbu/RunningButton/RunningButton.csproj index d663c35..d36079d 100644 --- a/C#/forSpbu/RunningButton/RunningButton.csproj +++ b/C#/forSpbu/RunningButton/RunningButton.csproj @@ -6,7 +6,7 @@ enable true enable - true + true \ No newline at end of file