Skip to content

Commit

Permalink
fixed bug #73 and improvement #72
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando Cerqueira committed Oct 5, 2023
1 parent 5b5ee26 commit e454e56
Show file tree
Hide file tree
Showing 64 changed files with 568 additions and 331 deletions.
2 changes: 1 addition & 1 deletion Samples/BrowserMultSelectSamples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static void Main(string[] args)

PromptPlus.DoubleDash("Control:BrowserMultiSelect - DisabledRecursiveExpand usage");
PromptPlus.BrowserMultiSelect("Browser", "expandall has same behavior expand when used DisabledRecursiveExpand.")
.Root(new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory).Root.FullName, true)
.Root(new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory).Root.FullName, false)
.DisabledRecursiveExpand()
.Run();

Expand Down
3 changes: 3 additions & 0 deletions Samples/ChartSamples/ChartSamples.csproj
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@



<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
Expand Down
8 changes: 0 additions & 8 deletions Samples/SliderSwitchSamples/Properties/launchSettings.json

This file was deleted.

6 changes: 6 additions & 0 deletions Samples/SliderSwitchSamples/SliderSwitchSamples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
<Configurations>Debug;Release;local</Configurations>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Properties\**" />
<EmbeddedResource Remove="Properties\**" />
<None Remove="Properties\**" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Src\PromptPlus.csproj" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Samples/TreeViewSamples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static void Main(string[] args)
var trv = PromptPlus.TreeView<MyOrg>("MyMorg")
.RootNode(MyOrg.LoadEmpresa(),
(item) => item.Name,
expandall: false,
expandall: true,
separatePath: '|',
validselect: (item) => item.TypeInfo == TypeMyOrg.Funcionario,
setdisabled: (item) => item.TypeInfo != TypeMyOrg.Funcionario,
Expand Down
6 changes: 4 additions & 2 deletions Src/Controls/AddtoList/IControlList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public interface IControlList : IPromptControls<IEnumerable<string>>
IControlList AcceptInput(Func<char, bool> value);

/// <summary>
/// MaxLength of input text.
/// MaxLength of input text.The value must be greater than or equal to 1
/// <br>Default value is 0 (no limit)</br>
/// </summary>
/// <param name="value">Length</param>
/// <returns><see cref="IControlList"/></returns>
Expand Down Expand Up @@ -93,7 +94,8 @@ public interface IControlList : IPromptControls<IEnumerable<string>>
IControlList AddItems(IEnumerable<string> values, bool immutable = false);

/// <summary>
/// Set max.item view per page.Default value for this control is 10.
/// Set max.item view per page.
/// <br>Default value : 10.The value must be greater than or equal to 1</br>
/// </summary>
/// <param name="value">Number of Max.items</param>
/// <returns><see cref="IControlList"/></returns>
Expand Down
2 changes: 1 addition & 1 deletion Src/Controls/AddtoList/IControlMaskEditList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public interface IControlMaskEditList : IPromptControls<IEnumerable<ResultMasked
/// <param name="value">text of masked when type is Generic. otherwise must be null.</param>
/// <param name="promptmask">Prompt mask overwriter. Default value is '■'/'_'</param>
/// <returns><see cref="IControlMaskEditList"/></returns>
IControlMaskEditList Mask(string value = null, char? promptmask = null);
IControlMaskEditList Mask(string value, char? promptmask = null);

/// <summary>
/// Defines type of mask control.
Expand Down
12 changes: 8 additions & 4 deletions Src/Controls/AddtoList/ListControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ public IControlList SuggestionHandler(Func<SuggestionInput, SuggestionOutput> va

public IControlList MaxLength(ushort value)
{
if (value < 1)
{
throw new PromptPlusException("MaxLength must be greater than 0");
}
_options.MaxLength = value;
return this;
}
Expand Down Expand Up @@ -165,7 +169,7 @@ public IControlList PageSize(int value)
{
if (value < 1)
{
value = 1;
throw new PromptPlusException("PageSize must be greater than or equal to 1");
}
_options.PageSize = value;
return this;
Expand All @@ -185,15 +189,15 @@ public IControlList Range(int minvalue, int? maxvalue = null)
}
if (minvalue < 0)
{
minvalue = 0;
throw new PromptPlusException($"Ranger invalid. minvalue({minvalue})");
}
if (maxvalue < 0)
{
maxvalue = minvalue;
throw new PromptPlusException($"Ranger invalid. maxvalue({maxvalue})");
}
if (minvalue > maxvalue)
{
throw new PromptPlusException($"RangerSelect invalid. Minvalue({minvalue}) > Maxvalue({maxvalue})");
throw new PromptPlusException($"Ranger invalid. minvalue({minvalue}) > maxvalue({maxvalue})");
}
_options.Minimum = minvalue;
_options.Maximum = maxvalue.Value;
Expand Down
9 changes: 5 additions & 4 deletions Src/Controls/AddtoList/MaskEditListControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,14 @@ public IControlMaskEditList Mask(MaskedType maskedType, char? promptmask = null)
return this;
}

public IControlMaskEditList Mask(string value = null, char? promptmask = null)
public IControlMaskEditList Mask(string value, char? promptmask = null)
{
_options.Type = ControlMaskedType.Generic;
if (value != null)
if (string.IsNullOrEmpty(value))
{
_options.MaskValue = value;
throw new PromptPlusException("Mask is Null Or Empty");
}
_options.MaskValue = value;
if (promptmask != null)
{
_options.Symbols(SymbolType.MaskEmpty, promptmask.Value.ToString());
Expand All @@ -285,7 +286,7 @@ public IControlMaskEditList PageSize(int value)
{
if (value < 1)
{
value = 1;
throw new PromptPlusException("PageSize must be greater than or equal to 1");
}
_options.PageSize = value;
return this;
Expand Down
8 changes: 6 additions & 2 deletions Src/Controls/Banner/BannerControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public IBannerControl LoadFont(Stream value)

public IBannerControl LoadFont(string value)
{
if (value == null)
if (string.IsNullOrEmpty(value))
{
throw new PromptPlusException("BannerControl.LoadFont is null");
throw new PromptPlusException("BannerControl.LoadFont is null or empty");
}
Font = new FigletFont(value);
return this;
Expand All @@ -55,6 +55,10 @@ public IBannerControl LoadFont(string value)

public void Run(Color? color = null, BannerDashOptions bannerDash = BannerDashOptions.None)
{
if (string.IsNullOrEmpty(Text))
{
return;
}
Color localcorlor = _console.ForegroundColor;
if (color != null)
{
Expand Down
8 changes: 6 additions & 2 deletions Src/Controls/Calendar/CalendarControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ public IControlCalendar OverwriteDefaultFrom(string value, TimeSpan? timeout)
_options.OverwriteDefaultFrom = value;
if (timeout != null)
{
if (timeout.Value.TotalMilliseconds == 0)
{
throw new PromptPlusException("timeout must be greater than 0");
}
_options.TimeoutOverwriteDefault = timeout.Value;
}
return this;
Expand Down Expand Up @@ -111,8 +115,8 @@ public IControlCalendar DisabledWeekends(bool value = true)
public IControlCalendar PageSize(int value)
{
if (value < 1)
{
value = 1;
{
throw new PromptPlusException("PageSize must be greater than or equal to 1");
}
_options.PageSize = value;
return this;
Expand Down
3 changes: 2 additions & 1 deletion Src/Controls/Calendar/IControlCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ public interface IControlCalendar : IPromptControls<DateTime>
IControlCalendar HotKeySwitchNotes(HotKey value);

/// <summary>
/// Set max.item view per page on notes.Default value for this control is 5.
/// Set max.item notes view per page.
/// <br>Default value : 5.The value must be greater than or equal to 1</br>
/// </summary>
/// <param name="value">Number of Max.items</param>
/// <returns><see cref="IControlCalendar"/></returns>
Expand Down
8 changes: 6 additions & 2 deletions Src/Controls/Chart/ChartBarControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ public IControlChartBar Culture(string value)

public IControlChartBar Width(int value)
{
if (value < 10)
{
throw new PromptPlusException("Width must be greater than or equal to 10");
}
_options.Witdth = value;
return this;
}
Expand Down Expand Up @@ -156,7 +160,7 @@ public IControlChartBar FracionalDig(int value)
{
if (value < 0)
{
value = 0;
throw new PromptPlusException("FracionalDig must be greater than or equal to 0");
}
_options.FracionalDig = value;
return this;
Expand Down Expand Up @@ -214,7 +218,7 @@ public IControlChartBar PageSize(int value)
{
if (value < 1)
{
value = 1;
throw new PromptPlusException("PageSize must be greater than or equal to 1");
}
_options.PageSize = value;
return this;
Expand Down
11 changes: 6 additions & 5 deletions Src/Controls/Chart/IControlChartBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public interface IControlChartBar: IPromptControls<bool>
IControlChartBar Culture(string value);

/// <summary>
/// Define Width to ChartBar. Default value is 80.
/// Define Width to ChartBar. Default value is 80.The value must be greater than or equal to 10.
/// </summary>
/// <param name="value">Width</param>
/// <returns><see cref="IControlChartBar"/></returns>
Expand Down Expand Up @@ -149,29 +149,30 @@ public interface IControlChartBar: IPromptControls<bool>


/// <summary>
/// Set max.item view per page. Default value for this control is 10.
/// Set max.item view per page when EnabledInteractionUser is active
/// <br>Default value : 10.The value must be greater than or equal to 1</br>
/// </summary>
/// <param name="value">Number of Max.items</param>
/// <returns><see cref="IControlChartBar"/></returns>
IControlChartBar PageSize(int value);


/// <summary>
/// Overwrite a HotKey to Switch Layout Chart. Default value is 'F2'
/// Overwrite a HotKey to Switch Layout Chart when EnabledInteractionUser is active. Default value is 'F2'
/// </summary>
/// <param name="value">The <see cref="HotKey"/> to Switch Layout Chart</param>
/// <returns><see cref="IControlChartBar"/></returns>
IControlChartBar HotKeySwitchType(HotKey value);

/// <summary>
/// Overwrite a HotKey to Switch Legend Chart. Default value is 'F3'
/// Overwrite a HotKey to Switch Legend Chart when EnabledInteractionUser is active. Default value is 'F3'
/// </summary>
/// <param name="value">The <see cref="HotKey"/> to Switch Legend Chart</param>
/// <returns><see cref="IControlChartBar"/></returns>
IControlChartBar HotKeySwitchLegend(HotKey value);

/// <summary>
/// Overwrite a HotKey to Switch ordination bar and label. Default value is 'F4'
/// Overwrite a HotKey to Switch ordination bar and label when EnabledInteractionUser is active. Default value is 'F4'
/// </summary>
/// <param name="value">The <see cref="HotKey"/> to Switch ordination bar and label</param>
/// <returns><see cref="IControlChartBar"/></returns>
Expand Down
12 changes: 6 additions & 6 deletions Src/Controls/ConfigControls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,16 @@ public int PageSize

/// <summary>
/// Get/Set Minimum Prefix Length.
/// <br>Default value : 3.If value less than 0 internal set to 0.</br>
/// <br>Default value : 3.If value less than 1 internal set to 1.</br>
/// </summary>
public int CompletionMinimumPrefixLength
{
get { return _completionMinimumPrefixLength; }
set
{
if (value < 0)
if (value < 1)
{
value = 0;
value = 1;
}
_completionMinimumPrefixLength = value;
}
Expand All @@ -123,16 +123,16 @@ public int CompletionMinimumPrefixLength

/// <summary>
/// Get/Set Interval in mileseconds to wait start Completion funcion.
/// <br>Default value : 1000. If value less than 10 internal set to 10.</br>
/// <br>Default value : 1000. If value less than 100 internal set to 100.</br>
/// </summary>
public int CompletionWaitToStart
{
get { return _completionWaitToStart; }
set
{
if (value < 10)
if (value < 100)
{
value = 10;
value = 100;
}
_completionWaitToStart = value;
}
Expand Down
16 changes: 12 additions & 4 deletions Src/Controls/Input/AutoCompleteControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public IControlAutoComplete PageSize(int value)
{
if (value < 1)
{
value = 1;
throw new PromptPlusException("PageSize must be greater than or equal to 1");
}
_options.PageSize = value;
return this;
Expand Down Expand Up @@ -157,7 +157,7 @@ public IControlAutoComplete MinimumPrefixLength(int value)
{
if (value < 1)
{
value = 1;
throw new PromptPlusException("MinimumPrefixLength must be greater than or equal to 1");
}
_options.MinimumPrefixLength = value;
return this;
Expand All @@ -167,7 +167,7 @@ public IControlAutoComplete CompletionWaitToStart(int value)
{
if (value < 100)
{
value = 100;
throw new PromptPlusException("CompletionWaitToStart must be greater than or equal to 100");
}
_options.CompletionWaitToStart = value;
return this;
Expand All @@ -177,7 +177,7 @@ public IControlAutoComplete CompletionMaxCount(int value)
{
if (value < 1)
{
value = 1;
throw new PromptPlusException("CompletionMaxCount must be greater than or equal to 1");
}
_options.CompletionMaxCount = value;
return this;
Expand Down Expand Up @@ -206,6 +206,10 @@ public IControlAutoComplete OverwriteDefaultFrom(string value, TimeSpan? timeout
_options.OverwriteDefaultFrom = value;
if (timeout != null)
{
if (timeout.Value.TotalMilliseconds == 0)
{
throw new PromptPlusException("timeout must be greater than 0");
}
_options.TimeoutOverwriteDefault = timeout.Value;
}
return this;
Expand All @@ -225,6 +229,10 @@ public IControlAutoComplete AcceptInput(Func<char, bool> value)

public IControlAutoComplete MaxLength(ushort value)
{
if (value < 1)
{
throw new PromptPlusException("MaxLength must be greater than 0");
}
_options.MaxLength = value;
return this;
}
Expand Down
Loading

0 comments on commit e454e56

Please sign in to comment.