ControlUp Stress Settings calculator

The ControlUp Stress Settings calculator enables you to use your own historical data to determine how to set your Stress thresholds in the real-time console. The calculator requires historical data exported from ControlUp Monitor of from ControlUp Insights.
For full step-by-step instructions on preparing the data and using the calculator, please visit the following page:
https://support.controlup.com/hc/en-us/articles/360013867718
Version 1.13.25
Created on 2020-12-18
Modified on 2021-01-17
Created by Wouter Kursten
Downloads: 451

The Script Copy Script Copied to clipboard
[CmdletBinding()]
param (
    [parameter(Position=3, Mandatory = $false,
        HelpMessage = "Default Location of the folder with the ControlUp monitor export files.")]
    [string]$sourcepath = [Environment]::GetFolderPath("Desktop"),
    [parameter(Position=4, Mandatory = $false,
    HelpMessage = "Default location where csv's will be exported to.")]
    [string]$ExportPath = [Environment]::GetFolderPath("Desktop"),
    [parameter(Position=0,Mandatory = $false,
        HelpMessage = "Percentile used for yellow stress levels.")]
    [string]$yellowpercentile = 75,
    [parameter(Position=1,Mandatory = $false,
        HelpMessage = "Percentile used for red stress levels.")]
    [string]$redpercentile = 90,
    [parameter(Position=2,Mandatory = $false,
        HelpMessage = "Array with usernames or parts of usernames that shouldn't be taken into the calculations.")]
    [array]$filteredaccounts
)

<#
.SYNOPSIS
        This script can be used to calculate suggested Stress tresholds for ControlUp Real-Time Console
.DESCRIPTION
        This script uses either automated Monitor exports or Insights Exports as a base to calculate recommended Stres Tresholds for the ControlUp Console.
.PARAMETER Sourcepath
        This is an optional parameter pointing to a folder where the source files are located i.e. c:\dataset\
        Will default to the users desktop if the path can't be found or was not configured.
.PARAMETER Sourcepath
        This is an optional parameter pointing to a folder where the csv file will be exported to i.e. c:\export\
        Will default to the users desktop if the path can't be found or was not configured.
.PARAMETER yellowpercentile
        Number for the percentile to be used for recommending the Yellow Treshold
        Defaults to 75 if not configured.
.PARAMETER redpercentile
        Number for the percentile to be used for recommending the Yellow Treshold
        Defaults to 75 if not configured.
.PARAMETER Filteredaccounts
        Array of (parts of) accounts to be filtered out for the session metrics. i.e. "loginbot,wouterk,user1"
        No wildcards needed parts of accounts will also work.
.EXAMPLE
        If you want to specify the username and the session id:
        ./"Analyze Blast Bandwidth.ps1" "1" "controlup\samuel.legrand"
        In order to analyze the current session (no specific right needed):
        ./"Analyze Blast Bandwidth.ps1"
.OUTPUTS
        A list of the measured virtual channels with the bandwidth consumption in kbps.
.LINK
        https://www.powershellgallery.com/packages/Formulaic/0.2.1.0/Content/Get-Median.ps1
        https://gist.github.com/jbirley/f4c7775007aabbcf6b67b9160276b198
#>


if($verboseoutput -eq $True) {
    $VerbosePreference = "Continue"
}
if (test-path $sourcepath){
    $SourcePath=$sourcepath
    write-verbose -Message "Set default sourcepath to $sourcepath"
}
else{
    write-verbose -Message "Error validating sourcepath switching to default (Desktop)"
    [string]$SourcePath=[Environment]::GetFolderPath("Desktop")
}

if (test-path $ExportPath){
    $ExportPath=$ExportPath
    write-verbose -Message "Set default ExportPath to $ExportPath"
}
else{
    write-verbose -Message "Error validating exportpath switching to default (Desktop)"
    [string]$ExportPath=[Environment]::GetFolderPath("Desktop")
}

write-verbose -Message "Configured Yellow treshold percentile as $yellowpercentile "
write-verbose -Message "Configured Red treshold percentile as $redpercentile "

if($null -ne $filteredaccounts){
    write-verbose -message "Filtered accounts: $filteredaccounts."
    $Userfilter=New-Object System.Collections.ArrayList
    $filteredaccounts.Split(",") | foreach-object  {
        [void]$userfilter.add($_)
        write-verbose -message "Added $_ to user filter"
    }
}


$filteredmetrics="Id,Stress Level,AWS Owner,Hypervisor Platform,HZ Is Licensed,VM Snapshot Exists,VM Tools Version,Registered IP Addresses,NTP Status,Number of NICs,SSH enabled,vCPU/pCPU Ratio,GPU encoder Utilization,GPU Frame Buffer Memory Utilization,GPU decoder Utilization,Frames Per Second,Packet Loss"
$metricfilter=New-Object System.Collections.ArrayList
$filteredmetrics.Split(",") | foreach-object  {
    [void]$metricfilter.add($_)
    write-verbose -message "Added $_ to Metric filter"
}

# Create arrays for both monitor and Insights related data
$Monitor_Sourcedata=New-Object System.Collections.ArrayList
$Monitor_Data=New-Object System.Collections.ArrayList
$Insights_Sourcedata=New-Object System.Collections.ArrayList
$Insights_Data=New-Object System.Collections.ArrayList

