Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion TN3270Sharp.Example.App/Example3270App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public void CreateServer()
var fName = screens[ProgramScreen.FormScreen].GetFieldData("fname");
var lName = screens[ProgramScreen.FormScreen].GetFieldData("lname");
var password = screens[ProgramScreen.FormScreen].GetFieldData("password");
var employeeId = screens[ProgramScreen.FormScreen].GetFieldData("employeeId");

// Check for errors...
string? errorMessage = null;
Expand All @@ -82,8 +83,10 @@ public void CreateServer()
errorMessage = "Last Name field is required.";
else if (string.IsNullOrWhiteSpace(password))
errorMessage = "Password field is required.";
else if (string.IsNullOrWhiteSpace(employeeId))
errorMessage = "EmployeeId field is required.";

if(!string.IsNullOrWhiteSpace(password) && password.Trim().ToUpper() != "ADMIN")
if (!string.IsNullOrWhiteSpace(password) && password.Trim().ToUpper() != "ADMIN")
errorMessage = "Invalid password.";

if (!string.IsNullOrWhiteSpace(errorMessage))
Expand All @@ -109,6 +112,7 @@ public void CreateServer()
screens[ProgramScreen.FormScreen].ClearFieldValue("fname");
screens[ProgramScreen.FormScreen].ClearFieldValue("lname");
screens[ProgramScreen.FormScreen].ClearFieldValue("password");
screens[ProgramScreen.FormScreen].ClearFieldValue("employeeId");
screens[ProgramScreen.FormScreen].ClearFieldValue("errormsg");
},
formScreenAction);
Expand Down Expand Up @@ -160,6 +164,9 @@ private Dictionary<ProgramScreen, Screen> DefineScreens()
FormScreen.AddText(7,1,"Password . . . .");
FormScreen.AddInput(7,20,"password", true);
FormScreen.AddEOF(7, 41);
FormScreen.AddText(8, 1, "Employee ID . .");
FormScreen.AddInput(8, 20, "employeeId", numericonly: true);
FormScreen.AddEOF(8, 41);
FormScreen.AddText(9,1,"Press");
FormScreen.AddText(9,7,"ENTER", true);
FormScreen.AddText(9,13,"to submit your name.");
Expand Down
3 changes: 3 additions & 0 deletions TN3270Sharp/Field.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public class Field
// password input field).
public bool Hidden { get; set; }

// NumericOnly indicates if the client only accepts numeric input.
public bool NumericOnly { get; set; }

// Color is the field color. The default value is the default color.
public Colors Color { get; set; }

Expand Down
11 changes: 8 additions & 3 deletions TN3270Sharp/Screen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ public void AddText(int row, int column, string contents, bool intensity = false
/// <param name="hidden">text is hidden (i.e., password)</param>
/// <param name="write">is input field writable (true/false)</param>
/// <param name="underscore">should the input field be underscored (true/false)</param>
/// <param name="numericonly">allows only numeric input</param>
/// <returns></returns>
public void AddInput(int row, int column, string name, bool hidden = false, bool write = true, bool underscore = true)
public void AddInput(int row, int column, string name, bool hidden = false, bool write = true, bool underscore = true, bool numericonly = false)
=> Fields.Add(new Field
{
Column = column,
Expand All @@ -107,6 +108,7 @@ public void AddInput(int row, int column, string name, bool hidden = false, bool
? Highlight.Underscore
: Highlight.DefaultHighlight,
Hidden = hidden,
NumericOnly = numericonly,
});

/// <summary>
Expand All @@ -120,11 +122,12 @@ public void AddInput(int row, int column, string name, bool hidden = false, bool
/// <param name="hidden">text is hidden (i.e., password)</param>
/// <param name="write">is input field writable (true/false)</param>
/// <param name="underscore">should the input field be underscored (true/false)</param>
/// <param name="numericonly">allows only numeric input</param>
/// <returns></returns>
public void AddInput(int row, int column, int length, string name, bool hidden = false, bool write = true,
bool underscore = true)
bool underscore = true, bool numericonly = false)
{
AddInput(row, column, name, hidden, write, underscore);
AddInput(row, column, name, hidden, write, underscore, numericonly);
AddEOF(row, column + length + 1);
}

Expand Down Expand Up @@ -157,6 +160,7 @@ public byte[] BuildField(Field fld)
buffer.Add((byte)ControlChars.SF);
buffer.Add((byte)(
(fld.Write ? AttribChar.Unprotected : AttribChar.Protected) |
(fld.NumericOnly ? AttribChar.Numeric : AttribChar.Alpha) |
(fld.Intensity ? AttribChar.Intensity : AttribChar.Normal) |
(fld.Hidden ? AttribChar.Hidden : AttribChar.Normal)
));
Expand All @@ -179,6 +183,7 @@ public byte[] BuildField(Field fld)
buffer.Add(0xc0);
buffer.Add((byte)(
(fld.Write ? AttribChar.Unprotected : AttribChar.Protected) |
(fld.NumericOnly ? AttribChar.Numeric : AttribChar.Alpha) |
(fld.Intensity ? AttribChar.Intensity : AttribChar.Normal) |
(fld.Hidden ? AttribChar.Hidden : AttribChar.Normal)
));
Expand Down