Skip to content

Commit

Permalink
tune animation
Browse files Browse the repository at this point in the history
  • Loading branch information
PavelKulbida committed Mar 14, 2021
1 parent d6f680a commit b63fe78
Show file tree
Hide file tree
Showing 13 changed files with 250 additions and 28 deletions.
37 changes: 19 additions & 18 deletions DemoService/BL/MessageProcessingLogic.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using DemoService.Controllers;
using DemoService.Properties;
Expand All @@ -14,6 +13,20 @@ internal class MessageProcessingLogic : IMessageProcessingLogic

private readonly ILogger<AppConsole> _logger;

private readonly string[] _animation =
{
Resources.AnimationMessage0,
Resources.AnimationMessage1,
Resources.AnimationMessage2,
Resources.AnimationMessage3,
Resources.AnimationMessage4,
Resources.AnimationMessage5,
Resources.AnimationMessage6,
Resources.AnimationMessage7,
Resources.AnimationMessage8,
Resources.AnimationMessage9,
};

public MessageProcessingLogic(ILogger<AppConsole> logger)
{
_logger = logger;
Expand Down Expand Up @@ -43,40 +56,28 @@ public ServiceMessage Process(ServiceMessage request)

if (request.Text.ToUpper() == $"GIVE ANIMATION")
{
using var reader = new StringReader(Resources.ImageMessage);
string first = reader.ReadLine();

var headers = new Dictionary<string, IEnumerable<string>>()
{
{"pooling", new List<string>() {"1"}},
{"clrscr", new List<string>() {"-"}},
{"write", new List<string>() {"-"}},
{"count", new List<string>() {"1"}},
{"count", new List<string>() {"0"}},
};

return new ServiceMessage(first, headers);
return new ServiceMessage(_animation[0], headers);
}

if (request.Context.ContainsKey("pooling"))
{
var linesRequest = Convert.ToInt32(request.Context["count"].First());

var linesImage = Resources.ImageMessage.Split('\n').Length;
linesRequest++;

if (linesRequest == linesImage)
if (linesRequest == _animation.Length)
{
return new ServiceMessage(string.Empty, new Dictionary<string, IEnumerable<string>>());
}

linesRequest++;

string[] lines = Resources.ImageMessage
.Split('\n')
.Take(linesRequest)
.ToArray();

var output = string.Join('\n', lines);

var headers = new Dictionary<string, IEnumerable<string>>()
{
{"pooling", new List<string>() {"1000"}},
Expand All @@ -85,7 +86,7 @@ public ServiceMessage Process(ServiceMessage request)
{"count", new List<string>() { linesRequest.ToString() }},
};

return new ServiceMessage(output, headers);
return new ServiceMessage(_animation[linesRequest], headers);
}

if (request.Text.ToUpper() == $"GIVE FORMATED")
Expand Down
5 changes: 5 additions & 0 deletions DemoService/DATA/AnimationMessage0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


o
/|\
/ \
5 changes: 5 additions & 0 deletions DemoService/DATA/AnimationMessage1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


\o/
|
/ \
5 changes: 5 additions & 0 deletions DemoService/DATA/AnimationMessage2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


_ o
/\
| \
5 changes: 5 additions & 0 deletions DemoService/DATA/AnimationMessage3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@



__\o
/) |
5 changes: 5 additions & 0 deletions DemoService/DATA/AnimationMessage4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


__|
\o
( \
5 changes: 5 additions & 0 deletions DemoService/DATA/AnimationMessage5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


\ /
|
/o\
5 changes: 5 additions & 0 deletions DemoService/DATA/AnimationMessage6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


|__
o/
/ )
5 changes: 5 additions & 0 deletions DemoService/DATA/AnimationMessage7.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@



o/__
| (\
5 changes: 5 additions & 0 deletions DemoService/DATA/AnimationMessage8.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


o _
/\
/ |
5 changes: 5 additions & 0 deletions DemoService/DATA/AnimationMessage9.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


\o/
|
/ \
161 changes: 151 additions & 10 deletions DemoService/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions DemoService/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,36 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="AnimationMessage0" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\data\animationmessage0.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="AnimationMessage1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\data\animationmessage1.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="AnimationMessage2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\data\animationmessage2.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="AnimationMessage3" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\data\animationmessage3.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="AnimationMessage4" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\data\animationmessage4.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="AnimationMessage5" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\data\animationmessage5.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="AnimationMessage6" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\data\animationmessage6.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="AnimationMessage7" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\data\animationmessage7.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="AnimationMessage8" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\data\animationmessage8.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="AnimationMessage9" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\data\animationmessage9.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="BorderedMessage" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\data\borderedmessage.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
Expand Down

0 comments on commit b63fe78

Please sign in to comment.