From 816ef0abe0b09159f41f1483f8b4ae672f5f6fda Mon Sep 17 00:00:00 2001 From: Wroclaw Date: Sat, 12 Nov 2022 01:05:51 +0100 Subject: [PATCH] FormItems: add conversion from any list --- revanced.ps1 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/revanced.ps1 b/revanced.ps1 index 04816f6..e498c8f 100644 --- a/revanced.ps1 +++ b/revanced.ps1 @@ -65,6 +65,22 @@ class FormItems : System.Collections.ArrayList<#FormItem#> { } return $rvalue } + + FormItems() {} + + FormItems([System.Collections.IEnumerable] $list) { + <# + .Description + Creates FormItems list with all items in list + where values are those items + and displaytext as string representation of them + + TLDR it converts any list to FormItems + #> + foreach ($i in $list) { + [void] $this.Add([FormItem]::new($i, $i.ToString())) + } + } } function renderForm([FormItems]$items, [String]$label, [String]$title, [System.Windows.Forms.SelectionMode]$mode) {