diff --git a/MixAssembler/Properties/launchSettings.json b/MixAssembler/Properties/launchSettings.json deleted file mode 100644 index 0535482..0000000 --- a/MixAssembler/Properties/launchSettings.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:55636/", - "sslPort": 0 - } - }, - "profiles": { - "MixAssembler": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "http://localhost:5000" - } - } -} \ No newline at end of file diff --git a/MixAssembler/Thumbs.db b/MixAssembler/Thumbs.db deleted file mode 100644 index 1b4f715..0000000 Binary files a/MixAssembler/Thumbs.db and /dev/null differ diff --git a/MixEmul/Components/AboutForm.cs b/MixEmul/Components/AboutForm.cs index 677124d..da3f2fc 100644 --- a/MixEmul/Components/AboutForm.cs +++ b/MixEmul/Components/AboutForm.cs @@ -49,7 +49,7 @@ private void FullVersionLabel_Click(object sender, EventArgs e) => Clipboard.SetText(_versionString); private void FullVersionLabel_DoubleClick(object sender, EventArgs e) - => Clipboard.SetText(_versionString.Replace('.', '_')); + => Clipboard.SetText(_versionString); private void InitializeComponent() { diff --git a/MixEmul/Components/InstructionInstanceTextBox.cs b/MixEmul/Components/InstructionInstanceTextBox.cs index ae4706d..aa15f27 100644 --- a/MixEmul/Components/InstructionInstanceTextBox.cs +++ b/MixEmul/Components/InstructionInstanceTextBox.cs @@ -474,7 +474,7 @@ private static string GetAddressErrorsCaption(InstanceValidationError[] errors) captionBuilder.Insert(0, "Instruction error: "); else - captionBuilder.Insert(0, String.Format("Instruction errors:{0}", Environment.NewLine)); + captionBuilder.Insert(0, $"Instruction errors:{Environment.NewLine}"); return captionBuilder.ToString(); } diff --git a/MixEmul/Components/MemoryEditor.cs b/MixEmul/Components/MemoryEditor.cs index 1539a3a..c1910f8 100644 --- a/MixEmul/Components/MemoryEditor.cs +++ b/MixEmul/Components/MemoryEditor.cs @@ -520,7 +520,7 @@ public void FindMatch(SearchParameters options) if (result == null) { - MessageBox.Show(this, string.Format("Search text \"{0}\" could not be found.", options.SearchText), "Text not found", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show(this, $"Search text \"{options.SearchText}\" could not be found.", "Text not found", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } diff --git a/MixEmul/Components/SourceAndFindingsForm.cs b/MixEmul/Components/SourceAndFindingsForm.cs index 922ce1b..b835dd4 100644 --- a/MixEmul/Components/SourceAndFindingsForm.cs +++ b/MixEmul/Components/SourceAndFindingsForm.cs @@ -34,136 +34,133 @@ public void UpdateLayout() private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SourceAndFindingsForm)); - _statusStrip = new System.Windows.Forms.StatusStrip(); - _toolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); - _listPanel = new System.Windows.Forms.Panel(); - _closeButton = new System.Windows.Forms.Button(); - _exportButton = new System.Windows.Forms.Button(); - _loadButton = new System.Windows.Forms.Button(); - _findingListView = new MixGui.Components.AssemblyFindingListView(); - _splitter = new System.Windows.Forms.Splitter(); - _saveExportFileDialog = new System.Windows.Forms.SaveFileDialog(); - _sourceControl = new MixGui.Components.SourceCodeControl(); - _statusStrip.SuspendLayout(); - _listPanel.SuspendLayout(); - SuspendLayout(); - // - // mStatusStrip - // - _statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - _toolStripStatusLabel}); - _statusStrip.Location = new System.Drawing.Point(0, 383); - _statusStrip.Name = "mStatusStrip"; - _statusStrip.Size = new System.Drawing.Size(568, 22); - _statusStrip.TabIndex = 3; - // - // mToolStripStatusLabel - // - _toolStripStatusLabel.Name = "mToolStripStatusLabel"; - _toolStripStatusLabel.Size = new System.Drawing.Size(0, 17); - // - // mListPanel - // - _listPanel.Controls.Add(_closeButton); - _listPanel.Controls.Add(_exportButton); - _listPanel.Controls.Add(_loadButton); - _listPanel.Controls.Add(_findingListView); - _listPanel.Dock = System.Windows.Forms.DockStyle.Bottom; - _listPanel.Location = new System.Drawing.Point(0, 303); - _listPanel.Name = "mListPanel"; - _listPanel.Size = new System.Drawing.Size(568, 80); - _listPanel.TabIndex = 2; - // - // mCloseButton - // - _closeButton.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right); - _closeButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - _closeButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - _closeButton.Location = new System.Drawing.Point(498, 56); - _closeButton.Name = "mCloseButton"; - _closeButton.Size = new System.Drawing.Size(62, 23); - _closeButton.TabIndex = 3; - _closeButton.Text = "&Close"; - // - // mExportButton - // - _exportButton.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right); - _exportButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - _exportButton.Location = new System.Drawing.Point(498, 28); - _exportButton.Name = "mExportButton"; - _exportButton.Size = new System.Drawing.Size(62, 23); - _exportButton.TabIndex = 2; - _exportButton.Text = "&Export..."; - // - // mLoadButton - // - _loadButton.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right); - _loadButton.DialogResult = System.Windows.Forms.DialogResult.OK; - _loadButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - _loadButton.Location = new System.Drawing.Point(498, 0); - _loadButton.Name = "mLoadButton"; - _loadButton.Size = new System.Drawing.Size(62, 23); - _loadButton.TabIndex = 1; - _loadButton.Text = "&Load"; - // - // mFindingListView - // - _findingListView.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - _findingListView.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - _findingListView.Location = new System.Drawing.Point(0, 0); - _findingListView.Name = "mFindingListView"; - _findingListView.SeverityImageList = null; - _findingListView.Size = new System.Drawing.Size(492, 80); - _findingListView.TabIndex = 0; - // - // mSplitter - // - _splitter.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; - _splitter.Dock = System.Windows.Forms.DockStyle.Bottom; - _splitter.Location = new System.Drawing.Point(0, 295); - _splitter.MinExtra = 100; - _splitter.MinSize = 80; - _splitter.Name = "mSplitter"; - _splitter.Size = new System.Drawing.Size(568, 8); - _splitter.TabIndex = 1; - _splitter.TabStop = false; - // - // mSaveExportFileDialog - // - _saveExportFileDialog.DefaultExt = "mixdeck"; - _saveExportFileDialog.Filter = "MixEmul card deck files|*.mixdeck|All files|*.*"; - _saveExportFileDialog.Title = "Specify export file name"; - // - // mSourceControl - // - _sourceControl.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - _sourceControl.Dock = System.Windows.Forms.DockStyle.Fill; - _sourceControl.Location = new System.Drawing.Point(0, 0); - _sourceControl.MarkedFinding = null; - _sourceControl.Name = "mSourceControl"; - _sourceControl.Size = new System.Drawing.Size(568, 295); - _sourceControl.TabIndex = 0; + this._statusStrip = new System.Windows.Forms.StatusStrip(); + this._toolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); + this._listPanel = new System.Windows.Forms.Panel(); + this._closeButton = new System.Windows.Forms.Button(); + this._exportButton = new System.Windows.Forms.Button(); + this._loadButton = new System.Windows.Forms.Button(); + this._findingListView = new MixGui.Components.AssemblyFindingListView(); + this._splitter = new System.Windows.Forms.Splitter(); + this._saveExportFileDialog = new System.Windows.Forms.SaveFileDialog(); + this._sourceControl = new MixGui.Components.SourceCodeControl(); + this._statusStrip.SuspendLayout(); + this._listPanel.SuspendLayout(); + this.SuspendLayout(); + // + // _statusStrip + // + this._statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this._toolStripStatusLabel}); + this._statusStrip.Location = new System.Drawing.Point(0, 383); + this._statusStrip.Name = "_statusStrip"; + this._statusStrip.Size = new System.Drawing.Size(568, 22); + this._statusStrip.TabIndex = 3; + // + // _toolStripStatusLabel + // + this._toolStripStatusLabel.Name = "_toolStripStatusLabel"; + this._toolStripStatusLabel.Size = new System.Drawing.Size(0, 17); + // + // _listPanel + // + this._listPanel.Controls.Add(this._closeButton); + this._listPanel.Controls.Add(this._exportButton); + this._listPanel.Controls.Add(this._loadButton); + this._listPanel.Controls.Add(this._findingListView); + this._listPanel.Dock = System.Windows.Forms.DockStyle.Bottom; + this._listPanel.Location = new System.Drawing.Point(0, 303); + this._listPanel.Name = "_listPanel"; + this._listPanel.Size = new System.Drawing.Size(568, 80); + this._listPanel.TabIndex = 2; + // + // _closeButton + // + this._closeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this._closeButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this._closeButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this._closeButton.Location = new System.Drawing.Point(498, 56); + this._closeButton.Name = "_closeButton"; + this._closeButton.Size = new System.Drawing.Size(62, 23); + this._closeButton.TabIndex = 3; + this._closeButton.Text = "&Close"; + // + // _exportButton + // + this._exportButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this._exportButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this._exportButton.Location = new System.Drawing.Point(498, 28); + this._exportButton.Name = "_exportButton"; + this._exportButton.Size = new System.Drawing.Size(62, 23); + this._exportButton.TabIndex = 2; + this._exportButton.Text = "&Export..."; + // + // _loadButton + // + this._loadButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this._loadButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this._loadButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this._loadButton.Location = new System.Drawing.Point(498, 0); + this._loadButton.Name = "_loadButton"; + this._loadButton.Size = new System.Drawing.Size(62, 23); + this._loadButton.TabIndex = 1; + this._loadButton.Text = "&Load"; + // + // _findingListView + // + this._findingListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this._findingListView.Location = new System.Drawing.Point(0, 0); + this._findingListView.Name = "_findingListView"; + this._findingListView.SeverityImageList = null; + this._findingListView.Size = new System.Drawing.Size(492, 80); + this._findingListView.TabIndex = 0; + // + // _splitter + // + this._splitter.Dock = System.Windows.Forms.DockStyle.Bottom; + this._splitter.Location = new System.Drawing.Point(0, 295); + this._splitter.MinExtra = 100; + this._splitter.MinSize = 80; + this._splitter.Name = "_splitter"; + this._splitter.Size = new System.Drawing.Size(568, 8); + this._splitter.TabIndex = 1; + this._splitter.TabStop = false; + // + // _saveExportFileDialog + // + this._saveExportFileDialog.DefaultExt = "mixdeck"; + this._saveExportFileDialog.Filter = "MixEmul card deck files|*.mixdeck|All files|*.*"; + this._saveExportFileDialog.Title = "Specify export file name"; + // + // _sourceControl + // + this._sourceControl.Dock = System.Windows.Forms.DockStyle.Fill; + this._sourceControl.Location = new System.Drawing.Point(0, 0); + this._sourceControl.MarkedFinding = null; + this._sourceControl.Name = "_sourceControl"; + this._sourceControl.Size = new System.Drawing.Size(568, 295); + this._sourceControl.TabIndex = 0; // // SourceAndFindingsForm // - ClientSize = new System.Drawing.Size(568, 405); - Controls.Add(_sourceControl); - Controls.Add(_splitter); - Controls.Add(_listPanel); - Controls.Add(_statusStrip); - Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon"); - MinimizeBox = false; - MinimumSize = new System.Drawing.Size(400, 224); - Name = "SourceAndFindingsForm"; - ShowInTaskbar = false; - Text = "Assembly result"; - _statusStrip.ResumeLayout(false); - _statusStrip.PerformLayout(); - _listPanel.ResumeLayout(false); - ResumeLayout(false); - PerformLayout(); + this.ClientSize = new System.Drawing.Size(568, 405); + this.Controls.Add(this._sourceControl); + this.Controls.Add(this._splitter); + this.Controls.Add(this._listPanel); + this.Controls.Add(this._statusStrip); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(400, 224); + this.Name = "SourceAndFindingsForm"; + this.ShowInTaskbar = false; + this.Text = "Assembly result"; + this._statusStrip.ResumeLayout(false); + this._statusStrip.PerformLayout(); + this._listPanel.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); } diff --git a/MixEmul/Components/SourceCodeControl.cs b/MixEmul/Components/SourceCodeControl.cs index 5c0be61..2932413 100644 --- a/MixEmul/Components/SourceCodeControl.cs +++ b/MixEmul/Components/SourceCodeControl.cs @@ -38,6 +38,7 @@ public SourceCodeControl() SuspendLayout(); _sourceBox.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top; + _sourceBox.BorderStyle = BorderStyle.FixedSingle; _sourceBox.Location = new Point(0, 0); _sourceBox.Name = "mSourceBox"; _sourceBox.ReadOnly = true; diff --git a/MixEmul/Components/ToolStripCycleButton.cs b/MixEmul/Components/ToolStripCycleButton.cs index 0e5e1b8..a32dda2 100644 --- a/MixEmul/Components/ToolStripCycleButton.cs +++ b/MixEmul/Components/ToolStripCycleButton.cs @@ -96,7 +96,7 @@ public void AddStep(Step step) throw new ArgumentNullException(nameof(step), "step and its Value may not be null"); if (_steps.Any(s => s.Value is IComparable comparable ? comparable.CompareTo(step.Value) == 0 : s.Value.Equals(step.Value))) - throw new ArgumentException(string.Format("another step with Value {0} already exists", step.Value)); + throw new ArgumentException($"another step with Value {step.Value} already exists"); _steps.Add(step); @@ -115,7 +115,7 @@ public object Value var step = _steps.FirstOrDefault(s => s.Value is IComparable comparable ? comparable.CompareTo(value) == 0 : s.Value.Equals(value)); if (step == null) - throw new ArgumentException(string.Format("no step with Value {0} exists", value)); + throw new ArgumentException($"no step with Value {value} exists"); SetCurrentStep(step); } diff --git a/MixEmul/Documentation/Changes.txt b/MixEmul/Documentation/Changes.txt index 8b45c16..5db76b5 100644 --- a/MixEmul/Documentation/Changes.txt +++ b/MixEmul/Documentation/Changes.txt @@ -9,6 +9,14 @@ x: Bugfix ========================================= +0.4.7755.38010 (2021-03-26) +x Fixed regression in settings (de)serialisation, which made that colours weren't applied +x Fixed opening of device and teletype windows on saved screen location +! The settings file format changed, and its name changed from config.bin to config.json. This means that any saved settings in earlier versions will not be loaded when starting this version, the first time +* Cleaned up binary (de)serialization code leftovers +* Made the visual style of the "Assembly result" window more consistent +* Removed a number of unnecessary/outdated files from the solution folders + 0.4.7752.30280 (2021-03-23) * Migrated to .NET 5.0 * Applied visual changes, of which enabling visual styles is the most noticeable diff --git a/MixEmul/MixForm.cs b/MixEmul/MixForm.cs index 2a2f170..191de10 100644 --- a/MixEmul/MixForm.cs +++ b/MixEmul/MixForm.cs @@ -179,7 +179,10 @@ public MixForm() _teletype.VisibleChanged += Teletype_VisibleChanged; if (_configuration.TeletypeWindowLocation != Point.Empty) + { + _teletype.StartPosition = FormStartPosition.Manual; _teletype.Location = _configuration.TeletypeWindowLocation; + } if (_configuration.TeletypeWindowSize != Size.Empty) _teletype.Size = _configuration.TeletypeWindowSize; @@ -199,7 +202,10 @@ public MixForm() _deviceEditor.VisibleChanged += DeviceEditor_VisibleChanged; if (_configuration.DeviceEditorWindowLocation != Point.Empty) + { + _deviceEditor.StartPosition = FormStartPosition.Manual; _deviceEditor.Location = _configuration.DeviceEditorWindowLocation; + } if (_configuration.DeviceEditorWindowSize != Size.Empty) _deviceEditor.Size = _configuration.DeviceEditorWindowSize; @@ -234,7 +240,12 @@ public MixForm() Update(); if (_configuration.MainWindowLocation != Point.Empty) + { + StartPosition = FormStartPosition.Manual; Location = _configuration.MainWindowLocation; + } + else + StartPosition = FormStartPosition.CenterScreen; if (_configuration.MainWindowSize != Size.Empty) Size = _configuration.MainWindowSize; @@ -283,17 +294,17 @@ private SymbolCollection LoadModuleProgram(ModuleBase module, string fileName, s if (instances != null) { if (!module.LoadInstructionInstances(instances, symbols)) - _logListView.AddLogLine(new LogLine("Assembler", Severity.Error, "Load failed", string.Format("Failed to load {0} program", programName))); + _logListView.AddLogLine(new LogLine("Assembler", Severity.Error, "Load failed", $"Failed to load {programName} program")); } else { if (findings != null) { - _logListView.AddLogLine(new LogLine("Assembler", Severity.Error, "Parse failed", string.Format("Error(s) occured while assembling {0} program", programName))); + _logListView.AddLogLine(new LogLine("Assembler", Severity.Error, "Parse failed", $"Error(s) occured while assembling {programName} program")); foreach (AssemblyFinding finding in findings) - _logListView.AddLogLine(new LogLine("Assembler", finding.Severity, "Parse error", finding.LineNumber == int.MinValue ? finding.Message : string.Format("Line {0}: {1}", finding.LineNumber, finding.Message))); + _logListView.AddLogLine(new LogLine("Assembler", finding.Severity, "Parse error", finding.LineNumber == int.MinValue ? finding.Message : $"Line {finding.LineNumber}: {finding.Message}")); } - _logListView.AddLogLine(new LogLine("Assembler", Severity.Error, "Load failed", string.Format("Failed to assemble {0} program", programName))); + _logListView.AddLogLine(new LogLine("Assembler", Severity.Error, "Load failed", $"Failed to assemble {programName} program")); return symbols; @@ -301,7 +312,7 @@ private SymbolCollection LoadModuleProgram(ModuleBase module, string fileName, s } catch (Exception ex) { - _logListView.AddLogLine(new LogLine("Assembler", Severity.Error, "Load failed", string.Format("Failed to read {0} program: {1}", programName, ex.Message))); + _logListView.AddLogLine(new LogLine("Assembler", Severity.Error, "Load failed", $"Failed to read {programName} program: {ex.Message}")); } return null; diff --git a/MixEmul/Properties/launchSettings.json b/MixEmul/Properties/launchSettings.json deleted file mode 100644 index 6836274..0000000 --- a/MixEmul/Properties/launchSettings.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:56696/", - "sslPort": 44374 - } - }, - "profiles": { - "MixEmul": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "https://localhost:5001;http://localhost:5000" - } - } -} \ No newline at end of file diff --git a/MixEmul/Settings/Configuration.cs b/MixEmul/Settings/Configuration.cs index 729e673..c49624c 100644 --- a/MixEmul/Settings/Configuration.cs +++ b/MixEmul/Settings/Configuration.cs @@ -2,23 +2,23 @@ using System.Collections.Generic; using System.Drawing; using System.IO; -using System.Runtime.Serialization; using System.Text.Json; using System.Windows.Forms; +using MixGui.Utils; using MixLib.Device.Settings; namespace MixGui.Settings { - [Serializable] - public class Configuration : ISerializable, IDeserializationCallback + public class Configuration { - private const string FileName = "config.bin"; + private const string FileName = "config.json"; + + private static JsonSerializerOptions _jsonSerializerOptions; - private readonly SerializationInfo _serializationInfo; private string _deviceFilesDirectory; - public Dictionary Colors { get; private set; } - public Dictionary DeviceFilePaths { get; private set; } + public Dictionary Colors { get; set; } + public Dictionary DeviceFilePaths { get; set; } public string[] LoaderCards { get; set; } public bool DeviceEditorVisible { get; set; } public Point DeviceEditorWindowLocation { get; set; } @@ -53,9 +53,6 @@ public Configuration() FillEmptyMembers(); } - protected Configuration(SerializationInfo info, StreamingContext context) - => _serializationInfo = info; - private void FillEmptyMembers() { if (Colors == null) @@ -68,49 +65,47 @@ private void FillEmptyMembers() DeviceFilePaths = new Dictionary(); } - public virtual void GetObjectData(SerializationInfo info, StreamingContext context) + public static JsonSerializerOptions JsonSerializerOptions { - info.AddValue("mColors", Colors); - info.AddValue("mTickCounts", TickCounts); - info.AddValue("mDeviceFiles", DeviceFilePaths); - info.AddValue("mDeviceDirectory", DeviceFilesDirectory); - info.AddValue("mDeviceEditorWindowLocation", DeviceEditorWindowLocation); - info.AddValue("mDeviceEditorWindowSize", DeviceEditorWindowSize); - info.AddValue("mDeviceEditorVisible", DeviceEditorVisible); - info.AddValue("mMainWindowLocation", MainWindowLocation); - info.AddValue("mMainWindowSize", MainWindowSize); - info.AddValue("mMainWindowState", MainWindowState); - info.AddValue("mTeletypeOnTop", TeletypeOnTop); - info.AddValue("mTeletypeWindowLocation", TeletypeWindowLocation); - info.AddValue("mTeletypeWindowSize", TeletypeWindowSize); - info.AddValue("mTeletypeVisible", TeletypeVisible); - info.AddValue("mTeletypeEchoInput", TeletypeEchoInput); - info.AddValue("mDeviceReloadInterval", DeviceReloadInterval); - info.AddValue("mLoaderCards", LoaderCards); - info.AddValue("mFloatingPointMemoryWordCount", FloatingPointMemoryWordCount); - info.AddValue("mProfilingEnabled", ProfilingEnabled); - info.AddValue("mShowProfilingInfo", ShowProfilingInfo); - info.AddValue("mColorProfilingCounts", ColorProfilingCounts); + get + { + if (_jsonSerializerOptions == null) + { + _jsonSerializerOptions = new JsonSerializerOptions(); + _jsonSerializerOptions.Converters.Add(new ColorJsonConverter()); + } + + return _jsonSerializerOptions; + } } + public static Configuration Load(string directory) { + Configuration configuration = null; + try { var path = Path.Combine(directory, FileName); if (File.Exists(path)) - return JsonSerializer.Deserialize(File.ReadAllBytes(path)); + configuration = JsonSerializer.Deserialize(File.ReadAllBytes(path), JsonSerializerOptions); } - catch (Exception) { } + catch (Exception) + {} - return new Configuration(); + if (configuration == null) + configuration = new(); + + configuration.FillEmptyMembers(); + + return configuration; } public void Save(string directory) { using var serializationStream = new FileStream(Path.Combine(directory, FileName), FileMode.Create); - JsonSerializer.Serialize(new Utf8JsonWriter(serializationStream), this); + JsonSerializer.Serialize(new Utf8JsonWriter(serializationStream), this, JsonSerializerOptions); serializationStream.Close(); } @@ -123,147 +118,5 @@ public string DeviceFilesDirectory _deviceFilesDirectory = value; } } - - public void OnDeserialization(object sender) - { - DeviceEditorWindowSize = Size.Empty; - DeviceEditorWindowLocation = Point.Empty; - TeletypeWindowSize = Size.Empty; - TeletypeWindowLocation = Point.Empty; - TeletypeEchoInput = true; - MainWindowSize = Size.Empty; - MainWindowLocation = Point.Empty; - DeviceReloadInterval = DeviceSettings.UnsetDeviceReloadInterval; - FloatingPointMemoryWordCount = null; - ColorProfilingCounts = true; - - try - { - Colors = (Dictionary)_serializationInfo.GetValue("mColors", typeof(Dictionary)); - } - catch (SystemException) { } - - try - { - TickCounts = (Dictionary)_serializationInfo.GetValue("mTickCounts", typeof(Dictionary)); - } - catch (SystemException) { } - - try - { - DeviceFilePaths = (Dictionary)_serializationInfo.GetValue("mDeviceFiles", typeof(Dictionary)); - } - catch (SystemException) { } - - try - { - DeviceFilesDirectory = _serializationInfo.GetString("mDeviceDirectory"); - } - catch (SystemException) { } - - try - { - DeviceEditorWindowLocation = (Point)_serializationInfo.GetValue("mDeviceEditorWindowLocation", typeof(Point)); - } - catch (SystemException) { } - - try - { - DeviceEditorWindowSize = (Size)_serializationInfo.GetValue("mDeviceEditorWindowSize", typeof(Size)); - } - catch (SystemException) { } - - try - { - DeviceEditorVisible = _serializationInfo.GetBoolean("mDeviceEditorVisible"); - } - catch (SystemException) { } - - try - { - MainWindowLocation = (Point)_serializationInfo.GetValue("mMainWindowLocation", typeof(Point)); - } - catch (SystemException) { } - - try - { - MainWindowSize = (Size)_serializationInfo.GetValue("mMainWindowSize", typeof(Size)); - } - catch (SystemException) { } - - try - { - MainWindowState = (FormWindowState)_serializationInfo.GetValue("mMainWindowState", typeof(FormWindowState)); - } - catch (SystemException) { } - - try - { - TeletypeOnTop = _serializationInfo.GetBoolean("mTeletypeOnTop"); - } - catch (SystemException) { } - - try - { - TeletypeWindowLocation = (Point)_serializationInfo.GetValue("mTeletypeWindowLocation", typeof(Point)); - } - catch (SystemException) { } - - try - { - TeletypeWindowSize = (Size)_serializationInfo.GetValue("mTeletypeWindowSize", typeof(Size)); - } - catch (SystemException) { } - - try - { - TeletypeVisible = _serializationInfo.GetBoolean("mTeletypeVisible"); - } - catch (SystemException) { } - - try - { - TeletypeEchoInput = _serializationInfo.GetBoolean("mTeletypeEchoInput"); - } - catch (SystemException) { } - - try - { - DeviceReloadInterval = _serializationInfo.GetInt32("mDeviceReloadInterval"); - } - catch (SystemException) { } - - try - { - LoaderCards = (string[])_serializationInfo.GetValue("mLoaderCards", typeof(string[])); - } - catch (SystemException) { } - - try - { - FloatingPointMemoryWordCount = (int?)_serializationInfo.GetValue("mFloatingPointMemoryWordCount", typeof(int?)); - } - catch (SystemException) { } - - try - { - ProfilingEnabled = _serializationInfo.GetBoolean("mProfilingEnabled"); - } - catch (SystemException) { } - - try - { - ShowProfilingInfo = (GuiSettings.ProfilingInfoType)_serializationInfo.GetValue("mShowProfilingInfo", typeof(GuiSettings.ProfilingInfoType)); - } - catch (SystemException) { } - - try - { - ColorProfilingCounts = _serializationInfo.GetBoolean("mColorProfilingCounts"); - } - catch (SystemException) { } - - FillEmptyMembers(); - } } } diff --git a/MixEmul/Thumbs.db b/MixEmul/Thumbs.db deleted file mode 100644 index 01b5ee1..0000000 Binary files a/MixEmul/Thumbs.db and /dev/null differ diff --git a/MixEmul/Utils/ColorJsonConverter.cs b/MixEmul/Utils/ColorJsonConverter.cs new file mode 100644 index 0000000..ce301c5 --- /dev/null +++ b/MixEmul/Utils/ColorJsonConverter.cs @@ -0,0 +1,15 @@ +using System; +using System.Drawing; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace MixGui.Utils +{ + class ColorJsonConverter : JsonConverter + { + public override Color Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + => Color.FromArgb(reader.GetInt32()); + public override void Write(Utf8JsonWriter writer, Color value, JsonSerializerOptions options) + => writer.WriteNumberValue(value.ToArgb()); + } +} diff --git a/MixEmul/app.config b/MixEmul/app.config deleted file mode 100644 index 5c22b42..0000000 --- a/MixEmul/app.config +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/MixLib/Instruction/ArithmaticInstructions.cs b/MixLib/Instruction/ArithmaticInstructions.cs index 330fad3..4ffaf37 100644 --- a/MixLib/Instruction/ArithmaticInstructions.cs +++ b/MixLib/Instruction/ArithmaticInstructions.cs @@ -8,7 +8,7 @@ namespace MixLib.Instruction /// public static class ArithmaticInstructions { - private const byte SubstractOpcode = 2; + private const byte SUB_Opcode = 2; /// /// Method for performing ADD and SUB instructions @@ -24,7 +24,7 @@ public static bool AddSubstract(ModuleBase module, MixInstruction.Instance insta long rALongValue = rA.LongValue; long memoryWordValue = WordField.LoadFromFullWord(instance.FieldSpec, module.Memory[indexedAddress]).LongValue; - if (instance.MixInstruction.Opcode == SubstractOpcode) + if (instance.MixInstruction.Opcode == SUB_Opcode) memoryWordValue = -memoryWordValue; long sumValue = rALongValue + memoryWordValue; diff --git a/MixLib/Instruction/FloatingPointInstructions.cs b/MixLib/Instruction/FloatingPointInstructions.cs index fcc5e49..1a5443e 100644 --- a/MixLib/Instruction/FloatingPointInstructions.cs +++ b/MixLib/Instruction/FloatingPointInstructions.cs @@ -7,28 +7,28 @@ namespace MixLib.Instruction { public static class FloatingPointInstructions { - private const int FaddOpcode = 1; - private const int FsubOpcode = 2; - private const int FmulOpcode = 3; - private const int FdivOpcode = 4; - private const int FcmpOpcode = 56; - public const string FcmpMnemonic = "FCMP"; + private const int FADD_Opcode = 1; + private const int FSUB_Opcode = 2; + private const int FMUL_Opcode = 3; + private const int FDIV_Opcode = 4; + private const int FCMP_Opcode = 56; + public const string FCMP_Mnemonic = "FCMP"; private static ExecutionStatus _executionStatus; - private static readonly int[] _prenormOpcodes = { FaddOpcode, FsubOpcode, FmulOpcode, FdivOpcode }; + private static readonly int[] _prenormOpcodes = { FADD_Opcode, FSUB_Opcode, FMUL_Opcode, FDIV_Opcode }; public static bool DoFloatingPoint(ModuleBase module, MixInstruction.Instance instance) { if (module is not Mix mix) { - module.ReportRuntimeError(string.Format("Floating point instruction {0} is only available within Mix", instance.Instruction.Mnemonic)); + module.ReportRuntimeError($"Floating point instruction {instance.Instruction.Mnemonic} is only available within Mix"); return false; } FloatingPointModule floatingPointModule = mix.FloatingPointModule; if (floatingPointModule == null) { - module.ReportRuntimeError(string.Format("Instruction {0} requires floating point module to be enabled", instance.Instruction.Mnemonic)); + module.ReportRuntimeError($"Instruction {instance.Instruction.Mnemonic} requires floating point module to be enabled"); return false; } @@ -43,7 +43,7 @@ public static bool DoFloatingPoint(ModuleBase module, MixInstruction.Instance in _executionStatus.RAValue = module.Registers.RA.FullWordValue; bool prenormInstruction = Array.IndexOf(_prenormOpcodes, instance.MixInstruction.Opcode) != -1; - bool fcmpInstruction = !prenormInstruction && instance.MixInstruction.Opcode == FcmpOpcode; + bool fcmpInstruction = !prenormInstruction && instance.MixInstruction.Opcode == FCMP_Opcode; if (prenormInstruction || fcmpInstruction) { @@ -131,7 +131,7 @@ public static bool DoFloatingPoint(ModuleBase module, MixInstruction.Instance in module.Registers.LoadFromMemory(floatingPointModule.FullMemory, ModuleSettings.FloatingPointMemoryWordCount); module.Registers.OverflowIndicator = _executionStatus.OverflowDetected; - if (_executionStatus.Mnemonic == FcmpMnemonic) + if (_executionStatus.Mnemonic == FCMP_Mnemonic) module.Registers.CompareIndicator = comparatorValue; else @@ -156,7 +156,7 @@ public static bool DoFloatingPoint(ModuleBase module, MixInstruction.Instance in case ModuleBase.RunStatus.InvalidInstruction: case ModuleBase.RunStatus.RuntimeError: - module.ReportRuntimeError(string.Format("Floating point module failed to execute instruction {0}", _executionStatus.Mnemonic)); + module.ReportRuntimeError($"Floating point module failed to execute instruction {_executionStatus.Mnemonic}"); module.Mode = _executionStatus.Mode; _executionStatus = null; diff --git a/MixLib/Instruction/MiscInstructions.cs b/MixLib/Instruction/MiscInstructions.cs index d7bb50c..879bab7 100644 --- a/MixLib/Instruction/MiscInstructions.cs +++ b/MixLib/Instruction/MiscInstructions.cs @@ -87,7 +87,7 @@ public static bool ForceInterrupt(ModuleBase module, MixInstruction.Instance ins { if (!(module is Mix)) { - module.ReportRuntimeError(string.Format("The {0} instruction is only available in Mix", instance.Instruction.Mnemonic)); + module.ReportRuntimeError($"The {instance.Instruction.Mnemonic} instruction is only available in Mix"); return false; } diff --git a/MixLib/Instruction/StoreInstructions.cs b/MixLib/Instruction/StoreInstructions.cs index 7e6d9cd..711d3db 100644 --- a/MixLib/Instruction/StoreInstructions.cs +++ b/MixLib/Instruction/StoreInstructions.cs @@ -9,7 +9,7 @@ namespace MixLib.Instruction public static class StoreInstructions { private const byte StoreOpcodeBase = 24; - private const byte StoreJOpcode = 32; + private const byte STJ_Opcode = 32; /// /// Method for performing STx instructions @@ -21,7 +21,7 @@ public static bool StoreRegister(ModuleBase module, MixInstruction.Instance inst { Register sourceRegister; - if (instance.MixInstruction.Opcode == StoreJOpcode) + if (instance.MixInstruction.Opcode == STJ_Opcode) sourceRegister = module.Registers.RJ; else diff --git a/MixLib/InstructionSet.cs b/MixLib/InstructionSet.cs index c3d3414..8c029a2 100644 --- a/MixLib/InstructionSet.cs +++ b/MixLib/InstructionSet.cs @@ -198,7 +198,7 @@ public InstructionSet() AddInstruction("FDIV", 4, rangeSpecs[6], 11, executor, validator); AddInstruction("FLOT", 5, rangeSpecs[6], 3, executor, validator); AddInstruction("FIX", 5, rangeSpecs[7], 3, executor, validator); - AddInstruction(FloatingPointInstructions.FcmpMnemonic, 56, rangeSpecs[6], 4, executor, validator); + AddInstruction(FloatingPointInstructions.FCMP_Mnemonic, 56, rangeSpecs[6], 4, executor, validator); executor = MiscInstructions.Move; AddInstruction("MOVE", 7, new MetaFieldSpec(false, rangeSpecs[1]), 1, executor, validator); diff --git a/MixLib/Memory.cs b/MixLib/Memory.cs index 18cfb62..f8233cf 100644 --- a/MixLib/Memory.cs +++ b/MixLib/Memory.cs @@ -159,7 +159,7 @@ public IMemoryFullWord this[int index] get { if (index < MinWordIndex || index > MaxWordIndex) - throw new ArgumentOutOfRangeException(nameof(index), string.Format("value must be between MinWordIndex ({0}) and MaxWordIndex ({1}), inclusive", MinWordIndex, MaxWordIndex)); + throw new ArgumentOutOfRangeException(nameof(index), $"value must be between MinWordIndex ({MinWordIndex}) and MaxWordIndex ({MaxWordIndex}), inclusive"); MemoryFullWord word; @@ -173,7 +173,7 @@ public IMemoryFullWord this[int index] set { if (index < MinWordIndex || index > MaxWordIndex) - throw new IndexOutOfRangeException(string.Format("index must be between MinWordIndex ({0}) and MaxWordIndex ({1}), inclusive", MinWordIndex, MaxWordIndex)); + throw new IndexOutOfRangeException($"index must be between MinWordIndex ({MinWordIndex}) and MaxWordIndex ({MaxWordIndex}), inclusive"); var word = GetRealWord(index); diff --git a/MixLib/Mix.cs b/MixLib/Mix.cs index 7905805..74bfc1a 100644 --- a/MixLib/Mix.cs +++ b/MixLib/Mix.cs @@ -150,7 +150,7 @@ public void ContinueRun(TimeSpan runSpan) public override void Halt(int code) { - AddLogLine(new LogLine(ModuleName, Severity.Info, ProgramCounter, "Halted", string.Format("System halted with code {0}", code))); + AddLogLine(new LogLine(ModuleName, Severity.Info, ProgramCounter, "Halted", $"System halted with code {code}")); Status = RunStatus.Halted; } diff --git a/MixLib/Modules/FloatingPointModule.cs b/MixLib/Modules/FloatingPointModule.cs index 27c48bb..adcaf99 100644 --- a/MixLib/Modules/FloatingPointModule.cs +++ b/MixLib/Modules/FloatingPointModule.cs @@ -122,7 +122,7 @@ private bool ValidateAddress(Severity severity, string name, int address) { if (address < 0 || address >= ModuleSettings.FloatingPointMemoryWordCount) { - AddLogLine(new LogLine(MyModuleName, severity, "Address invalid", string.Format("Symbol {0} contains invalid address value {1}", name, address))); + AddLogLine(new LogLine(MyModuleName, severity, "Address invalid", $"Symbol {name} contains invalid address value {address}")); return false; } @@ -133,7 +133,7 @@ private bool ValidateAddresses(Severity severity) { if (_accAddress == null || _prenormAddress == null || _exitAddress == null) { - AddLogLine(new LogLine(MyModuleName, severity, "Symbols unset", string.Format("Symbols {0}, {1} and/or {2} are unset", AccSymbol, PrenormSymbol, ExitSymbol))); + AddLogLine(new LogLine(MyModuleName, severity, "Symbols unset", $"Symbols {AccSymbol}, {PrenormSymbol} and/or {ExitSymbol} are unset")); return false; } @@ -204,7 +204,7 @@ public override RunMode Mode set { if (value != RunMode.Normal) - AddLogLine(new LogLine(ModuleName, Severity.Warning, "Invalid mode", string.Format("Mode {0} not supported by this module, change request ignored", value))); + AddLogLine(new LogLine(ModuleName, Severity.Warning, "Invalid mode", $"Mode {value} not supported by this module, change request ignored")); } } @@ -220,7 +220,7 @@ public bool Tick() if (_unexpectedOverflowAddress != null && ProgramCounter == _unexpectedOverflowAddress.Value) { - ReportRuntimeError(string.Format("Overflow set at instruction start")); + ReportRuntimeError("Overflow set at instruction start"); return true; } diff --git a/MixLib/Modules/ModuleBase.cs b/MixLib/Modules/ModuleBase.cs index dd56f4e..983c92d 100644 --- a/MixLib/Modules/ModuleBase.cs +++ b/MixLib/Modules/ModuleBase.cs @@ -64,7 +64,7 @@ private int LoadInstructionInstance(LoaderInstruction.Instance instance, int loc if (desiredLC >= FullMemory.MinWordIndex && desiredLC <= FullMemory.MaxWordIndex) return desiredLC; - ReportLoadError(locationCounter, string.Format("Attempt to set location counter to invalid value {0}", desiredLC)); + ReportLoadError(locationCounter, message: string.Format("Attempt to set location counter to invalid value {0}", desiredLC)); return locationCounter; @@ -88,7 +88,7 @@ private int LoadInstructionInstance(LoaderInstruction.Instance instance, int loc return locationCounter; } - ReportLoadError(locationCounter, string.Format("Attempt to set program counter to invalid value {0}", desiredPC)); + ReportLoadError(locationCounter, $"Attempt to set program counter to invalid value {desiredPC}"); return locationCounter; } diff --git a/MixLib/Properties/launchSettings.json b/MixLib/Properties/launchSettings.json deleted file mode 100644 index 1229b99..0000000 --- a/MixLib/Properties/launchSettings.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:55485/", - "sslPort": 0 - } - }, - "profiles": { - "MixLib": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "http://localhost:5000" - } - } -} \ No newline at end of file diff --git a/MixLib/Thumbs.db b/MixLib/Thumbs.db deleted file mode 100644 index d755769..0000000 Binary files a/MixLib/Thumbs.db and /dev/null differ