# Load the assemblies for the GUI
Add-Type -AssemblyName PresentationFramework
Add-Type -AssemblyName System.Windows.Forms
add-Type -AssemblyName WindowsBase
#Region XAML
$xaml = @"
<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="ControlUp Stress Settings Calculator" Height="550" Width="1024">
    <Grid>
        <TabControl>
            <TabItem Header="Monitor Data">
                <ScrollViewer
                    HorizontalScrollBarVisibility = "auto"
                    VerticalScrollBarVisibility = "auto">
                    <Canvas Height="440" Width="950">
                        <TextBox
                            x:Name = "Monitor_Folder_TextBox"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Top"
                            Height="auto"
                            Width="200"
                            Margin="20,20,0,0"
                            Text="$SourcePath"
                            HorizontalScrollBarVisibility = "auto"
                        />
                        <Button x:Name="Monitor_Select_Folder"
                            Content="Browse"
                            HorizontalAlignment="Left"
                            Height="20"
                            Width="100"
                            Margin="250,20,0,0"
                            VerticalAlignment="Top"
                            ClickMode="Press"
                            ToolTip="See the Help tab for more information on how to get the required files from the ControlUp Monitors."
                        />
                        <Button x:Name="Monitor_Load_Data"
                            Content="Load Data"
                            HorizontalAlignment="Left"
                            Height="20"
                            Width="100"
                            Margin="380,20,0,0"
                            VerticalAlignment="Top"
                            ClickMode="Press"
                            ToolTip="Depending on the amount of files and file sizes it might take some time to load the data."
                        />
                        <ComboBox x:Name="Monitor_SourceType"
                            IsEditable="True"
                            IsReadOnly="True"
                            Text = "Select Data Source"
                            HorizontalAlignment="Left"
                            Height="20"
                            Width="200"
                            Margin="20,70,0,0"
                            VerticalAlignment="Top"
                            IsSynchronizedWithCurrentItem="True"
                        >
                                <ComboBoxItem Content="Sessions"/>
                                <ComboBoxItem Content="Hosts"/>
                                <ComboBoxItem Content="Machines"/>
                                <ComboBoxItem Content="Folders"/>
                        </ComboBox>
                        <ComboBox x:Name="Monitor_Available_Metrics"
                            IsEditable="True"
                            IsReadOnly="True"
                            Text = "Load Data first"
                            HorizontalAlignment="Left"
                            Height="20"
                            Width="200"
                            Margin="20,100,0,0"
                            VerticalAlignment="Top"
                            ToolTip="Load data first before metrics are visible"
                        />
                        <ComboBox x:Name="Monitor_Folder_Selector"
                            IsEditable="True"
                            IsReadOnly="True"
                            Text = "Select a folder"
                            HorizontalAlignment="Left"
                            Visibility = "Hidden"
                            Height="20"
                            Width="200"
                            Margin="20,130,0,0"
                            VerticalAlignment="Top"
                            ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=SelectedValue}"
                        >
                        </ComboBox>
                        <DataGrid x:Name="Monitor_Datagrid" AutoGenerateColumns="True"
                            Margin="20,160,0,0"
                            Height="200"
                            Width="800"
                            IsReadOnly = "true"
                            HorizontalScrollBarVisibility = "Auto"
                            VerticalScrollBarVisibility = "Auto"
                        >
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="Metric Name" Binding="{Binding Name}" Width="auto" >
                                    <DataGridTextColumn.CellStyle>
                                        <Style TargetType="DataGridCell">
                                            <Setter Property="ToolTip" Value="{Binding name}" />
                                        </Style>
                                    </DataGridTextColumn.CellStyle>
                                </DataGridTextColumn>
                                <DataGridTextColumn Header="Metric Source" Binding="{Binding Source}" Width="auto">
                                    <DataGridTextColumn.CellStyle>
                                        <Style TargetType="DataGridCell">
                                            <Setter Property="ToolTip" Value="{Binding Source}" />
                                        </Style>
                                    </DataGridTextColumn.CellStyle>
                                </DataGridTextColumn>
                                <DataGridTextColumn Header="Source Folder" Binding="{Binding Folder}" Width="auto">
                                    <DataGridTextColumn.CellStyle>
                                        <Style TargetType="DataGridCell">
                                            <Setter Property="ToolTip" Value="{Binding Folder}" />
                                        </Style>
                                    </DataGridTextColumn.CellStyle>
                                </DataGridTextColumn>
                                <DataGridTextColumn Header="Suggested Stress Treshold" Binding="{Binding Stress_Level}" Width="auto">
                                    <DataGridTextColumn.CellStyle>
                                        <Style TargetType="DataGridCell">
                                            <Setter Property="ToolTip" Value="{Binding Stress_Level}" />
                                        </Style>
                                    </DataGridTextColumn.CellStyle>
                                </DataGridTextColumn>
                                <DataGridTextColumn Header="Calculation" Binding="{Binding Calculation}" Width="auto">
                                    <DataGridTextColumn.CellStyle>
                                        <Style TargetType="DataGridCell">
                                            <Setter Property="ToolTip" Value="{Binding Calculation}" />
                                        </Style>
                                    </DataGridTextColumn.CellStyle>
                                </DataGridTextColumn>
                                <DataGridTextColumn Header="Value" Binding="{Binding Value}" Width="auto">
                                    <DataGridTextColumn.CellStyle>
                                        <Style TargetType="DataGridCell">
                                            <Setter Property="ToolTip" Value="{Binding Value}" />
                                        </Style>
                                    </DataGridTextColumn.CellStyle>
                                </DataGridTextColumn>
                                <DataGridTextColumn Header="Datapoints" Binding="{Binding Datapoints}" Width="auto">
                                    <DataGridTextColumn.CellStyle>
                                        <Style TargetType="DataGridCell">
                                            <Setter Property="ToolTip" Value="{Binding Datapoints}" />
                                        </Style>
                                    </DataGridTextColumn.CellStyle>
                                </DataGridTextColumn>
                            </DataGrid.Columns>
                        </DataGrid>
                        <Button x:Name="Monitor_Export"
                            Content="Export to CSV"
                            HorizontalAlignment="Left"
                            Height="20"
                            Width="100"
                            Margin="20,390,0,0"
                            VerticalAlignment="Top"
                            ClickMode="Press"
                        />
                        <Button x:Name="Monitor_Copy"
                            Content="Copy CSV Data"
                            HorizontalAlignment="Left"
                            Height="20"
                            Width="100"
                            Margin="140,390,0,0"
                            VerticalAlignment="Top"
                            ClickMode="Press"
                        />
                        <Button x:Name="Monitor_Clear"
                            Content="Clear"
                            HorizontalAlignment="Left"
                            Height="20"
                            Width="100"
                            Margin="260,390,0,0"
                            VerticalAlignment="Top"
                            ClickMode="Press"
                        />
                        <CheckBox x:Name="Monitor_Show_Median"
                            Content = 'Show Median'
                            HorizontalAlignment="Left"
                            Height="20"
                            Width="100"
                            Margin="250,70,0,0"
                            VerticalAlignment="Top"
                        />
                        <CheckBox x:Name="Monitor_Show_Average"
                            Content = 'Show Average'
                            HorizontalAlignment="Left"
                            Height="20"
                            Width="100"
                            Margin="250,100,0,0"
                            VerticalAlignment="Top"
                        />
                        <CheckBox x:Name="Monitor_Ignore_0_values"
                            Content = 'Ignore 0 values'
                            HorizontalAlignment="Left"
                            Height="20"
                            Width="150"
                            Margin="380,70,0,0"
                            VerticalAlignment="Top"
                            ToolTip="If checked values that have a value of 0 or that show N/A in the grid will be ignored"
                        />
                        <Image x:Name="Monitor_Image" Height="150" Canvas.Left="510" Canvas.Top="5" Width="112"/>
                            <TextBlock
                            Height="20"
                            Width="20"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Top"
                            TextWrapping="Wrap"
                            Margin="540,50,0,0"
                            ToolTip="Isn't VEronica awesome?"
                        />
                    </Canvas>
                </ScrollViewer>
            </TabItem>
            <TabItem Header="Insights Data">
                <ScrollViewer
                    HorizontalScrollBarVisibility = "auto"
                    VerticalScrollBarVisibility = "auto">
                    <Canvas Height="440" Width="950">
                        <TextBox
                            x:Name = "Insights_File_TextBox"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Top"
                            Height="auto"
                            Width="200"
                            Margin="20,20,0,0"
                            Text="$SourcePath"
                            ToolTip="$sourcepath"
                            HorizontalScrollBarVisibility = "auto"
                        />
                        <Button x:Name="Insights_Select_File"
                            Content="Browse"
                            HorizontalAlignment="Left"
                            Height="20"
                            Width="100"
                            Margin="250,20,0,0"
                            VerticalAlignment="Top"
                            ClickMode="Press"
                            ToolTip="See the Help tab for more information on how to get the required files from ControlUp Insights."
                        />
                        <ComboBox x:Name="Insights_Available_Metrics"
                            IsEditable="True"
                            IsReadOnly="True"
                            Text = "Load Data first"
                            HorizontalAlignment="Left"
                            Height="20"
                            Width="200"
                            Margin="20,100,0,0"
                            VerticalAlignment="Top"
                            ToolTip="Load data first before metrics are visible"
                        />
                        <ComboBox x:Name="Insights_Folder_Selector"
                            IsEditable="True"
                            IsReadOnly="True"
                            Text = "Select a folder"
                            HorizontalAlignment="Left"
                            Visibility = "Hidden"
                            Height="20"
                            Width="200"
                            Margin="20,130,0,0"
                            VerticalAlignment="Top"
                            ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=SelectedValue}"
                        >
                        </ComboBox>
                        <DataGrid x:Name="Insights_Datagrid" AutoGenerateColumns="True"
                            Margin="20,160,0,0"
                            Height="200"
                            Width="580"
                            IsReadOnly = "true"
                            HorizontalScrollBarVisibility = "Auto"
                            VerticalScrollBarVisibility = "Auto"
                        >
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="Metric Name" Binding="{Binding Name}" Width="auto" >
                                    <DataGridTextColumn.CellStyle>
                                        <Style TargetType="DataGridCell">
                                            <Setter Property="ToolTip" Value="{Binding name}" />
                                        </Style>
                                    </DataGridTextColumn.CellStyle>
                                    </DataGridTextColumn>
                                <DataGridTextColumn Header="Suggested Stress Treshold" Binding="{Binding Stress_Level}" Width="auto">
                                    <DataGridTextColumn.CellStyle>
                                    <Style TargetType="DataGridCell">
                                        <Setter Property="ToolTip" Value="{Binding Stress_Level}" />
                                    </Style>
                                </DataGridTextColumn.CellStyle>
                                </DataGridTextColumn>
                                <DataGridTextColumn Header="Calculation" Binding="{Binding Calculation}" Width="auto">
                                    <DataGridTextColumn.CellStyle>
                                        <Style TargetType="DataGridCell">
                                            <Setter Property="ToolTip" Value="{Binding Calculation}" />
                                        </Style>
                                    </DataGridTextColumn.CellStyle>
                                </DataGridTextColumn>
                                <DataGridTextColumn Header="Value" Binding="{Binding Value}" Width="auto">
                                    <DataGridTextColumn.CellStyle>
                                        <Style TargetType="DataGridCell">
                                            <Setter Property="ToolTip" Value="{Binding Value}" />
                                        </Style>
                                    </DataGridTextColumn.CellStyle>
                                </DataGridTextColumn>
                                <DataGridTextColumn Header="Datapoints" Binding="{Binding Datapoints}" Width="auto">
                                <DataGridTextColumn.CellStyle>
                                    <Style TargetType="DataGridCell">
                                        <Setter Property="ToolTip" Value="{Binding Datapoints}" />
                                    </Style>
                                </DataGridTextColumn.CellStyle>
                            </DataGridTextColumn>
                            </DataGrid.Columns>
                        </DataGrid>
                        <Button x:Name="Insights_Export"
                            Content="Export to CSV"
                            HorizontalAlignment="Left"
                            Height="20"
                            Width="100"
                            Margin="20,390,0,0"
                            VerticalAlignment="Top"
                            ClickMode="Press"
                        />
                        <Button x:Name="Insights_Load_Data"
                            Content="Load Data"
                            HorizontalAlignment="Left"
                            Height="20"
                            Width="100"
                            Margin="380,20,0,0"
                            VerticalAlignment="Top"
                            ClickMode="Press"
                            ToolTip="Depending on the file size it might take some time to load the data."
                        />
                        <Button x:Name="Insights_Copy"
                            Content="Copy CSV Data"
                            HorizontalAlignment="Left"
                            Height="20"
                            Width="100"
                            Margin="140,390,0,0"
                            VerticalAlignment="Top"
                            ClickMode="Press"
                        />
                        <Button x:Name="Insights_Clear"
                            Content="Clear"
                            HorizontalAlignment="Left"
                            Height="20"
                            Width="100"
                            Margin="260,390,0,0"
                            VerticalAlignment="Top"
                            ClickMode="Press"
                        />
                        <CheckBox x:Name="Insights_Show_Median"
                            Content = 'Show Median'
                            HorizontalAlignment="Left"
                            Height="20"
                            Width="100"
                            Margin="250,70,0,0"
                            VerticalAlignment="Top"
                        />
                        <CheckBox x:Name="Insights_Show_Average"
                            Content = 'Show Average'
                            HorizontalAlignment="Left"
                            Height="20"
                            Width="100"
                            Margin="250,100,0,0"
                            VerticalAlignment="Top"
                        />
                        <CheckBox x:Name="Insights_Ignore_0_values"
                            Content = 'Ignore 0 values'
                            HorizontalAlignment="Left"
                            Height="20"
                            Width="150"
                            Margin="380,70,0,0"
                            VerticalAlignment="Top"
                            ToolTip="If checked values that have a value of 0 will be ignored"
                        />
                        <Image x:Name="Insights_Image" Height="150" Canvas.Left="510" Canvas.Top="5" Width="112"/>
                        <TextBlock
                            Height="20"
                            Width="20"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Top"
                            TextWrapping="Wrap"
                            Margin="540,50,0,0"
                            ToolTip="Isn't VEronica awesome?"
                        />
                    </Canvas>
                </ScrollViewer>
            </TabItem>
            <TabItem Header="Help">
                <ScrollViewer
                    HorizontalScrollBarVisibility = "auto"
                    VerticalScrollBarVisibility = "auto">
                    <Canvas Height="440" Width="900">
                        <RichTextBox
                            HorizontalScrollBarVisibility = "Disabled"
                            VerticalScrollBarVisibility = "auto"
                            Height="65"
                            Width="880"
                            BorderThickness="0"
                            IsReadOnly="True"
                            Margin="10,10,0,0">
                            <FlowDocument>
                                <Paragraph  Margin="6" TextAlignment="Left" FontWeight="Bold" FontSize="18">About</Paragraph>
                                <Paragraph  Margin="6" TextAlignment="Left">The ControlUp Stress Settings Calculator enables you to use your own data to determine how to set your Stress Thresholds in the Real-Time Console.
                                <LineBreak/>
                                For a full guide on using the tool, access the Knowledge Base article linked from the bottom of this page.
                                </Paragraph>
                            </FlowDocument>
                        </RichTextBox>
                            <RichTextBox
                                HorizontalScrollBarVisibility = "Disabled"
                                VerticalScrollBarVisibility = "auto"
                                Height="30"
                                Width="880"
                                BorderThickness="0"
                                IsReadOnly="True"
                                Margin="10,75,0,0">
                                <FlowDocument>
                                    <Paragraph Margin="6" TextAlignment="Left" FontWeight="Bold" FontSize="18">Usage</Paragraph>
                                </FlowDocument>
                            </RichTextBox>
                            <RichTextBox
                                HorizontalScrollBarVisibility = "Disabled"
                                VerticalScrollBarVisibility = "auto"
                                Height="280"
                                Width="880"
                                BorderThickness="0"
                                IsReadOnly="True"
                                Margin="10,100,0,0">
                                <FlowDocument>
                                    <Paragraph Margin="6" TextAlignment="Left"><Bold>Browse</Bold>
                                    <LineBreak/>
                                    Select the location of the CSV file exported from Insights data, or the folder for the exported Monitor Data. Alternatively, copy/paste the location into the empty field.
                                    </Paragraph>
                                    <Paragraph Margin="6" TextAlignment="Left"><Bold>Load Data</Bold>
                                    <LineBreak/>
                                    Once you selected or entered the location, click to load the data into the tool.
                                    </Paragraph>
                                    <Paragraph Margin="6" TextAlignment="Left"><Bold>Select Data Source</Bold>
                                    <LineBreak/>
                                    For Monitor Data only, select from the dropdown options, which include: Sessions, Hosts, Machines, Folders - per the views displayed in the Real-Time Console.
                                    </Paragraph>
                                    <Paragraph Margin="6" TextAlignment="Left"><Bold>Select Metric</Bold>
                                    <LineBreak/>
                                    Use the dropdown list to select which metric you want to see results for and set stress thresholds.
                                    </Paragraph>
                                    <Paragraph Margin="6" TextAlignment="Left" FontWeight="Bold" FontSize="18">Options</Paragraph>
                                    <Paragraph Margin="6" TextAlignment="Left"><Bold>Select a folder</Bold>
                                    <LineBreak/>
                                    When you select Folders, Hosts or Machines as the Data Source for Monitor Data, you can filter the metrics to calculate by selecting a folder from your organization tree.
                                    </Paragraph>
                                    <Paragraph Margin="6" TextAlignment="Left"><Bold>Show Median</Bold>
                                    <LineBreak/>
                                    Select to also display the median value of the imported metrics.
                                    </Paragraph>
                                    <Paragraph Margin="6" TextAlignment="Left"><Bold>Show average</Bold>
                                    <LineBreak/>
                                    Select to also display the average value of the imported metrics.
                                    </Paragraph>
                                    <Paragraph Margin="6" TextAlignment="Left"><Bold>Ignore 0 values</Bold>
                                    <LineBreak/>
                                    Select to ignore all values of 0 or n/a that might otherwise skew the threshold percentage values.
                                    </Paragraph>
                                    <Paragraph Margin="6" TextAlignment="Left" FontWeight="Bold" FontSize="18">Tips</Paragraph>
                                    <Paragraph Margin="6" TextAlignment="Left">- Once the data comes in, you can drag the column widths to easily view the values.
                                    <LineBreak/>
                                    - The <Bold>Suggested Stress Threshold</Bold> column gives you the stress level you should define for Yellow and Red values.
                                    <LineBreak/>
                                    - If you will need to refer to this data, you can select <Bold>Export to CSV</Bold> or <Bold>Copy CSV Data</Bold>.
                                    <LineBreak/>
                                    - Click <Bold>Clear</Bold> to start a new calculation.
                                    </Paragraph>
                                </FlowDocument>
                        </RichTextBox>
                            <RichTextBox
                            HorizontalScrollBarVisibility = "Disabled"
                            VerticalScrollBarVisibility = "auto"
                            Height="30"
                            Width="880"
                            BorderThickness="0"
                            IsReadOnly="True"
                            Margin="10,380,0,0">
                            <FlowDocument>
                                <Paragraph Margin="6" TextAlignment="Left" FontWeight="Bold" FontSize="18">Links</Paragraph>
                            </FlowDocument>
                        </RichTextBox>
                        <Label x:Name="Help_Link1" Content="Full instructions in this Knowledge Base article." HorizontalAlignment="Left" Margin="16,400,0,0" VerticalAlignment="Top" Width="auto" FontSize='14' Foreground='DarkBlue' Cursor="Hand" ToolTip='ControlUp KB'/>
                        <Label x:Name="Help_Link2" Content="Video guide on YouTube." HorizontalAlignment="Left" Margin="16,415,0,0" VerticalAlignment="Top" Width="auto" FontSize='14' Foreground='DarkBlue' Cursor="Hand" ToolTip='Youtube'/>
                    </Canvas>
                </ScrollViewer>
            </TabItem>
        </TabControl>
    </Grid>
