Skip to content

Commit 6d2dee5

Browse files
committed
V1.5.1.0 Release
1 parent 88631f0 commit 6d2dee5

6 files changed

Lines changed: 39 additions & 35 deletions

File tree

AVRControl.Helpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace AVRControl
2424
{
2525
public partial class AVRControl : Form
2626
{
27-
private void timerProgress_Tick(object sender, EventArgs e)
27+
private void timerProgress_Tick(object? sender, EventArgs e)
2828
{
2929
if (!IsAVROn) { return; }
3030

AVRControl.HeosUI.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,15 @@ private async Task LoadAlbumArtAsync(string url)
3131

3232
try
3333
{
34-
using (var client = new System.Net.WebClient())
34+
// Daten herunterladen
35+
byte[] imageBytes = await _httpClient.GetByteArrayAsync(url);
36+
37+
using (var ms = new System.IO.MemoryStream(imageBytes))
3538
{
36-
byte[] imageBytes = await client.DownloadDataTaskAsync(url);
37-
using (var ms = new System.IO.MemoryStream(imageBytes))
38-
{
39-
this.Invoke((MethodInvoker)delegate {
40-
pbAlbumArt.Image = Image.FromStream(ms);
41-
pbAlbumArt.SizeMode = PictureBoxSizeMode.Zoom;
42-
});
43-
}
39+
// Da wir 'await' nutzen, springt .NET automatisch zurück in den UI-Thread.
40+
// Ein 'this.Invoke' ist hier meistens gar nicht mehr nötig!
41+
pbAlbumArt.Image = Image.FromStream(ms);
42+
pbAlbumArt.SizeMode = PictureBoxSizeMode.Zoom;
4443
}
4544
}
4645
catch (Exception ex)

AVRControl.Installer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ private void RefreshInstallState()
3434

3535
isRunningFromRoaming = Application.ExecutablePath.Equals(roamingPath, StringComparison.OrdinalIgnoreCase);
3636

37-
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(registryPath, false))
37+
using (RegistryKey? key = Registry.CurrentUser.OpenSubKey(registryPath, false))
3838
{
3939
if (key != null)
4040
{
@@ -69,7 +69,7 @@ private void RefreshInstallState()
6969

7070
// Github Update Part
7171
////////////////////////////////////////////////////////////////////////////////////////////////////////
72-
private async Task<Version> GetGitHubVersionAsync()
72+
private async Task<Version?> GetGitHubVersionAsync()
7373
{
7474
string url = "https://api.github.com/repos/SAMDestroy/AVRControl/releases/latest";
7575

@@ -105,7 +105,7 @@ private async Task<Version> GetGitHubVersionAsync()
105105
}
106106
private async void CheckForGitHubUpdate()
107107
{
108-
Version githubVersion = await GetGitHubVersionAsync();
108+
Version? githubVersion = await GetGitHubVersionAsync();
109109
//Version localVersion = typeof(Program).Assembly.GetName().Version;
110110
Version localVersion = new Version("1.5.0.0"); // lokal test
111111

AVRControl.cs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ public partial class AVRControl : Form
2828

2929
private string roamingPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "AVRControl", "AVRControl.exe");
3030
private bool isRunningFromRoaming = false;
31-
private string currentConfigPath;
31+
private string currentConfigPath = string.Empty;
3232

33-
private readonly string config = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "\\AVRControl.cfg";
33+
private static readonly HttpClient _httpClient = new HttpClient();
34+
35+
private readonly string config = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AVRControl.cfg");
3436
private bool _muted = false;
3537
private int CurVol = 10;
3638
private bool IsAVROn = false;
@@ -129,8 +131,8 @@ private void LoadDevice()
129131

130132
try
131133
{
132-
string savedIP = ConfigManager.GetValue(currentConfigPath, "IP");
133-
string savedTray = ConfigManager.GetValue(currentConfigPath, "Systray");
134+
string? savedIP = ConfigManager.GetValue(currentConfigPath, "IP");
135+
string? savedTray = ConfigManager.GetValue(currentConfigPath, "Systray");
134136

135137
if (savedIP != null)
136138
{
@@ -473,7 +475,7 @@ private void btnHeosPlayRepeatOne_MouseEnter(object sender, EventArgs e)
473475
}
474476
private void btnInstall_Click(object sender, EventArgs e)
475477
{
476-
string targetDir = Path.GetDirectoryName(roamingPath);
478+
string? targetDir = Path.GetDirectoryName(roamingPath);
477479
string registryPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run";
478480

479481
try
@@ -498,12 +500,15 @@ private void btnInstall_Click(object sender, EventArgs e)
498500
return;
499501
}
500502

501-
if (!Directory.Exists(targetDir))
502-
Directory.CreateDirectory(targetDir);
503+
if (!string.IsNullOrEmpty(targetDir))
504+
{
505+
if (!Directory.Exists(targetDir))
506+
Directory.CreateDirectory(targetDir);
507+
}
503508

504509
System.IO.File.Copy(Application.ExecutablePath, roamingPath, true);
505510

506-
string targetCfg = Path.Combine(targetDir, "AVRControl.cfg");
511+
string targetCfg = Path.Combine(targetDir!, "AVRControl.cfg");
507512
if (!System.IO.File.Exists(targetCfg))
508513
{
509514
currentConfigPath = targetCfg;
@@ -512,7 +517,7 @@ private void btnInstall_Click(object sender, EventArgs e)
512517
ConfigManager.SaveValue(currentConfigPath, "Systray", "TRUE");
513518
}
514519

515-
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(registryPath, true))
520+
using (RegistryKey? key = Registry.CurrentUser.OpenSubKey(registryPath, true))
516521
{
517522
if (key != null) key.SetValue("AVRControl", $"\"{roamingPath}\"");
518523
}
@@ -525,7 +530,7 @@ private void btnInstall_Click(object sender, EventArgs e)
525530
}
526531
else if (btnInstall.Text == "Uninstall")
527532
{
528-
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(registryPath, true))
533+
using (RegistryKey? key = Registry.CurrentUser.OpenSubKey(registryPath, true))
529534
{
530535
if (key != null) key.DeleteValue("AVRControl", false);
531536
}

ConfigManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ public static string GetConfigPath(string roamingPath, bool isRunningFromRoaming
2626
{
2727
if (isRunningFromRoaming)
2828
{
29-
return Path.Combine(Path.GetDirectoryName(roamingPath), "AVRControl.cfg");
29+
return Path.Combine(Path.GetDirectoryName(roamingPath)!, "AVRControl.cfg");
3030
}
3131
return Path.Combine(Application.StartupPath, "AVRControl.cfg");
3232
}
3333

34-
public static string GetValue(string configPath, string key)
34+
public static string? GetValue(string configPath, string key)
3535
{
3636
if (!File.Exists(configPath)) return null;
3737

@@ -48,7 +48,7 @@ public static string GetValue(string configPath, string key)
4848

4949
public static void SaveValue(string configPath, string key, string value)
5050
{
51-
string dir = Path.GetDirectoryName(configPath);
51+
string? dir = Path.GetDirectoryName(configPath);
5252
if (!string.IsNullOrEmpty(dir) && !Directory.Exists(dir))
5353
Directory.CreateDirectory(dir);
5454

TelnetClient.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,25 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2727

2828
public class AsyncTelnetClient
2929
{
30-
private TcpClient _client;
31-
private NetworkStream _stream;
30+
private TcpClient? _client = null!;
31+
private NetworkStream? _stream = null!;
3232
private bool _shouldReconnect = false;
3333
private bool _isConnecting = false;
3434
private DateTime _lastResponseTime = DateTime.UtcNow;
3535
public bool Initialized { get; private set; } = false;
3636

37-
private CancellationTokenSource _cts;
37+
private CancellationTokenSource? _cts;
3838

39-
private string _IP;
39+
private string _IP = null!;
4040

4141
public int ConnectedPort { get; private set; }
4242

4343
public bool DoStatusUpdates { get; set; }
4444

45-
public event Action<string> DataReceived;
46-
public event Action<string> ErrorOccurred;
47-
public event Action<string> StatusChanged;
48-
45+
public event Action<string>? DataReceived;
46+
public event Action<string>? ErrorOccurred;
47+
public event Action<string>? StatusChanged;
48+
4949
// XML Reader Part
5050
////////////////////////////////////////////////////////////////////////////////////////////////////////
5151
public async Task<string> ReadXMLDeviceInfoAsync()
@@ -64,7 +64,7 @@ public async Task<string> ReadXMLDeviceInfoAsync()
6464
var xmlDoc = new XmlDocument();
6565
xmlDoc.LoadXml(liteXmlString);
6666

67-
var rawvalue = xmlDoc.DocumentElement.SelectSingleNode("//InputFuncSelect")?.InnerText;
67+
var rawvalue = xmlDoc.DocumentElement?.SelectSingleNode("//InputFuncSelect")?.InnerText;
6868
if (string.IsNullOrEmpty(rawvalue)) return "HEOS";
6969

7070
if (rawvalue == "NET") return "HEOS";

0 commit comments

Comments
 (0)