Skip to content

Commit

Permalink
Add AddDarkMode support
Browse files Browse the repository at this point in the history
  • Loading branch information
paul1956 committed Sep 24, 2024
1 parent 60e8dca commit 65c38f6
Show file tree
Hide file tree
Showing 32 changed files with 46,518 additions and 843 deletions.
4 changes: 3 additions & 1 deletion src/CareLink/ApplicationEvents.vb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ Namespace My

' Setting the HighDpiMode for the Application:
e.HighDpiMode = HighDpiMode.PerMonitorV2

#Disable Warning WFO5001 ' Type is for evaluation purposes only and is subject to change or removal in future updates.
e.ColorMode = SystemColorMode.Dark
#Enable Warning WFO5001 ' Type is for evaluation purposes only and is subject to change or removal in future updates.
' ' If a splash dialog is used, this sets the minimum display time:
' e.MinimumSplashScreenDisplayTime = 4000
End Sub
Expand Down
3 changes: 2 additions & 1 deletion src/CareLink/CareLink.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
<TargetFramework>net9.0-windows10.0.17763.0</TargetFramework>
<RootNamespace>CareLink</RootNamespace>
<StartupObject>Sub Main</StartupObject>
<UseWindowsForms>true</UseWindowsForms>
Expand Down Expand Up @@ -36,6 +36,7 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
<ImportedNamespaces>System.Data=True,System.Drawing=True,System.Windows.Forms=True,System.Windows.Forms.DataVisualization.Charting=True,Microsoft.VisualBasic=True,System=True,System.Collections=True,System.Collections.Generic=True,System.Diagnostics=True,System.Linq=True,System.Xml.Linq=True,System.Threading.Tasks=True,CareLink=True</ImportedNamespaces>
<GenerateResourceWarnOnBinaryFormatterUse>false</GenerateResourceWarnOnBinaryFormatterUse>
<NoWarn>$(NoWarn);WFO1000</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
3 changes: 3 additions & 0 deletions src/CareLink/CareLink.vbproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Dialogs\CleanUpObsoleteFilesDialog.resx">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Update="Forms\AboutBox1.resx">
<SubType>Designer</SubType>
</EmbeddedResource>
Expand Down
6 changes: 3 additions & 3 deletions src/CareLink/Dialogs/LoginDialog.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,273 changes: 1,035 additions & 238 deletions src/CareLink/Dialogs/LoginDialog.resx

Large diffs are not rendered by default.

573 changes: 459 additions & 114 deletions src/CareLink/Forms/Form1.Designer.vb

Large diffs are not rendered by default.

44,714 changes: 44,710 additions & 4 deletions src/CareLink/Forms/Form1.resx

Large diffs are not rendered by default.

90 changes: 60 additions & 30 deletions src/CareLink/Forms/Form1.vb
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,6 @@ Imports Microsoft.Win32
Imports TableLayputPanelTop

Public Class Form1
Friend WithEvents TableLayoutPanelActiveInsulinTop As TableLayoutPanelTopEx
Friend WithEvents TableLayoutPanelAutoBasalDeliveryTop As TableLayoutPanelTopEx
Friend WithEvents TableLayoutPanelAutoModeStatusTop As TableLayoutPanelTopEx
Friend WithEvents TableLayoutPanelBannerStateTop As TableLayoutPanelTopEx
Friend WithEvents TableLayoutPanelBasalTop As TableLayoutPanelTopEx
Friend WithEvents TableLayoutPanelBgReadingsTop As TableLayoutPanelTopEx
Friend WithEvents TableLayoutPanelCalibrationTop As TableLayoutPanelTopEx
Friend WithEvents TableLayoutPanelInsulinTop As TableLayoutPanelTopEx
Friend WithEvents TableLayoutPanelLastAlarmTop As TableLayoutPanelTopEx
Friend WithEvents TableLayoutPanelLastSgTop As TableLayoutPanelTopEx
Friend WithEvents TableLayoutPanelLimitsTop As TableLayoutPanelTopEx
Friend WithEvents TableLayoutPanelLowGlucoseSuspendedTop As TableLayoutPanelTopEx
Friend WithEvents TableLayoutPanelMealTop As TableLayoutPanelTopEx
Friend WithEvents TableLayoutPanelNotificationHistoryTop As TableLayoutPanelTopEx
Friend WithEvents TableLayoutPanelSgsTop As TableLayoutPanelTopEx
Friend WithEvents TableLayoutPanelTherapyAlgorithmTop As TableLayoutPanelTopEx
Friend WithEvents TableLayoutPanelTimeChangeTop As TableLayoutPanelTopEx