</Window>
"@
#Endregion

#region Generic Functions

function DecodeBase64Image {
    param (
        [Parameter(Mandatory=$true)]
        [String]$ImageBase64
    )
    # Parameter help description
    $ObjBitmapImage = New-Object System.Windows.Media.Imaging.BitmapImage #Provides a specialized BitmapSource that is optimized for loading images using Extensible Application Markup Language (XAML).
    $ObjBitmapImage.BeginInit() #Signals the start of the BitmapImage initialization.
    $ObjBitmapImage.StreamSource = [System.IO.MemoryStream][System.Convert]::FromBase64String($ImageBase64) #Creates a stream whose backing store is memory.
    $ObjBitmapImage.EndInit() #Signals the end of the BitmapImage initialization.
    $ObjBitmapImage.Freeze() #Makes the current object unmodifiable and sets its IsFrozen property to true.
    $ObjBitmapImage
}
Function Get-filecontent {
    # Uses iostream to read the csv files
    Param(
    [string]$file
    )
    Process
    {
        $read = New-Object System.IO.StreamReader($file)
        #$filecontent = @()
        $filecontent=New-Object System.Collections.Generic.List[System.String]

        while (($line = $read.ReadLine()) -ne $null)
        {
            $filecontent.add($line)
        }

        $read.Dispose()
        return $filecontent
    }
}

