PowLINQPad 0.0.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package PowLINQPad --version 0.0.4                
NuGet\Install-Package PowLINQPad -Version 0.0.4                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PowLINQPad" Version="0.0.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PowLINQPad --version 0.0.4                
#r "nuget: PowLINQPad, 0.0.4"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PowLINQPad as a Cake Addin
#addin nuget:?package=PowLINQPad&version=0.0.4

// Install PowLINQPad as a Cake Tool
#tool nuget:?package=PowLINQPad&version=0.0.4                

LINQPadUILib

Setup

Write this in your LINQPad query to init the library

public static Disp D => RxUI.D;

void OnStart()
{
	RxUI.Start();
}

Flex layouts

void Main() =>
	Flex.Vert(Dim.Fill, Dim.Fill,
		Flex.Horz(Dim.Fill, Dim.Auto,
			new Span("Header Start"),
			new Span("Header End")
		),
		
		Flex.Horz(Dim.Fill, Dim.Fill,
			Flex.Scroll(Dim.Fill, Dim.Fill,
				Enumerable.Range(0, 30).SelectToArray(e => new Span($"Left Item: {e}"))
			),
			Flex.Scroll(Dim.Fill, Dim.Fill,
				Enumerable.Range(0, 60).SelectToArray(e => new Span($"Right Item: {e}"))
			)
		),
		
		Flex.Horz(Dim.Fill, Dim.Auto,
			new Span("Footer")
		)
	)
		.Build(true)
		.Dump();

public static Disp D => RxUI.D;
void OnStart() => RxUI.Start();

Persist user settings

record Person(
	string Name,
	string Address
)
{
	public static readonly Person Empty = new(string.Empty, string.Empty);
}

class Sets : ISettings
{
	// properties need to have a getter and a setter
	public int Version { get; set; } = string.Empty;

	// properties can be records
	public Person Person { get; set; } = Person.Empty;
};

void Main()
{
	// load
	var sets = Settings.Load<Sets>();

	// get a reactive variable representing a field
	var varAddress = settings.Get(e => e.Person.Address);

	// read the value
	var addressValue = varAddress.V;

	// write the value. this will automatically save the new value to disk
	// with a debounce period
	varAddress.V = "new address";
}

Reactive controls

using static LINQPadUILib.RxControls.Utils.CtrlBlocks;


enum Status
{
	First,
	Second,
	Third
}
record Filt(
	int? Id,
	BoolOpt BoolOpt,
	TxtSearch Text,
	RngInt RngInt,
	RngTime RngTime,
	Status[] Enums
)
{
	public static readonly Filt Empty = new(
		null,
		BoolOpt.None,
		TxtSearch.Empty,
		RngInt.Empty,
		RngTime.Empty,
		Array.Empty<Status>()
	);
}
class Sets : ISettings
{
	public Filt F { get; set; } = Filt.Empty;
}

void Main()
{
	var sets = Settings.Load<Sets>();
	
	var rxId = sets.Get(e => e.F.Id).D(D);
	var rxBoolOpt = sets.Get(e => e.F.BoolOpt).D(D);
	var rxText = sets.Get(e => e.F.Text).D(D);
	var rxRngInt = sets.Get(e => e.F.RngInt).D(D);
	var rxRngTime = sets.Get(e => e.F.RngTime).D(D);
	var rxEnums = sets.Get(e => e.F.Enums).D(D);
	
	CtrlOpt o(int? keyWidth, int? valWidth, string title) => new(title, keyWidth, valWidth);
	
	var uiId		= Ctrls.MkInt			(rxId,		o(null, null, "Id"		)).D(D);
	var uiBoolOpt	= Ctrls.MkBoolOpt		(rxBoolOpt,	o(null, null, "BoolOpt"	)).D(D);
	var uiText		= Ctrls.MkText			(rxText,	o(null, null, "Text"	), true).D(D);
	var uiRngInt	= Ctrls.MkRngInt		(rxRngInt,	o(null, null, "RngInt"	), new RngIntBounds(25, 50)).D(D);
	var uiRngTime	= Ctrls.MkRngTime		(rxRngTime,	o(null, null, "RngTime"	), RngTime.SampleTimes, 20).D(D);
	var uiEnums		= Ctrls.MkEnumMultiple	(rxEnums,	o(null, null, "Enums"	)).D(D);
	

	
	vert(
		horz(
			vert(
				uiId,
				uiBoolOpt
			),
			uiText,
			uiRngInt
		),
		horz(
			uiRngTime,
			uiEnums
		)
	).Dump();

	Util.VerticalRun(
		rxId		.Select(e => $"Id: {e}"		).ToSpan(D),
		rxBoolOpt	.Select(e => $"BoolOpt: {e}").ToSpan(D),
		rxText		.Select(e => $"Text: [{e.Fmt()}]").ToSpan(D),
		rxRngInt	.Select(e => $"RngInt: {e}"	).ToSpan(D),
		rxRngTime	.Select(e => $"RngTime: {e}").ToSpan(D),
		rxEnums		.Select(e => $"Enums: {e}"	).ToSpan(D)
	).Dump("Vars");
}


static class FmtExt
{
	public static string Fmt(this TxtSearch e)
	{
		var sb = new StringBuilder();
		
		sb.Append($"useRegex:{e.UseRegex}");
		
		sb.Append($"  text:'{e.Text}'");
		
		sb.Append("  parts:");
		if (e.Parts == null)
			sb.Append("_");
		else
			sb.Append($"({e.Parts.JoinText(",")})");
			
		sb.Append("  regex:");
		if (e.Regex == null)
			sb.Append("_");
		else
			sb.Append("yes");

		sb.Append($"  isError:{e.IsError}");

		return sb.ToString();
	}
}


public static Disp D => RxUI.D;

void OnStart()
{
	RxUI.Start();
}
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.16 174 9/15/2023
0.0.15 158 8/23/2023
0.0.14 142 8/22/2023
0.0.13 141 8/22/2023
0.0.12 119 8/22/2023
0.0.11 137 8/22/2023
0.0.10 150 8/20/2023
0.0.9 142 8/19/2023
0.0.8 137 8/19/2023
0.0.7 148 8/19/2023
0.0.6 131 8/19/2023
0.0.5 143 8/19/2023
0.0.4 138 8/18/2023
0.0.3 137 8/18/2023
0.0.2 125 8/18/2023
0.0.1 133 8/17/2023