Skip to content

Commit

Permalink
Fisrt-Code to TableControl
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando Cerqueira committed Sep 20, 2023
1 parent fb0f70c commit 82856e5
Show file tree
Hide file tree
Showing 35 changed files with 2,107 additions and 255 deletions.
10 changes: 9 additions & 1 deletion PromptPlus.sln
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{191C90E6-4
docs\migrateversion.md = docs\migrateversion.md
docs\snapshot.md = docs\snapshot.md
docs\validators.md = docs\validators.md
whatsnewprev.md = whatsnewprev.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SliderSwitchSamples", "Samples\SliderSwitchSamples\SliderSwitchSamples.csproj", "{3702034B-7D26-4BC3-AB1E-864C2EE2D785}"
Expand All @@ -118,6 +117,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Template", "Template", "{04
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PromptPlusTemplate", "Template\PromptPlusTemplate\PromptPlusTemplate.csproj", "{E713CD59-5AB5-40AA-80B3-436D0C6511DA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TableBasicSamples", "Samples\TableBasicSamples\TableBasicSamples.csproj", "{C5189623-17BD-472E-8A11-832115ABD152}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -377,6 +378,12 @@ Global
{E713CD59-5AB5-40AA-80B3-436D0C6511DA}.local|Any CPU.Build.0 = Debug|Any CPU
{E713CD59-5AB5-40AA-80B3-436D0C6511DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E713CD59-5AB5-40AA-80B3-436D0C6511DA}.Release|Any CPU.Build.0 = Release|Any CPU
{C5189623-17BD-472E-8A11-832115ABD152}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C5189623-17BD-472E-8A11-832115ABD152}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C5189623-17BD-472E-8A11-832115ABD152}.local|Any CPU.ActiveCfg = Debug|Any CPU
{C5189623-17BD-472E-8A11-832115ABD152}.local|Any CPU.Build.0 = Debug|Any CPU
{C5189623-17BD-472E-8A11-832115ABD152}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C5189623-17BD-472E-8A11-832115ABD152}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -422,6 +429,7 @@ Global
{184F90B1-EBF2-4D34-88B3-9D7A252CB2B4} = {F85DFC6B-0BBA-4B8D-BBF7-8FE175FE165C}
{83BB7962-34D7-4F51-8856-94BDC7B68A64} = {F85DFC6B-0BBA-4B8D-BBF7-8FE175FE165C}
{E713CD59-5AB5-40AA-80B3-436D0C6511DA} = {0468C89D-43EE-4B08-96BB-FDDA42033AA5}
{C5189623-17BD-472E-8A11-832115ABD152} = {F85DFC6B-0BBA-4B8D-BBF7-8FE175FE165C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2E883401-DEB0-496F-A6BC-8AA0F44BC5B9}
Expand Down
8 changes: 4 additions & 4 deletions Samples/CalendarSamples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

cld = PromptPlus
.Calendar("Date", "Select date")
.Layout(LayoutCalendar.DoubleGrid)
.Layout(CalendarLayout.DoubleGrid)
.Culture("pt-BR")
.Run();
if (!cld.IsAborted)
Expand All @@ -44,15 +44,15 @@

PromptPlus
.Calendar("Date", "Select date")
.Layout(LayoutCalendar.HeavyGrid)
.Layout(CalendarLayout.HeavyGrid)
.DisabledWeekends()
.Run();

PromptPlus.DoubleDash($"Control:Calendar DateTime - with Disabled dates");

PromptPlus
.Calendar("Date", "Select date")
.Layout(LayoutCalendar.AsciiSingleGrid)
.Layout(CalendarLayout.AsciiSingleGrid)
.AddItems(CalendarScope.Disabled,
new ItemCalendar(DateTime.Now.AddDays(1)),
new ItemCalendar(DateTime.Now.AddDays(2)))
Expand All @@ -62,7 +62,7 @@

PromptPlus
.Calendar("Date", "Select date")
.Layout(LayoutCalendar.AsciiDoubleGrid)
.Layout(CalendarLayout.AsciiDoubleGrid)
.AddItems(CalendarScope.Note,
new ItemCalendar(DateTime.Now.AddDays(1), "Note1"),
new ItemCalendar(DateTime.Now.AddDays(1), "Note2"),
Expand Down
60 changes: 60 additions & 0 deletions Samples/TableBasicSamples/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System.Globalization;
using System.IO.Pipes;
using PPlus;
using static System.Net.Mime.MediaTypeNames;

namespace TableBasicSamples
{
internal class Program
{
internal class MyTable
{
public int Id { get; set; }
public required string MyText { get; set; }
public required DateTime MyDate { get; set; }
}



static void Main(string[] args)
{
static MyTable[] CreateItem()
{
return new MyTable[]
{
new MyTable { Id = 1, MyDate = new DateTime().AddDays(1), MyText = "Test1" },
new MyTable { Id = 2, MyDate = new DateTime().AddDays(2), MyText = "Test2 very very very very very very very very long" },
new MyTable { Id = 3, MyDate = new DateTime().AddDays(3), MyText = "Test3" }
};
}

//Ensure ValueResult Culture for all controls
PromptPlus.Config.DefaultCulture = new CultureInfo("en-us");

PromptPlus.Table<MyTable>()
.AddItems(CreateItem())
.AddColumn((item) => item.Id, 10, null)
.AddColumn((item) => item.MyDate, 15, null)
.AddColumn((item) => item.MyText, 20, null,format:(arg) => $"Text: {arg}")
.AddFormatType<DateTime>(FmtDate)
.AddFormatType<int>(FmtInt)
.EnabledInteractionUser(
(item, col) => $"Current ID : {item.Id}. [yellow]Current col {col}[/]",
(item, col) => $"[green]Selected ID : {item.Id}. Current col {col}[/]")
.Run();

}

private static string FmtInt(object arg)
{
var value = (int)arg;
return value.ToString();
}

private static string FmtDate(object arg)
{
var value = (DateTime)arg;
return value.ToString("G");
}
}
}
14 changes: 14 additions & 0 deletions Samples/TableBasicSamples/TableBasicSamples.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\Src\PromptPlus.csproj" />
</ItemGroup>

</Project>
22 changes: 11 additions & 11 deletions Src/Controls/Calendar/CalendarControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public IControlCalendar ChangeDescription(Func<DateTime, string> value)
return this;
}