# Function sourced from https://gist.github.com/jbirley/f4c7775007aabbcf6b67b9160276b198
function Get-Percentile {

    <#
    .SYNOPSIS
        Returns the specified percentile value for a given set of numbers.

    .DESCRIPTION
        This function expects a set of numbers passed as an array to the 'Sequence' parameter.  For a given percentile, passed as the 'Percentile' argument,
        it returns the calculated percentile value for the set of numbers.

    .PARAMETER Sequence
        A array of integer and/or decimal values the function uses as the data set.
    .PARAMETER Percentile
        The target percentile to be used by the function's algorithm.

    .EXAMPLE
        $values = 98.2,96.5,92.0,97.8,100,95.6,93.3
        Get-Percentile -Sequence $values -Percentile 0.95

    .NOTES
        Author:  Jim Birley
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory)]
        [Double[]]$Sequence
        ,
        [Parameter(Mandatory)]
        [Double]$Percentile
    )

    $Sequence = $Sequence | Sort-Object
    [int]$N = $Sequence.Length
    #Write-Verbose "N is $N"
    [Double]$Num = ($N - 1) * $Percentile + 1
    #Write-Verbose "Num is $Num"
    if ($num -eq 1) {
        return $Sequence[0]
    } elseif ($num -eq $N) {
        return $Sequence[$N-1]
    } else {
        $k = [Math]::Floor($Num)
        [Double]$d = $num - $k
        return $Sequence[$k - 1] + $d * ($Sequence[$k] - $Sequence[$k - 1])
    }
}


# sourced from https://www.powershellgallery.com/packages/Formulaic/0.2.1.0/Content/Get-Median.ps1
function Get-Median{
    <#
    .Synopsis
        Gets a median
    .Description
        Gets the median of a series of numbers
    .Example
        Get-Median 2,4,6,8
    .Link
        Get-Average
    .Link
        Get-StandardDeviation
    #>
    param(
    # The numbers to average
    [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true,Position=0)]
    [Double[]]
    $Number
    )

    begin {
        $numberSeries = @()
    }

    process {
        $numberSeries += $number
    }

    end {
        $sortedNumbers = @($numberSeries | Sort-Object)
        if ($numberSeries.Count % 2) {
            # Odd, pick the middle
            $sortedNumbers[($sortedNumbers.Count / 2) - 1]
        } else {
            # Even, average the middle two
            ($sortedNumbers[($sortedNumbers.Count / 2)] + $sortedNumbers[($sortedNumbers.Count / 2) - 1]) / 2
        }
    }
}


