├── CareLink
├── Images
│ ├── Shield.png
│ ├── MealImage .png
│ ├── InsulinVial.png
│ ├── SensorExpired.png
│ ├── SensorLifeOK.png
│ ├── CalibrationDot.png
│ ├── MealImageLarge.png
│ ├── PumpBatteryFull.png
│ ├── PumpBatteryHigh.png
│ ├── PumpBatteryLow.png
│ ├── SensorLifeNotOK.png
│ ├── Shield Disabled.png
│ ├── CalibrationDotRed.png
│ ├── InsulinVial Tiny.png
│ ├── PumpBatteryMedium.png
│ ├── PumpBatteryUnknown.png
│ ├── ReservoirRemains0.png
│ ├── ReservoirRemains1+.png
│ ├── CalibrationNotReady.png
│ ├── PumpBatteryCritical.png
│ ├── ReservoirRemains15+.png
│ ├── ReservoirRemains29+.png
│ ├── ReservoirRemains43+.png
│ ├── ReservoirRemains57+.png
│ ├── ReservoirRemains71+.png
│ ├── ReservoirRemains85+.png
│ ├── TransmitterBatteryOK.png
│ ├── CalibrationUnavailable.png
│ ├── SensorCommunicationLost.png
│ ├── SensorExpirationUnknown.png
│ ├── TransmitterBatteryFull.png
│ ├── TransmitterBatteryLow.png
│ ├── TransmitterBatteryMedium.png
│ ├── TransmitterBatteryUnknown.png
│ ├── PumpConnectivityToPhoneNotOK.png
│ ├── PumpConnicitivityToPhoneOK.png
│ ├── TransmitterBatteryCritical.png
│ ├── PumpConnicitivityToTransmitterOK.png
│ ├── PumpConnicitivityToTransmitterNotOK.png
│ └── PumpConnicitivityToTransmitterUnknown.png
├── img_e3917_4nK_icon.ico
├── obj
│ ├── CareLink.vbproj.nuget.g.targets
│ ├── CareLink.vbproj.nuget.g.props
│ ├── project.nuget.cache
│ ├── CareLink.vbproj.nuget.dgspec.json
│ └── project.assets.json
├── CareLink.vbproj.DotSettings
├── My Project
│ ├── Application.myapp
│ ├── Settings.settings
│ ├── Application.Designer.vb
│ ├── Application.Designer.HighDpi.vb
│ ├── Settings.Designer.vb
│ ├── Resources.resx
│ └── Resources.Designer.vb
├── ApplicationEvents.vb
├── IndexClass.vb
├── Extensions
│ ├── ForEachExtensions.vb
│ ├── ControlExtensions.vb
│ ├── HttpClientExtensions.vb
│ ├── SupportFunctions.vb
│ ├── JsonExtension.vb
│ └── UnicodeNewline.vb
├── Insulin.vb
├── LoginForm1.vb
├── App.config
├── CareLink.vbproj
├── LoginForm1.Designer.vb
├── carelink_client.vb
└── LoginForm1.resx
├── Screenshot 2021-05-16 050718.png
├── CareLink.sln.DotSettings.user
├── .gitignore
├── README.md
├── CareLink.sln
└── .editorconfig
/CareLink/Images/Shield.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/Shield.png
--------------------------------------------------------------------------------
/CareLink/Images/MealImage .png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/MealImage .png
--------------------------------------------------------------------------------
/CareLink/Images/InsulinVial.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/InsulinVial.png
--------------------------------------------------------------------------------
/CareLink/Images/SensorExpired.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/SensorExpired.png
--------------------------------------------------------------------------------
/CareLink/Images/SensorLifeOK.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/SensorLifeOK.png
--------------------------------------------------------------------------------
/CareLink/img_e3917_4nK_icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/img_e3917_4nK_icon.ico
--------------------------------------------------------------------------------
/Screenshot 2021-05-16 050718.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/Screenshot 2021-05-16 050718.png
--------------------------------------------------------------------------------
/CareLink/Images/CalibrationDot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/CalibrationDot.png
--------------------------------------------------------------------------------
/CareLink/Images/MealImageLarge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/MealImageLarge.png
--------------------------------------------------------------------------------
/CareLink/Images/PumpBatteryFull.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/PumpBatteryFull.png
--------------------------------------------------------------------------------
/CareLink/Images/PumpBatteryHigh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/PumpBatteryHigh.png
--------------------------------------------------------------------------------
/CareLink/Images/PumpBatteryLow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/PumpBatteryLow.png
--------------------------------------------------------------------------------
/CareLink/Images/SensorLifeNotOK.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/SensorLifeNotOK.png
--------------------------------------------------------------------------------
/CareLink/Images/Shield Disabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/Shield Disabled.png
--------------------------------------------------------------------------------
/CareLink/Images/CalibrationDotRed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/CalibrationDotRed.png
--------------------------------------------------------------------------------
/CareLink/Images/InsulinVial Tiny.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/InsulinVial Tiny.png
--------------------------------------------------------------------------------
/CareLink/Images/PumpBatteryMedium.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/PumpBatteryMedium.png
--------------------------------------------------------------------------------
/CareLink/Images/PumpBatteryUnknown.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/PumpBatteryUnknown.png
--------------------------------------------------------------------------------
/CareLink/Images/ReservoirRemains0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/ReservoirRemains0.png
--------------------------------------------------------------------------------
/CareLink/Images/ReservoirRemains1+.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/ReservoirRemains1+.png
--------------------------------------------------------------------------------
/CareLink/Images/CalibrationNotReady.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/CalibrationNotReady.png
--------------------------------------------------------------------------------
/CareLink/Images/PumpBatteryCritical.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/PumpBatteryCritical.png
--------------------------------------------------------------------------------
/CareLink/Images/ReservoirRemains15+.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/ReservoirRemains15+.png
--------------------------------------------------------------------------------
/CareLink/Images/ReservoirRemains29+.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/ReservoirRemains29+.png
--------------------------------------------------------------------------------
/CareLink/Images/ReservoirRemains43+.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/ReservoirRemains43+.png
--------------------------------------------------------------------------------
/CareLink/Images/ReservoirRemains57+.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/ReservoirRemains57+.png
--------------------------------------------------------------------------------
/CareLink/Images/ReservoirRemains71+.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/ReservoirRemains71+.png
--------------------------------------------------------------------------------
/CareLink/Images/ReservoirRemains85+.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/ReservoirRemains85+.png
--------------------------------------------------------------------------------
/CareLink/Images/TransmitterBatteryOK.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/TransmitterBatteryOK.png
--------------------------------------------------------------------------------
/CareLink/Images/CalibrationUnavailable.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/CalibrationUnavailable.png
--------------------------------------------------------------------------------
/CareLink/Images/SensorCommunicationLost.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/SensorCommunicationLost.png
--------------------------------------------------------------------------------
/CareLink/Images/SensorExpirationUnknown.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/SensorExpirationUnknown.png
--------------------------------------------------------------------------------
/CareLink/Images/TransmitterBatteryFull.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/TransmitterBatteryFull.png
--------------------------------------------------------------------------------
/CareLink/Images/TransmitterBatteryLow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/TransmitterBatteryLow.png
--------------------------------------------------------------------------------
/CareLink/Images/TransmitterBatteryMedium.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/TransmitterBatteryMedium.png
--------------------------------------------------------------------------------
/CareLink/Images/TransmitterBatteryUnknown.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/TransmitterBatteryUnknown.png
--------------------------------------------------------------------------------
/CareLink/Images/PumpConnectivityToPhoneNotOK.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/PumpConnectivityToPhoneNotOK.png
--------------------------------------------------------------------------------
/CareLink/Images/PumpConnicitivityToPhoneOK.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/PumpConnicitivityToPhoneOK.png
--------------------------------------------------------------------------------
/CareLink/Images/TransmitterBatteryCritical.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/TransmitterBatteryCritical.png
--------------------------------------------------------------------------------
/CareLink/Images/PumpConnicitivityToTransmitterOK.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/PumpConnicitivityToTransmitterOK.png
--------------------------------------------------------------------------------
/CareLink/Images/PumpConnicitivityToTransmitterNotOK.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/PumpConnicitivityToTransmitterNotOK.png
--------------------------------------------------------------------------------
/CareLink/Images/PumpConnicitivityToTransmitterUnknown.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shanselman/CareLink/master/CareLink/Images/PumpConnicitivityToTransmitterUnknown.png
--------------------------------------------------------------------------------
/CareLink/obj/CareLink.vbproj.nuget.g.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 |
6 |
--------------------------------------------------------------------------------
/CareLink/CareLink.vbproj.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | True
--------------------------------------------------------------------------------
/CareLink.sln.DotSettings.user:
--------------------------------------------------------------------------------
1 |
2 | <Policy Inspect="True" Prefix="_" Suffix="" Style="AaBb_AaBb" />
--------------------------------------------------------------------------------
/CareLink/My Project/Application.myapp:
--------------------------------------------------------------------------------
1 |
2 |
3 | true
4 | Form1
5 | true
6 | 0
7 | true
8 | 0
9 | true
10 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # This .gitignore file was automatically created by Microsoft(R) Visual Studio.
3 | ################################################################################
4 |
5 | /.vs/CareLink
6 | /CareLink/obj/Debug/net5.0-windows
7 | /CareLink/CareLink.vbproj.user
8 | /CareLink/bin/Debug/net5.0-windows
9 | /CareLink/Images/IMG_E4006.JPG
10 | /CareLink/Images/IMG_4011.PNG
11 | /CareLink/Images/IMG_4010.PNG
12 | /CareLink/Images/IMG_4009.PNG
13 | /CareLink/Images/IMG_4008.PNG
14 | /CareLink/Images/IMG_4007.PNG
15 | /CareLink/Images/ReservoirAll.png
16 | /CareLink/obj/Release/net5.0-windows
17 | /.vs
18 | /TestProject1
19 | /CareLink/obj/Debug/net5.0
20 |
--------------------------------------------------------------------------------
/CareLink/My Project/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | 03:00:00
13 |
14 |
15 |
--------------------------------------------------------------------------------
/CareLink/ApplicationEvents.vb:
--------------------------------------------------------------------------------
1 | ' ReSharper disable once CheckNamespace
2 | Namespace My
3 | ' The following events are available for MyApplication:
4 | ' Startup: Raised when the application starts, before the startup form is created.
5 | ' Shutdown: Raised after all application forms are closed. This event is not raised if the application terminates abnormally.
6 | ' UnhandledException: Raised if the application encounters an unhandled exception.
7 | ' StartupNextInstance: Raised when launching a single-instance application and the application is already active.
8 | ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
9 | Partial Friend Class MyApplication
10 | End Class
11 | End Namespace
12 |
--------------------------------------------------------------------------------
/CareLink/IndexClass.vb:
--------------------------------------------------------------------------------
1 | ' Licensed to the .NET Foundation under one or more agreements.
2 | ' The .NET Foundation licenses this file to you under the MIT license.
3 | ' See the LICENSE file in the project root for more information.
4 |
5 | Public Class IndexClass(Of T)
6 | Public Property Value As T
7 | Public Property Index As Integer ' first element has index = 0
8 |
9 | Public ReadOnly Property IsFirst As Boolean
10 | Get
11 | Return Me.Index = 0
12 | End Get
13 | End Property
14 |
15 | Public Property IsLast As Boolean
16 | Public Property Enumerator As IEnumerator(Of T)
17 |
18 | Public Sub MoveNext()
19 | Me.Value = Me.Enumerator.Current
20 | Me.IsLast = Not Me.Enumerator.MoveNext()
21 | ' may be called with .AsParallel
22 | Threading.Interlocked.Increment(Me.Index)
23 | End Sub
24 |
25 | End Class
26 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CareLink
2 | ## Requires
3 | - Visual Studio 2019 Version 16.9
4 | - .NET Core 5.0
5 |
6 | ## License
7 | - MIT
8 |
9 | ## Technologies
10 | - Windows Forms
11 | - dotnet-core
12 |
13 | ## Topics
14 | - Medtronic CareLink data display
15 |
16 | ## Updated
17 | - 5/21/2021
18 |
19 | ## Description
20 |
21 | Repo for CareLink Windows App
22 | This is a Visual Basic application that provides a UI to view Medtronic 670G and 770G (possibly 780G but that has not been tested).
23 | This shows all available data and is not in any way supported by Medtronic, it was created from publicly available data.
24 | Some data was filtered out because I could not see any use for it. You can turn off filters but performance will suffer.
25 |
26 | For the visualization layer I use the open source package by Angelo Cresta.
27 | https://github.com/AngeloCresta/winforms-datavisualization-net5
28 |
29 | Try it out and send feedback.
30 | This update has a simple UI to show all the available data and a visual version that mimics the one on iPhone.
31 | 
32 |
--------------------------------------------------------------------------------
/CareLink/Extensions/ForEachExtensions.vb:
--------------------------------------------------------------------------------
1 | ' Licensed to the .NET Foundation under one or more agreements.
2 | ' The .NET Foundation licenses this file to you under the MIT license.
3 | ' See the LICENSE file in the project root for more information.
4 |
5 | Imports System.Runtime.CompilerServices
6 |
7 | Public Module ForEachExtensions
8 |
9 |
10 | Public Iterator Function WithIndex(Of T)(
11 | source As IEnumerable(Of T)
12 | ) As IEnumerable(Of IndexClass(Of T))
13 | If source Is Nothing Then
14 | Throw New ArgumentNullException(NameOf(source))
15 | End If
16 |
17 | Using enumerator As IEnumerator(Of T) = source.GetEnumerator
18 | Dim hasNext As Boolean = enumerator.MoveNext
19 | Dim index As Integer = -1
20 | While hasNext
21 | Dim wi As New IndexClass(Of T) With {.Index = index, .Enumerator = enumerator}
22 | wi.MoveNext()
23 | Yield wi
24 | hasNext = Not wi.IsLast
25 | index = wi.Index ' if .MoveNext was used
26 | End While
27 | End Using
28 | End Function
29 |
30 | End Module
31 |
--------------------------------------------------------------------------------
/CareLink/obj/CareLink.vbproj.nuget.g.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | True
5 | NuGet
6 | $(MSBuildThisFileDirectory)project.assets.json
7 | $(UserProfile)\.nuget\packages\
8 | C:\Users\PaulM\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages;C:\Program Files\dotnet\sdk\NuGetFallbackFolder
9 | PackageReference
10 | 5.10.0
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
19 |
20 |
--------------------------------------------------------------------------------
/CareLink/My Project/Application.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' This code was generated by a tool.
4 | ' Runtime Version:4.0.30319.42000
5 | '
6 | ' Changes to this file may cause incorrect behavior and will be lost if
7 | ' the code is regenerated.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 |
15 | Namespace My
16 |
17 | 'NOTE: This file is auto-generated; do not modify it directly. To make changes,
18 | ' or if you encounter build errors in this file, go to the Project Designer
19 | ' (go to Project Properties or double-click the My Project node in
20 | ' Solution Explorer), and make changes on the Application tab.
21 | '
22 | Partial Friend Class MyApplication
23 |
24 | _
25 | Public Sub New()
26 | MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
27 | Me.IsSingleInstance = true
28 | Me.EnableVisualStyles = true
29 | Me.SaveMySettingsOnExit = true
30 | Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
31 | End Sub
32 |
33 | _
34 | Protected Overrides Sub OnCreateMainForm()
35 | Me.MainForm = Global.CareLink.Form1
36 | End Sub
37 | End Class
38 | End Namespace
39 |
--------------------------------------------------------------------------------
/CareLink/Insulin.vb:
--------------------------------------------------------------------------------
1 | ' Licensed to the .NET Foundation under one or more agreements.
2 | ' The .NET Foundation licenses this file to you under the MIT license.
3 | ' See the LICENSE file in the project root for more information.
4 |
5 | Friend Class Insulin
6 | Private ReadOnly _incrementDownCount As Integer
7 | Private _adjustmentValue As Double
8 | Private _incrementUpCount As Integer
9 |
10 | Public Sub New(oaTime As Double, initialInsulinLevel As Double, activeInsulinIncrements As Integer)
11 | Me.OaTime = oaTime
12 | Me.EventDate = Date.FromOADate(oaTime)
13 | _incrementUpCount = CInt(Math.Ceiling(activeInsulinIncrements * (1 / 3)))
14 | _incrementDownCount = activeInsulinIncrements - _incrementUpCount
15 | _adjustmentValue = initialInsulinLevel / activeInsulinIncrements
16 | Me.CurrentInsulinLevel = _adjustmentValue * _incrementDownCount
17 | End Sub
18 |
19 | Public Property CurrentInsulinLevel As Double
20 |
21 | Public Property EventDate As Date
22 |
23 | Public Property OaTime As Double
24 |
25 | Friend Function Adjust() As Insulin
26 | If Me.CurrentInsulinLevel > 0 Then
27 | If _incrementUpCount > 0 Then
28 | _incrementUpCount -= 1
29 | Me.CurrentInsulinLevel += _adjustmentValue
30 | If _incrementUpCount = 0 Then
31 | _adjustmentValue = Me.CurrentInsulinLevel / _incrementDownCount
32 | End If
33 | Else
34 | Me.CurrentInsulinLevel -= _adjustmentValue
35 | End If
36 | End If
37 | Return Me
38 | End Function
39 |
40 | Public Overrides Function ToString() As String
41 | Return $"{Me.EventDate.ToShortTimeString()} {Me.CurrentInsulinLevel.RoundDouble(3)}"
42 | End Function
43 | End Class
44 |
--------------------------------------------------------------------------------
/CareLink.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31129.286
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "CareLink", "CareLink\CareLink.vbproj", "{3DF0DB17-7515-4C29-916E-C6EF66A82672}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C157782E-77AD-4CB6-8450-BC2908317F1F}"
9 | ProjectSection(SolutionItems) = preProject
10 | .editorconfig = .editorconfig
11 | README.md = README.md
12 | Screenshot 2021-05-16 050718.png = Screenshot 2021-05-16 050718.png
13 | EndProjectSection
14 | EndProject
15 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChartWin", "..\winforms-datavisualization-net5\src\System.Windows.Forms.DataVisualization\ChartWin.csproj", "{DA066E4E-DB85-49DB-8481-B0D6C424DE1A}"
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 | {3DF0DB17-7515-4C29-916E-C6EF66A82672}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24 | {3DF0DB17-7515-4C29-916E-C6EF66A82672}.Debug|Any CPU.Build.0 = Debug|Any CPU
25 | {3DF0DB17-7515-4C29-916E-C6EF66A82672}.Release|Any CPU.ActiveCfg = Release|Any CPU
26 | {3DF0DB17-7515-4C29-916E-C6EF66A82672}.Release|Any CPU.Build.0 = Release|Any CPU
27 | {DA066E4E-DB85-49DB-8481-B0D6C424DE1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28 | {DA066E4E-DB85-49DB-8481-B0D6C424DE1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
29 | {DA066E4E-DB85-49DB-8481-B0D6C424DE1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
30 | {DA066E4E-DB85-49DB-8481-B0D6C424DE1A}.Release|Any CPU.Build.0 = Release|Any CPU
31 | EndGlobalSection
32 | GlobalSection(SolutionProperties) = preSolution
33 | HideSolutionNode = FALSE
34 | EndGlobalSection
35 | GlobalSection(ExtensibilityGlobals) = postSolution
36 | SolutionGuid = {13BF20DF-74A1-41DF-8198-566771A9AF00}
37 | EndGlobalSection
38 | EndGlobal
39 |
--------------------------------------------------------------------------------
/CareLink/LoginForm1.vb:
--------------------------------------------------------------------------------
1 | ' Licensed to the .NET Foundation under one or more agreements.
2 | ' The .NET Foundation licenses this file to you under the MIT license.
3 | ' See the LICENSE file in the project root for more information.
4 |
5 | Public Class LoginForm1
6 | Public Property Client As CarelinkClient.CareLinkClient
7 |
8 | Private Sub Cancel_Click(sender As Object, e As EventArgs) Handles Cancel.Click
9 | Me.Close()
10 | End Sub
11 |
12 | Private Sub LoginForm1_Load(sender As Object, e As EventArgs) Handles Me.Load
13 | Me.UsernameTextBox.Text = My.Settings.username
14 | Me.PasswordTextBox.Text = My.Settings.password
15 | End Sub
16 |
17 | Private Sub OK_Click(sender As Object, e As EventArgs) Handles OK.Click
18 | Me.OK.Enabled = False
19 | Me.Cancel.Enabled = False
20 | If Me.Client Is Nothing Then
21 | Me.Client = New CarelinkClient.CareLinkClient(Me.UsernameTextBox.Text, Me.PasswordTextBox.Text, "us")
22 | End If
23 | If Not Me.Client.LoggedIn Then
24 | Dim recentData As Dictionary(Of String, String) = Me.Client.GetRecentData()
25 | If recentData IsNot Nothing AndAlso recentData.Count > 0 Then
26 | Me.OK.Enabled = True
27 | Me.Cancel.Enabled = True
28 | If Me.SaveCredentials.CheckState = CheckState.Checked Then
29 | My.Settings.username = Me.UsernameTextBox.Text
30 | My.Settings.password = Me.PasswordTextBox.Text
31 | End If
32 |
33 | My.Settings.Save()
34 | Me.Hide()
35 | Exit Sub
36 | End If
37 | Else
38 | Me.OK.Enabled = True
39 | Me.Cancel.Enabled = True
40 | Me.Hide()
41 | Exit Sub
42 | End If
43 |
44 | If MsgBox("Login Unsuccessful. try again? If no program will exit!", Buttons:=MsgBoxStyle.YesNo, Title:="Login Failed") = MsgBoxResult.No Then
45 | End
46 | End If
47 | Me.OK.Enabled = True
48 | Me.Cancel.Enabled = True
49 | End Sub
50 |
51 | End Class
52 |
--------------------------------------------------------------------------------
/CareLink/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/CareLink/My Project/Application.Designer.HighDpi.vb:
--------------------------------------------------------------------------------
1 | Option Strict On
2 | Option Explicit On
3 |
4 | 'This constant indicates whether the Application Framework is in use.
5 | #Const APPLICATION_FRAMEWORK = True
6 |
7 | #If APPLICATION_FRAMEWORK Then
8 |
9 | #If NET5_0 And Not NET6_0 Then
10 |
11 | Imports System.Collections.ObjectModel
12 |
13 | Namespace My
14 |
15 | Partial Friend Class MyApplication
16 |
17 | Public Event ApplyHighDpiMode(sender As Object, e As ApplyHighDpiModeEventArgs)
18 |
19 | Private _highDpiMode As HighDpiMode?
20 |
21 | Friend Shadows Property HighDpiMode As HighDpiMode
22 | Get
23 | Return If(
24 | _highDpiMode Is Nothing,
25 | Application.HighDpiMode,
26 | _highDpiMode.Value)
27 | End Get
28 | Set(value As HighDpiMode)
29 | _highDpiMode = value
30 | End Set
31 | End Property
32 |
33 | ' IMPORTANT:
34 | ' If this method causes an compilation error after you've unchecked 'Application Framework'
35 | ' in the project properties, go to the top of this file and change the value to 'False' in this line:
36 | ' #Const APPLICATION_FRAMEWORK = False
37 |
38 | ' For more about using WinForms without the Application Framework
39 | ' see: https://aka.ms/visualbasic-appframework-net5
40 | Protected Overrides Function OnInitialize(commandLineArgs As ReadOnlyCollection(Of String)) As Boolean
41 | Dim eventArgs As New ApplyHighDpiModeEventArgs(
42 | If(
43 | _highDpiMode Is Nothing,
44 | HighDpiMode.SystemAware,
45 | _highDpiMode.Value))
46 |
47 | RaiseEvent ApplyHighDpiMode(Me, eventArgs)
48 |
49 | Windows.Forms.Application.SetHighDpiMode(eventArgs.HighDpiMode)
50 |
51 | Return MyBase.OnInitialize(commandLineArgs)
52 | End Function
53 |
54 | End Class
55 |
56 | Public Class ApplyHighDpiModeEventArgs
57 | Inherits EventArgs
58 |
59 | Public Sub New(highDpiMode As HighDpiMode)
60 | Me.HighDpiMode = highDpiMode
61 | End Sub
62 |
63 | Public Property HighDpiMode As HighDpiMode
64 |
65 | End Class
66 |
67 | End Namespace
68 |
69 | #End If ' #If NET5_0 And Not NET6_0
70 | #End If ' #If APPLICATION_FRAMEWORK
71 |
--------------------------------------------------------------------------------
/CareLink/Extensions/ControlExtensions.vb:
--------------------------------------------------------------------------------
1 | ' Licensed to the .NET Foundation under one or more agreements.
2 | ' The .NET Foundation licenses this file to you under the MIT license.
3 | ' See the LICENSE file in the project root for more information.
4 |
5 | Imports System.Runtime.CompilerServices
6 | Imports System.Windows.Forms.DataVisualization.Charting
7 |
8 | Public Module ControlExtensions
9 |
10 |
11 | Friend Function FindHorizontalMidpoint(ctrl As Control) As Integer
12 | Return ctrl.Left + (ctrl.Width \ 2)
13 | End Function
14 |
15 |
16 | Friend Function FindVerticalMidpoint(ctrl As Control) As Integer
17 | Return ctrl.Top + (ctrl.Height \ 2)
18 | End Function
19 |
20 |
21 | Friend Function HorizontalCenterOn(parentControl As Control, ParamArray childControls() As Control) As Integer
22 | Dim totalWidth As Integer = childControls.First.Right - childControls.Last.Left
23 | Return parentControl.FindHorizontalMidpoint - (totalWidth \ 2)
24 | End Function
25 |
26 |
27 | Friend Sub PaintMarker(e As ChartPaintEventArgs, markerImage As Bitmap, marketDictionary As Dictionary(Of Double, Integer), imageYOffset As Integer)
28 | ' Draw the cloned portion of the Bitmap object.
29 | Dim halfHeight As Single = CSng(markerImage.Height / 2)
30 | Dim halfWidth As Single = CSng(markerImage.Width / 2)
31 | For Each markerKvp As KeyValuePair(Of Double, Integer) In marketDictionary
32 | Dim imagePosition As RectangleF = RectangleF.Empty
33 | imagePosition.X = CSng(e.ChartGraphics.GetPositionFromAxis("Default", AxisName.X, markerKvp.Key))
34 | imagePosition.Y = CSng(e.ChartGraphics.GetPositionFromAxis("Default", AxisName.Y, markerKvp.Value))
35 | imagePosition = e.ChartGraphics.GetAbsoluteRectangle(imagePosition)
36 | imagePosition.Width = markerImage.Width
37 | imagePosition.Height = markerImage.Height
38 | imagePosition.Y -= halfHeight
39 | imagePosition.X -= halfWidth
40 | ' Draw image
41 | e.ChartGraphics.Graphics.DrawImage(markerImage, imagePosition.X, imagePosition.Y + imageYOffset)
42 | Next
43 | End Sub
44 |
45 |
46 | Friend Function PositionBelow(controlAbove As Control) As Integer
47 | Return controlAbove.Top + controlAbove.Height + 1
48 | End Function
49 |
50 | End Module
51 |
--------------------------------------------------------------------------------
/CareLink/obj/project.nuget.cache:
--------------------------------------------------------------------------------
1 | {
2 | "version": 2,
3 | "dgSpecHash": "gd8myr7EEZWw+uo3ea1JcS8o6vcCNo9hMd54ty0WB3NT+FeTjnnyYranYzrv6TD/NM47lNiUhra9Bn4bbdaOrA==",
4 | "success": true,
5 | "projectFilePath": "C:\\Users\\PaulM\\Source\\Repos\\CareLink\\CareLink\\CareLink.vbproj",
6 | "expectedPackageFiles": [
7 | "C:\\Users\\PaulM\\.nuget\\packages\\microsoft.netcore.platforms\\5.0.2\\microsoft.netcore.platforms.5.0.2.nupkg.sha512",
8 | "C:\\Users\\PaulM\\.nuget\\packages\\microsoft.netcore.targets\\1.1.0\\microsoft.netcore.targets.1.1.0.nupkg.sha512",
9 | "C:\\Users\\PaulM\\.nuget\\packages\\microsoft.win32.registry\\4.7.0\\microsoft.win32.registry.4.7.0.nupkg.sha512",
10 | "C:\\Users\\PaulM\\.nuget\\packages\\microsoft.win32.systemevents\\5.0.0\\microsoft.win32.systemevents.5.0.0.nupkg.sha512",
11 | "C:\\Users\\PaulM\\.nuget\\packages\\runtime.native.system.data.sqlclient.sni\\4.7.0\\runtime.native.system.data.sqlclient.sni.4.7.0.nupkg.sha512",
12 | "C:\\Users\\PaulM\\.nuget\\packages\\runtime.win-arm64.runtime.native.system.data.sqlclient.sni\\4.4.0\\runtime.win-arm64.runtime.native.system.data.sqlclient.sni.4.4.0.nupkg.sha512",
13 | "C:\\Users\\PaulM\\.nuget\\packages\\runtime.win-x64.runtime.native.system.data.sqlclient.sni\\4.4.0\\runtime.win-x64.runtime.native.system.data.sqlclient.sni.4.4.0.nupkg.sha512",
14 | "C:\\Users\\PaulM\\.nuget\\packages\\runtime.win-x86.runtime.native.system.data.sqlclient.sni\\4.4.0\\runtime.win-x86.runtime.native.system.data.sqlclient.sni.4.4.0.nupkg.sha512",
15 | "C:\\Users\\PaulM\\.nuget\\packages\\system.data.sqlclient\\4.8.2\\system.data.sqlclient.4.8.2.nupkg.sha512",
16 | "C:\\Users\\PaulM\\.nuget\\packages\\system.drawing.common\\5.0.2\\system.drawing.common.5.0.2.nupkg.sha512",
17 | "C:\\Users\\PaulM\\.nuget\\packages\\system.drawing.primitives\\4.3.0\\system.drawing.primitives.4.3.0.nupkg.sha512",
18 | "C:\\Users\\PaulM\\.nuget\\packages\\system.resources.extensions\\5.0.0\\system.resources.extensions.5.0.0.nupkg.sha512",
19 | "C:\\Users\\PaulM\\.nuget\\packages\\system.runtime\\4.3.0\\system.runtime.4.3.0.nupkg.sha512",
20 | "C:\\Users\\PaulM\\.nuget\\packages\\system.runtime.extensions\\4.3.0\\system.runtime.extensions.4.3.0.nupkg.sha512",
21 | "C:\\Users\\PaulM\\.nuget\\packages\\system.security.accesscontrol\\4.7.0\\system.security.accesscontrol.4.7.0.nupkg.sha512",
22 | "C:\\Users\\PaulM\\.nuget\\packages\\system.security.principal.windows\\4.7.0\\system.security.principal.windows.4.7.0.nupkg.sha512",
23 | "C:\\Users\\PaulM\\.nuget\\packages\\system.windows.extensions\\5.0.0\\system.windows.extensions.5.0.0.nupkg.sha512"
24 | ],
25 | "logs": []
26 | }
--------------------------------------------------------------------------------
/CareLink/Extensions/HttpClientExtensions.vb:
--------------------------------------------------------------------------------
1 | ' Licensed to the .NET Foundation under one or more agreements.
2 | ' The .NET Foundation licenses this file to you under the MIT license.
3 | ' See the LICENSE file in the project root for more information.
4 |
5 | Imports System.Net.Http
6 | Imports System.Runtime.CompilerServices
7 |
8 | Module HttpClientExtensions
9 |
10 |
11 | Public Function [Get](client As HttpClient, url As String, Optional headers As Dictionary(Of String, String) = Nothing, Optional params As Dictionary(Of String, String) = Nothing, Optional data As Dictionary(Of String, String) = Nothing) As HttpResponseMessage
12 | Dim formContent As HttpContent = Nothing
13 | If data IsNot Nothing Then
14 | formContent = New FormUrlEncodedContent(data.ToList())
15 | End If
16 | If headers IsNot Nothing Then
17 | client.DefaultRequestHeaders.Clear()
18 | For Each header As KeyValuePair(Of String, String) In headers
19 | If header.Key = "Content-Type" Then
20 | If formContent IsNot Nothing Then
21 | formContent.Headers.ContentType.MediaType = header.Value
22 | End If
23 | Else
24 | client.DefaultRequestHeaders.Add(header.Key, header.Value)
25 | End If
26 | Next
27 | End If
28 | If params IsNot Nothing Then
29 | url &= "?"
30 | For Each param As KeyValuePair(Of String, String) In params
31 | url &= $"{param.Key}={param.Value}&"
32 | Next
33 | url = url.TrimEnd("&"c)
34 | End If
35 | If data Is Nothing Then
36 | Return client.GetAsync(url).Result
37 | End If
38 | Return client.PostAsync(url, formContent).Result
39 | End Function
40 |
41 |
42 | Public Function Post(client As HttpClient, url As String, Optional headers As Dictionary(Of String, String) = Nothing, Optional params As Dictionary(Of String, String) = Nothing, Optional data As Dictionary(Of String, String) = Nothing) As HttpResponseMessage
43 | If params IsNot Nothing Then
44 | url &= "?"
45 | For Each header As KeyValuePair(Of String, String) In params
46 | url &= $"{header.Key}={header.Value}&"
47 | Next
48 | url = url.TrimEnd("&"c)
49 | End If
50 | Dim formData As New FormUrlEncodedContent(data.ToList())
51 | If headers IsNot Nothing Then
52 | client.DefaultRequestHeaders.Clear()
53 | For Each header As KeyValuePair(Of String, String) In headers
54 | If header.Key = "Content-Type" Then
55 | formData.Headers.ContentType.MediaType = header.Value
56 | Else
57 | client.DefaultRequestHeaders.Add(header.Key, header.Value)
58 | End If
59 | Next
60 | End If
61 | Return client.PostAsync(url, formData).Result
62 | End Function
63 |
64 |
65 | Public Function Text(client As HttpResponseMessage) As String
66 | Return client.Content.ReadAsStringAsync().Result
67 | End Function
68 |
69 | End Module
70 |
--------------------------------------------------------------------------------
/CareLink/CareLink.vbproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net5.0-windows
6 | CareLink
7 | Sub Main
8 | true
9 | WindowsForms
10 | en-US
11 | On
12 | Text
13 | Off
14 | img_e3917_4nK_icon.ico
15 |
16 |
17 |
18 | 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036
19 | x64
20 |
21 |
22 |
23 | 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | tlbimp
37 | 0
38 | 4
39 | 3050f1c5-98b5-11cf-bb82-00aa00bdce0b
40 | 0
41 | false
42 | false
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | True
59 | True
60 | Application.myapp
61 |
62 |
63 | True
64 | True
65 | Resources.resx
66 |
67 |
68 | True
69 | True
70 | Settings.settings
71 |
72 |
73 |
74 |
75 |
76 | My.Resources
77 | VbMyResourcesResXFileCodeGenerator
78 | Resources.Designer.vb
79 |
80 |
81 |
82 |
83 |
84 | Never
85 |
86 |
87 | MyApplicationCodeGenerator
88 | Application.Designer.vb
89 |
90 |
91 | My
92 | SettingsSingleFileGenerator
93 | Settings.Designer.vb
94 |
95 |
96 | PreserveNewest
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/CareLink/My Project/Settings.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' This code was generated by a tool.
4 | ' Runtime Version:4.0.30319.42000
5 | '
6 | ' Changes to this file may cause incorrect behavior and will be lost if
7 | ' the code is regenerated.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 |
15 | Namespace My
16 |
17 | _
20 | Partial Friend NotInheritable Class MySettings
21 | Inherits Global.System.Configuration.ApplicationSettingsBase
22 |
23 | Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings)
24 |
25 | #Region "My.Settings Auto-Save Functionality"
26 | #If _MyType = "WindowsForms" Then
27 | Private Shared addedHandler As Boolean
28 |
29 | Private Shared addedHandlerLockObject As New Object
30 |
31 | _
32 | Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs)
33 | If My.Application.SaveMySettingsOnExit Then
34 | My.Settings.Save()
35 | End If
36 | End Sub
37 | #End If
38 | #End Region
39 |
40 | Public Shared ReadOnly Property [Default]() As MySettings
41 | Get
42 |
43 | #If _MyType = "WindowsForms" Then
44 | If Not addedHandler Then
45 | SyncLock addedHandlerLockObject
46 | If Not addedHandler Then
47 | AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
48 | addedHandler = True
49 | End If
50 | End SyncLock
51 | End If
52 | #End If
53 | Return defaultInstance
54 | End Get
55 | End Property
56 |
57 | _
60 | Public Property username() As String
61 | Get
62 | Return CType(Me("username"),String)
63 | End Get
64 | Set
65 | Me("username") = value
66 | End Set
67 | End Property
68 |
69 | _
72 | Public Property password() As String
73 | Get
74 | Return CType(Me("password"),String)
75 | End Get
76 | Set
77 | Me("password") = value
78 | End Set
79 | End Property
80 |
81 | _
84 | Public Property AIT() As Global.System.TimeSpan
85 | Get
86 | Return CType(Me("AIT"),Global.System.TimeSpan)
87 | End Get
88 | Set
89 | Me("AIT") = value
90 | End Set
91 | End Property
92 | End Class
93 | End Namespace
94 |
95 | Namespace My
96 |
97 | _
100 | Friend Module MySettingsProperty
101 |
102 | _
103 | Friend ReadOnly Property Settings() As Global.CareLink.My.MySettings
104 | Get
105 | Return Global.CareLink.My.MySettings.Default
106 | End Get
107 | End Property
108 | End Module
109 | End Namespace
110 |
--------------------------------------------------------------------------------
/CareLink/Extensions/SupportFunctions.vb:
--------------------------------------------------------------------------------
1 | ' Licensed to the .NET Foundation under one or more agreements.
2 | ' The .NET Foundation licenses this file to you under the MIT license.
3 | ' See the LICENSE file in the project root for more information.
4 |
5 | Imports System.Runtime.CompilerServices
6 |
7 | Public Module SupportFunctions
8 |
9 | Public Enum RoundTo
10 | Second
11 | Minute
12 | Hour
13 | Day
14 | End Enum
15 |
16 |
17 | Friend Sub Adjustlist(myList As List(Of Insulin), startIndex As Integer, count As Integer)
18 | For i As Integer = startIndex To startIndex + count
19 | If i >= myList.Count Then Exit Sub
20 | myList(i) = myList(i).Adjust()
21 | Next
22 | End Sub
23 |
24 |
25 | Friend Function ConditionalSum(myList As List(Of Insulin), start As Integer, length As Integer) As Double
26 | If start + length > myList.Count Then
27 | length = myList.Count - start
28 | End If
29 | Return myList.GetRange(start, length).Sum(Function(i As Insulin) i.CurrentInsulinLevel)
30 | End Function
31 |
32 |
33 | Friend Function GetDecimalValue(item As Dictionary(Of String, String), ParamArray values() As String) As Double
34 | Dim returnValueString As String = ""
35 | For Each value As String In values
36 | If item.TryGetValue(value, returnValueString) Then
37 | Return Double.Parse(returnValueString)
38 | End If
39 | Next
40 | Return Double.NaN
41 | End Function
42 |
43 |
44 | Friend Function GetMilitaryHour(selectedStartTime As String) As Integer
45 | Return CInt(Format(Date.Parse(selectedStartTime), "HH"))
46 | End Function
47 |
48 |
49 | Friend Function RoundDouble(value As Double, decimalDigits As Integer) As Double
50 |
51 | Return Math.Round(value, decimalDigits)
52 | End Function
53 |
54 |
55 | Friend Function RoundDouble(value As String, decimalDigits As Integer) As Double
56 |
57 | Return Math.Round(Double.Parse(value), decimalDigits)
58 | End Function
59 |
60 |
61 | Friend Function RoundSingle(value As Double, decimalDigits As Integer) As Single
62 |
63 | Return CSng(Math.Round(value, decimalDigits))
64 | End Function
65 |
66 | Friend Sub SetValue(myList As List(Of KeyValuePair(Of Double, Double)), ByRef value As KeyValuePair(Of Double, Double))
67 | For Each v As IndexClass(Of KeyValuePair(Of Double, Double)) In myList.WithIndex()
68 | If Not v.IsLast Then
69 | If myList(v.Index).Key >= value.Key Then
70 | Continue For
71 | End If
72 | End If
73 | myList(v.Index) = New KeyValuePair(Of Double, Double)(v.Value.Key, value.Value)
74 | value = myList(v.Index)
75 | Exit For
76 | Next
77 | End Sub
78 |
79 |
80 | Friend Function ToDisplay(d As SortedDictionary(Of Double, Double)) As Dictionary(Of String, Double)
81 | Dim result As New Dictionary(Of String, Double)
82 | For Each entry As KeyValuePair(Of Double, Double) In d
83 | result.Add(Date.FromOADate(entry.Key).ToLongTimeString(), Math.Round(entry.Value, 3))
84 | Next
85 | Return result
86 | End Function
87 |
88 |
89 | Public Function RoundDown(d As Date, rt As RoundTo) As Date
90 | Dim dtRounded As New DateTime()
91 |
92 | Select Case rt
93 | Case RoundTo.Second
94 | dtRounded = New DateTime(d.Year, d.Month, d.Day, d.Hour, d.Minute, d.Second)
95 | Case RoundTo.Minute
96 | dtRounded = New DateTime(d.Year, d.Month, d.Day, d.Hour, d.Minute, 0)
97 | Case RoundTo.Hour
98 | dtRounded = New DateTime(d.Year, d.Month, d.Day, d.Hour, 0, 0)
99 | Case RoundTo.Day
100 | dtRounded = New DateTime(d.Year, d.Month, d.Day, 0, 0, 0)
101 | End Select
102 |
103 | Return dtRounded
104 | End Function
105 |
106 |
107 | Public Function SafeGetSgDateTime(sgList As List(Of Dictionary(Of String, String)), index As Integer) As Date
108 | Dim sgDateTimeString As String = ""
109 | Dim sgDateTime As Date
110 | If sgList(index).Count < 7 Then
111 | index -= 1
112 | End If
113 | If sgList(index).TryGetValue("previousDateTime", sgDateTimeString) Then
114 | sgDateTime = Date.Parse(sgDateTimeString)
115 | ElseIf sgList(index).TryGetValue("datetime", sgDateTimeString) Then
116 | sgDateTime = Date.Parse(sgDateTimeString)
117 | ElseIf sgList(index).TryGetValue("dateTime", sgDateTimeString) Then
118 | sgDateTime = Date.Parse(sgDateTimeString.Split("-")(0))
119 | Else
120 | sgDateTime = Now
121 | End If
122 | If sgDateTime.Year = 2000 Then
123 | sgDateTime = Date.Now - ((sgList.Count - index) * Form1._FiveMinutes)
124 | End If
125 | If sgList(index).Count < 7 Then
126 | sgDateTime = sgDateTime.AddMinutes(5)
127 | End If
128 | Return sgDateTime
129 | End Function
130 |
131 | End Module
132 |
--------------------------------------------------------------------------------
/CareLink/LoginForm1.Designer.vb:
--------------------------------------------------------------------------------
1 | _
2 | _
3 | Partial Class LoginForm1
4 | Inherits System.Windows.Forms.Form
5 |
6 | 'Form overrides dispose to clean up the component list.
7 | _
8 | Protected Overrides Sub Dispose(ByVal disposing As Boolean)
9 | Try
10 | If disposing AndAlso components IsNot Nothing Then
11 | components.Dispose()
12 | End If
13 | Finally
14 | MyBase.Dispose(disposing)
15 | End Try
16 | End Sub
17 | Friend WithEvents LogoPictureBox As System.Windows.Forms.PictureBox
18 | Friend WithEvents UsernameLabel As System.Windows.Forms.Label
19 | Friend WithEvents PasswordLabel As System.Windows.Forms.Label
20 | Friend WithEvents UsernameTextBox As System.Windows.Forms.TextBox
21 | Friend WithEvents PasswordTextBox As System.Windows.Forms.TextBox
22 | Friend WithEvents OK As System.Windows.Forms.Button
23 | Friend WithEvents Cancel As System.Windows.Forms.Button
24 |
25 | 'Required by the Windows Form Designer
26 | Private components As System.ComponentModel.IContainer
27 |
28 | 'NOTE: The following procedure is required by the Windows Form Designer
29 | 'It can be modified using the Windows Form Designer.
30 | 'Do not modify it using the code editor.
31 | _
32 | Private Sub InitializeComponent()
33 | Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(LoginForm1))
34 | Me.LogoPictureBox = New System.Windows.Forms.PictureBox()
35 | Me.UsernameLabel = New System.Windows.Forms.Label()
36 | Me.PasswordLabel = New System.Windows.Forms.Label()
37 | Me.UsernameTextBox = New System.Windows.Forms.TextBox()
38 | Me.PasswordTextBox = New System.Windows.Forms.TextBox()
39 | Me.OK = New System.Windows.Forms.Button()
40 | Me.Cancel = New System.Windows.Forms.Button()
41 | Me.SaveCredentials = New System.Windows.Forms.CheckBox()
42 | CType(Me.LogoPictureBox,System.ComponentModel.ISupportInitialize).BeginInit
43 | Me.SuspendLayout
44 | '
45 | 'LogoPictureBox
46 | '
47 | Me.LogoPictureBox.Image = CType(resources.GetObject("LogoPictureBox.Image"),System.Drawing.Image)
48 | Me.LogoPictureBox.Location = New System.Drawing.Point(0, 0)
49 | Me.LogoPictureBox.Name = "LogoPictureBox"
50 | Me.LogoPictureBox.Size = New System.Drawing.Size(165, 193)
51 | Me.LogoPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom
52 | Me.LogoPictureBox.TabIndex = 0
53 | Me.LogoPictureBox.TabStop = false
54 | '
55 | 'UsernameLabel
56 | '
57 | Me.UsernameLabel.Location = New System.Drawing.Point(172, 8)
58 | Me.UsernameLabel.Name = "UsernameLabel"
59 | Me.UsernameLabel.Size = New System.Drawing.Size(220, 23)
60 | Me.UsernameLabel.TabIndex = 0
61 | Me.UsernameLabel.Text = "&User name"
62 | Me.UsernameLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
63 | '
64 | 'PasswordLabel
65 | '
66 | Me.PasswordLabel.Location = New System.Drawing.Point(172, 55)
67 | Me.PasswordLabel.Name = "PasswordLabel"
68 | Me.PasswordLabel.Size = New System.Drawing.Size(220, 23)
69 | Me.PasswordLabel.TabIndex = 2
70 | Me.PasswordLabel.Text = "&Password"
71 | Me.PasswordLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
72 | '
73 | 'UsernameTextBox
74 | '
75 | Me.UsernameTextBox.Location = New System.Drawing.Point(174, 30)
76 | Me.UsernameTextBox.Name = "UsernameTextBox"
77 | Me.UsernameTextBox.Size = New System.Drawing.Size(220, 23)
78 | Me.UsernameTextBox.TabIndex = 1
79 | '
80 | 'PasswordTextBox
81 | '
82 | Me.PasswordTextBox.Location = New System.Drawing.Point(174, 78)
83 | Me.PasswordTextBox.Name = "PasswordTextBox"
84 | Me.PasswordTextBox.PasswordChar = Global.Microsoft.VisualBasic.ChrW(42)
85 | Me.PasswordTextBox.Size = New System.Drawing.Size(220, 23)
86 | Me.PasswordTextBox.TabIndex = 3
87 | '
88 | 'OK
89 | '
90 | Me.OK.Location = New System.Drawing.Point(197, 161)
91 | Me.OK.Name = "OK"
92 | Me.OK.Size = New System.Drawing.Size(94, 23)
93 | Me.OK.TabIndex = 4
94 | Me.OK.Text = "&OK"
95 | '
96 | 'Cancel
97 | '
98 | Me.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
99 | Me.Cancel.Location = New System.Drawing.Point(300, 161)
100 | Me.Cancel.Name = "Cancel"
101 | Me.Cancel.Size = New System.Drawing.Size(94, 23)
102 | Me.Cancel.TabIndex = 5
103 | Me.Cancel.Text = "&Cancel"
104 | '
105 | 'SaveCredentials
106 | '
107 | Me.SaveCredentials.AutoSize = true
108 | Me.SaveCredentials.Location = New System.Drawing.Point(174, 126)
109 | Me.SaveCredentials.Name = "SaveCredentials"
110 | Me.SaveCredentials.Size = New System.Drawing.Size(187, 19)
111 | Me.SaveCredentials.TabIndex = 6
112 | Me.SaveCredentials.Text = "Save User Name and Password"
113 | Me.SaveCredentials.UseVisualStyleBackColor = true
114 | '
115 | 'LoginForm1
116 | '
117 | Me.AcceptButton = Me.OK
118 | Me.AutoScaleDimensions = New System.Drawing.SizeF(7!, 15!)
119 | Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
120 | Me.CancelButton = Me.Cancel
121 | Me.ClientSize = New System.Drawing.Size(401, 192)
122 | Me.Controls.Add(Me.SaveCredentials)
123 | Me.Controls.Add(Me.Cancel)
124 | Me.Controls.Add(Me.OK)
125 | Me.Controls.Add(Me.PasswordTextBox)
126 | Me.Controls.Add(Me.UsernameTextBox)
127 | Me.Controls.Add(Me.PasswordLabel)
128 | Me.Controls.Add(Me.UsernameLabel)
129 | Me.Controls.Add(Me.LogoPictureBox)
130 | Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
131 | Me.MaximizeBox = false
132 | Me.MinimizeBox = false
133 | Me.Name = "LoginForm1"
134 | Me.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide
135 | Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
136 | Me.Text = "Login"
137 | CType(Me.LogoPictureBox,System.ComponentModel.ISupportInitialize).EndInit
138 | Me.ResumeLayout(false)
139 | Me.PerformLayout
140 |
141 | End Sub
142 |
143 | Friend WithEvents SaveCredentials As CheckBox
144 | End Class
145 |
--------------------------------------------------------------------------------
/CareLink/Extensions/JsonExtension.vb:
--------------------------------------------------------------------------------
1 | ' Licensed to the .NET Foundation under one or more agreements.
2 | ' The .NET Foundation licenses this file to you under the MIT license.
3 | ' See the LICENSE file in the project root for more information.
4 |
5 | Imports System.Runtime.CompilerServices
6 | Imports System.Text.Json
7 | Imports System.Text.Json.Serialization
8 |
9 | Public Module Json
10 |
11 | Private Function GetItemAsString(item As KeyValuePair(Of String, Object)) As String
12 | Dim itemValue As JsonElement = CType(item.Value, JsonElement)
13 | Dim itemAsString As String = itemValue.ToString
14 | Dim result As String = itemAsString
15 | Select Case itemValue.ValueKind
16 | Case JsonValueKind.False
17 | result = "False"
18 | Case JsonValueKind.Null
19 | result = ""
20 | Case JsonValueKind.Number
21 | Case JsonValueKind.True
22 | result = "True"
23 | Case JsonValueKind.String
24 | Try
25 | If Char.IsDigit(result(0)) Then
26 | Dim dateSplit As String() = itemAsString.Split("T")
27 | If dateSplit.Length = 2 Then
28 | Dim zDateString As String() = dateSplit(0).Split("-"c)
29 | Dim zTimeString As String() = dateSplit(1).TrimEnd("Z"c).Replace("+", ".").Split(":")
30 | Select Case item.Key
31 | Case "techHours"
32 | Case "lastConduitDateTime",
33 | "medicalDeviceTimeAsString",
34 | "previousDateTime" ' "2021-05-17T01:02:22.307-07:00"
35 | result = $"{ New DateTime(CInt(zDateString(0)),
36 | CInt(zDateString(1)),
37 | CInt(zDateString(2)),
38 | CInt(zTimeString(0)),
39 | CInt(zTimeString(1)),
40 | CInt(zTimeString(2).Substring(0, 2)),
41 | CInt(zTimeString(2).Substring(3, 3)), DateTimeKind.Local)}{ _
42 | itemAsString.Substring(itemAsString.Length - 6)}"
43 | Case "lastSensorTSAsString",
44 | "sLastSensorTime",
45 | "sMedicalDeviceTime",
46 | "triggeredDateTime" '2021-05-16T20:28:00.000Z
47 | result = New DateTime(CInt(zDateString(0)), CInt(zDateString(1)), CInt(zDateString(2)), CInt(zTimeString(0)), CInt(zTimeString(1)), CInt(zTimeString(2).Substring(0, 2)), DateTimeKind.Local).ToString()
48 | Case "loginDateUTC" ' UTC 2021-05-16T20:28:00.000Z
49 | result = New DateTime(CInt(zDateString(0)), CInt(zDateString(1)), CInt(zDateString(2)), CInt(zTimeString(0)), CInt(zTimeString(1)), CInt(zTimeString(2).Substring(0, 2)), DateTimeKind.Utc).ToString()
50 | Case "datetime"
51 | If item.Value.ToString().EndsWith("Z"c) Then
52 | result = New DateTime(CInt(zDateString(0)), CInt(zDateString(1)), CInt(zDateString(2)), CInt(zTimeString(0)), CInt(zTimeString(1)), CInt(zTimeString(2).Substring(0, 2)), DateTimeKind.Local).ToString()
53 | Else
54 | ' "2021-05-17T01:02:22.307-07:00"
55 | result = $"{ New DateTime(CInt(zDateString(0)),
56 | CInt(zDateString(1)),
57 | CInt(zDateString(2)),
58 | CInt(zTimeString(0)),
59 | CInt(zTimeString(1)),
60 | CInt(zTimeString(2).Substring(0, 2)),
61 | CInt(zTimeString(2).Substring(3, 3)), DateTimeKind.Local)}{ _
62 | itemAsString.Substring(itemAsString.Length - 6)}"
63 | End If
64 |
65 | Case Else
66 | Stop
67 | End Select
68 |
69 | End If
70 | End If
71 | Catch ex As Exception
72 | Stop
73 | End Try
74 | End Select
75 | Return result
76 | End Function
77 |
78 | Public Function LoadList(value As String) As List(Of Dictionary(Of String, String))
79 | Dim resultDictionaryArray As New List(Of Dictionary(Of String, String))
80 | Dim options As New JsonSerializerOptions() With {
81 | .IgnoreNullValues = True,
82 | .NumberHandling = JsonNumberHandling.WriteAsString}
83 |
84 | Dim deserializeList As List(Of Dictionary(Of String, Object)) = JsonSerializer.Deserialize(Of List(Of Dictionary(Of String, Object)))(value, options)
85 | For Each deserializeItem As Dictionary(Of String, Object) In deserializeList
86 | Dim resultDictionary As New Dictionary(Of String, String)
87 | For Each item As KeyValuePair(Of String, Object) In deserializeItem
88 | If item.Value Is Nothing Then
89 | resultDictionary.Add(item.Key, Nothing)
90 | Else
91 | resultDictionary.Add(item.Key, GetItemAsString(item))
92 | End If
93 | Next
94 | resultDictionaryArray.Add(resultDictionary)
95 | Next
96 | Return resultDictionaryArray
97 | End Function
98 |
99 | Public Function Loads(value As String) As Dictionary(Of String, String)
100 | Dim resultDictionary As New Dictionary(Of String, String)
101 | Dim options As New JsonSerializerOptions() With {
102 | .IgnoreNullValues = True,
103 | .NumberHandling = JsonNumberHandling.WriteAsString}
104 |
105 | For Each item As KeyValuePair(Of String, Object) In JsonSerializer.Deserialize(Of Dictionary(Of String, Object))(value, options).ToList()
106 | If item.Value Is Nothing Then
107 | resultDictionary.Add(item.Key, Nothing)
108 | Else
109 | resultDictionary.Add(item.Key, GetItemAsString(item))
110 | End If
111 | Next
112 | Return resultDictionary
113 | End Function
114 |
115 |
116 | Public Function UtcToLocalTime(utcTime As String) As String
117 | Dim convertedDate As Date = Date.SpecifyKind(Date.Parse(utcTime), DateTimeKind.Utc)
118 | Return convertedDate.ToLocalTime.ToString
119 | End Function
120 |
121 | End Module
122 |
--------------------------------------------------------------------------------
/CareLink/obj/CareLink.vbproj.nuget.dgspec.json:
--------------------------------------------------------------------------------
1 | {
2 | "format": 1,
3 | "restore": {
4 | "C:\\Users\\PaulM\\Source\\Repos\\CareLink\\CareLink\\CareLink.vbproj": {}
5 | },
6 | "projects": {
7 | "C:\\Users\\PaulM\\Source\\Repos\\CareLink\\CareLink\\CareLink.vbproj": {
8 | "version": "1.0.0",
9 | "restore": {
10 | "projectUniqueName": "C:\\Users\\PaulM\\Source\\Repos\\CareLink\\CareLink\\CareLink.vbproj",
11 | "projectName": "CareLink",
12 | "projectPath": "C:\\Users\\PaulM\\Source\\Repos\\CareLink\\CareLink\\CareLink.vbproj",
13 | "packagesPath": "C:\\Users\\PaulM\\.nuget\\packages\\",
14 | "outputPath": "C:\\Users\\PaulM\\Source\\Repos\\CareLink\\CareLink\\obj\\",
15 | "projectStyle": "PackageReference",
16 | "fallbackFolders": [
17 | "C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages",
18 | "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
19 | ],
20 | "configFilePaths": [
21 | "C:\\Users\\PaulM\\AppData\\Roaming\\NuGet\\NuGet.Config",
22 | "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
23 | "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
24 | ],
25 | "originalTargetFrameworks": [
26 | "net5.0-windows7.0"
27 | ],
28 | "sources": {
29 | "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
30 | "https://api.nuget.org/v3/index.json": {},
31 | "https://dotnet.myget.org/F/roslyn-analyzers/api/v3/index.json": {},
32 | "https://dotnet.myget.org/F/roslyn/api/v3/index.json": {},
33 | "https://dotnet.myget.org/F/system-commandline/api/v3/index.json": {},
34 | "https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json": {}
35 | },
36 | "frameworks": {
37 | "net5.0-windows7.0": {
38 | "targetAlias": "net5.0-windows",
39 | "projectReferences": {
40 | "C:\\Users\\PaulM\\Source\\Repos\\winforms-datavisualization-net5\\src\\System.Windows.Forms.DataVisualization\\ChartWin.csproj": {
41 | "projectPath": "C:\\Users\\PaulM\\Source\\Repos\\winforms-datavisualization-net5\\src\\System.Windows.Forms.DataVisualization\\ChartWin.csproj"
42 | }
43 | }
44 | }
45 | }
46 | },
47 | "frameworks": {
48 | "net5.0-windows7.0": {
49 | "targetAlias": "net5.0-windows",
50 | "imports": [
51 | "net461",
52 | "net462",
53 | "net47",
54 | "net471",
55 | "net472",
56 | "net48"
57 | ],
58 | "assetTargetFallback": true,
59 | "warn": true,
60 | "frameworkReferences": {
61 | "Microsoft.NETCore.App": {
62 | "privateAssets": "all"
63 | },
64 | "Microsoft.WindowsDesktop.App.WindowsForms": {
65 | "privateAssets": "none"
66 | }
67 | },
68 | "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\6.0.100-preview.2.21155.3\\RuntimeIdentifierGraph.json"
69 | }
70 | }
71 | },
72 | "C:\\Users\\PaulM\\Source\\Repos\\winforms-datavisualization-net5\\src\\System.Windows.Forms.DataVisualization\\ChartWin.csproj": {
73 | "version": "1.0.0",
74 | "restore": {
75 | "projectUniqueName": "C:\\Users\\PaulM\\Source\\Repos\\winforms-datavisualization-net5\\src\\System.Windows.Forms.DataVisualization\\ChartWin.csproj",
76 | "projectName": "System.Windows.Forms.DataVisualization",
77 | "projectPath": "C:\\Users\\PaulM\\Source\\Repos\\winforms-datavisualization-net5\\src\\System.Windows.Forms.DataVisualization\\ChartWin.csproj",
78 | "packagesPath": "C:\\Users\\PaulM\\.nuget\\packages\\",
79 | "outputPath": "C:\\Users\\PaulM\\Source\\Repos\\winforms-datavisualization-net5\\src\\System.Windows.Forms.DataVisualization\\obj\\",
80 | "projectStyle": "PackageReference",
81 | "fallbackFolders": [
82 | "C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages",
83 | "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
84 | ],
85 | "configFilePaths": [
86 | "C:\\Users\\PaulM\\AppData\\Roaming\\NuGet\\NuGet.Config",
87 | "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
88 | "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
89 | ],
90 | "originalTargetFrameworks": [
91 | "net5.0-windows7.0"
92 | ],
93 | "sources": {
94 | "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
95 | "https://api.nuget.org/v3/index.json": {},
96 | "https://dotnet.myget.org/F/roslyn-analyzers/api/v3/index.json": {},
97 | "https://dotnet.myget.org/F/roslyn/api/v3/index.json": {},
98 | "https://dotnet.myget.org/F/system-commandline/api/v3/index.json": {},
99 | "https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json": {}
100 | },
101 | "frameworks": {
102 | "net5.0-windows7.0": {
103 | "targetAlias": "net5.0-windows",
104 | "projectReferences": {}
105 | }
106 | },
107 | "warningProperties": {
108 | "warnAsError": [
109 | "NU1605"
110 | ]
111 | }
112 | },
113 | "frameworks": {
114 | "net5.0-windows7.0": {
115 | "targetAlias": "net5.0-windows",
116 | "dependencies": {
117 | "Microsoft.NETCore.Platforms": {
118 | "target": "Package",
119 | "version": "[5.0.2, )"
120 | },
121 | "System.Data.SqlClient": {
122 | "target": "Package",
123 | "version": "[4.8.2, )"
124 | },
125 | "System.Drawing.Common": {
126 | "target": "Package",
127 | "version": "[5.0.2, )"
128 | },
129 | "System.Drawing.Primitives": {
130 | "target": "Package",
131 | "version": "[4.3.0, )"
132 | },
133 | "System.Resources.Extensions": {
134 | "target": "Package",
135 | "version": "[5.0.0, )"
136 | },
137 | "System.Windows.Extensions": {
138 | "target": "Package",
139 | "version": "[5.0.0, )"
140 | }
141 | },
142 | "imports": [
143 | "net461",
144 | "net462",
145 | "net47",
146 | "net471",
147 | "net472",
148 | "net48"
149 | ],
150 | "assetTargetFallback": true,
151 | "warn": true,
152 | "frameworkReferences": {
153 | "Microsoft.NETCore.App": {
154 | "privateAssets": "all"
155 | },
156 | "Microsoft.WindowsDesktop.App.WindowsForms": {
157 | "privateAssets": "none"
158 | }
159 | },
160 | "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\6.0.100-preview.2.21155.3\\RuntimeIdentifierGraph.json"
161 | }
162 | }
163 | }
164 | }
165 | }
--------------------------------------------------------------------------------
/CareLink/Extensions/UnicodeNewline.vb:
--------------------------------------------------------------------------------
1 | ' Licensed to the .NET Foundation under one or more agreements.
2 | ' The .NET Foundation licenses this file to you under the MIT license.
3 | ' See the LICENSE file in the project root for more information.
4 |
5 | Imports System.Runtime.CompilerServices
6 | Imports System.Runtime.InteropServices
7 | Imports System.Text
8 |
9 | Public Enum UnicodeNewline
10 | Unknown
11 |
12 | '''
13 | ''' Line Feed, U+000A
14 | '''
15 | Lf = &HA
16 |
17 | CrLf = &HD0A
18 |
19 | '''
20 | ''' Carriage Return, U+000D
21 | '''
22 | Cr = &HD
23 |
24 | '''
25 | ''' Next Line, U+0085
26 | '''
27 | Nel = &H85
28 |
29 | '''
30 | ''' Vertical Tab, U+000B
31 | '''
32 | Vt = &HB
33 |
34 | '''
35 | ''' Form Feed, U+000C
36 | '''
37 | Ff = &HC
38 |
39 | '''
40 | ''' Line Separator, U+2028
41 | '''
42 | Ls = &H2028
43 |
44 | '''
45 | ''' Paragraph Separator, U+2029
46 | '''
47 | Ps = &H2029
48 |
49 | End Enum
50 |
51 | '''
52 | ''' Defines Unicode new lines according to Unicode Technical Report #13
53 | ''' http://www.unicode.org/standard/reports/tr13/tr13-5.html
54 | '''
55 |
56 | Public Module NewLine
57 |
58 | '''
59 | ''' Carriage Return, U+000D
60 | '''
61 | Public Const Cr As Char = ChrW(&HD)
62 |
63 | '''
64 | ''' Line Feed, U+000A
65 | '''
66 | Public Const Lf As Char = ChrW(&HA)
67 |
68 | '''
69 | ''' Next Line, U+0085
70 | '''
71 | Public Const Nel As Char = ChrW(&H85)
72 |
73 | '''
74 | ''' Vertical Tab, U+000B
75 | '''
76 | Public Const Vt As Char = ChrW(&HB)
77 |
78 | '''
79 | ''' Form Feed, U+000C
80 | '''
81 | Public Const Ff As Char = ChrW(&HC)
82 |
83 | '''
84 | ''' Line Separator, U+2028
85 | '''
86 | Public Const Ls As Char = ChrW(&H2028)
87 |
88 | '''
89 | ''' Paragraph Separator, U+2029
90 | '''
91 | Public Const Ps As Char = ChrW(&H2029)
92 |
93 | '''
94 | ''' Determines if a char is a new line delimiter.
95 | '''
96 | ''' 0 == no new line, otherwise it returns either 1 or 2 depending of the length of the delimiter.
97 | ''' The current character.
98 | ''' The next character (if != LF then length will always be 0 or 1).
99 | Public Function GetDelimiterLength(curChar As Char, nextChar As Char) As Integer
100 | If curChar = Cr Then
101 | If nextChar = Lf Then
102 | Return 2
103 | End If
104 | Return 1
105 | End If
106 |
107 | If curChar = Lf OrElse curChar = Nel OrElse curChar = Vt OrElse curChar = Ff OrElse curChar = Ls OrElse curChar = Ps Then
108 | Return 1
109 | End If
110 | Return 0
111 | End Function
112 |
113 | '''
114 | ''' Determines if a char is a new line delimiter.
115 | '''
116 | ''' 0 == no new line, otherwise it returns either 1 or 2 depending of the length of the delimiter.
117 | ''' The current character.
118 | ''' The length of the delimiter
119 | ''' The type of the delimiter
120 | ''' A callback getting the next character (may be null).
121 | Friend Function TryGetDelimiterLengthAndType(curChar As Char, ByRef length As Integer, ByRef type As UnicodeNewline, Optional nextChar As Func(Of Char) = Nothing) As Boolean
122 | If curChar = Cr Then
123 | If nextChar IsNot Nothing AndAlso nextChar() = Lf Then
124 | length = 2
125 | type = UnicodeNewline.CrLf
126 | Else
127 | length = 1
128 | type = UnicodeNewline.Cr
129 |
130 | End If
131 | Return True
132 | End If
133 |
134 | Select Case curChar
135 | Case Lf
136 | type = UnicodeNewline.Lf
137 | length = 1
138 | Return True
139 | Case Nel
140 | type = UnicodeNewline.Nel
141 | length = 1
142 | Return True
143 | Case Vt
144 | type = UnicodeNewline.Vt
145 | length = 1
146 | Return True
147 | Case Ff
148 | type = UnicodeNewline.Ff
149 | length = 1
150 | Return True
151 | Case Ls
152 | type = UnicodeNewline.Ls
153 | length = 1
154 | Return True
155 | Case Ps
156 | type = UnicodeNewline.Ps
157 | length = 1
158 | Return True
159 | End Select
160 | length = -1
161 | type = UnicodeNewline.Unknown
162 | Return False
163 | End Function
164 |
165 | '''
166 | ''' Determines if a string is a new line delimiter.
167 | '''
168 | ''' Note that the only 2 char wide new line is CR LF
169 | '''
170 |
171 | Friend Function IsNewLine(str As String) As Boolean
172 | If String.IsNullOrEmpty(str) Then
173 | Return False
174 | End If
175 | Dim ch As Char = str.Chars(0)
176 | Select Case str.Length
177 | Case 0
178 | Return False
179 | Case 1, 2
180 | Return ch = Cr OrElse ch = Lf OrElse ch = Nel OrElse ch = Vt OrElse ch = Ff OrElse ch = Ls OrElse ch = Ps
181 | Case Else
182 | Return False
183 | End Select
184 | End Function
185 |
186 |
187 | Public Function SplitLines(text As String) As String()
188 | Dim result As New List(Of String)()
189 | If text Is Nothing Then
190 | Return result.ToArray
191 | End If
192 | Dim sb As New StringBuilder()
193 |
194 | Dim length As Integer = Nothing
195 | Dim type As UnicodeNewline = Nothing
196 |
197 | For index As Integer = 0 To text.Length - 1
198 | Dim ch As Char = text.Chars(index)
199 | ' Do not delete the next line
200 | Dim j As Integer = index
201 | If TryGetDelimiterLengthAndType(ch, length, type, Function() If(j < text.Length - 1, text.Chars(j + 1), ControlChars.NullChar)) Then
202 | result.Add(sb.ToString)
203 | sb.Length = 0
204 | ' ReSharper disable once RedundantAssignment
205 | index += length - 1
206 | Continue For
207 | End If
208 | sb.Append(ch)
209 | Next index
210 | If sb.Length > 0 Then
211 | result.Add(sb.ToString)
212 | End If
213 |
214 | Return result.ToArray
215 | End Function
216 |
217 |
218 | Friend Function JoinLines(lines As String(), delimiter As String) As String
219 | Return String.Join(separator:=delimiter, lines)
220 | End Function
221 |
222 |
223 | Friend Function NormalizeLineEndings(lines As String, Optional delimiter As String = vbCrLf) As String
224 | Return lines.SplitLines.JoinLines(delimiter)
225 | End Function
226 |
227 | '''
228 | ''' Replace Unicode NewLines with ControlChars.NullChar or Specified Character
229 | '''
230 | ''' Source Test
231 | ''' Default is vbNullChar
232 | ''' String with Unicode NewLines replaced with SubstituteChar
233 |
234 | Public Function WithoutNewLines(text As String, Optional substituteChar As Char = ControlChars.NullChar) As String
235 | If text Is Nothing Then
236 | Throw New ArgumentNullException(NameOf(text))
237 | End If
238 |
239 | Dim sb As New StringBuilder()
240 | Dim length As Integer = Nothing
241 | Dim type As UnicodeNewline = Nothing
242 |
243 | For index As Integer = 0 To text.Length - 1
244 | Dim ch As Char = text.Chars(index)
245 | ' Do not delete the next line
246 | Dim j As Integer = index
247 | If TryGetDelimiterLengthAndType(ch, length, type, Function() If(j < text.Length - 1, text.Chars(j + 1), substituteChar)) Then
248 | ' ReSharper disable once RedundantAssignment
249 | index += length - 1
250 | Continue For
251 | End If
252 | sb.Append(ch)
253 | Next index
254 | Return sb.ToString
255 | End Function
256 |
257 | End Module
258 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 | # editorconfig.org
3 |
4 | # top-most EditorConfig file
5 |
6 | # Default settings:
7 | # A newline ending every file
8 | # Use 4 spaces as indentation
9 | [*]
10 | indent_style = space
11 | indent_size = 4
12 | file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.\nSee the LICENSE file in the project root for more information.
13 |
14 | # ReSharper properties
15 | resharper_vb_prefer_qualified_reference = true
16 |
17 | [*.json]
18 | indent_size = 2
19 |
20 | # C# and VB files
21 | [*.{cs,vb}]
22 | charset = utf-8-bom
23 | insert_final_newline = true
24 | trim_trailing_whitespace = true
25 |
26 | dotnet_separate_import_directive_groups = false
27 | dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:suggestion
28 | dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:suggestion
29 | dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion
30 | dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:suggestion
31 | dotnet_style_prefer_auto_properties = true:silent
32 | dotnet_style_prefer_conditional_expression_over_assignment = true
33 | dotnet_style_prefer_conditional_expression_over_return = true
34 | dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
35 | dotnet_style_prefer_inferred_tuple_names = true:suggestion
36 | dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent
37 | dotnet_style_readonly_field = true:suggestion
38 | dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
39 |
40 | # avoid this. unless absolutely necessary
41 | dotnet_style_qualification_for_field = false:suggestion
42 | dotnet_style_qualification_for_property = false:suggestion
43 | dotnet_style_qualification_for_event = false:suggestion
44 | # use language keywords instead of BCL types
45 | dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
46 | dotnet_style_predefined_type_for_member_access = true:suggestion
47 |
48 | # name all constant fields using PascalCase
49 | dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
50 | dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
51 | dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
52 |
53 | dotnet_naming_symbols.constant_fields.applicable_kinds = field
54 | dotnet_naming_symbols.constant_fields.required_modifiers = const
55 |
56 | dotnet_naming_style.pascal_case_style.capitalization = pascal_case
57 |
58 | # static fields should have s_ prefix
59 | dotnet_naming_rule.static_fields_should_have_prefix.severity = silent
60 | dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields
61 | dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
62 |
63 | dotnet_naming_symbols.static_fields.applicable_kinds = field
64 | dotnet_naming_symbols.static_fields.required_modifiers = static
65 |
66 | dotnet_naming_style.static_prefix_style.required_prefix = s_
67 | dotnet_naming_style.static_prefix_style.capitalization = camel_case
68 |
69 | # internal and private fields should be _camelCase
70 | dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
71 | dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
72 | dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
73 |
74 | dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
75 | dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
76 |
77 | dotnet_naming_style.camel_case_underscore_style.required_prefix = _
78 | dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
79 |
80 | # Code style defaults
81 | dotnet_sort_system_directives_first = true
82 |
83 | # Expression-level preferences
84 | dotnet_style_object_initializer = true:suggestion
85 | dotnet_style_collection_initializer = true:suggestion
86 | dotnet_style_explicit_tuple_names = true:suggestion
87 | dotnet_style_coalesce_expression = true:suggestion
88 | dotnet_style_null_propagation = true:suggestion
89 |
90 | # C# files
91 | [*.cs]
92 | dotnet_style_qualification_for_method = false:suggestion
93 | csharp_indent_case_contents_when_block = true
94 | csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
95 | csharp_prefer_braces = true:silent
96 | csharp_prefer_simple_default_expression = true:suggestion
97 | csharp_style_deconstructed_variable_declaration = true:suggestion
98 | csharp_style_pattern_local_over_anonymous_function = true:suggestion
99 | csharp_using_directive_placement = outside_namespace:silent
100 |
101 | # New line preferences
102 | csharp_new_line_before_open_brace = all
103 | csharp_new_line_before_else = true
104 | csharp_new_line_before_catch = true
105 | csharp_new_line_before_finally = true
106 | csharp_new_line_before_members_in_object_initializers = true
107 | csharp_new_line_before_members_in_anonymous_types = true
108 | csharp_new_line_between_query_expression_clauses = true
109 |
110 | # Indentation preferences
111 | csharp_indent_block_contents = true
112 | csharp_indent_braces = false
113 | csharp_indent_case_contents = true
114 | csharp_indent_switch_labels = true
115 | csharp_indent_labels = one_less_than_current
116 |
117 | # only use var when it's obvious what the variable type is
118 | csharp_style_var_for_built_in_types = false:none
119 | csharp_style_var_when_type_is_apparent = false:none
120 | csharp_style_var_elsewhere = false:suggestion
121 |
122 | # Code style defaults
123 | csharp_preserve_single_line_blocks = true
124 | csharp_preserve_single_line_statements = false
125 |
126 | # Expression-bodied members
127 | csharp_style_expression_bodied_methods = false:none
128 | csharp_style_expression_bodied_constructors = false:none
129 | csharp_style_expression_bodied_operators = false:none
130 | csharp_style_expression_bodied_properties = true:none
131 | csharp_style_expression_bodied_indexers = true:none
132 | csharp_style_expression_bodied_accessors = true:none
133 |
134 | # Pattern matching
135 | csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
136 | csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
137 | csharp_style_inlined_variable_declaration = true:suggestion
138 |
139 | # Null checking preferences
140 | csharp_style_throw_expression = true:suggestion
141 | csharp_style_conditional_delegate_call = true:suggestion
142 |
143 | # Space preferences
144 | csharp_space_after_cast = false
145 | csharp_space_after_colon_in_inheritance_clause = true
146 | csharp_space_after_comma = true
147 | csharp_space_after_dot = false
148 | csharp_space_after_keywords_in_control_flow_statements = true
149 | csharp_space_after_semicolon_in_for_statement = true
150 | csharp_space_around_binary_operators = before_and_after
151 | csharp_space_around_declaration_statements = do_not_ignore
152 | csharp_space_before_colon_in_inheritance_clause = true
153 | csharp_space_before_comma = false
154 | csharp_space_before_dot = false
155 | csharp_space_before_open_square_brackets = false
156 | csharp_space_before_semicolon_in_for_statement = false
157 | csharp_space_between_empty_square_brackets = false
158 | csharp_space_between_method_call_empty_parameter_list_parentheses = false
159 | csharp_space_between_method_call_name_and_opening_parenthesis = false
160 | csharp_space_between_method_call_parameter_list_parentheses = false
161 | csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
162 | csharp_space_between_method_declaration_name_and_open_parenthesis = false
163 | csharp_space_between_method_declaration_parameter_list_parentheses = false
164 | csharp_space_between_parentheses = false
165 | csharp_space_between_square_brackets = false
166 |
167 | # Visual Basic files
168 | [*.vb]
169 | # Modifier preferences
170 | visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:suggestion
171 | dotnet_style_qualification_for_method = true:warning
172 | dotnet_style_qualification_for_property = true:warning
173 |
174 | # locals should be camelCase
175 | dotnet_naming_symbols.locals.applicable_kinds = local
176 | dotnet_naming_style.camel_case_style.capitalization = camel_case
177 | dotnet_naming_rule.locals_must_have_camel_case.symbols = locals
178 | dotnet_naming_rule.locals_must_have_camel_case.severity = warning
179 | dotnet_naming_rule.locals_must_have_camel_case.style = camel_case_style
180 |
181 | # See https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions?view=vs-2019
182 | # Also see https://github.com/canton7/RestEase/blob/f7efb7684b96ce9da4f55d52f7abfa94eb7c0340/src/.editorconfig#L215
183 |
184 | # Symbols: async and method
185 | #dotnet_naming_symbols.async_methods.applicable_kinds = method
186 | #dotnet_naming_symbols.async_methods.required_modifiers = async
187 |
188 | # Style: must be Pascal case and end in Async
189 | #dotnet_naming_style.async_suffix.required_suffix = Async
190 | #dotnet_naming_style.async_suffix.capitalization = pascal_case
191 |
192 | # Rule: async methods must be pascal case and end with "Async"
193 | #dotnet_naming_rule.async_methods_must_have_async_suffix.symbols = async_methods
194 | #dotnet_naming_rule.async_methods_must_have_async_suffix.style = async_suffix
195 | #dotnet_naming_rule.async_methods_must_have_async_suffix.severity = warning
196 |
197 | # CA1031: Do not catch general exception types
198 | dotnet_diagnostic.ca1031.severity = silent
199 |
200 | # CA1050: Declare types in namespaces
201 | dotnet_diagnostic.CA1050.severity = none
202 |
203 | # CA1303: Do not pass literals as localized parameters
204 | dotnet_diagnostic.ca1303.severity = silent
205 |
206 | # CA1308: Do not pass literals as localized parameters
207 | dotnet_diagnostic.ca1308.severity = suggestion
208 |
209 | # CA1826: Do not use Enumerable methods on indexable collections. Instead use the collection directly
210 | dotnet_diagnostic.ca1826.severity = silent
211 |
212 | # Xml project files
213 | [*.{csproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj,vbproj}]
214 | indent_size = 2
215 |
216 | # Xml config files
217 | [*.{props,targets,config,nuspec}]
218 | indent_size = 2
219 |
220 | # resx Files
221 | [*.{resx,xlf}]
222 | indent_size = 2
223 | charset = utf-8-bom
224 | insert_final_newline = true
225 |
226 | [*.{cmd,bat}]
227 | end_of_line = crlf
228 |
--------------------------------------------------------------------------------
/CareLink/My Project/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | ..\Images\Shield.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
123 |
124 |
125 | ..\Images\SensorCommunicationLost.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
126 |
127 |
128 | ..\Images\SensorExpirationUnknown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
129 |
130 |
131 | ..\Images\CalibrationDotRed.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
132 |
133 |
134 | ..\Images\PumpBatteryFull.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
135 |
136 |
137 | ..\Images\PumpBatteryHigh.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
138 |
139 |
140 | ..\Images\InsulinVial.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
141 |
142 |
143 | ..\Images\PumpBatteryCritical.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
144 |
145 |
146 | ..\Images\SensorLifeNotOK.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
147 |
148 |
149 | ..\Images\TransmitterBatteryMedium.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
150 |
151 |
152 | ..\Images\Shield Disabled.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
153 |
154 |
155 | ..\Images\InsulinVial Tiny.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
156 |
157 |
158 | ..\Images\TransmitterBatteryLow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
159 |
160 |
161 | ..\Images\SensorExpired.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
162 |
163 |
164 | ..\Images\CalibrationDot.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
165 |
166 |
167 | ..\Images\TransmitterBatteryFull.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
168 |
169 |
170 | ..\Images\MealImage .png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
171 |
172 |
173 | ..\Images\TransmitterBatteryOK.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
174 |
175 |
176 | ..\Images\SensorLifeOK.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
177 |
178 |
179 | ..\Images\MealImageLarge.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
180 |
181 |
182 | ..\Images\PumpBatteryUnknown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
183 |
184 |
185 | ..\Images\PumpBatteryLow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
186 |
187 |
188 | ..\Images\PumpBatteryMedium.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
189 |
190 |
191 | ..\Images\TransmitterBatteryUnknown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
192 |
193 |
194 | ..\Images\CalibrationNotReady.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
195 |
196 |
197 | ..\Images\CalibrationUnavailable.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
198 |
199 |
--------------------------------------------------------------------------------
/CareLink/My Project/Resources.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' This code was generated by a tool.
4 | ' Runtime Version:4.0.30319.42000
5 | '
6 | ' Changes to this file may cause incorrect behavior and will be lost if
7 | ' the code is regenerated.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 | Imports System
15 |
16 | Namespace My.Resources
17 |
18 | 'This class was auto-generated by the StronglyTypedResourceBuilder
19 | 'class via a tool like ResGen or Visual Studio.
20 | 'To add or remove a member, edit your .ResX file then rerun ResGen
21 | 'with the /str option, or rebuild your VS project.
22 | '''
23 | ''' A strongly-typed resource class, for looking up localized strings, etc.
24 | '''
25 | _
29 | Friend Module Resources
30 |
31 | Private resourceMan As Global.System.Resources.ResourceManager
32 |
33 | Private resourceCulture As Global.System.Globalization.CultureInfo
34 |
35 | '''
36 | ''' Returns the cached ResourceManager instance used by this class.
37 | '''
38 | _
39 | Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
40 | Get
41 | If Object.ReferenceEquals(resourceMan, Nothing) Then
42 | Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("CareLink.Resources", GetType(Resources).Assembly)
43 | resourceMan = temp
44 | End If
45 | Return resourceMan
46 | End Get
47 | End Property
48 |
49 | '''
50 | ''' Overrides the current thread's CurrentUICulture property for all
51 | ''' resource lookups using this strongly typed resource class.
52 | '''
53 | _
54 | Friend Property Culture() As Global.System.Globalization.CultureInfo
55 | Get
56 | Return resourceCulture
57 | End Get
58 | Set
59 | resourceCulture = value
60 | End Set
61 | End Property
62 |
63 | '''
64 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
65 | '''
66 | Friend ReadOnly Property CalibrationDot() As System.Drawing.Bitmap
67 | Get
68 | Dim obj As Object = ResourceManager.GetObject("CalibrationDot", resourceCulture)
69 | Return CType(obj,System.Drawing.Bitmap)
70 | End Get
71 | End Property
72 |
73 | '''
74 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
75 | '''
76 | Friend ReadOnly Property CalibrationDotRed() As System.Drawing.Bitmap
77 | Get
78 | Dim obj As Object = ResourceManager.GetObject("CalibrationDotRed", resourceCulture)
79 | Return CType(obj,System.Drawing.Bitmap)
80 | End Get
81 | End Property
82 |
83 | '''
84 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
85 | '''
86 | Friend ReadOnly Property CalibrationNotReady() As System.Drawing.Bitmap
87 | Get
88 | Dim obj As Object = ResourceManager.GetObject("CalibrationNotReady", resourceCulture)
89 | Return CType(obj,System.Drawing.Bitmap)
90 | End Get
91 | End Property
92 |
93 | '''
94 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
95 | '''
96 | Friend ReadOnly Property CalibrationUnavailable() As System.Drawing.Bitmap
97 | Get
98 | Dim obj As Object = ResourceManager.GetObject("CalibrationUnavailable", resourceCulture)
99 | Return CType(obj,System.Drawing.Bitmap)
100 | End Get
101 | End Property
102 |
103 | '''
104 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
105 | '''
106 | Friend ReadOnly Property InsulinVial() As System.Drawing.Bitmap
107 | Get
108 | Dim obj As Object = ResourceManager.GetObject("InsulinVial", resourceCulture)
109 | Return CType(obj,System.Drawing.Bitmap)
110 | End Get
111 | End Property
112 |
113 | '''
114 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
115 | '''
116 | Friend ReadOnly Property InsulinVial_Tiny() As System.Drawing.Bitmap
117 | Get
118 | Dim obj As Object = ResourceManager.GetObject("InsulinVial_Tiny", resourceCulture)
119 | Return CType(obj,System.Drawing.Bitmap)
120 | End Get
121 | End Property
122 |
123 | '''
124 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
125 | '''
126 | Friend ReadOnly Property MealImage() As System.Drawing.Bitmap
127 | Get
128 | Dim obj As Object = ResourceManager.GetObject("MealImage", resourceCulture)
129 | Return CType(obj,System.Drawing.Bitmap)
130 | End Get
131 | End Property
132 |
133 | '''
134 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
135 | '''
136 | Friend ReadOnly Property MealImageLarge() As System.Drawing.Bitmap
137 | Get
138 | Dim obj As Object = ResourceManager.GetObject("MealImageLarge", resourceCulture)
139 | Return CType(obj,System.Drawing.Bitmap)
140 | End Get
141 | End Property
142 |
143 | '''
144 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
145 | '''
146 | Friend ReadOnly Property PumpBatteryCritical() As System.Drawing.Bitmap
147 | Get
148 | Dim obj As Object = ResourceManager.GetObject("PumpBatteryCritical", resourceCulture)
149 | Return CType(obj,System.Drawing.Bitmap)
150 | End Get
151 | End Property
152 |
153 | '''
154 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
155 | '''
156 | Friend ReadOnly Property PumpBatteryFull() As System.Drawing.Bitmap
157 | Get
158 | Dim obj As Object = ResourceManager.GetObject("PumpBatteryFull", resourceCulture)
159 | Return CType(obj,System.Drawing.Bitmap)
160 | End Get
161 | End Property
162 |
163 | '''
164 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
165 | '''
166 | Friend ReadOnly Property PumpBatteryHigh() As System.Drawing.Bitmap
167 | Get
168 | Dim obj As Object = ResourceManager.GetObject("PumpBatteryHigh", resourceCulture)
169 | Return CType(obj,System.Drawing.Bitmap)
170 | End Get
171 | End Property
172 |
173 | '''
174 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
175 | '''
176 | Friend ReadOnly Property PumpBatteryLow() As System.Drawing.Bitmap
177 | Get
178 | Dim obj As Object = ResourceManager.GetObject("PumpBatteryLow", resourceCulture)
179 | Return CType(obj,System.Drawing.Bitmap)
180 | End Get
181 | End Property
182 |
183 | '''
184 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
185 | '''
186 | Friend ReadOnly Property PumpBatteryMedium() As System.Drawing.Bitmap
187 | Get
188 | Dim obj As Object = ResourceManager.GetObject("PumpBatteryMedium", resourceCulture)
189 | Return CType(obj,System.Drawing.Bitmap)
190 | End Get
191 | End Property
192 |
193 | '''
194 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
195 | '''
196 | Friend ReadOnly Property PumpBatteryUnknown() As System.Drawing.Bitmap
197 | Get
198 | Dim obj As Object = ResourceManager.GetObject("PumpBatteryUnknown", resourceCulture)
199 | Return CType(obj,System.Drawing.Bitmap)
200 | End Get
201 | End Property
202 |
203 | '''
204 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
205 | '''
206 | Friend ReadOnly Property SensorCommunicationLost() As System.Drawing.Bitmap
207 | Get
208 | Dim obj As Object = ResourceManager.GetObject("SensorCommunicationLost", resourceCulture)
209 | Return CType(obj,System.Drawing.Bitmap)
210 | End Get
211 | End Property
212 |
213 | '''
214 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
215 | '''
216 | Friend ReadOnly Property SensorExpirationUnknown() As System.Drawing.Bitmap
217 | Get
218 | Dim obj As Object = ResourceManager.GetObject("SensorExpirationUnknown", resourceCulture)
219 | Return CType(obj,System.Drawing.Bitmap)
220 | End Get
221 | End Property
222 |
223 | '''
224 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
225 | '''
226 | Friend ReadOnly Property SensorExpired() As System.Drawing.Bitmap
227 | Get
228 | Dim obj As Object = ResourceManager.GetObject("SensorExpired", resourceCulture)
229 | Return CType(obj,System.Drawing.Bitmap)
230 | End Get
231 | End Property
232 |
233 | '''
234 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
235 | '''
236 | Friend ReadOnly Property SensorLifeNotOK() As System.Drawing.Bitmap
237 | Get
238 | Dim obj As Object = ResourceManager.GetObject("SensorLifeNotOK", resourceCulture)
239 | Return CType(obj,System.Drawing.Bitmap)
240 | End Get
241 | End Property
242 |
243 | '''
244 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
245 | '''
246 | Friend ReadOnly Property SensorLifeOK() As System.Drawing.Bitmap
247 | Get
248 | Dim obj As Object = ResourceManager.GetObject("SensorLifeOK", resourceCulture)
249 | Return CType(obj,System.Drawing.Bitmap)
250 | End Get
251 | End Property
252 |
253 | '''
254 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
255 | '''
256 | Friend ReadOnly Property Shield() As System.Drawing.Bitmap
257 | Get
258 | Dim obj As Object = ResourceManager.GetObject("Shield", resourceCulture)
259 | Return CType(obj,System.Drawing.Bitmap)
260 | End Get
261 | End Property
262 |
263 | '''
264 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
265 | '''
266 | Friend ReadOnly Property Shield_Disabled() As System.Drawing.Bitmap
267 | Get
268 | Dim obj As Object = ResourceManager.GetObject("Shield_Disabled", resourceCulture)
269 | Return CType(obj,System.Drawing.Bitmap)
270 | End Get
271 | End Property
272 |
273 | '''
274 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
275 | '''
276 | Friend ReadOnly Property TransmitterBatteryFull() As System.Drawing.Bitmap
277 | Get
278 | Dim obj As Object = ResourceManager.GetObject("TransmitterBatteryFull", resourceCulture)
279 | Return CType(obj,System.Drawing.Bitmap)
280 | End Get
281 | End Property
282 |
283 | '''
284 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
285 | '''
286 | Friend ReadOnly Property TransmitterBatteryLow() As System.Drawing.Bitmap
287 | Get
288 | Dim obj As Object = ResourceManager.GetObject("TransmitterBatteryLow", resourceCulture)
289 | Return CType(obj,System.Drawing.Bitmap)
290 | End Get
291 | End Property
292 |
293 | '''
294 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
295 | '''
296 | Friend ReadOnly Property TransmitterBatteryMedium() As System.Drawing.Bitmap
297 | Get
298 | Dim obj As Object = ResourceManager.GetObject("TransmitterBatteryMedium", resourceCulture)
299 | Return CType(obj,System.Drawing.Bitmap)
300 | End Get
301 | End Property
302 |
303 | '''
304 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
305 | '''
306 | Friend ReadOnly Property TransmitterBatteryOK() As System.Drawing.Bitmap
307 | Get
308 | Dim obj As Object = ResourceManager.GetObject("TransmitterBatteryOK", resourceCulture)
309 | Return CType(obj,System.Drawing.Bitmap)
310 | End Get
311 | End Property
312 |
313 | '''
314 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
315 | '''
316 | Friend ReadOnly Property TransmitterBatteryUnknown() As System.Drawing.Bitmap
317 | Get
318 | Dim obj As Object = ResourceManager.GetObject("TransmitterBatteryUnknown", resourceCulture)
319 | Return CType(obj,System.Drawing.Bitmap)
320 | End Get
321 | End Property
322 | End Module
323 | End Namespace
324 |
--------------------------------------------------------------------------------
/CareLink/carelink_client.vb:
--------------------------------------------------------------------------------
1 | ' Licensed to the .NET Foundation under one or more agreements.
2 | ' The .NET Foundation licenses this file to you under the MIT license.
3 | ' See the LICENSE file in the project root for more information.
4 |
5 | Imports System.Net
6 | Imports System.Net.Http
7 |
8 | Public Module CarelinkClient
9 | Private Const CarelinkAuthTokenCookieName As String = "auth_tmp_token"
10 | Private Const CarelinkConnectServerEu As String = "carelink.minimed.eu"
11 | Private Const CarelinkConnectServerUs As String = "carelink.minimed.com"
12 | Private Const CarelinkLanguageEn As String = "en"
13 | Private Const CarelinkLocaleEn As String = "en"
14 | Private Const CarelinkTokenValidtoCookieName As String = "c_token_valid_to"
15 |
16 | Public Class CareLinkClient
17 | Inherits Object
18 |
19 | Private ReadOnly _carelinkCountry As String
20 | Private ReadOnly _carelinkPassword As String
21 | Private ReadOnly _carelinkUsername As String
22 | Private ReadOnly _commonHeaders As Dictionary(Of String, String)
23 | Private ReadOnly _httpClient As HttpClient
24 | Private ReadOnly _httpClientHandler As HttpClientHandler
25 | Private _lastDataSuccess As Boolean
26 | Private _lastResponseCode As HttpStatusCode
27 | Private _loginInProcess As Boolean
28 | Private _sessionCountrySettings As Dictionary(Of String, String)
29 | Private _sessionMonitorData As Dictionary(Of String, String)
30 | Private _sessionProfile As Dictionary(Of String, String)
31 | Private _sessionUser As Dictionary(Of String, String)
32 |
33 | Public Sub New(carelinkUsername As String, carelinkPassword As String, carelinkCountry As String)
34 | ' User info
35 | _carelinkUsername = carelinkUsername
36 | _carelinkPassword = carelinkPassword
37 | _carelinkCountry = carelinkCountry
38 | ' Session info
39 | _sessionUser = Nothing
40 | _sessionProfile = Nothing
41 | _sessionCountrySettings = Nothing
42 | _sessionMonitorData = Nothing
43 | ' State info
44 | _loginInProcess = False
45 | Me.LoggedIn = False
46 | _lastDataSuccess = False
47 | _lastResponseCode = Nothing
48 | Me.LastErrorMessage = Nothing
49 | _commonHeaders = New Dictionary(Of String, String) From {
50 | {
51 | "Accept-Language",
52 | "en;q=0.9, *;q=0.8"},
53 | {
54 | "Connection",
55 | "keep-alive"},
56 | {
57 | "sec-ch-ua",
58 | """Google Chrome"";v=""87"", "" Not;A Brand"";v=""99"", ""Chromium"";v=""87"""},
59 | {
60 | "User-Agent",
61 | "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"},
62 | {
63 | "Accept",
64 | "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"}}
65 |
66 | Dim cookieContainer As New CookieContainer()
67 | _httpClientHandler = New HttpClientHandler With {.CookieContainer = cookieContainer}
68 | _httpClient = New HttpClient(_httpClientHandler)
69 | End Sub
70 |
71 | Public Property LastErrorMessage As String
72 | Public Property LoggedIn As Boolean
73 |
74 | Private Shared Function Parse_qsl(loginSessionResponse As HttpResponseMessage) As Dictionary(Of String, String)
75 | Dim result As New Dictionary(Of String, String)
76 | Dim absoluteUri As String = loginSessionResponse.RequestMessage.RequestUri.AbsoluteUri
77 | Dim splitAbsoluteUri() As String = absoluteUri.Split("&")
78 | For Each item As String In splitAbsoluteUri
79 | Dim splitItem() As String
80 | If Not result.Any Then
81 | item = item.Split("?")(1)
82 | End If
83 | splitItem = item.Split("=")
84 | result.Add(splitItem(0), splitItem(1))
85 | Next
86 | Return result
87 | End Function
88 |
89 | Private Function GetCookies(url As String) As CookieCollection
90 | If String.IsNullOrWhiteSpace(url) Then
91 | Return Nothing
92 | End If
93 | Return _httpClientHandler.CookieContainer.GetCookies(New Uri($"https://{url}"))
94 | End Function
95 |
96 | Private Function GetCookieValue(url As String, cookieName As String) As String
97 | If String.IsNullOrWhiteSpace(url) Then
98 | Return Nothing
99 | End If
100 | Dim cookie As Cookie = _httpClientHandler.CookieContainer.GetCookies(New Uri($"https://{url}")).Cast(Of Cookie)().FirstOrDefault(Function(c As Cookie) c.Name = cookieName)
101 | Return cookie?.Value
102 | End Function
103 |
104 | Public Shared Sub Printdbg(msg As String)
105 | Console.WriteLine(msg)
106 | Application.DoEvents()
107 | End Sub
108 |
109 | ' Get server URL
110 | Public Overridable Function __careLinkServer() As String
111 | Return If(_carelinkCountry = "us", CarelinkConnectServerUs, CarelinkConnectServerEu)
112 | End Function
113 |
114 | Public Overridable Function __correctTimeInRecentData(recentData As Dictionary(Of String, String)) As Boolean
115 | ' TODO
116 | Return True
117 | End Function
118 |
119 | Public Overridable Function __doConsent(doLoginResponse As HttpResponseMessage) As HttpResponseMessage
120 |
121 | ' Extract data for consent
122 | Dim doLoginRespBody As String = doLoginResponse.Text
123 | Dim url As String = Me.__extractResponseData(doLoginRespBody, "