Skip to content

Commit

Permalink
📖 update element options tutorial | rename SingleRounded to SingleRound
Browse files Browse the repository at this point in the history
  • Loading branch information
MorganKryze committed Mar 23, 2024
1 parent 0cb694b commit be8aac0
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 25 deletions.
Binary file added docs/assets/img/jpg/elements_options/ascii.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img/jpg/elements_options/bold.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/img/jpg/elements_options/bottomcenter.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img/jpg/elements_options/double.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/img/jpg/elements_options/round.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/img/jpg/elements_options/topcenter.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/img/jpg/elements_options/topleft.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/img/jpg/elements_options/topright.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 44 additions & 5 deletions docs/introduction/elements_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ In this section, you will learn:
- How to deactivate/ remove elements
- How to use the `ElementsDashboard` inspector element
- How to use the `HeightSpacer` element
- Discover `Placement` and `TextAlignment` enumerations
- Discover `Placement`, `TextAlignment` and `BordersType` enumerations
- How to use the full potential of the element options

## Setup
Expand Down Expand Up @@ -146,7 +146,7 @@ Window.Close();

In all the tutorials and the [example project](https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/) the elements definitions are simplified and do not declare all the arguments available. To see all the arguments available for each element, you can consult the [references documentation](https://morgankryze.github.io/ConsoleAppVisuals/references/index.html).

Most of them are specific with generic type (`string`, `int`, `bool`...) and are used to customize the element. But some of them are common to all elements and are used to place the element on the window. These are the `Placement` and `TextAlignment` enumerations.
Most of them are specific with generic type (`string`, `int`, `bool`, `List`, ...) and are used to customize the element. But some of them are common to all elements and are used to place the element on the window. These are the `Placement` and `TextAlignment` enumerations.

### `Placement`

Expand All @@ -158,7 +158,7 @@ The available values are:

![TopLeft](../assets/img/jpg/elements_options/topleft.jpg)

- `TopCenter`: x(line) = 0, y(char) = windowWidth / 2
- `TopCenter`: (Default) x(line) = 0, y(char) = windowWidth / 2

![TopCenter](../assets/img/jpg/elements_options/topcenter.jpg)

Expand All @@ -178,7 +178,7 @@ The available values are:
> To choose the placement of an element, you can either set it from the constructor or use the `UpdatePlacement()` method after creating the element.
>
> ```csharp
> Prompt prompt = new Prompt("Enter your name", "Name", Placement.TopCenter);
> Prompt prompt = new Prompt("Enter your name:", "John", Placement.TopCenter);
> // or
> prompt.UpdatePlacement(Placement.TopCenter);
> ```
Expand All @@ -191,7 +191,7 @@ The `TextAlignment` enumeration is used to align the text in a string. It is use
![Left](../assets/img/jpg/elements_options/left.jpg)
- `Center`: Align the text to the center
- `Center`: (Default) Align the text to the center
![Center](../assets/img/jpg/elements_options/center.jpg)
Expand All @@ -208,6 +208,45 @@ The `TextAlignment` enumeration is used to align the text in a string. It is use
> embedText.UpdateTextAlignment(TextAlignment.Center);
> ```
### `BordersType`
The `BordersType` enumeration is used to set the borders of an element. It is used by the table and embed elements from the library. Here are the available values:
- `SingleStraight`: (Default) Single lines with straight corners
![SingleStraight](../assets/img/jpg/elements_options/straight.jpg)
- `SingleRound`: Single lines with round corners
![SingleRound](../assets/img/jpg/elements_options/round.jpg)
- `SingleBold`: Single bold lines with straight corners
![SingleBold](../assets/img/jpg/elements_options/bold.jpg)
- `DoubleStraight`: Double lines with straight corners
![DoubleStraight](../assets/img/jpg/elements_options/double.jpg)
- `ASCII`: ASCII basic characters for the borders (`+`, `-`, `|` only)
![ASCII](../assets/img/jpg/elements_options/ascii.jpg)
> [!WARNING]
> The following types are not available for Visual Studio or Windows Command Prompt:
>
> - `SingleRound`
> - `SingleBold`
> [!NOTE]
> To choose the border type of an element, you can either set it from the constructor or use the `UpdateBordersType()` method after creating the element (some elements may not have this method if the border type is not used in it so refer to the references documentation to get that specific information).
>
> ```csharp
> ElementsDashboard dashboard = new ElementsDashboard(Placement.TopCenter, BordersType.SingleStraight);
> // or
> dashboard.UpdateBordersType(BordersType.SingleStraight);
> ```
## Conclusion
In this section, you learned how to deactivate and remove elements from the window. You also discovered the `Placement` and `TextAlignment` enumerations and how to use the full potential of the element options by knowing all the arguments available. You may now be able to use more complex elements and place them at your desired location.
Expand Down
2 changes: 1 addition & 1 deletion src/ConsoleAppVisuals/enums/BordersType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public enum BordersType
/// <remarks>
/// Not supported on PowerShell (Windows).
/// </remarks>
SingleRounded,
SingleRound,

/// <summary>
/// Single line borders with bold lines (┏┓┗┛━┃┳┻┣┫╋)
Expand Down
4 changes: 2 additions & 2 deletions src/ConsoleAppVisuals/models/Borders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private static BordersType CheckType(BordersType type)
if (
type
is BordersType.SingleStraight
or BordersType.SingleRounded
or BordersType.SingleRound
or BordersType.SingleBold
or BordersType.DoubleStraight
or BordersType.ASCII
Expand Down Expand Up @@ -150,7 +150,7 @@ public char GetBorderChar(int index)
string border = _type switch
{
BordersType.SingleStraight => SINGLE_STRAIGHT,
BordersType.SingleRounded => SINGLE_ROUNDED,
BordersType.SingleRound => SINGLE_ROUNDED,
BordersType.SingleBold => SINGLE_BOLD,
BordersType.DoubleStraight => DOUBLE_STRAIGHT,
BordersType.ASCII => ASCII,
Expand Down
4 changes: 2 additions & 2 deletions testing/elements/interactive/Prompt.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ public void UpdateBorderType()
var prompt = new Prompt("What is your name?", "John Doe");

// Act
prompt.UpdateBordersType(BordersType.SingleRounded);
prompt.UpdateBordersType(BordersType.SingleRound);
var actual = prompt.BordersType;
var expected = BordersType.SingleRounded;
var expected = BordersType.SingleRound;

// Assert
Assert.AreEqual(expected, actual);
Expand Down
4 changes: 2 additions & 2 deletions testing/elements/passive/TableView.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,10 @@ public void UpdateBorderType_UpdatesBorderTypeCorrectly()
);

// Act
table.UpdateBordersType(BordersType.SingleRounded);
table.UpdateBordersType(BordersType.SingleRound);

// Assert
Assert.AreEqual(BordersType.SingleRounded, table.BordersType);
Assert.AreEqual(BordersType.SingleRound, table.BordersType);
}

[TestMethod]
Expand Down
26 changes: 13 additions & 13 deletions testing/models/Borders.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void Borders_Constructor_InvalidType()
[TestMethod]
[TestCategory("Borders")]
[DataRow(BordersType.SingleStraight, '┌')]
[DataRow(BordersType.SingleRounded, '╭')]
[DataRow(BordersType.SingleRound, '╭')]
[DataRow(BordersType.SingleBold, '┏')]
[DataRow(BordersType.DoubleStraight, '╔')]
[DataRow(BordersType.ASCII, '+')]
Expand All @@ -70,7 +70,7 @@ public void Borders_TopLeft(BordersType type, char expected)
[TestMethod]
[TestCategory("Borders")]
[DataRow(BordersType.SingleStraight, '┐')]
[DataRow(BordersType.SingleRounded, '╮')]
[DataRow(BordersType.SingleRound, '╮')]
[DataRow(BordersType.SingleBold, '┓')]
[DataRow(BordersType.DoubleStraight, '╗')]
[DataRow(BordersType.ASCII, '+')]
Expand All @@ -89,7 +89,7 @@ public void Borders_TopRight(BordersType type, char expected)
[TestMethod]
[TestCategory("Borders")]
[DataRow(BordersType.SingleStraight, '└')]
[DataRow(BordersType.SingleRounded, '╰')]
[DataRow(BordersType.SingleRound, '╰')]
[DataRow(BordersType.SingleBold, '┗')]
[DataRow(BordersType.DoubleStraight, '╚')]
[DataRow(BordersType.ASCII, '+')]
Expand All @@ -108,7 +108,7 @@ public void Borders_BottomLeft(BordersType type, char expected)
[TestMethod]
[TestCategory("Borders")]
[DataRow(BordersType.SingleStraight, '┘')]
[DataRow(BordersType.SingleRounded, '╯')]
[DataRow(BordersType.SingleRound, '╯')]
[DataRow(BordersType.SingleBold, '┛')]
[DataRow(BordersType.DoubleStraight, '╝')]
[DataRow(BordersType.ASCII, '+')]
Expand All @@ -127,7 +127,7 @@ public void Borders_BottomRight(BordersType type, char expected)
[TestMethod]
[TestCategory("Borders")]
[DataRow(BordersType.SingleStraight, '─')]
[DataRow(BordersType.SingleRounded, '─')]
[DataRow(BordersType.SingleRound, '─')]
[DataRow(BordersType.SingleBold, '━')]
[DataRow(BordersType.DoubleStraight, '═')]
[DataRow(BordersType.ASCII, '-')]
Expand All @@ -146,7 +146,7 @@ public void Borders_Horizontal(BordersType type, char expected)
[TestMethod]
[TestCategory("Borders")]
[DataRow(BordersType.SingleStraight, '│')]
[DataRow(BordersType.SingleRounded, '│')]
[DataRow(BordersType.SingleRound, '│')]
[DataRow(BordersType.SingleBold, '┃')]
[DataRow(BordersType.DoubleStraight, '║')]
[DataRow(BordersType.ASCII, '|')]
Expand All @@ -165,7 +165,7 @@ public void Borders_Vertical(BordersType type, char expected)
[TestMethod]
[TestCategory("Borders")]
[DataRow(BordersType.SingleStraight, '┬')]
[DataRow(BordersType.SingleRounded, '┬')]
[DataRow(BordersType.SingleRound, '┬')]
[DataRow(BordersType.SingleBold, '┳')]
[DataRow(BordersType.DoubleStraight, '╦')]
[DataRow(BordersType.ASCII, '+')]
Expand All @@ -184,7 +184,7 @@ public void Borders_Top(BordersType type, char expected)
[TestMethod]
[TestCategory("Borders")]
[DataRow(BordersType.SingleStraight, '┴')]
[DataRow(BordersType.SingleRounded, '┴')]
[DataRow(BordersType.SingleRound, '┴')]
[DataRow(BordersType.SingleBold, '┻')]
public void Borders_Bottom(BordersType type, char expected)
{
Expand All @@ -201,7 +201,7 @@ public void Borders_Bottom(BordersType type, char expected)
[TestMethod]
[TestCategory("Borders")]
[DataRow(BordersType.SingleStraight, '├')]
[DataRow(BordersType.SingleRounded, '├')]
[DataRow(BordersType.SingleRound, '├')]
public void Borders_Left(BordersType type, char expected)
{
// Arrange
Expand All @@ -217,7 +217,7 @@ public void Borders_Left(BordersType type, char expected)
[TestMethod]
[TestCategory("Borders")]
[DataRow(BordersType.SingleStraight, '┤')]
[DataRow(BordersType.SingleRounded, '┤')]
[DataRow(BordersType.SingleRound, '┤')]
public void Borders_Right(BordersType type, char expected)
{
// Arrange
Expand All @@ -233,7 +233,7 @@ public void Borders_Right(BordersType type, char expected)
[TestMethod]
[TestCategory("Borders")]
[DataRow(BordersType.SingleStraight, '┼')]
[DataRow(BordersType.SingleRounded, '┼')]
[DataRow(BordersType.SingleRound, '┼')]
public void Borders_Cross(BordersType type, char expected)
{
// Arrange
Expand Down Expand Up @@ -272,11 +272,11 @@ public void Borders_UpdateBorderType_SingleRounded()
Borders borders = new Borders();

// Act
borders.UpdateBordersType(BordersType.SingleRounded);
borders.UpdateBordersType(BordersType.SingleRound);
BordersType actual = borders.Type;

// Assert
Assert.AreEqual(BordersType.SingleRounded, actual);
Assert.AreEqual(BordersType.SingleRound, actual);
}
#endregion
}

0 comments on commit be8aac0

Please sign in to comment.