diff --git a/src/apps/Highbyte.DotNet6502.App.SadConsole/ConfigUI/C64ConfigUIConsole.cs b/src/apps/Highbyte.DotNet6502.App.SadConsole/ConfigUI/C64ConfigUIConsole.cs index ab99f3c1..7d9095bf 100644 --- a/src/apps/Highbyte.DotNet6502.App.SadConsole/ConfigUI/C64ConfigUIConsole.cs +++ b/src/apps/Highbyte.DotNet6502.App.SadConsole/ConfigUI/C64ConfigUIConsole.cs @@ -244,12 +244,6 @@ Label CreateLabel(string text, int col, int row, string? name = null) Controls.Add(labelTemp); return labelTemp; } - Label CreateLabelValue(string text, int col, int row, string? name = null) - { - var labelTemp = new Label(text) { Position = new Point(col, row), TextColor = Controls.GetThemeColors().Title, Name = name }; - Controls.Add(labelTemp); - return labelTemp; - } // Force OnIsDirtyChanged event which will set control states (see SetControlStates) OnIsDirtyChanged(); @@ -272,7 +266,7 @@ private void ShowROMFilePickerDialog(string romName) { if (window.DialogResult) { - C64SystemConfig.SetROM(romName, Path.GetFileName(window.SelectedFile.FullName)); + C64SystemConfig.SetROM(romName, Path.GetFileName(window.SelectedFile!.FullName)); IsDirty = true; } }; @@ -308,15 +302,15 @@ private void SetControlStates() romDirectoryTextBox!.IsDirty = true; var kernalROMTextBox = Controls["kernalROMTextBox"] as TextBox; - kernalROMTextBox!.Text = C64SystemConfig.ROMs.SingleOrDefault(x => x.Name == C64SystemConfig.KERNAL_ROM_NAME).File; + kernalROMTextBox!.Text = C64SystemConfig.ROMs.Single(x => x.Name == C64SystemConfig.KERNAL_ROM_NAME).File!; kernalROMTextBox!.IsDirty = true; var basicROMTextBox = Controls["basicROMTextBox"] as TextBox; - basicROMTextBox!.Text = C64SystemConfig.ROMs.SingleOrDefault(x => x.Name == C64SystemConfig.BASIC_ROM_NAME).File; + basicROMTextBox!.Text = C64SystemConfig.ROMs.Single(x => x.Name == C64SystemConfig.BASIC_ROM_NAME).File!; basicROMTextBox!.IsDirty = true; var chargenROMTextBox = Controls["chargenROMTextBox"] as TextBox; - chargenROMTextBox!.Text = C64SystemConfig.ROMs.SingleOrDefault(x => x.Name == C64SystemConfig.CHARGEN_ROM_NAME).File; + chargenROMTextBox!.Text = C64SystemConfig.ROMs.Single(x => x.Name == C64SystemConfig.CHARGEN_ROM_NAME).File!; chargenROMTextBox!.IsDirty = true; var codingAssistantTestButton = Controls["codingAssistantTestButton"] as Button; diff --git a/src/apps/Highbyte.DotNet6502.App.SadConsole/ConfigUI/C64MenuConsole.cs b/src/apps/Highbyte.DotNet6502.App.SadConsole/ConfigUI/C64MenuConsole.cs index be3a68ac..c275485d 100644 --- a/src/apps/Highbyte.DotNet6502.App.SadConsole/ConfigUI/C64MenuConsole.cs +++ b/src/apps/Highbyte.DotNet6502.App.SadConsole/ConfigUI/C64MenuConsole.cs @@ -76,7 +76,7 @@ private void DrawUIItems() Name = "c64CopyBasicSourceCodeButton", Position = (1, c64SaveBasicButton.Bounds.MaxExtentY + 2), }; - c64CopyBasicSourceCodeButton.Click += C64CopyBasicSourceCodeButton_Click; + c64CopyBasicSourceCodeButton.Click += C64CopyBasicSourceCodeButton_Click!; Controls.Add(c64CopyBasicSourceCodeButton); // Paste @@ -85,7 +85,7 @@ private void DrawUIItems() Name = "c64PasteTextButton", Position = (c64CopyBasicSourceCodeButton.Bounds.MaxExtentX + 9, c64CopyBasicSourceCodeButton.Position.Y), }; - c64PasteTextButton.Click += C64PasteTextButton_Click; + c64PasteTextButton.Click += C64PasteTextButton_Click!; Controls.Add(c64PasteTextButton); // Paste @@ -106,7 +106,7 @@ private void DrawUIItems() Name = "c64ConfigButton", Position = (1, c64aiBasicAssistantCheckbox.Bounds.MaxExtentY + 2), }; - c64ConfigButton.Click += C64ConfigButton_Click; + c64ConfigButton.Click += C64ConfigButton_Click!; Controls.Add(c64ConfigButton); @@ -114,12 +114,6 @@ private void DrawUIItems() validationMessageValueLabel.TextColor = Controls.GetThemeColors().Red; // Helper function to create a label and add it to the console - Label CreateLabel(string text, int col, int row, string? name = null) - { - var labelTemp = new Label(text) { Position = new Point(col, row), Name = name }; - Controls.Add(labelTemp); - return labelTemp; - } Label CreateLabelValue(string text, int col, int row, string? name = null) { var labelTemp = new Label(text) { Position = new Point(col, row), TextColor = Controls.GetThemeColors().Title, Name = name }; @@ -148,9 +142,9 @@ private void C64LoadBasicButton_Click(object? sender, EventArgs e) { try { - var fileName = window.SelectedFile.FullName; + var fileName = window.SelectedFile!.FullName; BinaryLoader.Load( - _sadConsoleHostApp.CurrentRunningSystem.Mem, + _sadConsoleHostApp.CurrentRunningSystem!.Mem, fileName, out ushort loadedAtAddress, out ushort fileLength); @@ -200,7 +194,7 @@ private void C64SaveBasicButton_Click(object? sender, EventArgs e) var fileName = window.SelectedFile.FullName; // TODO: Does FilePickerConsole check if file already exists and ask for overwrite? Or do this here? ushort startAddressValue = C64.BASIC_LOAD_ADDRESS; - var endAddressValue = ((C64)_sadConsoleHostApp.CurrentRunningSystem).GetBasicProgramEndAddress(); + var endAddressValue = ((C64)_sadConsoleHostApp.CurrentRunningSystem!).GetBasicProgramEndAddress(); BinarySaver.Save( _sadConsoleHostApp.CurrentRunningSystem.Mem, fileName, @@ -300,10 +294,11 @@ private void SetControlStates() validationMessageValueLabel!.IsVisible = !isOk; } - public async Task ToggleBasicAIAssistant() + public Task ToggleBasicAIAssistant() { var c64aiBasicAssistantCheckbox = Controls["c64aiBasicAssistantCheckbox"] as CheckBox; c64aiBasicAssistantCheckbox.IsSelected = !c64aiBasicAssistantCheckbox.IsSelected; + return Task.CompletedTask; } private async Task SetBasicAIAssistant(bool enabled) diff --git a/src/apps/Highbyte.DotNet6502.App.SadConsole/FilePickerConsole.cs b/src/apps/Highbyte.DotNet6502.App.SadConsole/FilePickerConsole.cs index 642063ec..3c57089b 100644 --- a/src/apps/Highbyte.DotNet6502.App.SadConsole/FilePickerConsole.cs +++ b/src/apps/Highbyte.DotNet6502.App.SadConsole/FilePickerConsole.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using System.IO; using SadConsole.UI; using SadConsole.UI.Controls; @@ -166,7 +165,7 @@ private void FileListBox_SelectedItemChanged(object? sender, ListBox.SelectedIte _selectedDirectory = new DirectoryInfo(fileListBox.CurrentFolder); if (_filePickerMode == FilePickerMode.OpenFile || _filePickerMode == FilePickerMode.SaveFile) { - if (_selectedFile != null && _selectedDirectory.FullName != _selectedFile.Directory.FullName) + if (_selectedFile != null && _selectedDirectory.FullName != _selectedFile.Directory!.FullName) _selectedFile = new FileInfo(Path.Combine(_selectedDirectory.FullName, _selectedFile.Name)); } else @@ -176,8 +175,8 @@ private void FileListBox_SelectedItemChanged(object? sender, ListBox.SelectedIte //selectedItemTextBox.IsDirty = true; } } - } + if (e.Item is DirectoryInfo directoryInfo) { //Debug.WriteLine($"DirectoryInfo: {directoryInfo.FullName}"); @@ -203,7 +202,7 @@ private void FileListBox_SelectedItemChanged(object? sender, ListBox.SelectedIte return; _selectedFile = fileInfo; - _selectedDirectory = fileInfo.Directory; + _selectedDirectory = fileInfo.Directory!; selectedItemTextBox.Text = _selectedFile.Name; selectedItemTextBox.IsDirty = true; diff --git a/src/apps/Highbyte.DotNet6502.App.SadConsole/InfoConsole.cs b/src/apps/Highbyte.DotNet6502.App.SadConsole/InfoConsole.cs index 8734d8e7..1112c177 100644 --- a/src/apps/Highbyte.DotNet6502.App.SadConsole/InfoConsole.cs +++ b/src/apps/Highbyte.DotNet6502.App.SadConsole/InfoConsole.cs @@ -137,7 +137,7 @@ Label CreateLabel(string text, int col, int row, string? name = null) // System debug info panel Panel debugInfoPanel = new Panel(10, 10); { - var labelTitleLength = 25; + var labelTitleLength = 28; _debugInfoLabels = new List