Private Shared s_webViewCacheDirectory As String
Private ReadOnly _calibrationToolTip As New ToolTip()
Expand Down Expand Up @@ -509,17 +492,22 @@ Public Class Form1
Private Sub DgvAutoBasalDelivery_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs) Handles DgvAutoBasalDelivery.CellFormatting
Dim dgv As DataGridView = CType(sender, DataGridView)
If e.Value Is Nothing Then
e.Value = String.Empty
Return
End If
' Set the background to red for negative values in the Balance column.
Select Case dgv.Columns(e.ColumnIndex).Name
Case NameOf(AutoBasalDeliveryRecord.bolusAmount)
CellFormattingSingleValue(e, 3)
If CellFormattingSingleValue(e, 3).IsMinBasal Then
CellFormattingApplyColor(e, GetGraphLineColor("Min Basal"), 0, False)
dgv.CellFormattingSingleValue(e, 3)
If dgv.CellFormattingSingleValue(e, 3).IsMinBasal Then
CellFormattingApplyColor(e, Color.DarkRed, isUri:=False)
Else
dgv.CellFormattingSetForegroundColor(e)
End If
Case NameOf(AutoBasalDeliveryRecord.dateTime)
CellFormattingDateTime(e)
dgv.CellFormattingDateTime(e)
Case Else
dgv.CellFormattingSetForegroundColor(e)
End Select
End Sub

Expand Down Expand Up @@ -579,6 +567,14 @@ Public Class Form1

End Sub

Private Sub DgvCareLinkUsers_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs) Handles DgvCareLinkUsers.CellFormatting
Dim dgv As DataGridView = CType(sender, DataGridView)
Dim col As DataGridViewTextBoxColumn = TryCast(dgv.Columns(e.ColumnIndex), DataGridViewTextBoxColumn)
If col IsNot Nothing Then
dgv.CellFormattingSetForegroundColor(e)
End If
End Sub

Private Sub DgvCareLinkUsers_CellValidating(sender As Object, e As DataGridViewCellValidatingEventArgs) Handles DgvCareLinkUsers.CellValidating
If e.ColumnIndex = 0 Then
Exit Sub
Expand Down Expand Up @@ -714,6 +710,16 @@ Public Class Form1

#End Region ' Dgv CareLink Users Events

#Region "Dgv Country Pg1 Events" ' Dgv Country Pg1 Events

Private Sub DgvCountryDataPg1_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs) Handles DgvCountryDataPg1.CellFormatting
If e.RowIndex = -1 Then Exit Sub
Dim dgv As DataGridView = CType(sender, DataGridView)
dgv.CellFormattingSetForegroundColor(e)
End Sub

#End Region ' Dgv Country Pg1 Events

#Region "Dgv Country Pg2 Events"

Private Sub DgvCountryDataPg2_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles DgvCountryDataPg2.CellClick
Expand All @@ -734,15 +740,37 @@ Public Class Form1
If e.RowIndex = -1 Then Exit Sub
Dim dgv As DataGridView = CType(sender, DataGridView)
If dgv.Columns(e.ColumnIndex).HeaderText = "Value" Then
Dim uriString As String = e.Value.ToString()
Dim uriString As String = $"{e.Value}"
If uriString.StartsWith("https:", StringComparison.InvariantCultureIgnoreCase) AndAlso Uri.IsWellFormedUriString(uriString, UriKind.Absolute) Then
dgv.CellFormattingUrl(e)
Else
dgv.CellFormattingSetForegroundColor(e)
End If
Else
dgv.CellFormattingSetForegroundColor(e)
End If
End Sub