function Is-Numeric ($Value) {
    # Checks if a value is numeric
    return $Value -match "^[\d\.]+$"
}

#endregion

#region Monitor calculator functions

function monitor-clear_selected_metric{
    $dontcalculate=$true
    $Monitor_Available_Metrics.Text="Select Metric."
    $Monitor_Available_Metrics.ToolTip="Select Metric."
}

Function Clear-Monitor_data{
    $Monitor_Datagrid.items.clear()
    $dontcalculate=$true
    $Monitor_Available_Metrics.Text="Select Metric."
    $Monitor_Available_Metrics.ToolTip="Select Metric."
}

Function copy-Monitor_data{
    # Copies the data of the monitor datagrid to the clipboard
    Set-Clipboard -value ($Monitor_Datagrid.items | convertto-csv -NoTypeInformation)
}

Function export-Monitor_data{
    # Exports data on the monitor datagrid to CSV
    [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") |
    Out-Null

    $SaveFileDialog = New-Object System.Windows.Forms.SaveFileDialog
    $SaveFileDialog.initialDirectory = $ExportPath
    $SaveFileDialog.filter = "csv (*.csv)| *.csv"
    $SaveFileDialog.filename="Monitor Stress Levels Calculation.csv"
    $Show = $SaveFileDialog.ShowDialog()
    If ($Show -eq "OK")
    {
        $Monitor_Datagrid.items | Export-Csv $SaveFileDialog.filename
    }
    Else
    {
    }
}

function set-Monitor_folderfilter {
    # Makes it possible to filter on folder name if applicable
    $filetype=$Monitor_SourceType.SelectedItem.Content
    $Monitor_Data.clear()
    $folderchoice=$Monitor_Folder_Selector.SelectedItem
    if ($folderchoice -eq "All Folders"){
        $Monitor_Sourcedata.foreach{[void]$Monitor_Data.add($_)}
    }
    elseif ($filetype -eq "Hosts" -OR $filetype -eq "Folders"){
        ($Monitor_Sourcedata.where{$_."Folder path" -eq $folderchoice}).foreach{$Monitor_Data.add($_)}
    }
    elseif ($filetype -eq "Machines"){
        ($Monitor_Sourcedata.where{$_."Folder" -eq $folderchoice}).foreach{$Monitor_Data.add($_)}
        }
    $dontcalculate=$true
    $Monitor_Available_Metrics.Text="Select Metric."
    $Monitor_Available_Metrics.ToolTip="Select Metric."
}

function get-Monitor_stats{
    #Calculates the values of the selected metric
    $useforyellow="0."+$yellowpercentile
    $useforred="0."+$redpercentile
    $Monitor_Available_Metrics.ToolTip=$Monitor_Available_Metrics.SelectedItem
    $metricname=$Monitor_Available_Metrics.SelectedItem
    $filetype=$Monitor_SourceType.SelectedItem.Content
    $folderchoice=$Monitor_Folder_Selector.SelectedItem
    if($NULL -eq $folderchoice -OR $folderchoice -eq "All Folders"){
        $folderchoice="n/a"
    }

    if(!$metricname -AND $Monitor_Available_Metrics.Text -ne "Disabled while loading data" -AND $Monitor_Available_Metrics.Text -ne "Select Metric.") {
            $ButtonType = [System.Windows.Forms.MessageBoxButtons]::OK
            $MessageIcon = [System.Windows.Forms.MessageBoxIcon]::Information
            $MessageBody = "Select a Metric first"
            $MessageTitle = "Warning"
            [System.Windows.Forms.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon)
    }
    elseif($Monitor_Available_Metrics.Text -eq "Disabled while loading data"){
        # Just need to not run get stats
    }
    elseif($dontcalculate -eq $true){
        $dontcalculate=$false
    }
    else{
        try {
            if($Monitor_Ignore_0_values.IsChecked -eq "True"){
                $filtereddatapoints=@()
                $filtereddatapoints=$Monitor_Data.where{$_.$metricname -ne "0" -AND $_.$metricname -ne "0.00" -AND $_.$metricname -ne "0,00"}
                #write-verbose -message $filtereddatapoints.$metricname
                $yellow=Get-Percentile -Sequence ($filtereddatapoints.$metricname) -Percentile $useforyellow
                $red=Get-Percentile -Sequence ($filtereddatapoints.$metricname) -Percentile $useforred
                $average=[Linq.Enumerable]::average([decimal[]] @($filtereddatapoints.$metricname))
                $median=(get-median $filtereddatapoints.$metricname)
                $Monitor_Datapoints=$filtereddatapoints.count
            }
            else{
                $yellow=Get-Percentile -Sequence ($Monitor_Data.$metricname) -Percentile $useforyellow
                $red=Get-Percentile -Sequence ($Monitor_Data.$metricname) -Percentile $useforred
                $average=[Linq.Enumerable]::average([decimal[]] @($Monitor_Data.$metricname))
                $median=(get-median $Monitor_Data.$metricname)
                $Monitor_Datapoints=$Monitor_Data.count
            }
            [void]$Monitor_Datagrid.AddChild([pscustomobject]@{Name=$metricname;Source=$filetype;Calculation=$yellowpercentile+"th Percentile";Value=[math]::Round($yellow,2);Datapoints=$Monitor_Datapoints;Folder=$folderchoice;Stress_level="Change Yellow to "+[math]::Round($yellow)})
            [void]$Monitor_Datagrid.AddChild([pscustomobject]@{Name=$metricname;Source=$filetype;Calculation=$redpercentile+"th percentile";Value=[math]::Round($red,2);Datapoints=$Monitor_Datapoints;Folder=$folderchoice;Stress_level="Change Red to "+[math]::Round($red)})
            if($Monitor_Show_Average.IsChecked -eq "True"){
                [void]$Monitor_Datagrid.AddChild([pscustomobject]@{Name=$metricname;Source=$filetype;Calculation="Average";Value=[math]::Round($Average,2);Datapoints=$Monitor_Datapoints;Folder=$folderchoice})
            }
            if($Monitor_Show_Median.IsChecked -eq "True"){
                [void]$Monitor_Datagrid.AddChild([pscustomobject]@{Name=$metricname;Source=$filetype;Calculation="Median";Value=[math]::Round($Median,2);Datapoints=$Monitor_Datapoints;Folder=$folderchoice})
            }
        }
        catch{
            write-verbose -message "Calculation failed this metric probably couldn't be converted to an integer"
        }
    }
}

function load-Monitor_data {
    $stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
    # Loads the data for the monitor export files
    $Monitor_Sourcedata.clear()
    $Monitor_Data.clear()
    $Monitor_Folder_Selector.items.clear()
    $Monitor_Available_Metrics.Text="Disabled while loading data"
    $Monitor_Available_Metrics.items.clear()
    $sourcefolder=$Monitor_Folder_TextBox.Text
    $filetype=$Monitor_SourceType.SelectedItem.Content
    write-verbose -message "Gathering metrics for $filetype"
    if ($filetype -eq "Use Browse or enter the source file location"){
        $ButtonType = [System.Windows.Forms.MessageBoxButtons]::OK
        $MessageIcon = [System.Windows.Forms.MessageBoxIcon]::Information
        $MessageBody = "Please select a metric type first"
        $MessageTitle = "Warning"
        [System.Windows.Forms.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon)
    }
    elseif($sourcefolder -eq ""){
            $ButtonType = [System.Windows.Forms.MessageBoxButtons]::OK
            $MessageIcon = [System.Windows.Forms.MessageBoxIcon]::Information
            $MessageBody = "Select a source path first"
            $MessageTitle = "Warning"
            [System.Windows.Forms.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon)
    }
    elseif($filetype -eq "" -OR $Null -eq $filetype){
        $ButtonType = [System.Windows.Forms.MessageBoxButtons]::OK
        $MessageIcon = [System.Windows.Forms.MessageBoxIcon]::Information
        $MessageBody = "Select a data source first"
        $MessageTitle = "Warning"
        [System.Windows.Forms.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon)
    }
    elseif(!(test-path $sourcefolder)){
            $ButtonType = [System.Windows.Forms.MessageBoxButtons]::OK
            $MessageIcon = [System.Windows.Forms.MessageBoxIcon]::Information
            $MessageBody = "Path not found"
            $MessageTitle = "Warning"
            [System.Windows.Forms.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon)
    }
    else {
        $files = (get-childitem $sourcefolder).where({$_.name -like "*$filetype*"})
        $filecount=$files.count
        write-verbose -message "importing $filecount files"
        if($files.count -gt 0){
            $header=((get-childitem $sourcefolder).where({$_.name -like "*$filetype*"}) | select-object -first 1 | get-content | Select-Object -skip 1 -first 1).Split(",")
            foreach ($file in $files){
                $content=$null
                if ($filetype -eq "sessions"){
                    [array]$content=((Get-filecontent -file $file.fullname).replace('","','"^"') | select-object -skip 2 | out-string | ConvertFrom-Csv -Header $header -Delimiter ^).where({$_.user -ne ""})
                    if ($Userfilter){
                        [array]$content=$content.where({$_.user |select-string -pattern $userfilter -notmatch })
                    }
                }
                else {
                    [array]$content=((Get-filecontent -file $file.fullname).replace('","','"^"') | select-object -skip 2 | out-string | ConvertFrom-Csv -Header $header -Delimiter ^)
                }
                $content.foreach({[void]$Monitor_Sourcedata.add($_)})
            }
            $stopwatch.stop()
            $elapsedtime=$stopwatch.Elapsed.TotalSeconds
            write-verbose -message "reading the files took $elapsedtime seconds"
            $stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
            $header=$header.where({$_ |select-string -pattern $metricfilter -notmatch }) 
            $header=$header | Sort-Object
            foreach ($i in $header){
                $p=$Monitor_Sourcedata."$i" | where-object {$_ -ne ""} | select-object -first 1
                try{
                    get-median $p | out-null
                    Get-Percentile -sequence $p -Percentile 0.75 | out-null
                    [void] $Monitor_Available_Metrics.Items.Add($i)
                }
                catch{}
            }
            $stopwatch.stop()
            $elapsedtime=$stopwatch.Elapsed.TotalSeconds
            write-verbose -message "Checking the metrics took $elapsedtime seconds"
            $stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
            if ($filetype -eq "hosts" -OR $filetype -eq "Folders"){
                $Monitor_Folder_Selector.Visibility="Visible"
                $foldermenuitems= $Monitor_Sourcedata."Folder path" | select-object -unique
                $foldermenuitems | sort-object | foreach-object {[void] $Monitor_Folder_Selector.Items.Add($_)}
                [void] $Monitor_Folder_Selector.Items.Add("All Folders")
            }
            elseif ($filetype -eq "Machines"){
                $Monitor_Folder_Selector.Visibility="Visible"
                $foldermenuitems= $Monitor_SourceData."Folder" | select-object -unique
                $foldermenuitems | sort-object | foreach-object {[void] $Monitor_Folder_Selector.Items.Add($_)}
                [void] $Monitor_Folder_Selector.Items.Add("All Folders")
            }
            else{
                $Monitor_Folder_Selector.Visibility="Hidden"
            }
            $Monitor_SourceData.foreach{[void]$Monitor_Data.add($_)}
            $Monitor_Available_Metrics.Text="Select Metric"
            $Monitor_Available_Metrics.ToolTip="Select Metric"
        }
        else{
            $ButtonType = [System.Windows.Forms.MessageBoxButtons]::OK
            $MessageIcon = [System.Windows.Forms.MessageBoxIcon]::Information
            $MessageBody = "Could not find any suitable files in this location"
            $MessageTitle = "Warning"
            [System.Windows.Forms.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon)
        }
    }
    $stopwatch.stop()
    $elapsedtime=$stopwatch.Elapsed.TotalSeconds
    write-verbose -message "Building the menu took $elapsedtime seconds"
    $stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
    $count = $Monitor_Data.count
    write-verbose -message "Object count: $count"
}

function select-Monitor_inputtype {
    # Sets the tooltip of the selected metric to show that metric
    $Monitor_SourceType.ToolTip=$Monitor_SourceType.SelectedItem.Content
}

function Select-Monitor_FolderDialog {
    # Allows for selecting the folder that holds the csv files
    [string]$Description="Select Folder"
    [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null

    $objForm = New-Object System.Windows.Forms.FolderBrowserDialog
    $objForm.SelectedPath = $SourcePath
    $objForm.Description = $Description
    $Show = $objForm.ShowDialog()
    If ($Show -eq "OK")
    {
        $Monitor_Folder_TextBox.Text=$objForm.SelectedPath
    }
    Else
    {
    }
}
#endregion

#region Insights related functions

function insights-clear_selected_metric{
    $dontcalculate=$true
    $Insights_Available_Metrics.Text="Select Metric."
    $Insights_Available_Metrics.ToolTip="Select Metric."
}

function open-Insights_FileDialog {
    [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
    $objForm = New-Object System.Windows.Forms.OpenFileDialog
    $objForm.InitialDirectory  = $SourcePath
    $Show = $objForm.ShowDialog()
    If ($Show -eq "OK")
    {
        $Insights_File_TextBox.Text=$objForm.FileName
        $Insights_File_TextBox.Tooltip=$objForm.FileName
    }
    Else
    {
        write-verbose -message "Operation cancelled by user."
    }
}

Function Clear-Insights_data{
    $Insights_Datagrid.items.clear()
    $dontcalculate=$true
    $Insights_Available_Metrics.Text="Select Metric."
    $Insights_Available_Metrics.ToolTip="Select Metric."
    }

Function copy-Insights_data{
    Set-Clipboard -value ($Insights_datagrid.items | convertto-csv -NoTypeInformation)
    }

Function export-Insights_data{
    [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") |
    Out-Null

    $SaveFileDialog = New-Object System.Windows.Forms.SaveFileDialog
    $SaveFileDialog.initialDirectory = $ExportPath
    $SaveFileDialog.filter = "csv (*.csv)| *.csv"
    $SaveFileDialog.filename="Insights Stress levels Calculation.csv"

    $Show = $SaveFileDialog.ShowDialog()
    If ($Show -eq "OK")
    {
        $Insights_datagrid.items | Export-Csv $SaveFileDialog.filename
    }
    Else
    {
        write-verbose -message "Operation cancelled by user."
    }
}
function load-Insights_data {
    $stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
    $Insights_sourcedata.clear()
    $Insights_data.clear()
    $Insights_Available_Metrics.Text="Disabled while loading data"
    $Insights_Available_Metrics.items.clear()
    $sourcefile=$Insights_File_TextBox.Text
    if(!(test-path $sourcefile)){
            write-verbose -message "File $sourcefile not found."
            $ButtonType = [System.Windows.Forms.MessageBoxButtons]::OK
            $MessageIcon = [System.Windows.Forms.MessageBoxIcon]::Information
            $MessageBody = "File not found"
            $MessageTitle = "Warning"
            [System.Windows.Forms.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon)
    }
    else {
        write-verbose -message "Reading $sourcefile."
        ((Get-filecontent -file $sourcefile | convertfrom-csv)).foreach{[void]$Insights_sourcedata.add($_)}
        if ($Userfilter){
            $Insights_sourcedata=$Insights_sourcedata | where-object {$_."user name" |select-string -pattern $userfilter -notmatch }
        }
        $header=$Insights_sourcedata | get-member -type noteproperty | select-object -expandproperty name
    }
    $stopwatch.stop()
    $elapsedtime=$stopwatch.Elapsed.TotalSeconds
    write-verbose -message "reading the file took $elapsedtime seconds"
    $stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
    foreach ($i in $header){
        $p=$Insights_sourcedata."$i" | where-object {$_ -ne ""} | select-object -first 1
        try{
            get-median $p | out-null
            Get-Percentile -sequence $p -Percentile 0.75 | out-null
            [void] $Insights_Available_Metrics.Items.Add($i)
        }
        catch{}
    }
    $stopwatch.stop()
    $elapsedtime=$stopwatch.Elapsed.TotalSeconds
    write-verbose -message "Checking the metrics took $elapsedtime seconds"
    $stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
    $Insights_sourcedata.foreach{[void]$Insights_data.add($_)}
    $Insights_Available_Metrics.Text="Select Metric"
    $Insights_Available_Metrics.ToolTip="Select Metric"
    $stopwatch.stop()
    $elapsedtime=$stopwatch.Elapsed.TotalSeconds
    write-verbose -message "Building the menu took $elapsedtime seconds"
    $stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
    $count = $Insights_data.count
    write-verbose -message "Object count: $count"
}

function get-Insights_stats{
    $useforyellow="0."+$yellowpercentile
    $useforred="0."+$redpercentile
    $Insights_Available_Metrics.ToolTip=$Insights_Available_Metrics.SelectedItem
    $metricname=$Insights_Available_Metrics.SelectedItem
    if(!$metricname -AND $Insights_Available_Metrics.Text -ne "Disabled while loading data" -AND $Insights_Available_Metrics.Text -ne "Select Metric.") {
            $ButtonType = [System.Windows.Forms.MessageBoxButtons]::OK
            $MessageIcon = [System.Windows.Forms.MessageBoxIcon]::Information
            $MessageBody = "Select a Metric first"
            $MessageTitle = "Warning"
            [System.Windows.Forms.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon)
    }
    elseif($Insights_Available_Metrics.Text -eq "Disabled while loading data"){
        # Don't need to do nothing
    }
    elseif($dontcalculate -eq $true){
        $dontcalculate=$false
    }
    else{
        try {
            if($Insights_Ignore_0_values.IsChecked -eq "True"){
                $filtereddatapoints=@()
                $filtereddatapoints=$Insights_data.where{$_.$metricname -ne "0"}
                #write-verbose -message $filtereddatapoints.$metricname
                $yellow=Get-Percentile -Sequence ($filtereddatapoints.$metricname) -Percentile $useforyellow
                $red=Get-Percentile -Sequence ($filtereddatapoints.$metricname) -Percentile $useforred
                $average=[Linq.Enumerable]::average([decimal[]] @($filtereddatapoints.$metricname))
                $median=(get-median $filtereddatapoints.$metricname)
                $Insights_datapoints=$filtereddatapoints.count
            }
            else{
                $yellow=Get-Percentile -Sequence ($Insights_data.$metricname) -Percentile $useforyellow
                $red=Get-Percentile -Sequence ($Insights_data.$metricname) -Percentile $useforred
                $average=[Linq.Enumerable]::average([decimal[]] @($Insights_data.$metricname))
                $median=(get-median $Insights_data.$metricname)
                $Insights_datapoints=$Insights_data.count
            }
            [void]$Insights_Datagrid.AddChild([pscustomobject]@{Name=$metricname;Calculation=$yellowpercentile+"th Percentile";Value=[math]::Round($yellow,2);Datapoints=$Insights_datapoints;Stress_level="Change Yellow to "+[math]::Round($yellow)})
            [void]$Insights_Datagrid.AddChild([pscustomobject]@{Name=$metricname;Calculation=$redpercentile+"th percentile";Value=[math]::Round($red,2);Datapoints=$Insights_datapoints;Stress_level="Change Red to "+[math]::Round($red)})
            if($Insights_Show_Average.IsChecked -eq "True"){
                [void]$Insights_Datagrid.AddChild([pscustomobject]@{Name=$metricname;Calculation="Average";Value=[math]::Round($Average,2);Datapoints=$Insights_datapoints})
            }
            if($Insights_Show_Median.IsChecked -eq "True"){
                [void]$Insights_Datagrid.AddChild([pscustomobject]@{Name=$metricname;Calculation="Median";Value=[math]::Round($Median,2);Datapoints=$Insights_datapoints})
            }
        }
        catch{
            write-verbose -message "Calculation failed this metric probably couldn't be converted to an integer"
        }
    }
}
#endregion

#region prepping the xml
$xaml = $xaml -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^<Win.*', '<Window'
[xml]$xml=$xaml
$reader = (New-Object System.Xml.XmlNodeReader $xml)
$window = [Windows.Markup.XamlReader]::Load($reader)
$xml.SelectNodes("//*[@Name]") | ForEach-Object { Set-Variable -Name $_.Name -Value $Window.FindName($_.Name) }
#endregion

#Region Image
$image="/9j/4AAQSkZJRgABAQEASABIAAD/4RR3aHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA2LjAtYzAwMiA3OS4xNjQ0NjAsIDIwMjAvMDUvMTItMTY6MDQ6MTcgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOm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gaW1hZ2UvcG5nIHRvIGltYWdlL2pwZWciLz4gPHJkZjpsaSBzdEV2dDphY3Rpb249InNhdmVkIiBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOjc1N2QwOTAxLTg2ZjUtNDBjZC1hOGIwLTk2MTc4ZDJlMTE1ZiIgc3RFdnQ6d2hlbj0iMjAyMC0wOS0wOVQxMDozOTozOSswMzowMCIgc3RFdnQ6c29mdHdhcmVBZ2VudD0iQWRvYmUgUGhvdG9zaG9wIDIxLjIgKE1hY2ludG9zaCkiIHN0RXZ0OmNoYW5nZWQ9Ii8iLz4gPC9yZGY6U2VxPiA8L3htcE1NOkhpc3Rvcnk+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjVlNjAwNTQyLTZiY2EtNGU3MC1hNTJhLTQ1NDU5YzM3ZjM4YyIgc3RSZWY6ZG9jdW1lbnRJRD0iYWRvYmU6ZG9jaWQ6cGhvdG9zaG9wOmZkYmU5YjdiLWZlNzctZjQ0MS04M2ViLTYyMWE1YzRjYmQzOSIgc3RSZWY6b3JpZ2luYWxEb2N1bWVudElEPSJ4bXAuZGlkOjI2NEIxMUExMzE0QkVBMTFBRjYxRjI3OTM2OTVFOTRCIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDw/eHBhY2tldCBlbmQ9InciPz7/7RsIUGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAA8cAVoAAxslRxwCAAACAAAAOEJJTQQlAAAAAAAQzc/6fajHvgkFcHaurwXDTjhCSU0EOgAAAAAA5QAAABAAAAABAAAAAAALcHJpbnRPdXRwdXQAAAAFAAAAAFBzdFNib29sAQAAAABJbnRlZW51bQAAAABJbnRlAAAAAENscm0AAAAPcHJpbnRTaXh0ZWVuQml0Ym9vbAAAAAALcHJpbnRlck5hbWVURVhUAAAAAQAAAAAAD3ByaW50UHJvb2ZTZXR1cE9iamM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vZmYAAQBsZmYABgAAAAAAAQAvZmYAAQChmZoABgAAAAAAAQAyAAAAAQBaAAAABgAAAAAAAQA1AAAAAQAtAAAABgAAAAAAAThCSU0D+AAAAAAAcAAA/////////////////////////////wPoAAAAAP////////////////////////////8D6AAAAAD/////////////////////////////A+gAAAAA/////////////////////////////wPoAAA4QklNBAAAAAAAAAIAADhCSU0EAgAAAAAAAgAAOEJJTQQwAAAAAAABAQA4QklNBC0AAAAAAAYAAQAAAAI4QklNBAgAAAAAABAAAAABAAACQAAAAkAAAAAAOEJJTQQeAAAAAAAEAAAAADhCSU0EGgAAAAADUQAAAAYAAAAAAAAAAAAAAzkAAAJIAAAADgBGAGUAcgBtAGEAbABlAF8ARQB4AHAAZQByAHQAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAkgAAAM5AAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAABudWxsAAAAAgAAAAZib3VuZHNPYmpjAAAAAQAAAAAAAFJjdDEAAAAEAAAAAFRvcCBsb25nAAAAAAAAAABMZWZ0bG9uZwAAAAAAAAAAQnRvbWxvbmcAAAM5AAAAAFJnaHRsb25nAAACSAAAAAZzbGljZXNWbExzAAAAAU9iamMAAAABAAAAAAAFc2xpY2UAAAASAAAAB3NsaWNlSURsb25nAAAAAAAAAAdncm91cElEbG9uZwAAAAAAAAAGb3JpZ2luZW51bQAAAAxFU2xpY2VPcmlnaW4AAAANYXV0b0dlbmVyYXRlZAAAAABUeXBlZW51bQAAAApFU2xpY2VUeXBlAAAAAEltZyAAAAAGYm91bmRzT2JqYwAAAAEAAAAAAABSY3QxAAAABAAAAABUb3AgbG9uZwAAAAAAAAAATGVmdGxvbmcAAAAAAAAAAEJ0b21sb25nAAADOQAAAABSZ2h0bG9uZwAAAkgAAAADdXJsVEVYVAAAAAEAAAAAAABudWxsVEVYVAAAAAEAAAAAAABNc2dlVEVYVAAAAAEAAAAAAAZhbHRU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Pocin4KpnEfEDiBBB+eqTq4JHxcMB4SLei5it0l+9antpuTP8RKnkNlk4R3id3w5GPE109GiMtIZZaShphpIS2y2nCUADkAOFL2N2Uu6f1BGutpkmexHKliK7hDhO0gYV8J4kHjt5VPnarudvWoXjSeoGWhzXGbbfR6koWa9r5YXcEdOLMaNBkB0stOHQzRh7qjNxO+fqmIwUKJDeVAfEvpXolsd6opwDjFLiD2x6PaAZmSpcFSeaX4jgI9cA1cxO0/Rcgkt3+Jg8twUn6gVPVJaYfZ7ijASDhST9w/8ef6clXqBnZfZ5U0poF0qIWRkZ49OHWmCi/Qbk37VYHxPWkYUlhJUlY8zy/OqH+5sy63B2VcVIhtOLKu6bVvUB4Z5D98Kg45TyVTWRQgk3v0t56eqsYRMyBzpJHWFvzJYeOtUm+Wz2WCZrsV/v2mxw3LCVJB8sbs58QKbsa3TVqaXIcQjIBcQlWSk+AOOPrUqzWaDZ2SiCwlBPxOHitXqasacwuiko4RG91+mwWjEauOqfxRttbfc/ZCQEgAchRRRVJTkUUUUIRRRRQhFFFFCEUUUUIXlIjMSU7ZDLTqfBaAr61HatFtaXuat8NCvFLCQfpRRQhTaKKKEIooooQiiiihC//Z"
$Insights_Image.Source = DecodeBase64Image -ImageBase64 $image
$Monitor_Image.Source = DecodeBase64Image -ImageBase64 $image
$Window.add_Loaded({
    $Window.Icon = DecodeBase64Image -ImageBase64 $icon
})
#EndRegion

#region Monitor_related_actions
$Monitor_Select_Folder.Add_Click({select-Monitor_folderdialog})
$Monitor_SourceType.Add_SelectionChanged({ select-Monitor_inputtype  })
$Monitor_Load_Data.Add_Click({ load-Monitor_data })
$Monitor_export.Add_Click({ export-Monitor_data  })
$Monitor_Copy.Add_Click({ copy-Monitor_data  })
$Monitor_Clear.Add_Click({ Clear-Monitor_data  })
$Monitor_Available_Metrics.Add_SelectionChanged({  get-Monitor_stats })
$Monitor_Folder_Selector.Add_SelectionChanged({ set-Monitor_folderfilter })
$Monitor_Ignore_0_values.Add_Checked({Monitor-clear_selected_metric})
$Monitor_Ignore_0_values.Add_Unchecked({Monitor-clear_selected_metric})
$Monitor_Show_Median.Add_Checked({Monitor-clear_selected_metric})
$Monitor_Show_Median.Add_Unchecked({Monitor-clear_selected_metric})
$Monitor_Show_Average.Add_Checked({Monitor-clear_selected_metric})
$Monitor_Show_Average.Add_Unchecked({Monitor-clear_selected_metric})
#endregion Monitor_related_actions

#region Insights related actions
$Insights_Select_File.Add_Click({Open-Insights_Filedialog})
$Insights_export.Add_Click({ export-Insights_data  })
$Insights_Copy.Add_Click({ copy-Insights_data  })
$Insights_Clear.Add_Click({ Clear-Insights_data  })
$Insights_Available_Metrics.Add_SelectionChanged({ get-Insights_stats })
$Insights_Ignore_0_values.Add_Checked({insights-clear_selected_metric})
$Insights_Ignore_0_values.Add_Unchecked({insights-clear_selected_metric})
$Insights_Show_Median.Add_Checked({insights-clear_selected_metric})
$Insights_Show_Median.Add_Unchecked({insights-clear_selected_metric})
$Insights_Show_Average.Add_Checked({insights-clear_selected_metric})
$Insights_Show_Average.Add_Unchecked({insights-clear_selected_metric})
$Insights_Load_Data.Add_Click({  load-Insights_data  })
#endregion

#region Help actions
$Help_Link1.Add_MouseLeftButtonUp({start-process 'https://support.controlup.com/hc/en-us/articles/360013867718'})
$Help_Link2.Add_MouseLeftButtonUp({start-process 'http://www.youtube.com'})
#endregion


$window.ShowDialog() | out-null