Types/AnyBox.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Add-Type -ReferencedAssemblies 'System.Management.Automation.dll','System.Drawing.dll','WPF\PresentationFramework.dll','WPF\PresentationCore.dll','WPF\WindowsBase.dll','System.Xaml.dll' -TypeDefinition @"
using System.Management.Automation;
using System.Windows.Media;
using System.Drawing;

namespace AnyBox
{
    public enum InputType {
        None, Text, FileOpen, FileSave, FolderOpen, Checkbox, Password, Date, Link
    };
    
    public enum MessagePosition { Top, Left };
    public enum SetPresentation { ComboBox, Radio, Radio_Wide };
    public enum DataGridSelectionMode { None, SingleCell, SingleRow, MultiRow };

    public enum WindowStartupLocation { Center, Top, TopLeft, TopRight, Bottom, BottomLeft, BottomRight };

    public class AnyBox
    {
        public string Icon;
        public string Title;
        public string Image;
        public string[] Message;
        public object[] Prompts;
        public object[] Buttons;
        public string CancelButton;
        public string DefaultButton;
        public System.UInt16 ButtonRows = 1;
        public string[] Comment;
        public string ContentAlignment = "Left";
        public bool CollapsibleGroups;
        public bool CollapsedGroups;
        public System.Management.Automation.ScriptBlock PrepScript;
        public System.Windows.Media.FontFamily FontFamily = new System.Windows.Media.FontFamily("Segoe UI");
        public System.UInt16 FontSize = 12;
        public System.Windows.Media.Brush FontColor = System.Windows.Media.Brushes.Black;
        public System.Windows.Media.Brush BackgroundColor;
        public System.Windows.Media.Brush AccentColor = System.Windows.Media.Brushes.Gainsboro;
        public System.Windows.WindowStyle WindowStyle = System.Windows.WindowStyle.SingleBorderWindow;
        public System.Windows.ResizeMode ResizeMode = System.Windows.ResizeMode.CanMinimize;
        public bool NoResize;
        public System.UInt16 MinHeight = 50;
        public System.UInt16 MinWidth = 50;
        public System.UInt16 MaxHeight = 0;
        public System.UInt16 MaxWidth = 0;
        public bool Topmost;
        public bool HideTaskbarIcon;
        public System.UInt32 Timeout;
        public bool Countdown;
        public bool ProgressBar;
        public System.Management.Automation.ScriptBlock While;
        public WindowStartupLocation WindowStartupLocation = WindowStartupLocation.Center;
        public System.Windows.Window ParentWindow;
        public object[] GridData;
        public bool GridAsList;
        public DataGridSelectionMode SelectionMode = DataGridSelectionMode.SingleCell;
        public bool NoGridSearch;
    }

    public class Prompt
    {
        public string Name;
        public string Tab;
        public string Group;
        public InputType InputType = InputType.Text;
        public string Message;
        public MessagePosition MessagePosition = MessagePosition.Top;
        public string Alignment;
        public System.UInt16 FontSize;
        public string FontFamily;
        public string FontColor;
        public string DefaultValue;
        public System.UInt16 LineHeight = 1;
        public bool ReadOnly = false;
        public string[] ValidateSet;
        public SetPresentation ShowSetAs = SetPresentation.ComboBox;
        public string RadioGroup;
        public bool ValidateNotEmpty = false;
        public System.Management.Automation.ScriptBlock ValidateScript;
        public bool ShowSeparator = false;
        public bool Collapsible = false;
        public bool Collapsed = false;
    }

    public class Button
    {
        public string Name;
        public string Text;
        public string ToolTip;
        public bool IsCancel = false;
        public bool IsDefault = false;
        public System.Management.Automation.ScriptBlock OnClick;
    }
}
"@
 -ErrorAction 'Stop'