Skip to content

Commit

Permalink
Improve mode color support
Browse files Browse the repository at this point in the history
Change Interlocked.Increment to Threading.Interlocked.Increment to partly address issue #72 and update tests
  • Loading branch information
paul1956 committed Mar 25, 2021
1 parent 806df6e commit d1a28b7
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 36 deletions.
6 changes: 3 additions & 3 deletions CSharpToVB.Tests/CSharpToVB.Tests.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
<RepositoryType>git</RepositoryType>
<Copyright>Copyright (c) .NET Foundation and Contributors</Copyright>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AssemblyVersion>5.0.0.14</AssemblyVersion>
<FileVersion>5.0.0.14</FileVersion>
<Version>5.0.0.14</Version>
<AssemblyVersion>5.0.0.15</AssemblyVersion>
<FileVersion>5.0.0.15</FileVersion>
<Version>5.0.0.15</Version>
<Product>CSharp To VB Tests</Product>
<UseDataCollector />
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion CSharpToVB.Tests/Tests/CSharpToVB/MemberTests.vb
Original file line number Diff line number Diff line change
Expand Up @@ -1511,7 +1511,7 @@ public class ConversionResult

Public WriteOnly Property Num As String
Set(Value As String)
Call Math.Min(Interlocked.Increment(_num), _num - 1)
Call Math.Min(Threading.Interlocked.Increment(_num), _num - 1)
End Set
End Property

Expand Down
4 changes: 2 additions & 2 deletions CSharpToVB.Tests/Tests/CSharpToVB/SpecialConversionTests.vb
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ End Class")

Private Sub TestMethod()
Dim b As Integer, a As Integer = 5
b = Math.Min(Interlocked.Increment(a), a - 1)
b = Math.Min(Threading.Interlocked.Increment(a), a - 1)
End Sub
End Class")
End Sub
Expand Down Expand Up @@ -741,7 +741,7 @@ End Class")

Private Sub TestMethod()
Dim b As Integer, a As Integer = 5
b = Math.Min(Interlocked.Increment(a), a - 1)
b = Math.Min(Threading.Interlocked.Increment(a), a - 1)
End Sub
End Class")
End Sub
Expand Down
2 changes: 1 addition & 1 deletion CSharpToVB.Tests/Tests/CSharpToVB/StatementTests.vb
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ End Class")
For i As Integer = 0 To x - 1

For j As Integer = 0 To y - 1
array(i, j) = Interlocked.Increment(count).ToString()
array(i, j) = Threading.Interlocked.Increment(count).ToString()
Next
Next

Expand Down
6 changes: 3 additions & 3 deletions CSharpToVB/CSharpToVB.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
<Product>CSharp To VB Converter</Product>
<Copyright>Copyright (c) .NET Foundation and Contributors</Copyright>
<PackageId>CSharp To VB Converter</PackageId>
<AssemblyVersion>5.0.3.0</AssemblyVersion>
<FileVersion>5.0.3.0</FileVersion>
<Version>5.0.3.0</Version>
<AssemblyVersion>5.0.3.1</AssemblyVersion>
<FileVersion>5.0.3.1</FileVersion>
<Version>5.0.3.1</Version>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand Down
14 changes: 0 additions & 14 deletions CSharpToVB/ColorModeSupport/ThemeSupport.vb
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,13 @@ Public Module ThemeSupport
t.ForeColor = Color.Silver
For Each tab As TabPage In t.TabPages
tab.BackColor = Color.FromArgb(40, 40, 40)
tab.BorderStyle = BorderStyle.None
SetDarkMode(tab.Controls, mCapturedRenderer)
Next

ElseIf TypeOf c Is Panel Then
Dim p As Panel = CType(c, Panel)
p.BackColor = Color.FromArgb(40, 40, 40)
p.ForeColor = Color.Silver
p.Padding = New Padding(1)
Dim panelEx As PanelEx = TryCast(c, PanelEx)
If panelEx IsNot Nothing Then
panelEx.BorderColor = Color.FromArgb(60, 60, 60)
Expand All @@ -77,20 +75,14 @@ Public Module ThemeSupport
Dim rtb As RichTextBox = CType(c, RichTextBox)
rtb.BackColor = Color.FromArgb(45, 45, 45)
rtb.ForeColor = Color.Silver
rtb.BorderStyle = BorderStyle.None
'If TypeOf rtb.Parent Is PanelEx Then
' CType(rtb.Parent, PanelEx).BorderColor = Color.FromArgb(60, 60, 60)
'End If

