diff --git a/Client/Client.csproj b/Client/Client.csproj
index b37da51..5cd02fb 100644
--- a/Client/Client.csproj
+++ b/Client/Client.csproj
@@ -67,6 +67,7 @@
+
@@ -97,6 +98,7 @@
+ Designer
diff --git a/Client/ConsoleForms/Graphics/DialogView.cs b/Client/ConsoleForms/Graphics/DialogView.cs
index def0736..7f3ab3e 100644
--- a/Client/ConsoleForms/Graphics/DialogView.cs
+++ b/Client/ConsoleForms/Graphics/DialogView.cs
@@ -38,11 +38,11 @@ namespace Client.ConsoleForms.Graphics
private static int ComputeLength(Tuple[] opts) => opts.CollectiveLength(true) + opts.Length - 1;
public DialogView(ViewData parameters, LangManager lang) :
- base(parameters.SetAttribute("width",
+ base(parameters/*.SetAttribute("width",
Math.Max(
parameters.AttribueAsInt("width") < 1 ? parameters.NestedText("Text").Length : parameters.AttribueAsInt("width"),
ComputeLength(parameters.Get("Options")?.CollectSub("Option") ?? new Tuple[0])
- )), lang)
+ ))*/, lang)
{
ViewData optionsData = parameters.Get("Options");
this.options = optionsData.nestedData.Filter(p => p.Name.Equals("Option")).ToArray();
diff --git a/Client/ConsoleForms/Graphics/TextView.cs b/Client/ConsoleForms/Graphics/TextView.cs
index 726ec6c..22accf3 100644
--- a/Client/ConsoleForms/Graphics/TextView.cs
+++ b/Client/ConsoleForms/Graphics/TextView.cs
@@ -85,8 +85,59 @@ namespace Client.ConsoleForms.Graphics
if (maxHeight == 0)
return new string[0];
+ // Extract newlines
+ List l = new List();
+ int afterCount = 0;
+ foreach (var t in text)
+ {
+ string txt = t;
+ while (txt.StartsWith("\n"))
+ {
+ l.Add("\n");
+ txt = txt.Substring(1);
+ }
+ while (txt.EndsWith("\n"))
+ {
+ ++afterCount;
+ txt = txt.Substring(0, txt.Length - 1);
+ }
+
+ var lines = txt.Split('\n');
+ for (int i = 0; i < lines.Length; ++i)
+ {
+ l.Add(lines[i]);
+ if (i != lines.Length - 1) l.Add("\n");
+ }
+
+ while (afterCount-- > 0) l.Add("\n");
+
+ }
+
BoundedList generate = new BoundedList(maxHeight);
+ int height = 0;
+
+ for (int i = 0; i < l.Count; ++i)
+ {
+ bool hasHeight = height < generate.Count;
+ string get = height >= generate.Count ? null : generate[height];
+ if (l[i].Equals("\n"))
+ {
+ if (hasHeight) generate[height] = get ?? "";
+ else if (!generate.Add("")) goto Done;
+ ++height;
+ continue;
+ }
+
+ if (get == null || get.Length == 0)
+ {
+ if(hasHeight) generate[height] = l[i];
+ else if (!generate.Add(l[i])) goto Done;
+ }
+ else generate[height] = get + " " + l[i];
+ }
+ Done:
+ return generate.ToArray();
for (int i = 0; i < text.Length; ++i)
{
if (generate.Count == 0)
diff --git a/Client/ConsoleForms/Graphics/View.cs b/Client/ConsoleForms/Graphics/View.cs
index 7fe8ee5..beded5c 100644
--- a/Client/ConsoleForms/Graphics/View.cs
+++ b/Client/ConsoleForms/Graphics/View.cs
@@ -125,6 +125,7 @@ namespace Client.ConsoleForms.Graphics
}
return false;
}
+ public virtual void TriggerKeyEvent(ConsoleKeyInfo info) => TriggerKeyEvent(new ConsoleController.KeyEvent(info));
public virtual void TriggerKeyEvent(ConsoleController.KeyEvent info) => HandleKeyEvent(info, true, true);
protected void DrawTopPadding(int left, ref int top) => DrawPadding(left, ref top, padding.Top());
protected void DrawBottomPadding(int left, ref int top) => DrawPadding(left, ref top, padding.Bottom());
diff --git a/Client/Context/IntroContext.cs b/Client/Context/IntroContext.cs
new file mode 100644
index 0000000..2d725b1
--- /dev/null
+++ b/Client/Context/IntroContext.cs
@@ -0,0 +1,98 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Client.ConsoleForms;
+using Client.ConsoleForms.Graphics;
+
+namespace Client
+{
+ public sealed class IntroContext : Context
+ {
+ public IntroContext(ContextManager manager, Action onComplete) : base(manager, "Intro", "Common")
+ {
+ GetView("welcome").RegisterSelectListener((v, i, s) =>
+ {
+ if (i == 1)
+ {
+ Hide(v);
+ onComplete();
+ }
+ else
+ {
+ Hide(v);
+ Show("describe1");
+ }
+ });
+
+ GetView("describe1").RegisterSelectListener((v, i, s) =>
+ {
+ if (i == 1) v.TriggerKeyEvent(new ConsoleKeyInfo('\0', ConsoleKey.Escape, false, false, false));
+ else
+ {
+ Hide(v);
+ Show("describe2");
+ }
+ });
+
+ GetView("describe2").RegisterSelectListener((v, i, s) =>
+ {
+ if (i == 1) v.TriggerKeyEvent(new ConsoleKeyInfo('\0', ConsoleKey.Escape, false, false, false));
+ else
+ {
+ Hide(v);
+ Show("describe3");
+ }
+ });
+
+ GetView("describe3").SubmissionsListener = v =>
+ {
+ Hide(v);
+ Show("describe4");
+ };
+
+ GetView("describe4").SubmissionsListener = v =>
+ {
+ Hide(v);
+ Show("describe4_1");
+ };
+
+ GetView("describe4_1").SubmissionsListener = v =>
+ {
+ Hide(v);
+ Show("describe5");
+ };
+
+ GetView("describe5").RegisterSelectListener((v, i, s) =>
+ {
+ Hide(v);
+ Show("describe4_1");
+ });
+
+ GetView("describe5").OnBackEvent = v =>
+ {
+ Hide(v);
+ onComplete();
+ };
+ }
+
+ public override void OnCreate()
+ {
+ Show("welcome");
+ }
+
+ public override void OnDestroy()
+ {
+
+ }
+
+ // Graphics update trigger
+ public override bool Update(ConsoleController.KeyEvent keypress, bool hasKeypress = true)
+ {
+
+ // Return: whether or not to redraw graphics
+ return base.Update(keypress, hasKeypress);
+ }
+ }
+}
diff --git a/Client/Program.cs b/Client/Program.cs
index e04d12b..56d352a 100644
--- a/Client/Program.cs
+++ b/Client/Program.cs
@@ -32,8 +32,10 @@ namespace ConsoleForms
// Start with the networking context
ContextManager manager = new ContextManager();
+ NetContext networking = new NetContext(manager);
- manager.LoadContext(new NetContext(manager));
+ if (CheckIsNewUser()) manager.LoadContext(new IntroContext(manager, () => manager.LoadContext(networking)));
+ else manager.LoadContext(networking);
// Start input listener loop. Graphics happen here too (triggered by keystrokes)
ConsoleController.KeyEvent info = new ConsoleController.KeyEvent(default(ConsoleKeyInfo))
@@ -58,6 +60,14 @@ namespace ConsoleForms
} while ((!info.ValidEvent || info.Event.Key != ConsoleKey.Escape) && !controller.ShouldExit);
}
+ private static bool CheckIsNewUser()
+ {
+ if (File.Exists(".cfvfy")) return false;
+ File.Create(".cfvfy").Close();
+ File.SetAttributes(".cfvfy", FileAttributes.Hidden);
+ return true;
+ }
+
// Detects if a key has been hit without blocking
[DllImport("msvcrt")]
public static extern int _kbhit();
diff --git a/Client/Properties/Resources.Designer.cs b/Client/Properties/Resources.Designer.cs
index 86849b3..38c7309 100644
--- a/Client/Properties/Resources.Designer.cs
+++ b/Client/Properties/Resources.Designer.cs
@@ -73,7 +73,14 @@ namespace Client.Properties {
/// </Options>
/// <Text>@string/ERR_empty</Text>
/// </DialogView>
- ///</Resources>.
+ ///
+ /// <DialogView id="ConnectionError"
+ /// padding_left="2"
+ /// padding_right="2"
+ /// padding_top="1"
+ /// padding_bottom="1"
+ /// border="4">
+ /// <Opt [rest of string was truncated]";.
///
internal static string Common {
get {
@@ -101,6 +108,33 @@ namespace Client.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to <?xml version="1.0" encoding="utf-8" ?>
+ ///<Elements xmlns="Client.ConsoleForms.Graphics">
+ ///
+ /// <!-- First dialog that welcomes new user -->
+ /// <DialogView id="welcome"
+ /// padding_left="2"
+ /// padding_right="2"
+ /// padding_top="1"
+ /// padding_bottom="1">
+ /// <Options>
+ /// <Option>@string/WS_accept</Option>
+ /// <Option>@string/WS_dismiss</Option>
+ /// </Options>
+ /// <Text>@string/WS_welcome</Text>
+ /// </DialogView>
+ ///
+ /// <!-- First intro dialog -->
+ /// <DialogView id="describe1"
+ /// padding_left="2" [rest of string was truncated]";.
+ ///
+ internal static string Intro {
+ get {
+ return ResourceManager.GetString("Intro", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized resource of type System.Byte[].
///
@@ -163,8 +197,8 @@ namespace Client.Properties {
/// padding_bottom="1">
/// <Text>@string/SE_bal</Text>
/// </TextView>
- ///
- /// <ListView id="me [rest of string was truncated]";.
+ ///
+ /// <TextView id="acco [rest of string was truncated]";.
///
internal static string Session {
get {
@@ -198,14 +232,15 @@ namespace Client.Properties {
///
/// Looks up a localized string similar to <?xml version="1.0" encoding="utf-8" ?>
///<Strings label="English">
- /// <Entry name="NC_head">Server configuration</Entry>
- /// <Entry name="NC_sec">The selected server's identity could not be verified. This implies that it is not an official server. Continue?</Entry>
- /// <Entry name="NC_stall">Connecting to server...</Entry>
- /// <Entry name="NC_next">Continue</Entry>
- /// <Entry name="NC_cancel">Cancel</Entry>
- /// <Entry name="NC_ip">Server IP:</Entry>
- /// <Entry name="NC_port">Port:</Entry>
- /// <Entry name="NC_iperr">The s [rest of string was truncated]";.
+ /// <Entry name="WS_welcome">Hello and welcome to the ConsoleForms bank project!
+ ///If you are unfamiliar with ConsoleForms and would like to
+ ///familiarize yourself with it, we are offering a beginner's
+ ///guide to the format! Note: This dialog will never be show again.
+ ///Would you like to be shown the features of ConsoleForms
+ ///before proceeding?</Entry>
+ /// <Entry name="WS_dismiss">No thank you</Entry>
+ /// <Entry name="WS_accept">Teach me</Entry>
+ /// <E [rest of string was truncated]";.
///
internal static string strings_lang_en_GB {
get {
@@ -216,14 +251,15 @@ namespace Client.Properties {
///
/// Looks up a localized string similar to <?xml version="1.0" encoding="utf-8" ?>
///<Strings label="English">
- /// <Entry name="NC_head">Server configuration</Entry>
- /// <Entry name="NC_sec">The selected server's identity could not be verified. This implies that it is not an official server. Continue?</Entry>
- /// <Entry name="NC_stall">Connecting to server...</Entry>
- /// <Entry name="NC_next">Continue</Entry>
- /// <Entry name="NC_cancel">Cancel</Entry>
- /// <Entry name="NC_ip">Server IP:</Entry>
- /// <Entry name="NC_port">Port:</Entry>
- /// <Entry name="NC_iperr">The s [rest of string was truncated]";.
+ /// <Entry name="WS_welcome">Hello and welcome to the ConsoleForms bank project!
+ ///If you are unfamiliar with ConsoleForms and would like to
+ ///familiarize yourself with it, we are offering a beginner's
+ ///guide to the format! Note: This dialog will never be show again.
+ ///Would you like to be shown the features of ConsoleForms
+ ///before proceeding?</Entry>
+ /// <Entry name="WS_dismiss">No thank you</Entry>
+ /// <Entry name="WS_accept">Teach me</Entry>
+ /// <E [rest of string was truncated]";.
///
internal static string strings_lang_en_US {
get {
@@ -234,14 +270,15 @@ namespace Client.Properties {
///
/// Looks up a localized string similar to <?xml version="1.0" encoding="utf-8" ?>
///<Strings label="Svenska">
- /// <Entry name="NC_head">Serverkonfiguration</Entry>
- /// <Entry name="NC_sec">Den valda serverns identitet kunde inte verifieras. Detta innebär att det inte är en officiell server. Fortsätt?</Entry>
- /// <Entry name="NC_stall">Kopplar upp mot servern...</Entry>
- /// <Entry name="NC_next">Fortsätt</Entry>
- /// <Entry name="NC_cancel">Avbryt</Entry>
- /// <Entry name="NC_ip">Server IP:</Entry>
- /// <Entry name="NC_port">Port:</Entry>
- /// <Entry name="NC_iperr">De [rest of string was truncated]";.
+ /// <Entry name="WS_welcome">Hej och välkommen till ConsoleForms bankprojektet!
+ ///Om du är ovan vid ConsoleForms-gränssnittet och vill
+ ///vänja dig vid dess funktioner, så finns det en guide
+ ///till gränssnittet!
+ ///Notera att denna dialog aldrig kommer att visas igen.
+ ///Vill du gå igenom en introduktion till gränssnittet?</Entry>
+ /// <Entry name="WS_dismiss">Nej tack</Entry>
+ /// <Entry name="WS_accept">Ja tack</Entry>
+ /// <Entry name="WS_continue">Nästa</ [rest of string was truncated]";.
///
internal static string strings_lang_sv_SE {
get {
diff --git a/Client/Properties/Resources.resx b/Client/Properties/Resources.resx
index bf7ea78..37cb80d 100644
--- a/Client/Properties/Resources.resx
+++ b/Client/Properties/Resources.resx
@@ -154,4 +154,7 @@
..\Resources\0x100.n;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ ..\Resources\Layout\Intro.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8
+
\ No newline at end of file
diff --git a/Client/Resources/Layout/Intro.xml b/Client/Resources/Layout/Intro.xml
new file mode 100644
index 0000000..91da77f
--- /dev/null
+++ b/Client/Resources/Layout/Intro.xml
@@ -0,0 +1,100 @@
+
+
+
+
+
+
+
+
+
+ @string/WS_welcome
+
+
+
+
+
+
+
+ @string/WS_describe1
+
+
+
+
+
+
+
+
+ @string/WS_describe2
+
+
+
+
+
+ @string/WS_input
+ @string/WS_input
+ @string/WS_input
+
+ @string/WS_describe3
+
+
+
+
+
+ @string/WS_input
+ @string/WS_input_integer
+ @string/WS_input_decimal
+ @string/WS_input_alphabet
+
+ @string/WS_describe4
+
+
+
+
+ @string/WS_input_alphanum
+ @string/WS_input_password
+ @string/WS_input_limited
+
+ @string/WS_describe4_1
+
+
+
+
+
+
+
+ @string/WS_describe5
+
+
\ No newline at end of file
diff --git a/Client/Resources/Strings/en_GB/strings.xml b/Client/Resources/Strings/en_GB/strings.xml
index 1a31a4c..106a019 100644
--- a/Client/Resources/Strings/en_GB/strings.xml
+++ b/Client/Resources/Strings/en_GB/strings.xml
@@ -1,5 +1,49 @@
+ Hello and welcome to the ConsoleForms bank project!
+If you are unfamiliar with ConsoleForms and would like to
+familiarize yourself with it, we are offering a beginner's
+guide to the format! Note: This dialog will never appear again.
+Would you like to be shown the features of ConsoleForms
+before proceeding?
+ No thank you
+ Teach me
+ Next
+ Back
+ ConsoleForms is a graphical interface API heavily inspired
+by the graphics of Windows 1.0, and the functionality
+of the Android UI experience.
+ As ConsoleForms is entirely based on the console, it relies
+completely on keyboard-based events.
+For example, press the [LEFT] and [RIGHT] arrow keys to select the
+options listed below.
+ ConsoleForms also supports input fields like the one below.
+To enter information into an input field, simply type.
+To switch which input field you are writing in, use
+the [UP] and [DOWN] arrow keys to navigate in the
+corresponding direction. To navigate within a field,
+use the [LEFT] and/or [RIGHT] arrow keys.
+Note: to quickly navigate to the inut field below the
+currently selected one, use [TAB]. To submit the input,
+press [ENTER].
+ Excellent! Now, some input fields require a certain
+input format, for example: integer, decimal, e.t.c.
+This means that if you enter characters that don't
+conform to the set format, the characters will be
+discarded.
+ Input field:
+ Integer input:
+ Decimal input:
+ Letters input:
+ More input types are demonstrated below...
+ Alphanumeric input:
+ Password input:
+ Limited-length input:
+ To exit (or go back) in most situations,
+simply press the [ESC] key. With that,
+the guide is complete. Press [ESC] to exit
+the tutorial and start using the program!
+
Server configurationThe selected server's identity could not be verified. This implies that it is not an official server. Continue?Connecting to server...
@@ -53,7 +97,7 @@ Is this correct?
Update passwordLog outOpen an account
- Close an account
+ Close accountShow accountsSupplied balance is higher than available amount in source account!
Available balance: $0 SEK
diff --git a/Client/Resources/Strings/en_US/strings.xml b/Client/Resources/Strings/en_US/strings.xml
index c667fbb..9acc3f8 100644
--- a/Client/Resources/Strings/en_US/strings.xml
+++ b/Client/Resources/Strings/en_US/strings.xml
@@ -1,5 +1,49 @@
+ Hello and welcome to the ConsoleForms bank project!
+If you are unfamiliar with ConsoleForms and would like to
+familiarize yourself with it, we are offering a beginner's
+guide to the format! Note: This dialog will never appear again.
+Would you like to be shown the features of ConsoleForms
+before proceeding?
+ No thank you
+ Teach me
+ Next
+ Back
+ ConsoleForms is a graphical interface API heavily inspired
+by the graphics of Windows 1.0, and the functionality
+of the Android UI experience.
+ As ConsoleForms is entirely based on the console, it relies
+completely on keyboard-based events.
+For example, press the [LEFT] and [RIGHT] arrow keys to select the
+options listed below.
+ ConsoleForms also supports input fields like the one below.
+To enter information into an input field, simply type.
+To switch which input field you are writing in, use
+the [UP] and [DOWN] arrow keys to navigate in the
+corresponding direction. To navigate within a field,
+use the [LEFT] and/or [RIGHT] arrow keys.
+Note: to quickly navigate to the inut field below the
+currently selected one, use [TAB]. To submit the input,
+press [ENTER].
+ Excellent! Now, some input fields require a certain
+input format, for example: integer, decimal, e.t.c.
+This means that if you enter characters that don't
+conform to the set format, the characters will be
+discarded.
+ Input field:
+ Integer input:
+ Decimal input:
+ Letters input:
+ More input types are demonstrated below...
+ Alphanumeric input:
+ Password input:
+ Limited-length input:
+ To exit (or go back) in most situations,
+simply press the [ESC] key. With that,
+the guide is complete. Press [ESC] to exit
+the tutorial and start using the program!
+
Server configurationThe selected server's identity could not be verified. This implies that it is not an official server. Continue?Connecting to server...
@@ -53,7 +97,7 @@ Is this correct?
Update passwordLog outOpen an account
- Close an account
+ Close accountShow accountsSupplied balance is higher than available amount in source account!
Available balance: $0 SEK
diff --git a/Client/Resources/Strings/sv_SE/strings.xml b/Client/Resources/Strings/sv_SE/strings.xml
index d51fd1f..399efa5 100644
--- a/Client/Resources/Strings/sv_SE/strings.xml
+++ b/Client/Resources/Strings/sv_SE/strings.xml
@@ -1,5 +1,54 @@
+ Hej och välkommen till ConsoleForms bankprojektet!
+Om du är ovan vid ConsoleForms-gränssnittet och vill
+vänja dig vid dess funktioner, så finns det en guide
+till gränssnittet!
+Notera att denna dialog aldrig kommer att visas igen.
+Vill du gå igenom en introduktion till gränssnittet?
+ Nej tack
+ Ja tack
+ Nästa
+ Backa
+ ConsoleForms är ett grafiskt gränssnitt som tar
+inspiration ifrån Windows 1.0's gränssnitt
+och från Android's kodningssätt samt
+eventsystem.
+ Eftersom ConsoleForms är helt och hållet konsollbaserat,
+beror den på tangentborsbaserade events.
+T.ex. kan du trycka på [VÄNSTER] och [HÖGER]
+tangenterna för att göra ett val här nedan.
+ ConsoleForms stöder dessutom input-fält som den här nedan.
+För att mata in information så är det bara att skriva.
+För att byta filket vält som du skriver i, använd
+[UPP] och [NED] tangenterna för att navigera i den
+korresponderande riktningen. För att navigera inom
+ett fält använder du bara [HÖGER] och [VÄNSTER]
+piltangent som i dialogrutan.
+Notera att man dessutom kan navigera till nästa
+inputfält genom att trycka på [TABB].
+För att lämna in informationen i inputfälten
+trycker du [ENTER]. Detta gör du dessutom för att
+fortsätta.
+ Underbart! I vissa fall kan det ske att inputfälten
+kräver ett visst format på den text som anges t.ex:
+Heltal, decimaltal, et.c. Detta innebär att om en
+karaktär anges som inte matchar det bestämda
+formatet, kommer den angivna karaktären att
+ignoreras.
+ Inputfält:
+ Heltals-input:
+ Decimaltals-input:
+ Bokstavs-input:
+ Fler inmatningsformat...
+ Alfanumerisk input:
+ Lösenords-input:
+ Längdbegränsad input:
+ För att avbryta (eller back) så används [ESC]-
+tangenten, och med det var guiden slut.
+För att lämna guiden och börja använda
+programmet, tryck [ESC].
+
ServerkonfigurationDen valda serverns identitet kunde inte verifieras. Detta innebär att det inte är en officiell server. Fortsätt?Kopplar upp mot servern...
@@ -53,7 +102,7 @@ Till kontot: $2
Uppdatera lösenordLogga utÖppna ett konto
- Stäng ett konto
+ Stäng kontoVisa kontonAngivet belopp är högre än det tillgängliga beloppet i ursprungskontot!
Tillgängligt saldo: $0 SEK