Skip to content

Commit

Permalink
rel11 v1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
qiangqiang101 committed Dec 23, 2022
1 parent 9c7d24f commit c5394dc
Show file tree
Hide file tree
Showing 10 changed files with 204 additions and 107 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ https://gitlab.com/OpenRGBDevelopers/OpenRGB-Wallpaper/-/releases
- [.NET Framework 4.8](https://dotnet.microsoft.com/en-us/download/dotnet-framework/net48)

# About Virus
From the latest release [test result](https://www.virustotal.com/gui/file/997f71f0c5fef3c339f841eb606e7c8986e08ee99fbe649504564c86c14a9313/detection) shows that 3 out of 72 vendors detected as Malicious, it's false positive, you're safe, if you have doubts, you can build the project by yourself, build instructions can be found below.
From the latest release [test result](https://www.virustotal.com/gui/file/34a2b0d40e1ae37f1184a6c3e52a1a207f5456cbdc6ecfa9f0539e864461043b/detection) shows that 2 out of 70 vendors detected as Malicious, it's false positive, you're safe, if you have doubts, you can build the project by yourself, build instructions can be found below.

# Build yourself
You need Visual Studio 2022 or newer, run Wallpaper.sln to begin. Click the Build on menu, select Build Solution.
Expand Down
Binary file added Wallpaper-Wallpaper/other33.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Wallpaper-Wallpaper/other34.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Wallpaper-Wallpaper/other35.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions Wallpaper/My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("1.2.0.0")>
<Assembly: AssemblyFileVersion("1.2.0.0")>
<Assembly: AssemblyVersion("1.3.0.0")>
<Assembly: AssemblyFileVersion("1.3.0.0")>
9 changes: 7 additions & 2 deletions Wallpaper/UserSettingData.vb
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ Public Structure UserSettingData
Public InterpolationMode As Drawing2D.InterpolationMode
Public PixelOffsetMode As Drawing2D.PixelOffsetMode
Public LEDShape As LEDShape
Public LEDPadding As Single
Public TimerIntervals As Integer
Public RoundedRectangleCornerRadius As Integer

'General
Public StartWithWindows As Boolean
Public NoToasters As Boolean
Public TimerIntervals As Integer
Public LEDPadding As Single
Public AutoPause As Boolean
Public CpuUsagePauseValue As Integer

'Static Effects
Public StaticEffect As Boolean
Expand Down
159 changes: 116 additions & 43 deletions Wallpaper/frmMain.Designer.vb

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions Wallpaper/frmMain.vb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ Public Class frmMain
.StaticEffect = False
.RGBTrasform = RGBTransform.Slide1
.RGBPattern = RGBPattern.Rainbow
.RoundedRectangleCornerRadius = 10
.AutoPause = True
.CpuUsagePauseValue = 70
.Screens = screenList
.SaveSilentXml()
End With
Expand Down Expand Up @@ -75,6 +78,14 @@ Public Class frmMain
cbStaticEffects.Checked = UserSettings.StaticEffect
GroupBox2.Enabled = cbStaticEffects.Checked

txtRoundRectRadius.Text = UserSettings.RoundedRectangleCornerRadius
numCPUUsageValue.Value = If(UserSettings.CpuUsagePauseValue = 0, 10, UserSettings.CpuUsagePauseValue)
cbAutoPause.Checked = UserSettings.AutoPause
cbAutoPause.Text = $"Automatically pause when CPU Usage reaches {numCPUUsageValue.Value}%"

txtRoundRectRadius.Enabled = (cmbLedShape.SelectedItem = LEDShape.RoundedRectangle)
numCPUUsageValue.Enabled = cbAutoPause.Checked

For Each scr In UserSettings.Screens
Dim newTab As New TabPage()
With newTab
Expand Down Expand Up @@ -245,6 +256,9 @@ Public Class frmMain
Next
.Screens = newScreenList
.StartWithWindows = cbStartAtLogin.Checked
.RoundedRectangleCornerRadius = CInt(txtRoundRectRadius.Text)
.AutoPause = cbAutoPause.Checked
.CpuUsagePauseValue = CInt(numCPUUsageValue.Value)
.SaveXml()
End With

Expand Down Expand Up @@ -323,6 +337,9 @@ Public Class frmMain
Next
.Screens = newScreenList
.StartWithWindows = cbStartAtLogin.Checked
.RoundedRectangleCornerRadius = CInt(txtRoundRectRadius.Text)
.AutoPause = cbAutoPause.Checked
.CpuUsagePauseValue = CInt(numCPUUsageValue.Value)
.SaveSilentXml()
End With

Expand All @@ -339,6 +356,14 @@ Public Class frmMain
GroupBox2.Enabled = cbStaticEffects.Checked
End Sub

Private Sub cbAutoPause_CheckedChanged(sender As Object, e As EventArgs) Handles cbAutoPause.CheckedChanged
numCPUUsageValue.Enabled = cbAutoPause.Checked
End Sub

Private Sub cmbLedShape_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbLedShape.SelectedIndexChanged
txtRoundRectRadius.Enabled = (cmbLedShape.SelectedItem = LEDShape.RoundedRectangle)
End Sub

Private Sub frmMain_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
If e.CloseReason = CloseReason.WindowsShutDown Then Return

Expand All @@ -351,4 +376,8 @@ Public Class frmMain
Private Sub Label8_Click(sender As Object, e As EventArgs) Handles Label8.Click
Process.Start("https://imnotmental.com/")
End Sub

Private Sub numCPUUsageValue_ValueChanged(sender As Object, e As EventArgs) Handles numCPUUsageValue.ValueChanged
cbAutoPause.Text = $"Automatically pause when CPU Usage reaches {numCPUUsageValue.Value}%"
End Sub
End Class
78 changes: 34 additions & 44 deletions Wallpaper/frmWallpaper.vb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Public Class frmWallpaper
Public BackImg As Image = Nothing
Public ImgFit As ImageFit = ImageFit.Stretch
Public WaitForOpenRGB As Boolean = False
Public cpuUsage As New PerformanceCounter("Processor", "% Processor Time", "_Total")

Public Property WScreen() As Screen

Expand All @@ -25,16 +26,14 @@ Public Class frmWallpaper

' Add any initialization after the InitializeComponent() call.

SetStyle(ControlStyles.UserPaint, True)
SetStyle(ControlStyles.AllPaintingInWmPaint, True)
SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
DoubleBuffered = True
End Sub

Private Sub frmWallpaper_Load(sender As Object, e As EventArgs) Handles MyBase.Load
BackColor = ColorTranslator.FromHtml(WScreen.BackgroundColor)
BackImg = WScreen.BackgroundImage.Base64ToImage
ImgFit = WScreen.ImageFit
DoubleBuffered = True

If BackImg IsNot Nothing Then
If ImgFit = ImageFit.Fit Then BackImg = BackImg.ResizeImage(ClientRectangle.Size, True)
End If
Expand All @@ -47,7 +46,7 @@ Public Class frmWallpaper
If Not oRgbClient Is Nothing Then oRgbClient.Dispose()
oRgbClient = New OpenRGBClient(ws.IPAddress, ws.Port, ws.Name, ws.Autoconnect, ws.Timeout, ws.ProtocolVersion)
Catch ex As Exception
renderString = $"46 Connect Error: {ex.Message}"
renderString = $"48 Connect Error: {ex.Message}"
Log(ex)
End Try
End Sub
Expand All @@ -56,7 +55,7 @@ Public Class frmWallpaper
Try
oRgbClient.Connect()
Catch ex As Exception
renderString = $"54 Connect Error: {ex.Message}"
renderString = $"57 Connect Error: {ex.Message}"
Log(ex)
End Try
End Sub
Expand All @@ -71,13 +70,21 @@ Public Class frmWallpaper
Connect(WScreen)
renderString = Nothing
Catch ex As Exception
renderString = $"68 Reconnect Error: {ex.Message}"
renderString = $"72 Reconnect Error: {ex.Message}"
Log(ex)
End Try
End Sub

Private Function HighCpuUsage() As Boolean
If UserSettings.AutoPause Then
Return CInt(Math.Ceiling(cpuUsage.NextValue)) >= UserSettings.CpuUsagePauseValue
Else
Return False
End If
End Function

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If Not IsPaused Then
If Not IsPaused AndAlso Not HighCpuUsage() Then
Invalidate()

If UserSettings.StaticEffect AndAlso StaticEffect Then
Expand Down Expand Up @@ -145,7 +152,7 @@ Public Class frmWallpaper

PrepareGraphics(graphic)

Dim rgbImg As New Bitmap(size.Width, size.Height)
Dim rgbImg As New Bitmap(size.Width, size.Height, PixelFormat.Format32bppPArgb)
Using g As Graphics = Graphics.FromImage(rgbImg)
PrepareGraphics(g)
g.FillRectangle(theBrush, 0, 0, size.Width, size.Height)
Expand All @@ -158,6 +165,7 @@ Public Class frmWallpaper
Protected Overrides Sub OnPaint(e As PaintEventArgs)
Dim graphic As Graphics = e.Graphics
PrepareGraphics(graphic)
graphic.Clear(BackColor)

Try
If oRgbClient IsNot Nothing Then
Expand All @@ -179,36 +187,20 @@ Public Class frmWallpaper
Dim rgbColor = wallpaper.Colors(count).ToColor

Using sb As New SolidBrush(rgbColor)
If UserSettings.LEDPadding >= 1 Then
Using pen As New Pen(BackColor, UserSettings.LEDPadding)
Dim X As Single = rectangleSize.Width * i
Dim Y As Single = rectangleSize.Height * j

Select Case UserSettings.LEDShape
Case LEDShape.Rectangle
graphic.FillRectangle(sb, New RectangleF(X, Y, rectangleSize.Width, rectangleSize.Height))
graphic.DrawRectangle(pen, New Rectangle(X, Y, rectangleSize.Width, rectangleSize.Height))
Case LEDShape.RoundedRectangle
graphic.FillRoundedRectangle(sb, New Rectangle(X, Y, rectangleSize.Width, rectangleSize.Height), 10)
graphic.DrawRoundedRectangle(pen, New Rectangle(X, Y, rectangleSize.Width, rectangleSize.Height), 10)
Case LEDShape.Sphere
graphic.FillEllipse(sb, New RectangleF(X, Y, rectangleSize.Width, rectangleSize.Height))
graphic.DrawEllipse(pen, New Rectangle(X, Y, rectangleSize.Width, rectangleSize.Height))
End Select
End Using
Else
Dim X As Single = rectangleSize.Width * i
Dim Y As Single = rectangleSize.Height * j

Select Case UserSettings.LEDShape
Case LEDShape.Rectangle
graphic.FillRectangle(sb, New RectangleF(X, Y, rectangleSize.Width, rectangleSize.Height))
Case LEDShape.RoundedRectangle
graphic.FillRoundedRectangle(sb, New Rectangle(X, Y, rectangleSize.Width, rectangleSize.Height), 10)
Case LEDShape.Sphere
graphic.FillEllipse(sb, New RectangleF(X, Y, rectangleSize.Width, rectangleSize.Height))
End Select
End If
Dim X As Single = rectangleSize.Width * i
Dim Y As Single = rectangleSize.Height * j
Dim W As Single = rectangleSize.Width
Dim H As Single = rectangleSize.Height
Dim P As Single = UserSettings.LEDPadding

Select Case UserSettings.LEDShape
Case LEDShape.Rectangle
graphic.FillRectangle(sb, New RectangleF(X + P, Y + P, W - P, H - P))
Case LEDShape.RoundedRectangle
graphic.FillRoundedRectangle(sb, New Rectangle(X + P, Y + P, W - P, H - P), UserSettings.RoundedRectangleCornerRadius)
Case LEDShape.Sphere
graphic.FillEllipse(sb, New RectangleF(X + P, Y + P, W - P, H - P))
End Select
End Using
count += 1
If count >= wallpaper.Leds.Count Then count = 0
Expand All @@ -222,7 +214,7 @@ Public Class frmWallpaper
End If
Catch ex As Exception
If Not StaticEffect Then StaticEffect = True
renderString = $"220 On Paint: {ex.Message}"
renderString = $"208 On Paint: {ex.Message}"
Log(ex)
End Try

Expand Down Expand Up @@ -284,15 +276,13 @@ Public Class frmWallpaper

End If
Catch ex As Exception
renderString = $"282 On Paint: {ex.Message}"
renderString = $"270 On Paint: {ex.Message}"
Log(ex)
End Try

Try
If renderString <> Nothing Then
Using sb As New SolidBrush(Color.White)
graphic.DrawString(renderString, Font, sb, New RectangleF(20.0F, 20.0F, ClientRectangle.Width - 20.0F, ClientRectangle.Height - 20.0F))
End Using
TextRenderer.DrawText(graphic, renderString, Font, New Point(20, 20), Color.White)
End If
Catch ex As Exception
Log(ex)
Expand Down
30 changes: 15 additions & 15 deletions Wallpaper/ucScreen.Designer.vb

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

0 comments on commit c5394dc

Please sign in to comment.