public IControlCalendar Layout(LayoutCalendar value)
public IControlCalendar Layout(CalendarLayout value)
{
_options.Layout = value;
return this;
Expand Down Expand Up @@ -1034,13 +1034,13 @@ private void WriteCalendar(ScreenBuffer screenBuffer, DateTime currentdate)
{
switch (_options.Layout)
{
case LayoutCalendar.SingleGrid:
case LayoutCalendar.AsciiSingleGrid:
case CalendarLayout.SingleGrid:
case CalendarLayout.AsciiSingleGrid:
WriteCalendarAsciiSingleGrid(screenBuffer, currentdate);
break;
case LayoutCalendar.HeavyGrid:
case LayoutCalendar.DoubleGrid:
case LayoutCalendar.AsciiDoubleGrid:
case CalendarLayout.HeavyGrid:
case CalendarLayout.DoubleGrid:
case CalendarLayout.AsciiDoubleGrid:
WriteCalendarAsciiDoubleGrid(screenBuffer, currentdate);
break;
default:
Expand All @@ -1050,19 +1050,19 @@ private void WriteCalendar(ScreenBuffer screenBuffer, DateTime currentdate)
}
switch (_options.Layout)
{
case LayoutCalendar.HeavyGrid:
case CalendarLayout.HeavyGrid:
WriteCalendarHeavyGrid(screenBuffer, currentdate);
break;
case LayoutCalendar.SingleGrid:
case CalendarLayout.SingleGrid:
WriteCalendarSingleGrid(screenBuffer, currentdate);
break;
case LayoutCalendar.DoubleGrid:
case CalendarLayout.DoubleGrid:
WriteCalendarDoubleGrid(screenBuffer, currentdate);
break;
case LayoutCalendar.AsciiSingleGrid:
case CalendarLayout.AsciiSingleGrid:
WriteCalendarAsciiSingleGrid(screenBuffer, currentdate);
break;
case LayoutCalendar.AsciiDoubleGrid:
case CalendarLayout.AsciiDoubleGrid:
WriteCalendarAsciiDoubleGrid(screenBuffer, currentdate);
break;
default:
Expand Down
34 changes: 34 additions & 0 deletions Src/Controls/Calendar/CalendarLayout.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// ***************************************************************************************
// MIT LICENCE
// The maintenance and evolution is maintained by the PromptPlus project under MIT license
// ***************************************************************************************

namespace PPlus.Controls
{
/// <summary>
/// Represents the Calendar Layout
/// </summary>
public enum CalendarLayout
{
/// <summary>
/// single line grid
/// </summary>
SingleGrid,
/// <summary>
/// Double line grid
/// </summary>
DoubleGrid,
/// <summary>
/// Acsii single grid
/// </summary>
AsciiSingleGrid,
/// <summary>
/// Acsii double grid
/// </summary>
AsciiDoubleGrid,
/// <summary>
/// Heavy line grid
/// </summary>
HeavyGrid
}
}
2 changes: 1 addition & 1 deletion Src/Controls/Calendar/CalendarOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal CalendarOptions(StyleSchema styleSchema, ConfigControls config, IConsol
SwitchNotes = config.CalendarSwitchNotesPress;
TimeoutOverwriteDefault = config.HistoryTimeout;
}
public LayoutCalendar Layout { get; set; } = LayoutCalendar.SingleGrid;
public CalendarLayout Layout { get; set; } = CalendarLayout.SingleGrid;
public CultureInfo CurrentCulture { get; set; } = null;
public PolicyInvalidDate PolicyInvalidDate { get; set; } = PolicyInvalidDate.NextDate;
public Style DescriptionStyle { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions Src/Controls/Calendar/IControlCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ namespace PPlus.Controls
public interface IControlCalendar : IPromptControls<DateTime>
{
/// <summary>
/// The layout canlendar. Default value is 'LayoutCalendar.SingleBorde'
/// The layout canlendar. Default value is 'CalendarLayout.SingleBorde'
/// </summary>
/// <param name="value">The <see cref="LayoutCalendar"/></param>
/// <param name="value">The <see cref="CalendarLayout"/></param>
/// <returns><see cref="IControlCalendar"/></returns>
IControlCalendar Layout(LayoutCalendar value);
IControlCalendar Layout(CalendarLayout value);

/// <summary>
/// <see cref="CultureInfo"/> to on show value format.
Expand Down
Loading

0 comments on commit 82856e5

Please sign in to comment.