ElseIf TypeOf c Is TreeView Then
Dim tvw As TreeView = CType(c, TreeView)
tvw.BackColor = Color.FromArgb(40, 40, 40)
tvw.ForeColor = Color.Silver
tvw.BorderStyle = BorderStyle.None

ElseIf TypeOf c Is TextBox Then
Dim tb As TextBox = CType(c, TextBox)
tb.BorderStyle = BorderStyle.FixedSingle
tb.BackColor = Color.FromArgb(60, 60, 60)
tb.ForeColor = Color.Silver

Expand All @@ -101,12 +93,10 @@ Public Module ThemeSupport
btn.ForeColor = Color.Silver
ElseIf TypeOf c Is Label Then
Dim lb As Label = CType(c, Label)
lb.BorderStyle = BorderStyle.FixedSingle
lb.BackColor = Color.FromArgb(60, 60, 60)
lb.ForeColor = Color.Silver
ElseIf TypeOf c Is ListBox Then
Dim lb As ListBox = CType(c, ListBox)
lb.BorderStyle = BorderStyle.FixedSingle
lb.BackColor = Color.FromArgb(60, 60, 60)
lb.ForeColor = Color.Silver
ElseIf TypeOf c Is ProgressBar Then
Expand Down Expand Up @@ -195,7 +185,6 @@ Public Module ThemeSupport
Dim p As Panel = CType(c, Panel)
p.BackColor = SystemColors.Control
p.ForeColor = SystemColors.ControlText
p.Padding = New Padding(1)
Dim panelEx As PanelEx = TryCast(c, PanelEx)
If panelEx IsNot Nothing Then
panelEx.BorderColor = SystemColors.WindowFrame
Expand All @@ -214,7 +203,6 @@ Public Module ThemeSupport

ElseIf TypeOf c Is TextBox Then
Dim tb As TextBox = CType(c, TextBox)
tb.BorderStyle = BorderStyle.FixedSingle
tb.BackColor = Color.White
tb.ForeColor = SystemColors.ControlText

Expand All @@ -225,13 +213,11 @@ Public Module ThemeSupport

ElseIf TypeOf c Is Label Then
Dim lb As Label = CType(c, Label)
lb.BorderStyle = BorderStyle.FixedSingle
lb.BackColor = Color.White
lb.ForeColor = SystemColors.ControlText

ElseIf TypeOf c Is ListBox Then
Dim lb As ListBox = CType(c, ListBox)
lb.BorderStyle = BorderStyle.FixedSingle
lb.BackColor = Color.White
lb.ForeColor = SystemColors.ControlText

Expand Down
13 changes: 12 additions & 1 deletion CSharpToVB/Forms/Form1.Designer.vb

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

12 changes: 6 additions & 6 deletions CSharpToVB/Forms/Form1.vb
Original file line number Diff line number Diff line change
Expand Up @@ -1113,13 +1113,13 @@ namespace Application
Me.ConversionOutput.Height = Me.ConversionInputPanelEx.Height - 6
Me.ConversionOutput.Width = halfClientWidth - lineNumberOutputWidth - 6

Me.FileListListBox.Left = 2
Me.FileListListBox.Width = Me.FileListPanelEx.ClientRectangle.Width - 4
Me.FileListListBox.Height = Me.FileListPanelEx.ClientRectangle.Height - 2
'Me.FileListListBox.Left = 2
'Me.FileListListBox.Width = Me.FileListPanelEx.ClientRectangle.Width - 4
'Me.FileListListBox.Height = Me.FileListPanelEx.ClientRectangle.Height - 2

Me.ErrorListListBox.Left = 2
Me.ErrorListListBox.Width = Me.ErrorListPanelEx.ClientRectangle.Width - 4
Me.ErrorListListBox.Height = Me.ErrorListPanelEx.ClientRectangle.Height - 2
'Me.ErrorListListBox.Left = 2
'Me.ErrorListListBox.Width = Me.ErrorListPanelEx.ClientRectangle.Width - 4
'Me.ErrorListListBox.Height = Me.ErrorListPanelEx.ClientRectangle.Height - 2

