-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from qiangqiang101/net8
Update project to .NET8
- Loading branch information
Showing
31 changed files
with
10,442 additions
and
1 deletion.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Imports Microsoft.VisualBasic.ApplicationServices | ||
|
||
Namespace My | ||
' The following events are available for MyApplication: | ||
' Startup: Raised when the application starts, before the startup form is created. | ||
' Shutdown: Raised after all application forms are closed. This event is not raised if the application terminates abnormally. | ||
' UnhandledException: Raised if the application encounters an unhandled exception. | ||
' StartupNextInstance: Raised when launching a single-instance application and the application is already active. | ||
' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected. | ||
|
||
' **NEW** ApplyApplicationDefaults: Raised when the application queries default values to be set for the application. | ||
|
||
' Example: | ||
' Private Sub MyApplication_ApplyApplicationDefaults(sender As Object, e As ApplyApplicationDefaultsEventArgs) Handles Me.ApplyApplicationDefaults | ||
' | ||
' ' Setting the application-wide default Font: | ||
' e.Font = New Font(FontFamily.GenericSansSerif, 12, FontStyle.Regular) | ||
' | ||
' ' Setting the HighDpiMode for the Application: | ||
' e.HighDpiMode = HighDpiMode.PerMonitorV2 | ||
' | ||
' ' If a splash dialog is used, this sets the minimum display time: | ||
' e.MinimumSplashScreenDisplayTime = 4000 | ||
' End Sub | ||
|
||
Partial Friend Class MyApplication | ||
|
||
End Class | ||
End Namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Public Class DropdownListItem(Of T) | ||
|
||
Private _text As String | ||
Private _value As T | ||
|
||
Public ReadOnly Property Text() As String | ||
Get | ||
Return _text | ||
End Get | ||
End Property | ||
|
||
Public ReadOnly Property Value() As T | ||
Get | ||
Return _value | ||
End Get | ||
End Property | ||
|
||
Public Overrides Function ToString() As String | ||
Return _text | ||
End Function | ||
|
||
Public Sub New(ByVal text_ As String, ByVal value_ As T) | ||
_text = text_ | ||
_value = value_ | ||
End Sub | ||
|
||
End Class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
Imports System.Drawing.Drawing2D | ||
Imports System.Drawing.Imaging | ||
Imports System.IO | ||
Imports System.Runtime.CompilerServices | ||
Imports IWshRuntimeLibrary | ||
|
||
Module Helper | ||
|
||
Public UserSettingFile As String = $"UserSettings.json" | ||
Public UserSettings As UserSetting = New UserSetting() | ||
Public LanguageDropdownList As New List(Of DropdownListItem(Of String)) From { | ||
New DropdownListItem(Of String)("English", "en-US"), New DropdownListItem(Of String)("Chinese Simplified", "zh-CN"), New DropdownListItem(Of String)("Chinese Traditional", "zh-TW")} | ||
Public Translation As Language = New Language() | ||
|
||
<Extension> | ||
Public Function ToColor(modelcolor As OpenRGB.NET.Color) As Color | ||
Return Color.FromArgb(modelcolor.R, modelcolor.G, modelcolor.B) | ||
End Function | ||
|
||
<Extension> | ||
Public Sub DrawRoundedRectangle(graphics As Graphics, pen As Pen, bounds As Rectangle, radius As Integer) | ||
If graphics Is Nothing Then | ||
Throw New ArgumentNullException("graphics") | ||
End If | ||
If pen Is Nothing Then | ||
Throw New ArgumentNullException("prush") | ||
End If | ||
|
||
Using path As GraphicsPath = RoundedRect(bounds, radius) | ||
graphics.DrawPath(pen, path) | ||
End Using | ||
End Sub | ||
|
||
<Extension> | ||
Public Sub FillRoundedRectangle(graphics As Graphics, brush As Brush, bounds As Rectangle, radius As Integer) | ||
If graphics Is Nothing Then | ||
Throw New ArgumentNullException("graphics") | ||
End If | ||
If brush Is Nothing Then | ||
Throw New ArgumentNullException("brush") | ||
End If | ||
|
||
Using path As GraphicsPath = RoundedRect(bounds, radius) | ||
graphics.FillPath(brush, path) | ||
End Using | ||
End Sub | ||
|
||
Private Function RoundedRect(bounds As Rectangle, radius As Integer) As GraphicsPath | ||
Dim diameter As Integer = radius * 2 | ||
Dim size As Size = New Size(diameter, diameter) | ||
Dim arc As Rectangle = New Rectangle(bounds.Location, size) | ||
Dim path As GraphicsPath = New GraphicsPath | ||
|
||
If (radius = 0) Then | ||
path.AddRectangle(bounds) | ||
Return path | ||
End If | ||
|
||
'top left arc | ||
path.AddArc(arc, 180, 90) | ||
|
||
'top right arc | ||
arc.X = bounds.Right - diameter | ||
path.AddArc(arc, 270, 90) | ||
|
||
'bottom right arc | ||
arc.Y = bounds.Bottom - diameter | ||
path.AddArc(arc, 0, 90) | ||
|
||
'bottom left arc | ||
arc.X = bounds.Left | ||
path.AddArc(arc, 90, 90) | ||
|
||
path.CloseFigure() | ||
Return path | ||
End Function | ||
|
||
<Extension> | ||
Public Function Base64ToImage(Image As String) As Image | ||
Try | ||
If Image = Nothing Then | ||
Return Nothing | ||
Else | ||
Dim b64 As String = Image.Replace(" ", "+") | ||
Dim bite() As Byte = Convert.FromBase64String(b64) | ||
Dim stream As New MemoryStream(bite) | ||
Return Drawing.Image.FromStream(stream) | ||
End If | ||
Catch ex As Exception | ||
Return Nothing | ||
End Try | ||
End Function | ||
|
||
<Extension> | ||
Public Function ImageToBase64(img As Image, Optional forceFormat As ImageFormat = Nothing, Optional formatting As Base64FormattingOptions = Base64FormattingOptions.InsertLineBreaks) As String | ||
Try | ||
If img IsNot Nothing Then | ||
If forceFormat Is Nothing Then forceFormat = img.RawFormat | ||
Dim stream As New MemoryStream | ||
img.Save(stream, forceFormat) | ||
Return Convert.ToBase64String(stream.ToArray, formatting) | ||
Else | ||
Return Nothing | ||
End If | ||
Catch ex As Exception | ||
Return Nothing | ||
End Try | ||
End Function | ||
|
||
Public Sub CreateShortcutInStartUp() | ||
Dim wshShell As New WshShell() | ||
Dim startupFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.Startup) | ||
|
||
Dim shortcut As IWshShortcut = CType(wshShell.CreateShortcut($"{startupFolder}\{Application.ProductName}.lnk"), IWshShortcut) | ||
With shortcut | ||
.TargetPath = Application.ExecutablePath | ||
.WorkingDirectory = Application.StartupPath | ||
.Description = "Launch OpenRGB Wallpaper" | ||
.Save() | ||
End With | ||
End Sub | ||
|
||
Public Sub DeleteShortcutInStartup() | ||
'Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run | ||
Dim startupFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.Startup) | ||
Dim shortcut As String = $"{startupFolder}\{Application.ProductName}.lnk" | ||
If IO.File.Exists(shortcut) Then IO.File.Delete(shortcut) | ||
End Sub | ||
|
||
Public Sub Log(ex As Exception) | ||
IO.File.AppendAllText(IO.Path.Combine($"{My.Application.Info.DirectoryPath}\", $"{Now.ToString("dd-MM-yyyy")}.log"), $"{Now.ToShortTimeString}: {ex.Message}{ex.StackTrace}{vbNewLine}") | ||
End Sub | ||
|
||
Public Sub Log(text As String) | ||
IO.File.AppendAllText(IO.Path.Combine($"{My.Application.Info.DirectoryPath}\", $"{Now.ToString("dd-MM-yyyy")}.log"), $"{Now.ToShortTimeString}: {text}{vbNewLine}") | ||
End Sub | ||
|
||
Public Function IsOpenRGBRunning() As Boolean | ||
Dim OpenRGB As Process = Process.GetProcessesByName("OpenRGB").FirstOrDefault | ||
Return Not OpenRGB Is Nothing | ||
End Function | ||
|
||
Public Function GetDesktopWallpaper() As String | ||
Dim wallpaper As String = New String(vbNullChar, 260) | ||
Win32Wrapper.SystemParametersInfo(Win32Wrapper.SPI_GETDESKWALLPAPER, wallpaper.Length, wallpaper, 0) | ||
Return wallpaper | ||
End Function | ||
|
||
Public Sub SetDesktopWallpaper(filename As String) | ||
Win32Wrapper.SystemParametersInfo(Win32Wrapper.SPI_SETDESKWALLPAPER, 0, filename, Win32Wrapper.SPIF_UPDATEINIFILE Or Win32Wrapper.SPIF_SENDWININICHANGE) | ||
End Sub | ||
|
||
End Module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
Imports System.Drawing.Drawing2D | ||
Imports Newtonsoft.Json | ||
Imports OpenRGB.NET | ||
|
||
Public Class UserSetting | ||
|
||
'GDI Graphics | ||
Public SmoothingMode As SmoothingMode = SmoothingMode.AntiAlias | ||
Public CompositingQuality As CompositingQuality = CompositingQuality.HighSpeed | ||
Public InterpolationMode As InterpolationMode = InterpolationMode.Bilinear | ||
Public PixelOffsetMode As PixelOffsetMode = PixelOffsetMode.HighSpeed | ||
|
||
'Global Graphics | ||
Public LEDShape As LEDShape = LEDShape.Rectangle | ||
Public LEDPadding As Single = 0 | ||
Public TimerIntervals As Integer = 30 | ||
Public RoundedRectangleCornerRadius As Integer = 10 | ||
|
||
'General | ||
Public StartWithWindows As Boolean = False | ||
Public StartMinimized As Boolean = True | ||
Public RestoreWallpaperWhenExit As Boolean = False | ||
Public NoToasters As Boolean = False | ||
Public AutoPause As Boolean = True | ||
Public CPUUsagePauseValue As Integer = 70 | ||
Public GrayscaleTrayIcon As Boolean = False | ||
Public Language As String = "en-US" | ||
Public Port As Integer | ||
Public AutoConnect As Boolean | ||
|
||
Public E131Devices As List(Of E131Device) | ||
|
||
Public Sub Save(filename As String, silent As Boolean) | ||
IO.File.WriteAllText(filename, JsonConvert.SerializeObject(Me, Formatting.Indented)) | ||
If Not silent Then MsgBox(Translation.Localization.UserSettingsSuccessfullySaved, MsgBoxStyle.Information, Translation.Localization.Successful) | ||
End Sub | ||
|
||
Public Function Load(filename As String) As UserSetting | ||
Return JsonConvert.DeserializeObject(Of UserSetting)(IO.File.ReadAllText(filename)) | ||
End Function | ||
|
||
End Class | ||
|
||
Public Class E131Device | ||
|
||
'Device | ||
Public Name As String | ||
Public Zone As String | ||
|
||
'Display | ||
Public Position As Point | ||
Public Size As Size | ||
Public BackgroundImage As String | ||
Public SizeMode As PictureBoxSizeMode | ||
Public BackgroundColor As String | ||
|
||
End Class | ||
|
||
Public Class Language | ||
|
||
Public Name As String = "English" | ||
Public ID As String = "en-US" | ||
Public Localization As New Localization() | ||
|
||
Public Function Load(filename As String) As Language | ||
Return JsonConvert.DeserializeObject(Of Language)(IO.File.ReadAllText(filename)) | ||
End Function | ||
|
||
Public Sub Save(filename As String) | ||
IO.File.WriteAllText(filename, JsonConvert.SerializeObject(Me, Formatting.Indented)) | ||
End Sub | ||
|
||
End Class | ||
|
||
Public Class Localization | ||
|
||
'Global | ||
Public Apply As String = "Apply" | ||
Public GettingDevicesInformation As String = "Getting devices information" | ||
Public [Error] As String = "Error" | ||
Public UserSettingsSuccessfullySaved As String = "User settings successfully saved." | ||
Public Successful As String = "Successful" | ||
|
||
'Main | ||
Public OpenRGBWallpaper2 As String = "OpenRGB Wallpaper 2" | ||
Public GraphicsSettings As String = "Graphics Settings" | ||
Public SmoothingMode As String = "Smoothing Mode" | ||
Public CompositingQuality As String = "Compositing Quality" | ||
Public InterpolationMode As String = "Interpolation Mode" | ||
Public PixelOffsetMode As String = "Pixel Offset Mode" | ||
Public LEDShape As String = "LED Shape" | ||
Public RoundedRectangleRadius As String = "Rounded Rectangle Radius" | ||
Public LEDPadding As String = "LED Padding" | ||
Public RefreshInterval As String = "Refresh Interval " | ||
Public _ms As String = " {0}ms" | ||
Public GeneralSettings As String = "General Settings" | ||
Public StartWithWindows As String = "Start With Windows" | ||
Public StartMinimized As String = "Start Minimized" | ||
Public RestoreWallpaperWhenExit As String = "Restore Wallpaper When Exit" | ||
Public DisableNotifications As String = "Disable Notifications" | ||
Public PauseWhenCPUUsageReaches As String = "Pause When CPU Usage Reaches " | ||
Public _pct As String = " {0}%" | ||
Public CPUUsagePauseValue As String = "CPU Usage Pause Value" | ||
Public GrayscaleTrayIcon As String = "Grayscale Tray Icon" | ||
Public Language As String = "Language" | ||
Public SDKPort As String = "SDK Port" | ||
Public AutoConnectToSDKServer As String = "Auto Connect to SDK Server" | ||
Public DeviceSettings As String = "Device Settings" | ||
Public WallpaperDevices As String = "Wallpaper Devices" | ||
Public AddDevice As String = "+ Add Device" | ||
Public MadeWithHeartBy As String = "Made with ❤ by " | ||
Public SaveChanges As String = "Save Changes" | ||
Public Cancel As String = "Cancel" | ||
Public WaitingOpenRGBProcess As String = "Waiting OpenRGB process to startup, this might take several seconds." | ||
Public OpenRGBProcessFound As String = "OpenRGB process found, applying Wallpaper(s)." | ||
Public Play As String = "Play" | ||
Public Pause As String = "Pause" | ||
Public Connect As String = "Connect" | ||
Public Reconnect As String = "Reconnect" | ||
Public Settings As String = "Settings" | ||
Public Help As String = "Help" | ||
Public [Exit] As String = "Exit" | ||
Public YouCanAccessSettings As String = "You can access settings by right clicking the icon." | ||
|
||
'Device | ||
Public Device As String = "Device" | ||
Public TheE131Device As String = "The E1.31 device" | ||
Public Refresh As String = "↻ Refresh" | ||
Public Name As String = "Name" | ||
Public Zone As String = "Zone" | ||
Public Display As String = "Display" | ||
Public X As String = "X" | ||
Public Y As String = "Y" | ||
Public Width As String = "Width" | ||
Public Height As String = "Height" | ||
Public CoverImage As String = "Cover Image" | ||
Public [Select] As String = "Select..." | ||
Public Clear As String = "Clear" | ||
Public GetWallpapers As String = "Get Wallpapers" | ||
Public SizeMode As String = "Size Mode" | ||
Public Background As String = "Background" | ||
Public YouHaveUnsaveChanges As String = "You have unsave changes." | ||
Public Remove As String = "Remove" | ||
Public ConfirmRemoveDevice As String = "Confirm remove device?" | ||
Public SelectImageFile As String = "Select image file..." | ||
|
||
'Wallpaper | ||
Public LocalOpenRGBServerUnavailable As String = "Connection attempt failed, Local OpenRGB server unavailable." | ||
Public OpenRGBIsntRunning As String = "Connection attempt failed, OpenRGB isn't running." | ||
Public AttemptingToConnectToLocalOpenRGBServer As String = "Attempting to connect to local OpenRGB server." | ||
|
||
End Class | ||
|
||
Public Enum LEDShape | ||
Rectangle | ||
RoundedRectangle | ||
Sphere | ||
End Enum |
Oops, something went wrong.