BlueMystical / Dark-Mode-Forms

Apply Dark Mode to all Controls in a Form [WinForms]
GNU General Public License v3.0
110 stars 15 forks source link

Some color application fixes. #64

Closed trparky closed 3 weeks ago

trparky commented 3 weeks ago

I found that the code wasn't applying colors to buttons, textboxes, and datagridrows properly so I fixed it.

BlueMystical commented 3 weeks ago

Hi Parky o/' yeah that has a reason: The DarkMode applied to those controls, and several others like ListView, TreeView, etc. is made thru implementation of Win32 APIs not by direct Color applying, The code you saw is to 'polish' the controls, because sometimes they have missing parts or stuff, Microsoft did not intended the controls to be themed, so we gotta have to be 'creative'. Some controls like the TabControl does required A LOT of creative thought, hehe. Still many thanks for your contribution, its appreciated. Regards.

trparky commented 3 weeks ago

Yeah, but in my experience, the theming without my changes don't apply properly.

BlueMystical commented 3 weeks ago

oh, noone had reported a bug like that, could you please share an screenshot of the issue so i can replicate ?

trparky commented 3 weeks ago

Before my changes...image After my changes...image

Notice the subtle color difference. The background of the textbox is gray, it should be white when in standard mode. Also look at the button, again... the color isn't right.

BlueMystical commented 3 weeks ago

i see now. ok could you please re-submit the PR and i'll just aprove it

kachnitata commented 3 weeks ago

I see... Would you please also post the screenshots for the dark mode, to check if there is any difference too?

trparky commented 3 weeks ago

And then there's how the datagrid doesn't get themed properly. Case in point... image With my fixes... it's not perfect but it's getting there. image

kachnitata commented 3 weeks ago

Is it really the older DataGrid? I use only DataGridView's and those seem always OK, at least in the dark mode.

BlueMystical commented 3 weeks ago

maybe it has something to do with the odd rows coloring the Example Form, has a Datagrid with all default properties, and it works just fine image

trparky commented 3 weeks ago

Older datagrid? I didn't know there was a new one. I'm just using the one that the .NET Framework came with.

trparky commented 3 weeks ago

This is snippets of the pertinent code for my DataGrid.

Me.Logs.AllowUserToAddRows = False
Me.Logs.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Logs.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight
Me.Logs.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
Me.Logs.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.ColTime, Me.colServerTime, Me.colLogType, Me.ColIPAddress, Me.ColHostname, Me.ColRemoteProcess, Me.ColLog, Me.ColAlerts})
Me.Logs.ContextMenuStrip = Me.LogsMenu
Me.Logs.Location = New System.Drawing.Point(12, 52)
Me.Logs.Name = "Logs"
Me.Logs.ReadOnly = True
Me.Logs.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect
Me.Logs.Size = New System.Drawing.Size(1151, 369)
Me.Logs.TabIndex = 18

Public Function MakeDataGridRow(serverTimeStamp As Date, dateObject As Date, strTime As String, strSourceAddress As String, strHostname As String, strRemoteProcess As String, strLog As String, strLogType As String, boolAlerted As Boolean, strRawLogText As String, strAlertText As String, ByRef dataGrid As DataGridView) As MyDataGridViewRow
    Using MyDataGridViewRow As New MyDataGridViewRow
        With MyDataGridViewRow
            .CreateCells(dataGrid)
            .Cells(ColumnIndex_ComputedTime).Value = strTime
            .Cells(ColumnIndex_ComputedTime).Style.Alignment = DataGridViewContentAlignment.MiddleCenter
            .Cells(ColumnIndex_LogType).Value = If(String.IsNullOrWhiteSpace(strLogType), "", strLogType)
            .Cells(ColumnIndex_IPAddress).Value = strSourceAddress
            .Cells(ColumnIndex_RemoteProcess).Value = If(String.IsNullOrWhiteSpace(strRemoteProcess), "", strRemoteProcess)
            .Cells(ColumnIndex_Hostname).Value = If(String.IsNullOrWhiteSpace(strHostname), "", strHostname)
            .Cells(ColumnIndex_ServerTime).Value = ToIso8601Format(serverTimeStamp)
            .Cells(ColumnIndex_LogText).Value = strLog
            .Cells(ColumnIndex_Alerted).Value = If(boolAlerted, "Yes", "No")
            .Cells(ColumnIndex_Alerted).Style.Alignment = DataGridViewContentAlignment.MiddleCenter
            .Cells(ColumnIndex_Alerted).Style.WrapMode = DataGridViewTriState.True
            .DateObject = dateObject
            .BoolAlerted = boolAlerted
            .ServerDate = serverTimeStamp
            .RawLogData = strRawLogText
            .AlertText = strAlertText
            .MinimumHeight = GetMinimumHeight(strLog, ParentForm.Logs.DefaultCellStyle.Font, ParentForm.ColLog.Width)

            If My.Settings.font IsNot Nothing Then
                .Cells(ColumnIndex_ComputedTime).Style.Font = My.Settings.font
                .Cells(ColumnIndex_LogType).Style.Font = My.Settings.font
                .Cells(ColumnIndex_IPAddress).Style.Font = My.Settings.font
                .Cells(ColumnIndex_RemoteProcess).Style.Font = My.Settings.font
                .Cells(ColumnIndex_Hostname).Style.Font = My.Settings.font
                .Cells(ColumnIndex_LogText).Style.Font = My.Settings.font
                .Cells(ColumnIndex_Alerted).Style.Font = My.Settings.font
                .Cells(ColumnIndex_ServerTime).Style.Font = My.Settings.font
            End If
        End With

        Return MyDataGridViewRow
    End Using
End Function

Logs.Rows.Add(SyslogParser.MakeDataGridRow(serverTimeStamp:=Now,
                                           dateObject:=Now,
                                           strTime:=Nothing,
                                           strSourceAddress:=Nothing,
                                           strHostname:="Local",
                                           strRemoteProcess:=Nothing,
                                           strLog:="Loading data and populating data grid... Please Wait.",
                                           strLogType:="Informational, Local",
                                           boolAlerted:=False,
                                           strRawLogText:=Nothing,
                                           strAlertText:=Nothing,
                                           dataGrid:=Logs)
                                          )
kachnitata commented 3 weeks ago

I meant the very old DataGrid as opposed to the newer DataGridView. I am not sure which one you use. You mentioned DataGrid multiple times but your code snippet refers, for example, DataGridViewRow... So it is confusing for me

trparky commented 3 weeks ago

DataGrid, DataGridView, same thing to me.

trparky commented 3 weeks ago

System.Windows.Forms.DataGridView