Me.StatusStripCurrentFileName.Width = halfClientWidth
_loading = False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2032,7 +2032,7 @@ Namespace CSharpToVBConverter.CSharpToVBVisitors
op = VB.SyntaxKind.AddExpression
End If
Dim vbMathExpression As MemberAccessExpressionSyntax = Factory.MemberAccessExpression(VB.SyntaxKind.SimpleMemberAccessExpression, MathIdentifier, DotToken, minMax)
Dim vbInterlockedExpressionName As MemberAccessExpressionSyntax = Factory.MemberAccessExpression(VB.SyntaxKind.SimpleMemberAccessExpression, InterlockedIdentifier, DotToken, operatorName)
Dim vbInterlockedExpressionName As MemberAccessExpressionSyntax = Factory.MemberAccessExpression(VB.SyntaxKind.SimpleMemberAccessExpression, SytemInterlockedExpression, DotToken, operatorName)

Dim vbOperandArgument As SimpleArgumentSyntax = Factory.SimpleArgument(leftExpr)

Expand Down Expand Up @@ -2079,7 +2079,7 @@ Namespace CSharpToVBConverter.CSharpToVBVisitors
End If
Else
Dim operatorName As IdentifierNameSyntax = If(kind = VB.SyntaxKind.AddAssignmentStatement, IncrementIdentifier, DecrementIdentifier)
Dim mathExpr As MemberAccessExpressionSyntax = Factory.MemberAccessExpression(VB.SyntaxKind.SimpleMemberAccessExpression, InterlockedIdentifier, DotToken, operatorName)
Dim mathExpr As MemberAccessExpressionSyntax = Factory.MemberAccessExpression(VB.SyntaxKind.SimpleMemberAccessExpression, SytemInterlockedExpression, DotToken, operatorName)
Return Factory.InvocationExpression(mathExpr,
Factory.ArgumentList(Factory.SeparatedList(
New ArgumentSyntax() {Factory.SimpleArgument(vbOperandExpression)})
Expand Down
6 changes: 3 additions & 3 deletions CodeConverter/CodeConverter.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<Product>VB Core Code Converter</Product>
<RepositoryUrl>https://github.com/paul1956/CSharpToVB</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<AssemblyVersion>5.0.1.14</AssemblyVersion>
<FileVersion>5.0.1.14</FileVersion>
<Version>5.0.1.14</Version>
<AssemblyVersion>5.0.1.15</AssemblyVersion>
<FileVersion>5.0.1.15</FileVersion>
<Version>5.0.1.15</Version>
<Copyright>Copyright (c) .NET Foundation and Contributors</Copyright>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
</PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions CodeConverter/Utilities/VisualBasicSyntaxFactory.vb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ Namespace Utilities

Public ReadOnly DecrementIdentifier As IdentifierNameSyntax = Factory.IdentifierName("Decrement")
Public ReadOnly IncrementIdentifier As IdentifierNameSyntax = Factory.IdentifierName("Increment")
Public ReadOnly ThreadingIdentifier As IdentifierNameSyntax = Factory.IdentifierName("Threading")
Public ReadOnly InterlockedIdentifier As IdentifierNameSyntax = Factory.IdentifierName("Interlocked")
Public ReadOnly SytemInterlockedExpression As MemberAccessExpressionSyntax = Factory.SimpleMemberAccessExpression(ThreadingIdentifier, DotToken, InterlockedIdentifier)
Public ReadOnly MathIdentifier As IdentifierNameSyntax = Factory.IdentifierName("Math")
Public ReadOnly MaxIdentifier As IdentifierNameSyntax = Factory.IdentifierName("Max")
Public ReadOnly MinIdentifier As IdentifierNameSyntax = Factory.IdentifierName("Min")
Expand Down
4 changes: 4 additions & 0 deletions ReadMe.MD
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ Microsoft.Dotnet.XUnitExtensions which provides ConditionalFact and PlatformSpec
Any changes to CSharpToVB application needs to change the version information in the project file **AND** in MyProject/AssemblyInfo.vb until Visual Studio is able to general file automatically for a WinForms application.

## What's New in this release
New in 5.0.3.1/5.0.1.15
- Change Interlocked.Increment to Threading.Interlocked.Increment to partly address issue #72
- Improve support for Dark Mode

New in 5.0.3.0/5.0.1.14
- Major improvement in colorize performance
- Improvement in StopButton responsiveness
Expand Down

0 comments on commit d1a28b7

Please sign in to comment.