#End Region ' Dgv Country Pg2 Events

#Region "Dgv Country Pg3 Events" ' Dgv Country Pg3 Events
Private Sub DgvCountryDataPg3_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs) Handles DgvCountryDataPg3.CellFormatting
If e.RowIndex = -1 Then Exit Sub
Dim dgv As DataGridView = CType(sender, DataGridView)
If dgv.Columns(e.ColumnIndex).HeaderText = "Value" Then
Dim uriString As String = $"{e.Value}"
If uriString.StartsWith("https:", StringComparison.InvariantCultureIgnoreCase) AndAlso Uri.IsWellFormedUriString(uriString, UriKind.Absolute) Then
dgv.CellFormattingUrl(e)
Else
dgv.CellFormattingSetForegroundColor(e)
End If
Else
dgv.CellFormattingSetForegroundColor(e)
End If
End Sub

#End Region ' Dgv Country Pg3 Events

#Region "Dgv Current User Events"

Private Sub DgvCurrentUser_ColumnAdded(sender As Object, e As DataGridViewColumnEventArgs) Handles DgvCurrentUser.ColumnAdded
Expand Down Expand Up @@ -773,9 +801,9 @@ Public Class Form1
Dim dgv As DataGridView = CType(sender, DataGridView)
Select Case dgv.Columns(e.ColumnIndex).Name
Case NameOf(MealRecord.amount)
CellFormattingInteger(e, s_sessionCountrySettings.carbDefaultUnit)
dgv.CellFormattingInteger(e, s_sessionCountrySettings.carbDefaultUnit)
Case NameOf(MealRecord.dateTime)
CellFormattingDateTime(e)
dgv.CellFormattingDateTime(e)
End Select
End Sub

Expand Down Expand Up @@ -813,13 +841,15 @@ Public Class Form1
Case NameOf(SgRecord.sensorState)
' Set the background to red for negative values in the Balance column.
If Not e.Value.Equals("NO_ERROR_MESSAGE") Then
CellFormattingApplyColor(e, Color.Red, 1 - alternateIndex, False)
CellFormattingApplyColor(e, Color.Red, isUri:=False)
End If
CellFormattingToTitle(e)
dgv.CellFormattingToTitle(e)
Case NameOf(SgRecord.datetime)
CellFormattingDateTime(e)
dgv.CellFormattingDateTime(e)
Case NameOf(SgRecord.sg), NameOf(SgRecord.sgMmolL), NameOf(SgRecord.sgMmDl)
dgv.CellFormattingSgValue(e, NameOf(SgRecord.sg), alternateIndex)
dgv.CellFormattingSgValue(e, NameOf(SgRecord.sg))
Case Else
dgv.CellFormattingSetForegroundColor(e)
End Select
End Sub

Expand Down Expand Up @@ -1082,7 +1112,6 @@ Public Class Form1
End If

Me.InitializeDgvCareLinkUsers(Me.DgvCareLinkUsers)
InitializeTableLayoutPanelTops()
s_formLoaded = True
Me.MenuOptionsAudioAlerts.Checked = My.Settings.SystemAudioAlertsEnabled
Me.MenuOptionsSpeechRecognitionEnabled.Checked = My.Settings.SystemSpeechRecognitionThreshold < 1
Expand Down Expand Up @@ -2969,7 +2998,8 @@ Public Class Form1

Me.TableLayoutPanelSgs.DisplayDataTableInDGV(
Me.DgvSGs,
ClassCollectionToDataTable(s_listOfSgRecords.OrderByDescending(Function(x) x.RecordNumber).ToList()),
ClassCollectionToDataTable(
classCollection:=s_listOfSgRecords.OrderByDescending(Function(x) x.RecordNumber).ToList()),
ItemIndexes.sgs)
Me.DgvSGs.Columns(0).HeaderCell.SortGlyphDirection = SortOrder.Descending

Expand Down
Loading

0 comments on commit 65c38f6

Please sign in to comment.