├── .gitignore
├── .vscode
└── database.json
├── Package.nuspec
├── README.md
├── poshlook.psd1
├── poshlook.psm1
└── scripts
├── Add-Menu.ps1
├── Add-MenuItem.ps1
├── Configs
└── example@company.com.json
├── Enter-PoshLookSession.ps1
├── New-CLIButton.ps1
├── New-CLIDialog.ps1
├── New-CLILabel.ps1
├── New-CLIList.ps1
├── Start-PoshLook.ps1
├── add-account.ps1
├── dll
└── CLRCLI-Master
│ └── CLRCLI-master
│ ├── .gitignore
│ ├── .nuget
│ ├── NuGet.Config
│ ├── NuGet.exe
│ └── NuGet.targets
│ ├── CLRCLI.sln
│ ├── CLRCLI
│ ├── CLRCLI.csproj
│ ├── CLRCLI.nuspec
│ ├── ConsoleHelper.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── RootWindow.cs
│ ├── Widget.cs
│ ├── Widgets
│ │ ├── Border.cs
│ │ ├── Button.cs
│ │ ├── Checkbox.cs
│ │ ├── Dialog.cs
│ │ ├── HorizontalBarGraph.cs
│ │ ├── HorizontalLine.cs
│ │ ├── HorizontalProgressBar.cs
│ │ ├── Interfaces
│ │ │ ├── IAcceptInput.cs
│ │ │ ├── IFocusable.cs
│ │ │ └── IUseCommand.cs
│ │ ├── Label.cs
│ │ ├── ListBox.cs
│ │ ├── RadioButton.cs
│ │ ├── SingleLineTextbox.cs
│ │ ├── SlideToggle.cs
│ │ ├── Spinner.cs
│ │ ├── TinySpinner.cs
│ │ └── VerticalLine.cs
│ ├── bin
│ │ └── Debug
│ │ │ ├── CLRCLI.dll
│ │ │ └── CLRCLI.pdb
│ └── obj
│ │ └── Debug
│ │ ├── CLRCLI.csproj.CoreCompileInputs.cache
│ │ ├── CLRCLI.csproj.FileListAbsolute.txt
│ │ ├── CLRCLI.csprojResolveAssemblyReference.cache
│ │ ├── CLRCLI.dll
│ │ ├── CLRCLI.pdb
│ │ ├── DesignTimeResolveAssemblyReferencesInput.cache
│ │ ├── TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
│ │ ├── TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
│ │ └── TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
│ ├── LICENSE
│ ├── README.md
│ └── TestHarness
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── TestHarness.csproj
│ ├── bin
│ └── Debug
│ │ ├── CLRCLI.dll
│ │ ├── CLRCLI.pdb
│ │ ├── TestHarness.exe
│ │ └── TestHarness.pdb
│ └── obj
│ └── Debug
│ ├── DesignTimeResolveAssemblyReferencesInput.cache
│ ├── TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
│ ├── TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
│ ├── TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
│ ├── TestHarness.csproj.CoreCompileInputs.cache
│ ├── TestHarness.csproj.FileListAbsolute.txt
│ ├── TestHarness.csprojResolveAssemblyReference.cache
│ ├── TestHarness.exe
│ └── TestHarness.pdb
├── example.json
├── get-mail.ps1
└── helpers
└── wrapText.ps1
/.gitignore:
--------------------------------------------------------------------------------
1 | .swp
2 | .nupkg
3 | *.cache
4 | /.vs
5 |
--------------------------------------------------------------------------------
/.vscode/database.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/Package.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | poshlook
5 | 0.0.1
6 | Josephe Beaudry Justino Garcia Nicholas Hansen
7 | Josephe Beaudry Justino Garcia Nicholas Hansen
8 | https://github.com/itadder/PoshLook
9 | false
10 | Exchange Powershell / Cli Email Client (like pine, but powershell based). And also to be used in automation scripts. Little by little start adding other Exchange features, like Calendar, Task/Reminders, and Contact list. CLI client, for those who spend all day in powershell and Conemu.
11 |
12 | Copyright 2016
13 | powershell exchange cliclient
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PoshLook
2 | Exchange Powershell / Cli Email Client (like pine, but powershell based). And also to be used in automation scripts. Little by little start adding other Exchange features, like Calendar, Task/Reminders, and Contact list. CLI client, for those who spend all day in powershell and Conemu.
3 |
4 | #requriments
5 | currently using this module to interface with outlook. https://www.powershellgallery.com/packages/OutlookConnector/0.92.1
6 | # Future
7 | Will work on connecting via EWS more in the future.
8 | ### Current Version
9 | 0.0.1
10 |
11 | ### Supported Platforms
12 |
13 | ## Scripts
14 |
15 | ## License and Authors
16 | Author: Justino Garcia, Stephen Chu, Adam Russell
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/poshlook.psd1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itadder/PoshLook/dfc259c9fc14e6e80fc0a7ed63963a1aa1f788f6/poshlook.psd1
--------------------------------------------------------------------------------
/poshlook.psm1:
--------------------------------------------------------------------------------
1 | $Public = @( Get-ChildItem -Path $PSScriptRoot\scripts\*.ps1 -ErrorAction silentlyContinue)
2 | $Private = @( Get-ChildItem -Path $PSScriptRoot\scripts\helpers\*.ps1 -ErrorAction SilentlyContinue )
3 |
4 |
5 | #Dot source the files
6 | Foreach($import in @($Public + $Private))
7 | {
8 | Try
9 | {
10 | . $import.fullname
11 | }
12 | Catch
13 | {
14 | Write-Error -Message "Failed to import function $($import.fullname): $_"
15 | }
16 | }
17 |
18 | # Export Public functions
19 |
20 | Export-ModuleMember -Function $Public.Basename
21 |
--------------------------------------------------------------------------------
/scripts/Add-Menu.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .Synopsis
3 | Imports a JSON file that contains the layout for a dynamic and fix menu
4 | .DESCRIPTION
5 | Imports a JSON file that contains the layout for the Menu and calls Add-MenuItem for each object within the json file under "Objects".
6 | Look at example.json for formating of JSON files.
7 | This can take a mix of static positioned items and dynamic positioned items.
8 | It returns the imported JSON file so it can be processed by things like menu navigation and submenus.
9 | .EXAMPLE
10 | Add-Menu -filepath dynamicexample.json
11 | Draws a menu based on example.json
12 | .EXAMPLE
13 | Add-Menu -filepath C:\example\customlayout\customdynamicmenu.json
14 | Draws a menu based on C:\example\customlayouy\customdynamicmenu.json
15 | .LINK
16 | Github project: https://github.com/poshlook/PoshLook
17 | #>
18 | Function Add-Menu{
19 | param(
20 | #Filepath to the JSON File.
21 | [string]$filepath
22 | )
23 |
24 | #Variables
25 | $DefaultMenuColor = "DarkMagenta" #Our menus default background color
26 | $IncorrectJSON = "relativity in JSON is incorrect, must be true or false."
27 | #End Variables
28 |
29 | Push-Location
30 | cd $PSScriptRoot
31 | [string]$json = Get-Content "$filepath" -Raw
32 | $InputFile = ConvertFrom-Json -InputObject $json
33 | Pop-Location
34 |
35 | if ($InputFile.Menu[0].Backgroundcolor -ne ""){$host.UI.RawUI.BackgroundColor = $InputFile.Menu[0].Backgroundcolor}
36 | else {$host.UI.RawUI.BackgroundColor = $DefaultMenuColor}
37 | cls
38 |
39 | $ch = [console]::WindowHeight
40 | $cw = [console]::WindowWidth
41 |
42 | foreach ($i in 0..($InputFile.Objects.Count-1)){
43 | $HashArguments = @{}
44 | if ($InputFile.Objects[$i-1].xisrelative = "true"){
45 | $HashArguments.x = $ch/100*$InputFile.Objects[$i-1].x
46 | } elseif ($InputFile.Objects[$i-1].xisrelative = "false") {
47 | $HashArguments.x = $InputFile.Objects[$i-1].x
48 | } else{
49 | throw $IncorrectJSON
50 | }
51 |
52 | if ($InputFile.Objects[$i-1].yisrelative = "true"){
53 | $HashArguments.y = $ch/100*$InputFile.Objects[$i-1].y
54 | } elseif ($InputFile.Objects[$i-1].yisrelative = "false") {
55 | $HashArguments.y = $InputFile.Objects[$i-1].y
56 | } else{
57 | throw $IncorrectJSON
58 | }
59 |
60 | if ($InputFile.Objects[$i-1].Alignment -eq "left"){
61 | if ($InputFile.Objects[$i-1].xisrelative = "true"){
62 | $HashArguments.x = $cw/100*$InputFile.Objects[$i-1].x
63 | } elseif ($InputFile.Objects[$i-1].xisrelative = "false") {
64 | $HashArguments.x = $InputFile.Objects[$i-1].x
65 | } else{
66 | throw $IncorrectJSON
67 | }
68 | } elseif ($InputFile.Objects[$i-1].Alignment -eq "right"){
69 | if ($InputFile.Objects[$i-1].xisrelative = "true"){
70 | $HashArguments.x = ($cw/100*$InputFile.Objects[$i-1].x)-$InputFile.Objects[$i-1].Text.Length
71 | } elseif ($InputFile.Objects[$i-1].yisrelative = "false") {
72 | $HashArguments.x = $InputFile.Objects[$i-1].x-$InputFile.Objects[$i-1].Text.Length
73 | } else {
74 | throw $IncorrectJSON
75 | }
76 | }
77 | elseif ($InputFile.Objects[$i-1].Alignment -eq "center"){
78 | if ($InputFile.Objects[$i-1].xisrelative = "true"){
79 | $HashArguments.x = ($cw/100*$InputFile.Objects[$i-1].x)-(($InputFile.Objects[$i-1].Text.Length)/2)
80 | } elseif ($InputFile.Objects[$i-1].xisrelative = "false4"){
81 | $HashArguments.x = $InputFile.Objects[$i-1].x-($InputFile.Objects[$i-1].Text.Length)/2
82 | } else {
83 | throw $IncorrectJSON
84 | }
85 | } else {
86 | throw "Alignment in JSON is incorrect: must be left, right or center"
87 | }
88 |
89 | $HashArguments.text = $InputFile.Objects[$i-1].Text
90 | if ($InputFile.Objects[$i-1].Backgroundcolor){ $HashArguments.Backgroundcolor = $InputFile.Objects[$i-1].Backgroundcolor }
91 | if ($InputFile.Objects[$i-1].Textcolor){ $HashArguments.Textcolor = $InputFile.Objects[$i-1].Textcolor }
92 | Add-MenuItem @HashArguments
93 | }
94 | return $InputFile
95 | }
--------------------------------------------------------------------------------
/scripts/Add-MenuItem.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .Synopsis
3 | Adds text, optionaly with color to the x and y positions of the interface.
4 | .DESCRIPTION
5 | Adds text, optionaly with color to the x and y positions of the interface.
6 | .EXAMPLE
7 | Add-MenuItem -text "You have new mail." -x 0 -y 10 -backgroundcolor "Blue"
8 | Adds "You have new mail." a x-coordinate 0 and y coordinate 10 with the backgroundcolor of the letters being blue.
9 | .EXAMPLE
10 | Add-MenuItem -text "[Contacts]" -x 6 -y 20 -textcolor "green"
11 | Adds "[Contacts]" a x-coordinate 6 and y coordinate 20 with the text color of the letters being green.
12 | .LINK
13 | Github project: https://github.com/poshlook/PoshLook
14 | #>
15 | function Add-MenuItem{
16 | param(
17 | #Input text that will be displayed
18 | [string]$text,
19 |
20 | #x coordinate
21 | [int]$x,
22 |
23 | #y coordinate
24 | [int]$y,
25 |
26 | #Backgroundcolor (Of the text, not the screen)
27 | [string]$backgroundcolor="DarkMagenta",
28 |
29 | #Text color
30 | [string]$textcolor="DarkYellow"
31 | )
32 | $position=$host.ui.rawui.cursorposition
33 | $position.x = $x
34 | $position.y = $y
35 | $host.ui.rawui.cursorposition=$position
36 | Write-Host -NoNewline $text -BackgroundColor $Backgroundcolor -ForegroundColor $textcolor
37 | }
--------------------------------------------------------------------------------
/scripts/Configs/example@company.com.json:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itadder/PoshLook/dfc259c9fc14e6e80fc0a7ed63963a1aa1f788f6/scripts/Configs/example@company.com.json
--------------------------------------------------------------------------------
/scripts/Enter-PoshLookSession.ps1:
--------------------------------------------------------------------------------
1 | function Enter-PoshLookSession {
2 | [cmdletbinding()]
3 | Param(
4 | [Parameter(Mandatory=$true)]
5 | [string]$Mailbox,
6 | [Parameter()]
7 | $ServiceURL,
8 | [Parameter()]
9 | [ValidateSet(
10 | 'Exchange2007_SP1',
11 | 'Exchange2010',
12 | 'Exchange2010_SP1',
13 | 'Exchange2010_SP2',
14 | 'Exchange2013',
15 | 'Exchange2013_SP1'
16 | )][string]$Version,
17 | [Parameter()]
18 | [switch]$AllowRedirect,
19 | [Parameter()]
20 | [pscredential]$Credential
21 | )
22 | if (-not (Get-EWSService -InformationAction Stop)) {
23 | $SelectedParams = $PSBoundParameters
24 | Write-Verbose -Message 'Connecting to EWS Service'
25 | Connect-EWSService @SelectedParams
26 | }
27 |
28 | #dll loading
29 | #Import-Module "$PSScriptRoot\dll\CLRCLI-Master\CLRCLI-master\CLRCLI\bin\Debug\CLRCLI.dll"
30 |
31 | #create root base
32 | $RootWindow = [CLRCLI.Widgets.RootWindow]::new()
33 |
34 | #Define Dialog boxes
35 | $Dialogs = @(
36 | @{
37 | Name = 'FolderSelect'
38 | Config = @{
39 | Parent = $RootWindow
40 | Text = "PoshLook [Mail,Contacts,Calendar,Tasks]"
41 | Visible = $true
42 | }
43 | Dialog = $null
44 | Labels = @(
45 | @{
46 | Name = 'Label1'
47 | Config = @{
48 | Text = "Posh Look E-mail Folders"
49 | TopPadding = 2
50 | LeftPadding = 2
51 | }
52 | Label = $null
53 | }
54 | )
55 | Lists = @(
56 | @{
57 | Name = 'Folders'
58 | Config = @{
59 | TopPadding = 10
60 | LeftPadding = 4
61 | Width = 32
62 | Height = 6
63 | Border = 'Thin'
64 | ClickAction = {
65 | $Dialogs[0].Dialog.Hide();
66 | $Dialogs[1].Dialog.Show();
67 | $selection = $Dialogs[0].Lists[0].List.SelectedItem
68 | $script:emails = (Get-EWSFolder -Path "MsgFolderRoot\$selection").FindItems(156)
69 | $script:emails.Subject | %{
70 | $Dialogs[1].Lists[0].List.Items.Add($_)
71 | }
72 | }
73 | }
74 | List = $null
75 | }
76 | )
77 | Buttons = @(
78 | @{
79 | Name = 'ShowMail'
80 | Config = @{
81 | Text = 'Show-MailFolder'
82 | Width = 25
83 | TopPadding = 4
84 | LeftPadding = 6
85 | ClickAction = {
86 | $listitem = [system.collections.arraylist]::new()
87 | (Get-EWSFolder -Path MsgFolderRoot).FindFolders([int]::MaxValue) | ?{$_.FolderClass -eq 'IPF.Note'} | %{
88 | [void]$listitem.Add($_.DisplayName)
89 | <#
90 | if ($_.ChildFolderCount){
91 | [void]$listitem.Add("($($_.ChildFolderCount))")
92 | }
93 | #>
94 | $Dialogs[0].Lists[0].List.items.add($listitem -join ' ')
95 | $Dialogs[0].Lists[0].List.SetFocus()
96 | $listitem.Clear()
97 | }
98 | }
99 | }
100 | Button = $null
101 | }
102 | )
103 | },
104 | @{
105 | Name = 'FolderView'
106 | Config = @{
107 | Parent = $RootWindow
108 | #Text = $selection
109 | Text = "view Inbox"
110 | Width = 150
111 | Height = 32
112 | TopPadding = 6
113 | LeftPadding = 6
114 | BorderStyle = 'Thick'
115 | }
116 | Dialog = $null
117 | Labels = @()
118 | Lists = @(
119 | @{
120 | Name = 'Emails'
121 | Config = @{
122 | TopPadding = 10
123 | LeftPadding = 4
124 | Width = 100
125 | height = 6
126 | Border = 'Thin'
127 | ClickAction = {
128 | $Dialogs[1].Lists[1].List.Items.Clear()
129 | $selection = $Dialogs[1].Lists[0].List.SelectedItem
130 | $SelectedEmail = $script:emails | ?{$_.Subject -eq $selection}
131 | $SelectedEmailBody = ((( Get-EWSMessage -id ($SelectedEmail.id | select -first 1) | select -ExpandProperty BodyText ) -replace '<[^>]+>','') -split "`r`n") | %{if($_){wrapText -text $_}else{$_}}
132 |
133 | $ErrorActionPreference = "SilentlyContinue"
134 | $SelectedEmailBody | select -first 155 | %{
135 | $Dialogs[1].Lists[1].List.Items.Add($_)
136 | }
137 | $ErrorActionPreference = "Continue"
138 | }
139 | }
140 | List = $null
141 | },
142 | @{
143 | Name = 'Email Preview'
144 | Config = @{
145 | TopPadding = 20
146 | LeftPadding = 10
147 | Width = 100
148 | height = 8
149 | Border = 'Thin'
150 | }
151 | List = $null
152 | }
153 | )
154 | Buttons = @(
155 | @{
156 | Name = 'Exit'
157 | Config = @{
158 | Text = "Exit"
159 | Width = 8
160 | Height = 3
161 | TopPadding = 30
162 | LeftPadding = 5
163 | ClickAction = {$RootWindow.Detach()}
164 | }
165 | Button = $null
166 | }
167 | )
168 | }
169 | )
170 |
171 | #Executing configuration
172 | $Dialogs | %{
173 | $ThisConfig = $_.Config
174 | $_.Dialog = New-CLIDialog @ThisConfig
175 | $ThisDialog = $_.Dialog
176 | $_.Labels | %{
177 | $ThisLabel = $_.Config
178 | $_.Label = New-CLILabel @ThisLabel -Parent $ThisDialog
179 | }
180 | $_.Lists | %{
181 | $ThisList = $_.Config
182 | $_.List = New-CLIList @ThisList -Parent $ThisDialog
183 | }
184 | $_.Buttons | %{
185 | $ThisButton = $_.Config
186 | $_.Button = New-CLIButton @ThisButton -Parent $ThisDialog
187 | }
188 | }
189 |
190 |
191 | #$selection = $list.SelectedItem
192 | #$selection2 = $list2.SelectedItem
193 |
194 |
195 | # run cli gui
196 | $RootWindow.Run()
197 | }
--------------------------------------------------------------------------------
/scripts/New-CLIButton.ps1:
--------------------------------------------------------------------------------
1 | function New-CLIButton {
2 | Param(
3 | [Parameter(Mandatory=$true)]
4 | $Parent,
5 | [Parameter(Mandatory=$true)]
6 | [string]$Text,
7 | [Parameter()]
8 | $Width = 25,
9 | [Parameter()]
10 | $Height = 3,
11 | [Parameter()]
12 | $TopPadding = 2,
13 | [Parameter()]
14 | $LeftPadding = 2,
15 | [Parameter()]
16 | $ClickAction
17 | #[Parameter()]
18 | #[ValidateSet('None','Thin','Thick','Block')][string]$BorderStyle = 'Thin',
19 | #[Parameter()]
20 | #[switch]$Visible
21 | )
22 |
23 | $ThisButton = [CLRCLI.Widgets.Button]::new($Parent)
24 | $ThisButton.Text = $Text
25 | $ThisButton.Top = $TopPadding
26 | $ThisButton.Left = $LeftPadding
27 | $ThisButton.Width = $Width
28 | $ThisButton.Height = $Height
29 | $ThisButton.Add_Clicked($ClickAction)
30 |
31 | $ThisButton
32 | }
33 |
34 |
35 |
--------------------------------------------------------------------------------
/scripts/New-CLIDialog.ps1:
--------------------------------------------------------------------------------
1 | #import-module "C:\Program Files\WindowsPowerShell\Modules\PoshLook\scripts\dll\CLRCLI-Master\CLRCLI-master\CLRCLI\bin\Debug\CLRCLI.dll"
2 |
3 | #Valid border styles - Make Parameter validation dynamic later
4 | # [CLRCLI.BorderStyle].DeclaredMembers | select -ExpandProperty Name | ?{$_ -notmatch '__'}
5 |
6 | function New-CLIDialog {
7 | Param(
8 | [Parameter(Mandatory=$true)]
9 | $Parent,
10 | [Parameter(Mandatory=$true)]
11 | [string]$Text,
12 | [Parameter()]
13 | $Width = 60,
14 | [Parameter()]
15 | $Height = 32,
16 | [Parameter()]
17 | $TopPadding = 4,
18 | [Parameter()]
19 | $LeftPadding = 4,
20 | [Parameter()]
21 | [ValidateSet('None','Thin','Thick','Block')][string]$BorderStyle = 'Thin',
22 | [Parameter()]
23 | [switch]$Visible
24 | )
25 |
26 | $ThisDialog = [CLRCLI.Widgets.Dialog]::new($RootWindow)
27 |
28 | $ThisDialog.Text = $Text
29 | $ThisDialog.Width = $Width
30 | $ThisDialog.Height = $Height
31 | $ThisDialog.Top = $TopPadding
32 | $ThisDialog.Left = $LeftPadding
33 | $ThisDialog.Border = [CLRCLI.BorderStyle]::$BorderStyle
34 | $ThisDialog.Visible = [bool]$Visible
35 |
36 | $ThisDialog
37 | }
--------------------------------------------------------------------------------
/scripts/New-CLILabel.ps1:
--------------------------------------------------------------------------------
1 | function New-CLILabel {
2 | Param(
3 | [Parameter(Mandatory=$true)]
4 | $Parent,
5 | [Parameter(Mandatory=$true)]
6 | [string]$Text,
7 | #[Parameter()]
8 | #$Width = 60,
9 | #[Parameter()]
10 | #$Height = 32,
11 | #[Parameter()]
12 | $TopPadding = 2,
13 | [Parameter()]
14 | $LeftPadding = 2
15 | #[Parameter()]
16 | #[ValidateSet('None','Thin','Thick','Block')][string]$BorderStyle = 'Thin',
17 | #[Parameter()]
18 | #[switch]$Visible
19 | )
20 |
21 | $ThisLabel = [CLRCLI.Widgets.Label]::new($Parent)
22 | $ThisLabel.Text = $Text
23 | $ThisLabel.Top = $TopPadding
24 | $ThisLabel.Left = $LeftPadding
25 |
26 | $ThisLabel
27 | }
--------------------------------------------------------------------------------
/scripts/New-CLIList.ps1:
--------------------------------------------------------------------------------
1 | function New-CLIList {
2 | Param(
3 | [Parameter(Mandatory=$true)]
4 | $Parent,
5 | [Parameter()]
6 | [string]$Text,
7 | [Parameter()]
8 | $Width = 32,
9 | [Parameter()]
10 | $Height = 6,
11 | [Parameter()]
12 | $TopPadding = 10,
13 | [Parameter()]
14 | $LeftPadding = 4,
15 | [Parameter()]
16 | [ValidateSet('None','Thin','Thick','Block')][string]$BorderStyle = 'Thin',
17 | [Parameter()]
18 | [scriptblock]$ClickAction
19 |
20 | )
21 |
22 | $ThisList = [CLRCLI.Widgets.ListBox]::new($Parent)
23 | $ThisList.top = $TopPadding
24 | $ThisList.Left = $LeftPadding
25 | $ThisList.Width = $Width
26 | $ThisList.height = $Height
27 | $ThisList.Border = [CLRCLI.BorderStyle]::$BorderStyle
28 | $ThisList.Add_Clicked($ClickAction)
29 |
30 | $ThisList
31 | }
32 |
33 |
34 |
--------------------------------------------------------------------------------
/scripts/Start-PoshLook.ps1:
--------------------------------------------------------------------------------
1 | #TODO:
2 | #Add logic here to start the Poshlook Script.
3 | #Add Logic here to check if a account was setup. (Does the JSON config file exist)
4 | #Add Logic to Skip to Adding an account if the JSON config file exist in the config folder.
--------------------------------------------------------------------------------
/scripts/add-account.ps1:
--------------------------------------------------------------------------------
1 | #This will be where we create new accounts
2 | Import-Module EWS
3 | <#
4 | .SYNOPSIS
5 | Helper Function to Add An account to a json file.
6 |
7 | .DESCRIPTION
8 | Helper Function to Add account to a CLIxml file or json or just passthru.
9 | This will add in saving a mailbox to use when connecting to poshlook
10 |
11 | .PARAMETER Mailbox
12 | Account or Mailbox you want to connect to Exchange in PoshLook
13 |
14 | .PARAMETER Version
15 | Version of Exchange Web Service.
16 |
17 | .PARAMETER ServiceUrl
18 | Optional URL to service (when specified, auto-discovery is not used).
19 |
20 | .PARAMETER json
21 | A description of the json parameter.
22 |
23 | .PARAMETER Credential
24 | Credentials used to authenticate to Exchange Web Service.
25 | Credentials used to authenticate to Exchange Web Service.
26 | Optional, only needed if your connecting to a differnet Mailbox
27 |
28 | .PARAMETER jsonconfig
29 | A description of the jsonconfig parameter.
30 |
31 | .EXAMPLE
32 | PS C:\> Add-Account
33 |
34 | .OUTPUTS
35 | string, string
36 |
37 | .NOTES
38 | Additional information about the function.
39 | #>
40 | function Add-Account {
41 | [CmdletBinding()]
42 | param
43 | (
44 | [Parameter(Mandatory = $true,
45 | ValueFromPipeline = $true,
46 | ValueFromPipelineByPropertyName = $true,
47 | Position = 0)]
48 | [ValidatePattern('\w+([-+.'''''''''''''''']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*')]
49 | [String]$Mailbox,
50 | [Parameter(Mandatory = $true,
51 | Position = 1)]
52 | #[ValidateSet('Exchange2007_SP1', 'Exchange2010', 'Exchange2010_SP1', 'Exchange2010_SP2', 'Exchange2013', 'Exchange2013_SP1', 'Exchange2016')]
53 | [system.string]$Version,
54 | [Parameter(Position = 2)]
55 | #[ValidatePattern('http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?')]
56 | [string]$ServiceURL,
57 | [Parameter(Position = 3)]
58 | [string]$json,
59 | [pscredential]$Credential
60 | )
61 |
62 | #TODO: Connect Script
63 | if ($ServiceUrl -ne $null) {
64 | $json = @"
65 | MailBox = $Mailbox
66 | Version = $Version
67 | ServiceURL = $ServiceURL
68 | "@
69 | ConvertTo-Json -InputObject $json | Out-File "$PSScriptRoot\Config\$Mailbox.json"
70 | }
71 |
72 | else {
73 |
74 | $json = @"
75 | MailBox = $Mailbox
76 | Version = $Version
77 | "@
78 |
79 | ConvertTo-Json -InputObject $json | Out-File "$PSScriptRoot\Config\$Mailbox.json"
80 | }
81 | }
82 |
83 |
--------------------------------------------------------------------------------
/scripts/dll/CLRCLI-Master/CLRCLI-master/.gitignore:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # This .gitignore file was automatically created by Microsoft(R) Visual Studio.
3 | ################################################################################
4 |
5 | *.suo
6 |
--------------------------------------------------------------------------------
/scripts/dll/CLRCLI-Master/CLRCLI-master/.nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/scripts/dll/CLRCLI-Master/CLRCLI-master/.nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/itadder/PoshLook/dfc259c9fc14e6e80fc0a7ed63963a1aa1f788f6/scripts/dll/CLRCLI-Master/CLRCLI-master/.nuget/NuGet.exe
--------------------------------------------------------------------------------
/scripts/dll/CLRCLI-Master/CLRCLI-master/.nuget/NuGet.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildProjectDirectory)\..\
5 |
6 |
7 | false
8 |
9 |
10 | false
11 |
12 |
13 | true
14 |
15 |
16 | false
17 |
18 |
19 |
20 |
21 |
22 |
26 |
27 |
28 |
29 |
30 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget"))
31 |
32 |
33 |
34 |
35 | $(SolutionDir).nuget
36 |
37 |
38 |
39 | $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config
40 | $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config
41 |
42 |
43 |
44 | $(MSBuildProjectDirectory)\packages.config
45 | $(PackagesProjectConfig)
46 |
47 |
48 |
49 |
50 | $(NuGetToolsPath)\NuGet.exe
51 | @(PackageSource)
52 |
53 | "$(NuGetExePath)"
54 | mono --runtime=v4.0.30319 "$(NuGetExePath)"
55 |
56 | $(TargetDir.Trim('\\'))
57 |
58 | -RequireConsent
59 | -NonInteractive
60 |
61 | "$(SolutionDir) "
62 | "$(SolutionDir)"
63 |
64 |
65 | $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)
66 | $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols
67 |
68 |
69 |
70 | RestorePackages;
71 | $(BuildDependsOn);
72 |
73 |
74 |
75 |
76 | $(BuildDependsOn);
77 | BuildPackage;
78 |
79 |
80 |
81 |
82 |
83 |
84 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
99 |
100 |
103 |
104 |
105 |
106 |
108 |
109 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
141 |
142 |
143 |
144 |
145 |
--------------------------------------------------------------------------------
/scripts/dll/CLRCLI-Master/CLRCLI-master/CLRCLI.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.31101.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CLRCLI", "CLRCLI\CLRCLI.csproj", "{928EE27E-046E-4DCE-9D04-1C065B51DC67}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestHarness", "TestHarness\TestHarness.csproj", "{BBB2E91C-C4D2-449F-ACD5-2823A90580BA}"
9 | EndProject
10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{308C244F-97CC-4E4E-8B51-3FA939FEC6A8}"
11 | ProjectSection(SolutionItems) = preProject
12 | .nuget\NuGet.Config = .nuget\NuGet.Config
13 | .nuget\NuGet.exe = .nuget\NuGet.exe
14 | .nuget\NuGet.targets = .nuget\NuGet.targets
15 | EndProjectSection
16 | EndProject
17 | Global
18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
19 | Debug|Any CPU = Debug|Any CPU
20 | Release|Any CPU = Release|Any CPU
21 | EndGlobalSection
22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
23 | {928EE27E-046E-4DCE-9D04-1C065B51DC67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24 | {928EE27E-046E-4DCE-9D04-1C065B51DC67}.Debug|Any CPU.Build.0 = Debug|Any CPU
25 | {928EE27E-046E-4DCE-9D04-1C065B51DC67}.Release|Any CPU.ActiveCfg = Release|Any CPU
26 | {928EE27E-046E-4DCE-9D04-1C065B51DC67}.Release|Any CPU.Build.0 = Release|Any CPU
27 | {BBB2E91C-C4D2-449F-ACD5-2823A90580BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28 | {BBB2E91C-C4D2-449F-ACD5-2823A90580BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
29 | {BBB2E91C-C4D2-449F-ACD5-2823A90580BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
30 | {BBB2E91C-C4D2-449F-ACD5-2823A90580BA}.Release|Any CPU.Build.0 = Release|Any CPU
31 | EndGlobalSection
32 | GlobalSection(SolutionProperties) = preSolution
33 | HideSolutionNode = FALSE
34 | EndGlobalSection
35 | EndGlobal
36 |
--------------------------------------------------------------------------------
/scripts/dll/CLRCLI-Master/CLRCLI-master/CLRCLI/CLRCLI.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {928EE27E-046E-4DCE-9D04-1C065B51DC67}
8 | Library
9 | Properties
10 | CLRCLI
11 | CLRCLI
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
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 |
79 |
80 |
--------------------------------------------------------------------------------
/scripts/dll/CLRCLI-Master/CLRCLI-master/CLRCLI/CLRCLI.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $id$
5 | $version$
6 | $title$
7 | CubeCoders Limited
8 | https://github.com/PhonicUK/CLRCLI/blob/master/LICENSE
9 | https://github.com/PhonicUK/CLRCLI
10 | true
11 | An event-driven library for building line-art user interfaces in C#/.Net command-line applications.
12 | Copyright 2015
13 | CommandLine
14 |
15 |
--------------------------------------------------------------------------------
/scripts/dll/CLRCLI-Master/CLRCLI-master/CLRCLI/ConsoleHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace CLRCLI
8 | {
9 | internal static class ConsoleHelper
10 | {
11 | internal static void ResetConsoleWindow()
12 | {
13 | Console.SetWindowPosition(0, 0);
14 | Console.SetCursorPosition(0, 0);
15 | }
16 |
17 | internal static void DrawText(int x, int y, ConsoleColor fg, ConsoleColor bg, string format, params object[] args)
18 | {
19 | Console.SetCursorPosition(x, y);
20 | Console.ForegroundColor = fg;
21 | Console.BackgroundColor = bg;
22 | Console.Write(format, args);
23 | }
24 |
25 | internal static void DrawText(int x, int y, ConsoleColor fg, string format, params object[] args)
26 | {
27 | Console.SetCursorPosition(x, y);
28 | Console.ForegroundColor = fg;
29 | Console.Write(format, args);
30 | }
31 |
32 | internal static void DrawRectShade(int x, int y, int w, int h, ConsoleColor bg, ConsoleColor fg, char ch)
33 | {
34 | Console.BackgroundColor = bg;
35 | Console.ForegroundColor = fg;
36 |
37 | var l = new String(ch, w);
38 |
39 | for (var i = 0; i < h - 1; i++)
40 | {
41 | Console.SetCursorPosition(x + w - 1, y + i);
42 | Console.Write(ch);
43 | }
44 | Console.SetCursorPosition(x, y + h - 1);
45 | Console.Write(l);
46 |
47 | ResetConsoleWindow();
48 | }
49 |
50 | internal delegate void DrawBoxMethod(int x, int y, int w, int h, ConsoleColor c);
51 |
52 | internal static void DrawNothing(int x, int y, int w, int h, ConsoleColor c){ }
53 |
54 | internal static void DrawRectSolid(int x, int y, int w, int h, ConsoleColor c)
55 | {
56 | Console.BackgroundColor = c;
57 | var l = new String(' ', w);
58 | for (var i = 0; i < h; i++)
59 | {
60 | Console.SetCursorPosition(x, y + i);
61 | Console.Write(l);
62 | }
63 | ResetConsoleWindow();
64 | }
65 |
66 | internal static void DrawBlockOutline(int x, int y, int w, int h, ConsoleColor c)
67 | {
68 | Console.ForegroundColor = c;
69 |
70 | Console.SetCursorPosition(x, y);
71 | Console.Write("▄");
72 | Console.Write(new String('█', w - 1));
73 | Console.Write("▄");
74 |
75 | for (int i = 1; i < h - 1; i++)
76 | {
77 | Console.SetCursorPosition(x, y + i);
78 | Console.Write("█");
79 | Console.SetCursorPosition(x + w, y + i);
80 | Console.Write("█");
81 | }
82 |
83 | Console.SetCursorPosition(x, y + h - 1);
84 | Console.Write("▀");
85 | Console.Write(new String('█', w - 1));
86 | Console.Write("▀");
87 | }
88 |
89 | internal static void DrawSingleOutline(int x, int y, int w, int h, ConsoleColor c)
90 | {
91 | Console.ForegroundColor = c;
92 |
93 | Console.SetCursorPosition(x, y);
94 | Console.Write("┌");
95 | Console.Write(new String('─', w - 1));
96 | Console.Write("┐");
97 |
98 | for (int i = 1; i < h - 1; i++)
99 | {
100 | Console.SetCursorPosition(x, y + i);
101 | Console.Write("│");
102 | Console.SetCursorPosition(x + w, y + i);
103 | Console.Write("│");
104 | }
105 |
106 | Console.SetCursorPosition(x, y + h - 1);
107 | Console.Write("└");
108 | Console.Write(new String('─', w - 1));
109 | Console.Write("┘");
110 | }
111 |
112 | internal static void DrawDoubleOutline(int x, int y, int w, int h, ConsoleColor c)
113 | {
114 | Console.ForegroundColor = c;
115 |
116 | Console.SetCursorPosition(x, y);
117 | Console.Write("╔");
118 | Console.Write(new String('═', w - 1));
119 | Console.Write("╗");
120 |
121 | for (int i = 1; i < h - 1; i++)
122 | {
123 | Console.SetCursorPosition(x, y + i);
124 | Console.Write("║");
125 | Console.SetCursorPosition(x + w, y + i);
126 | Console.Write("║");
127 | }
128 |
129 | Console.SetCursorPosition(x, y + h - 1);
130 | Console.Write("╚");
131 | Console.Write(new String('═', w - 1));
132 | Console.Write("╝");
133 | }
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/scripts/dll/CLRCLI-Master/CLRCLI-master/CLRCLI/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("CLRCLI")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("CLRCLI")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("f00e2b29-6265-4912-85ef-107ac74e5073")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.5")]
36 | [assembly: AssemblyFileVersion("1.0.0.5")]
37 |
--------------------------------------------------------------------------------
/scripts/dll/CLRCLI-Master/CLRCLI-master/CLRCLI/RootWindow.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Reflection;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Xml.Serialization;
9 |
10 | namespace CLRCLI.Widgets
11 | {
12 | public class RootWindow : Widget
13 | {
14 | [XmlIgnore]
15 | public List AllChildren;
16 | private List RootFocusableChildren;
17 | private List ActivableChildren
18 | {
19 | get
20 | {
21 | return RootFocusableChildren.Where(c => c.IsVisible).ToList();
22 | }
23 | }
24 |
25 | [XmlIgnore]
26 | public Object ViewModel { get; set; }
27 |
28 | public RootWindow()
29 | : base(null)
30 | {
31 | Top = 0;
32 | Left = 0;
33 | Width = Console.WindowWidth;
34 | Height = Console.WindowHeight;
35 | Background = ConsoleColor.DarkBlue;
36 | Foreground = ConsoleColor.White;
37 | SelectedBackground = ConsoleColor.Magenta;
38 | ActiveBackground = ConsoleColor.DarkMagenta;
39 | ActiveWidget = null;
40 | AllowDraw = false;
41 | AllChildren = new List();
42 | }
43 |
44 | internal override void Render()
45 | {
46 | ConsoleHelper.DrawRectSolid(DisplayLeft, DisplayTop, Width, Height, Background);
47 | }
48 |
49 | internal bool AllowDraw { get; private set; }
50 |
51 | private Widget _activeWidget;
52 | public Widget ActiveWidget
53 | {
54 | get
55 | {
56 | return _activeWidget;
57 | }
58 | set
59 | {
60 | if (value != null && value != _activeWidget)
61 | {
62 | if (_activeWidget != null)
63 | {
64 | _activeWidget.HasFocus = false;
65 | _activeWidget.Draw();
66 | }
67 |
68 | _activeWidget = value;
69 |
70 | _activeWidget.HasFocus = true;
71 | _activeWidget.Draw();
72 | }
73 | }
74 | }
75 |
76 | private Dictionary NameLookup;
77 |
78 | private void BuildLookup()
79 | {
80 | NameLookup = new Dictionary();
81 | AllChildren.ForEach(c =>
82 | {
83 | if (!String.IsNullOrEmpty(c.Id))
84 | {
85 | NameLookup.Add(c.Id, c);
86 | }
87 | });
88 | }
89 |
90 | ///
91 | /// Find a widget by its ID.
92 | ///
93 | /// The ID of the widget to search for.
94 | /// A widget object if it is found, or null if no such widget exists.
95 | public Widget Find(string Id)
96 | {
97 | if (NameLookup == null) { BuildLookup(); }
98 |
99 | if (NameLookup.ContainsKey(Id))
100 | {
101 | return NameLookup[Id];
102 | }
103 | else
104 | {
105 | return null;
106 | }
107 | }
108 |
109 | private bool Running = false;
110 |
111 | ///
112 | /// Stop displaying the UI and handling keyboard input. Can only be used in response to an in-UI event.
113 | ///
114 | public void Detach()
115 | {
116 | Console.CursorVisible = true;
117 | Running = false;
118 | Console.Clear();
119 | }
120 |
121 | ///
122 | /// Start displaying the UI and handling keyboard input.
123 | ///
124 | public void Run()
125 | {
126 | Running = true;
127 | AllowDraw = true;
128 | Console.CursorVisible = false;
129 | RootFocusableChildren = AllChildren.Where(c => c is IFocusable).OrderBy(c => c.TabStop).ToList();
130 | ActiveWidget = RootFocusableChildren.FirstOrDefault();
131 |
132 | Draw();
133 |
134 | while (Running)
135 | {
136 | var k = Console.ReadKey(true);
137 |
138 | bool ProcessKey = true;
139 |
140 | if (ActiveWidget is IAcceptInput)
141 | {
142 | ProcessKey = false;
143 | switch (k.Key)
144 | {
145 | case ConsoleKey.Tab:
146 | CycleFocus();
147 | break;
148 | default:
149 | ProcessKey = HandleWidgetInput(k);
150 | break;
151 | }
152 | }
153 |
154 | if (ProcessKey)
155 | {
156 | switch (k.Key)
157 | {
158 | case ConsoleKey.Tab:
159 | CycleFocus((k.Modifiers == ConsoleModifiers.Shift) ? -1 : 1);
160 | break;
161 | case ConsoleKey.RightArrow:
162 | MoveRight();
163 | break;
164 | case ConsoleKey.LeftArrow:
165 | MoveLeft();
166 | break;
167 | case ConsoleKey.UpArrow:
168 | MoveUp();
169 | break;
170 | case ConsoleKey.DownArrow:
171 | MoveDown();
172 | break;
173 | case ConsoleKey.Spacebar:
174 | case ConsoleKey.Enter:
175 | EnterPressed();
176 | break;
177 | case ConsoleKey.Escape:
178 | Running = false;
179 | break;
180 | }
181 | }
182 | }
183 | }
184 |
185 | private bool HandleWidgetInput(ConsoleKeyInfo k)
186 | {
187 | return (ActiveWidget as IAcceptInput).Keypress(k);
188 | }
189 |
190 | private void MoveDown()
191 | {
192 | var w = FindFocusableWidgetBelow(ActiveWidget);
193 | if (w != null)
194 | {
195 | ActiveWidget = w;
196 | lastIndex = RootFocusableChildren.IndexOf(ActiveWidget);
197 | }
198 | }
199 |
200 | private void MoveUp()
201 | {
202 | var w = FindFocusableWidgetAbove(ActiveWidget);
203 | if (w != null)
204 | {
205 | ActiveWidget = w;
206 | lastIndex = RootFocusableChildren.IndexOf(ActiveWidget);
207 | }
208 | }
209 |
210 | private void MoveLeft()
211 | {
212 | var w = FindFocusableWidgetToLeftOf(ActiveWidget);
213 | if (w != null)
214 | {
215 | ActiveWidget = w;
216 | lastIndex = RootFocusableChildren.IndexOf(ActiveWidget);
217 | }
218 | }
219 |
220 | private void MoveRight()
221 | {
222 | var w = FindFocusableWidgetToRightOf(ActiveWidget);
223 | if (w != null)
224 | {
225 | ActiveWidget = w;
226 | lastIndex = RootFocusableChildren.IndexOf(ActiveWidget);
227 | }
228 | }
229 |
230 | private void EnterPressed()
231 | {
232 | if (ActiveWidget != null && ActiveWidget.Enabled)
233 | {
234 | ActiveWidget.FireClicked();
235 | }
236 | }
237 |
238 | private int lastIndex = 0;
239 |
240 | private Widget FindFocusableWidgetToRightOf(Widget from)
241 | {
242 | var ImmediateRight = ActivableChildren.Where(c => c.Top == from.Top && c.Left > from.Left).OrderBy(c => c.Left).FirstOrDefault();
243 |
244 | if (ImmediateRight == null)
245 | {
246 | var RoughRight = ActivableChildren.Where(c => c.Left > from.Left && Math.Abs(c.Top - from.Top) < 2).OrderBy(c => c.Left).OrderBy(c => Math.Abs(c.Top - from.Top)).FirstOrDefault();
247 |
248 | if (RoughRight == null)
249 | {
250 | return ActivableChildren.Where(c => c.Top == from.Top).OrderBy(c => c.Left).FirstOrDefault();
251 | }
252 |
253 | return RoughRight;
254 | }
255 |
256 | return ImmediateRight;
257 | }
258 |
259 | private Widget FindFocusableWidgetToLeftOf(Widget from)
260 | {
261 | var ImmediateLeft = ActivableChildren.Where(c => c.Top == from.Top && c.Left < from.Left).OrderByDescending(c => c.Left).FirstOrDefault();
262 |
263 | if (ImmediateLeft == null)
264 | {
265 | var RoughLeft = ActivableChildren.Where(c => c.Left < from.Left && Math.Abs(c.Top - from.Top) < 2).OrderByDescending(c => c.Left).OrderBy(c => Math.Abs(c.Top - from.Top)).FirstOrDefault();
266 |
267 | if (RoughLeft == null)
268 | {
269 | return ActivableChildren.Where(c => c.Top == from.Top).OrderByDescending(c => c.Left).FirstOrDefault();
270 | }
271 |
272 | return RoughLeft;
273 | }
274 |
275 | return ImmediateLeft;
276 | }
277 |
278 | private Widget FindFocusableWidgetAbove(Widget from)
279 | {
280 | var ImmediateAbove = ActivableChildren.Where(c => c.Left == from.Left && c.Top < from.Top).OrderByDescending(c => c.Top).FirstOrDefault();
281 |
282 | if (ImmediateAbove == null)
283 | {
284 | return ActivableChildren.Where(c => c.Top < from.Top).OrderByDescending(c => c.Top).OrderBy(c => c.Left).FirstOrDefault();
285 | }
286 |
287 | return ImmediateAbove;
288 | }
289 |
290 | private Widget FindFocusableWidgetBelow(Widget from)
291 | {
292 | var ImmediateBelow = ActivableChildren.Where(c => c.Left == from.Left && c.Top > from.Top).OrderBy(c => c.Top).FirstOrDefault();
293 |
294 | if (ImmediateBelow == null)
295 | {
296 | return ActivableChildren.Where(c => c.Top > from.Top).OrderBy(c => c.Left).OrderBy(c => c.Top).FirstOrDefault();
297 | }
298 |
299 | return ImmediateBelow;
300 | }
301 |
302 | private void CycleFocus(int Direction = 1)
303 | {
304 | if (ActiveWidget == null)
305 | {
306 | lastIndex = 0;
307 | ActiveWidget = ActivableChildren.FirstOrDefault();
308 | }
309 | else
310 | {
311 | lastIndex = (lastIndex + Direction) % ActivableChildren.Count;
312 | if (lastIndex == -1) { lastIndex = ActivableChildren.Count - 1; }
313 | ActiveWidget = ActivableChildren[lastIndex];
314 | }
315 | }
316 |
317 | private static Type[] GetWidgetTypes()
318 | {
319 | return Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsClass && t.IsSubclassOf(typeof(Widget))).ToArray();
320 | }
321 |
322 | private XmlSerializerNamespaces GetNS()
323 | {
324 | XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
325 | ns.Add("", "");
326 | return ns;
327 | }
328 |
329 | public void Save(Stream stream)
330 | {
331 | var ser = new XmlSerializer(typeof(RootWindow), GetWidgetTypes());
332 | ser.Serialize(stream, this, GetNS());
333 | }
334 |
335 | public void Save(string Filename)
336 | {
337 | var ser = new XmlSerializer(typeof(RootWindow), GetWidgetTypes());
338 |
339 | using (var stream = new StreamWriter(Filename))
340 | {
341 | ser.Serialize(stream, this, GetNS());
342 | }
343 | }
344 |
345 | public String Save()
346 | {
347 | var ser = new XmlSerializer(typeof(RootWindow), GetWidgetTypes());
348 |
349 | using (var stream = new StringWriter())
350 | {
351 | ser.Serialize(stream, this, GetNS());
352 | return stream.ToString();
353 | }
354 | }
355 |
356 | public static RootWindow LoadFromStream(Stream stream)
357 | {
358 | var ser = new XmlSerializer(typeof(RootWindow), GetWidgetTypes());
359 |
360 | var obj = (RootWindow)ser.Deserialize(stream);
361 | obj.FixChildParents(obj);
362 | obj.BuildLookup();
363 | return obj;
364 | }
365 |
366 | public static RootWindow LoadFromString(String data)
367 | {
368 | var ser = new XmlSerializer(typeof(RootWindow), GetWidgetTypes());
369 |
370 | var obj = (RootWindow)ser.Deserialize(new StringReader(data));
371 | obj.FixChildParents(obj);
372 | obj.BuildLookup();
373 | return obj;
374 | }
375 |
376 | public static RootWindow LoadFromFile(string Filename)
377 | {
378 | var ser = new XmlSerializer(typeof(RootWindow), GetWidgetTypes());
379 |
380 | using (var stream = new StreamReader(Filename))
381 | {
382 | var obj = (RootWindow)ser.Deserialize(stream);
383 | obj.FixChildParents(obj);
384 | obj.BuildLookup();
385 | return obj;
386 | }
387 | }
388 | }
389 | }
390 |
--------------------------------------------------------------------------------
/scripts/dll/CLRCLI-Master/CLRCLI-master/CLRCLI/Widget.cs:
--------------------------------------------------------------------------------
1 | using CLRCLI.Widgets;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.ComponentModel;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading;
8 | using System.Threading.Tasks;
9 | using System.Xml.Serialization;
10 |
11 | namespace CLRCLI
12 | {
13 | public enum BorderStyle
14 | {
15 | Block,
16 | Thick,
17 | Thin,
18 | None
19 | }
20 |
21 | public abstract class Widget
22 | {
23 | [XmlAttribute]
24 | public string Id { get; set; }
25 | [XmlAttribute]
26 | public int Top { get; set; }
27 | [XmlAttribute]
28 | public int Left { get; set; }
29 | [XmlAttribute]
30 | public int Width { get; set; }
31 | [XmlAttribute]
32 | public int Height { get; set; }
33 | [XmlAttribute]
34 | [DefaultValue(ConsoleColor.Gray)]
35 | public ConsoleColor Background { get; set; }
36 | [XmlAttribute]
37 | [DefaultValue(ConsoleColor.White)]
38 | public ConsoleColor Foreground { get; set; }
39 | [XmlAttribute]
40 | [DefaultValue(ConsoleColor.Magenta)]
41 | public ConsoleColor SelectedBackground { get; set; }
42 | [XmlAttribute]
43 | [DefaultValue(ConsoleColor.DarkMagenta)]
44 | public ConsoleColor ActiveBackground { get; set; }
45 | [XmlAttribute]
46 | [DefaultValue(ConsoleColor.Black)]
47 | public ConsoleColor ActiveForeground { get; set; }
48 | [XmlAttribute]
49 | [DefaultValue(0)]
50 | public int TabStop { get; set; }
51 | [XmlAttribute]
52 | [DefaultValue(BorderStyle.Block)]
53 | public BorderStyle Border { get; set; }
54 | [XmlAttribute]
55 | [DefaultValue(true)]
56 | public bool Enabled { get; set; }
57 | [XmlAttribute]
58 | [DefaultValue(false)]
59 | public bool DrawShadow { get; set; }
60 |
61 | [XmlIgnore]
62 | public Widget Parent {get; internal set;}
63 |
64 | private bool _HasFocus;
65 | [XmlIgnore]
66 | public bool HasFocus
67 | {
68 | get
69 | {
70 | return _HasFocus;
71 | }
72 | internal set
73 | {
74 | if (value != _HasFocus)
75 | {
76 | _HasFocus = value;
77 | if (value)
78 | {
79 | if (GotFocus != null) { GotFocus(this, EventArgs.Empty); }
80 | }
81 | else
82 | {
83 | if (LostFocus != null) { LostFocus(this, EventArgs.Empty); }
84 | }
85 | }
86 | }
87 | }
88 |
89 | internal void FireTextChanged()
90 | {
91 | if (TextChanged != null) { TextChanged(this, EventArgs.Empty); }
92 | }
93 |
94 | internal string _Text = "";
95 | [XmlAttribute]
96 | [DefaultValue("")]
97 | public string Text
98 | {
99 | get { return _Text; }
100 | set
101 | {
102 | if (value != _Text)
103 | {
104 | bool parentRedraw = false;
105 | if (value.Length < _Text.Length)
106 | {
107 | parentRedraw = true;
108 | }
109 | _Text = value;
110 |
111 | if (TextChanged != null) { TextChanged(this, EventArgs.Empty); }
112 |
113 | if (Parent != null)
114 | {
115 | if (parentRedraw) { Parent.Draw(); }
116 | else { Draw(); }
117 | }
118 | }
119 | }
120 | }
121 |
122 | internal ConsoleHelper.DrawBoxMethod BorderDrawMethod
123 | {
124 | get
125 | {
126 | switch (Border)
127 | {
128 | case BorderStyle.Block: return ConsoleHelper.DrawBlockOutline;
129 | case BorderStyle.Thick: return ConsoleHelper.DrawDoubleOutline;
130 | case BorderStyle.Thin: return ConsoleHelper.DrawSingleOutline;
131 | default: return ConsoleHelper.DrawNothing;
132 | }
133 | }
134 | }
135 |
136 | internal string ShortenString(string input, int maxLen)
137 | {
138 | if (input.Length < maxLen)
139 | {
140 | return input;
141 | }
142 |
143 | return input.Substring(0, maxLen);
144 | }
145 |
146 | internal void DrawBackground()
147 | {
148 | ConsoleHelper.DrawRectSolid(DisplayLeft, DisplayTop, Width, Height, Background);
149 | }
150 |
151 | [XmlElement(typeof(Border)), XmlElement(typeof(Button)), XmlElement(typeof(Checkbox)),
152 | XmlElement(typeof(Dialog)), XmlElement(typeof(HorizontalBarGraph)), XmlElement(typeof(HorizontalLine)), XmlElement(typeof(VerticalLine)),
153 | XmlElement(typeof(HorizontalProgressBar)), XmlElement(typeof(Label)), XmlElement(typeof(ListBox)),
154 | XmlElement(typeof(RadioButton)), XmlElement(typeof(SingleLineTextbox)), XmlElement(typeof(SlideToggle)),
155 | XmlElement(typeof(Spinner)), XmlElement(typeof(TinySpinner))]
156 | public List Children { get; set; }
157 |
158 | internal abstract void Render();
159 |
160 | public event EventHandler Clicked;
161 | public event EventHandler GotFocus;
162 | public event EventHandler LostFocus;
163 | public event EventHandler TextChanged;
164 |
165 | private bool _visible = true;
166 | [XmlAttribute]
167 | [DefaultValue(true)]
168 | public bool Visible
169 | {
170 | get
171 | {
172 | return _visible;
173 | }
174 | set
175 | {
176 | if (value != _visible)
177 | {
178 | _visible = value;
179 |
180 | /*
181 | * Null check prevents drawing before fully instantiated (specifically when there's no parent).
182 | * Works because everything (Except RootWindow) has a parent but only after it has been fully set up.
183 | */
184 | if (Parent != null) { Draw(); }
185 | }
186 | }
187 | }
188 |
189 | [XmlIgnore]
190 | public bool IsVisible
191 | {
192 | get
193 | {
194 | return this.Visible && (Parent == null ? true : Parent.IsVisible);
195 | }
196 | }
197 |
198 | [XmlIgnore]
199 | public int DisplayTop
200 | {
201 | get
202 | {
203 | return (Parent == null) ? Top : Parent.DisplayTop + Top;
204 | }
205 | }
206 |
207 | [XmlIgnore]
208 | public int DisplayLeft
209 | {
210 | get
211 | {
212 | return (Parent == null) ? Top : Parent.DisplayLeft + Left;
213 | }
214 | }
215 |
216 | internal void FireClicked()
217 | {
218 | if (Clicked != null)
219 | {
220 | var OldBG = ActiveBackground;
221 | ActiveBackground = SelectedBackground;
222 | Draw();
223 | Thread.Sleep(100);
224 | ActiveBackground = OldBG;
225 | Draw();
226 | Clicked(this, EventArgs.Empty);
227 | }
228 | }
229 |
230 | internal Widget(){}
231 | public Widget(Widget parent)
232 | {
233 | Visible = true;
234 | Enabled = true;
235 | Children = new List();
236 | Parent = parent;
237 | if (parent != null)
238 | {
239 | parent.Children.Add(this);
240 | RootWindow.AllChildren.Add(this);
241 | }
242 | }
243 |
244 | internal void FixChildParents(RootWindow root)
245 | {
246 | Children.ForEach(c =>
247 | {
248 | root.AllChildren.Add(c);
249 | c.Parent = this;
250 | c.FixChildParents(root);
251 | });
252 | }
253 |
254 | [XmlIgnore]
255 | public RootWindow RootWindow
256 | {
257 | get
258 | {
259 | if (CachedRootWindow == null) { CachedRootWindow = FindRootWindow(); }
260 | return CachedRootWindow;
261 | }
262 | }
263 |
264 | private RootWindow CachedRootWindow = null;
265 |
266 | private RootWindow FindRootWindow()
267 | {
268 | if (this.GetType() == typeof(RootWindow))
269 | {
270 | return (RootWindow)this;
271 | }
272 | else
273 | {
274 | return Parent.FindRootWindow();
275 | }
276 | }
277 |
278 | [XmlIgnore]
279 | public List Siblings
280 | {
281 | get
282 | {
283 | if (Parent == null)
284 | {
285 | return new List();
286 | }
287 | else
288 | {
289 | return Parent.Children;
290 | }
291 | }
292 | }
293 |
294 | public void SetFocus()
295 | {
296 | RootWindow.ActiveWidget = this;
297 | }
298 |
299 | internal void Draw()
300 | {
301 | if (RootWindow.AllowDraw == false) { return; }
302 | if (Visible && (Parent == null || Parent.Visible))
303 | {
304 | lock (Console.Out)
305 | {
306 | Render();
307 | }
308 |
309 | if (Children != null)
310 | {
311 | Children.Where(c => c.Visible).ToList().ForEach(c => c.Draw());
312 | }
313 | }
314 | }
315 |
316 | public void Show()
317 | {
318 | Visible = true;
319 | }
320 |
321 | public void Hide()
322 | {
323 | Parent.Render();
324 | Visible = false;
325 | }
326 |
327 | private void Blank()
328 | {
329 | lock (Console.Out)
330 | {
331 | ConsoleHelper.DrawRectSolid(DisplayLeft, DisplayTop, Width, Height, (Parent == null) ? Background : Parent.Background);
332 | }
333 | }
334 |
335 | public Widget FindChildren(string Id)
336 | {
337 | if (Children.Any() == false)
338 | {
339 | return null;
340 | }
341 |
342 | var Find = Children.FirstOrDefault(c => c.Id == Id);
343 |
344 | if (Find != null) { return Find; }
345 |
346 | foreach (var c in Children)
347 | {
348 | var FindInChild = c.FindChildren(Id);
349 | if (FindInChild != null) { return FindInChild; }
350 | }
351 |
352 | return null;
353 | }
354 |
355 | public Widget Nearest() where T : Widget
356 | {
357 | if (this is T) { return this; }
358 | if (this.Parent == null) { return null; }
359 | return Parent.Nearest();
360 | }
361 |
362 | [XmlIgnore]
363 | public List FocusableChildren
364 | {
365 | get
366 | {
367 | return Children.Where(c => c is IFocusable).OrderBy(c => c.TabStop).ToList();
368 | }
369 | }
370 | }
371 | }
372 |
--------------------------------------------------------------------------------
/scripts/dll/CLRCLI-Master/CLRCLI-master/CLRCLI/Widgets/Border.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace CLRCLI.Widgets
8 | {
9 | public class Border : Widget
10 | {
11 | internal Border() { }
12 | public Border(Widget parent) : base(parent)
13 | {
14 | Top = 0;
15 | Left = 0;
16 | Width = 25;
17 | Height = 10;
18 | Background = ConsoleColor.DarkBlue;
19 | Foreground = ConsoleColor.White;
20 | }
21 |
22 | internal override void Render()
23 | {
24 | DrawBackground();
25 | BorderDrawMethod(DisplayLeft, DisplayTop, Width, Height, Foreground);
26 | DrawLabel();
27 | }
28 |
29 | private void DrawLabel()
30 | {
31 | ConsoleHelper.DrawText(DisplayLeft + 2, DisplayTop, Background, Foreground, " {0} ", Text);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/scripts/dll/CLRCLI-Master/CLRCLI-master/CLRCLI/Widgets/Button.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace CLRCLI.Widgets
8 | {
9 | public class Button : Widget, IFocusable
10 | {
11 | internal Button() {}
12 | public Button(Widget parent)
13 | : base(parent)
14 | {
15 | ActiveBackground = ConsoleColor.DarkMagenta;
16 | SelectedBackground = ConsoleColor.Magenta;
17 | Background = ConsoleColor.DarkGray;
18 | Foreground = ConsoleColor.White;
19 | DrawShadow = true;
20 | Text = "Button";
21 | Width = 10;
22 | Height = 3;
23 | }
24 |
25 | internal override void Render()
26 | {
27 | if (HasFocus)
28 | {
29 | if (DrawShadow)
30 | {
31 | ConsoleHelper.DrawRectShade(DisplayLeft + 1, DisplayTop + 1, Width, Height, Parent.Background, ConsoleColor.DarkGray, '▒');
32 | }
33 | ConsoleHelper.DrawRectSolid(DisplayLeft, DisplayTop, Width, Height, ActiveBackground);
34 | }
35 | else
36 | {
37 | ConsoleHelper.DrawRectShade(DisplayLeft + 1, DisplayTop + 1, Width, Height, Parent.Background, ConsoleColor.DarkGray, ' '); //Erase the shadow
38 | DrawBackground();
39 | }
40 |
41 | ConsoleHelper.DrawText(DisplayLeft + (Width / 2) - (Text.Length / 2), DisplayTop + (Height / 2), Foreground, Text);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/scripts/dll/CLRCLI-Master/CLRCLI-master/CLRCLI/Widgets/Checkbox.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Xml.Serialization;
7 |
8 | namespace CLRCLI.Widgets
9 | {
10 | public class Checkbox : Widget, IFocusable
11 | {
12 | internal Checkbox() {
13 | this.Clicked += Checkbox_Clicked;
14 | }
15 | public Checkbox(Widget parent)
16 | : base(parent)
17 | {
18 | Foreground = ConsoleColor.White;
19 | Background = Parent.Background;
20 | SelectedBackground = ConsoleColor.Magenta;
21 | ActiveBackground = ConsoleColor.DarkMagenta;
22 | Text = "Checkbox";
23 | this.Clicked += Checkbox_Clicked;
24 | }
25 |
26 | void Checkbox_Clicked(object sender, EventArgs e)
27 | {
28 | Checked = !Checked;
29 | }
30 |
31 | public event EventHandler ValueChanged;
32 |
33 | private bool _checked;
34 | [XmlAttribute]
35 | public bool Checked
36 | {
37 | get
38 | {
39 | return _checked;
40 | }
41 | set
42 | {
43 | if (value != _checked)
44 | {
45 | _checked = value;
46 | Draw();
47 | if (ValueChanged != null) { ValueChanged(this, EventArgs.Empty); }
48 | }
49 | }
50 | }
51 |
52 | internal override void Render()
53 | {
54 | char c = (Checked) ? 'X' : ' ';
55 |
56 | if (HasFocus)
57 | {
58 | ConsoleHelper.DrawText(DisplayLeft, DisplayTop, Foreground, ActiveBackground, "[{0}]", c);
59 | ConsoleHelper.DrawText(DisplayLeft + 4, DisplayTop, Foreground, Background, Text);
60 | }
61 | else
62 | {
63 | ConsoleHelper.DrawText(DisplayLeft, DisplayTop, Foreground, Background, "[{0}] {1}", c, Text);
64 | }
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/scripts/dll/CLRCLI-Master/CLRCLI-master/CLRCLI/Widgets/Dialog.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace CLRCLI.Widgets
8 | {
9 | public class Dialog : Widget
10 | {
11 | internal Dialog() { }
12 | public Dialog(Widget parent)
13 | : base(parent)
14 | {
15 | Top = 0;
16 | Left = 0;
17 | Width = 30;
18 | Height = 12;
19 | Background = ConsoleColor.Gray;
20 | Foreground = ConsoleColor.Black;
21 | SelectedBackground = ConsoleColor.Magenta;
22 | ActiveBackground = ConsoleColor.DarkMagenta;
23 | }
24 |
25 | internal override void Render()
26 | {
27 | if (Border == BorderStyle.None)
28 | {
29 | ConsoleHelper.DrawRectShade(DisplayLeft + 1, DisplayTop + 1, Width, Height, Parent.Background, ConsoleColor.Black, '▒');
30 | }
31 | else
32 | {
33 | ConsoleHelper.DrawRectShade(DisplayLeft, DisplayTop, Width + 2, Height + 2, Parent.Background, ConsoleColor.Black, '▓');
34 | }
35 |
36 | DrawBackground();
37 |
38 | BorderDrawMethod(DisplayLeft - 1, DisplayTop - 1, Width + 1, Height + 2, Foreground);
39 | DrawLabel();
40 | }
41 |
42 | private void DrawLabel()
43 | {
44 | ConsoleHelper.DrawText(DisplayLeft + 1, DisplayTop - 1, Background, Foreground, " {0} ", Text);
45 | }
46 |
47 | public new void Show()
48 | {
49 | base.Show();
50 | this.FocusableChildren.FirstOrDefault().SetFocus();
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/scripts/dll/CLRCLI-Master/CLRCLI-master/CLRCLI/Widgets/HorizontalBarGraph.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Xml.Serialization;
7 |
8 | namespace CLRCLI.Widgets
9 | {
10 | public class HorizontalBarGraph : Widget
11 | {
12 | internal HorizontalBarGraph() {
13 | Entries = new List();
14 | }
15 | public HorizontalBarGraph(Widget parent)
16 | : base(parent)
17 | {
18 | Entries = new List();
19 | Foreground = ConsoleColor.DarkGreen;
20 | Background = Parent.Background;
21 | Max = 100;
22 | }
23 |
24 | [XmlAttribute]
25 | public int Max { get; set; }
26 |
27 | private List Entries;
28 |
29 | public void AddPoint(int Value)
30 | {
31 | Entries.Add(Value);
32 | if (Entries.Count > Width) { Entries.RemoveAt(0); }
33 | Draw();
34 | }
35 |
36 | internal override void Render()
37 | {
38 | for (int i = 0; i < Entries.Count; i++)
39 | {
40 | var val = Entries[i];
41 | var scaledVal = (int)(((double)val / (double)Max) * Height);
42 |
43 | for (int j = 0; j < Height; j++)
44 | {
45 | var ch = j < scaledVal ? "│" : " ";
46 | if (j == scaledVal) { ch = "┐"; }
47 | var top = DisplayTop + (Height - j);
48 | ConsoleHelper.DrawText(DisplayLeft + i, top, Foreground, Background, "{0}", ch);
49 | }
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/scripts/dll/CLRCLI-Master/CLRCLI-master/CLRCLI/Widgets/HorizontalLine.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace CLRCLI.Widgets
8 | {
9 | public class HorizontalLine : Widget
10 | {
11 | internal HorizontalLine() { }
12 | public HorizontalLine(Widget parent)
13 | : base(parent)
14 | {
15 | Background = parent.Background;
16 | Foreground = ConsoleColor.Black;
17 | Border = BorderStyle.Thin;
18 | }
19 |
20 | internal override void Render()
21 | {
22 | if (Border != BorderStyle.None)
23 | {
24 | char b = (Border == BorderStyle.Thick) ? '═' : '─';
25 | ConsoleHelper.DrawText(DisplayLeft, DisplayTop, Foreground, Background, new String(b, Width));
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/scripts/dll/CLRCLI-Master/CLRCLI-master/CLRCLI/Widgets/HorizontalProgressBar.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Xml.Serialization;
7 |
8 | namespace CLRCLI.Widgets
9 | {
10 | public class HorizontalProgressBar : Widget
11 | {
12 | private int _value;
13 | [XmlAttribute]
14 | public int Value
15 | {
16 | get
17 | {
18 | return _value;
19 | }
20 | set
21 | {
22 | if (_value != value)
23 | {
24 | _value = value;
25 | if (_value < 0) { _value = 0; }
26 | if (_value > MaxValue) { _value = MaxValue; }
27 | Draw();
28 | }
29 | }
30 | }
31 |
32 | [XmlAttribute]
33 | public int MaxValue { get; set; }
34 |
35 | internal HorizontalProgressBar() {}
36 | public HorizontalProgressBar(Widget parent)
37 | : base(parent)
38 | {
39 | Background = ConsoleColor.DarkGray;
40 | Foreground = ConsoleColor.DarkGreen;
41 | Height = 1;
42 | MaxValue = 100;
43 | Value = 50;
44 | }
45 |
46 | internal override void Render()
47 | {
48 | var scaled = (int)(((Single)Value / MaxValue) * (Single)Width);
49 | var remainder = Width - scaled;
50 |
51 | if (scaled > 0)
52 | {
53 | ConsoleHelper.DrawRectSolid(DisplayLeft, DisplayTop, scaled, Height, Foreground);
54 | }
55 |
56 | if (remainder > 0)
57 | {
58 | ConsoleHelper.DrawRectSolid(DisplayLeft + scaled, DisplayTop, remainder, Height, Background);
59 | }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/scripts/dll/CLRCLI-Master/CLRCLI-master/CLRCLI/Widgets/Interfaces/IAcceptInput.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace CLRCLI.Widgets
8 | {
9 | interface IAcceptInput
10 | {
11 | bool Keypress(ConsoleKeyInfo key);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/scripts/dll/CLRCLI-Master/CLRCLI-master/CLRCLI/Widgets/Interfaces/IFocusable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace CLRCLI.Widgets
8 | {
9 | interface IFocusable
10 | {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/scripts/dll/CLRCLI-Master/CLRCLI-master/CLRCLI/Widgets/Interfaces/IUseCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Xml.Serialization;
7 |
8 | namespace CLRCLI.Widgets
9 | {
10 | interface IUseCommand
11 | {
12 | [XmlAttribute]
13 | string Command { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/scripts/dll/CLRCLI-Master/CLRCLI-master/CLRCLI/Widgets/Label.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace CLRCLI.Widgets
8 | {
9 | public class Label : Widget
10 | {
11 | internal Label() {}
12 | public Label(Widget parent) : base(parent)
13 | {
14 | Background = parent.Background;
15 | Foreground = ConsoleColor.White;
16 | }
17 |
18 | internal override void Render()
19 | {
20 | var lines = Text.Split(new string[]{"\n"}, StringSplitOptions.None);
21 |
22 | for (var i = 0; i < lines.Length; i++)
23 | {
24 | ConsoleHelper.DrawText(DisplayLeft, DisplayTop + i, Foreground, Background, lines[i]);
25 | }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/scripts/dll/CLRCLI-Master/CLRCLI-master/CLRCLI/Widgets/ListBox.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Xml.Serialization;
8 |
9 | namespace CLRCLI.Widgets
10 | {
11 | public class ListBox : Widget, IFocusable, IAcceptInput
12 | {
13 | internal ListBox() {
14 | Items.CollectionChanged += Items_CollectionChanged;
15 | }
16 | public ListBox(Widget Parent)
17 | : base(Parent)
18 | {
19 | Background = ConsoleColor.DarkGray;
20 | Foreground = ConsoleColor.White;
21 | SelectedBackground = ConsoleColor.Magenta;
22 | ActiveBackground = ConsoleColor.DarkMagenta;
23 | Items.CollectionChanged += Items_CollectionChanged;
24 | }
25 |
26 | void Items_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
27 | {
28 | Draw();
29 | }
30 |
31 | [XmlElement("ListItem", typeof(String))]
32 | public ObservableCollection