From 7c9200207f910a9e6b84e5e8873c339e1de4f0b5 Mon Sep 17 00:00:00 2001 From: Niek Schoemaker <32094562+niekschoemaker@users.noreply.github.com> Date: Mon, 12 Aug 2024 19:31:37 +0200 Subject: [PATCH] Update from .net Framework to .NET 8.0 --- CodeWalker.Core/CodeWalker.Core.csproj | 9 +--- CodeWalker.Core/Utils/Utils.cs | 1 + .../CodeWalker.ErrorReport.csproj | 4 +- CodeWalker.Peds/CodeWalker.Peds.csproj | 6 +-- .../CodeWalker.RPFExplorer.csproj | 6 +-- .../CodeWalker.Vehicles.csproj | 6 +-- .../CodeWalker.WinForms.csproj | 8 ++-- CodeWalker.WinForms/FormUtils.cs | 31 ++++---------- CodeWalker/CodeWalker.csproj | 16 ++----- CodeWalker/Forms/RelForm.Designer.cs | 42 ++++++++----------- CodeWalker/Forms/RelForm.cs | 22 ++++++---- 11 files changed, 54 insertions(+), 97 deletions(-) diff --git a/CodeWalker.Core/CodeWalker.Core.csproj b/CodeWalker.Core/CodeWalker.Core.csproj index 09bb40b..b35632a 100644 --- a/CodeWalker.Core/CodeWalker.Core.csproj +++ b/CodeWalker.Core/CodeWalker.Core.csproj @@ -1,20 +1,15 @@ - - netstandard2.0 + net8.0 - - - - - + \ No newline at end of file diff --git a/CodeWalker.Core/Utils/Utils.cs b/CodeWalker.Core/Utils/Utils.cs index 3d69eb0..74a442f 100644 --- a/CodeWalker.Core/Utils/Utils.cs +++ b/CodeWalker.Core/Utils/Utils.cs @@ -11,6 +11,7 @@ using System.Text; using System.Threading.Tasks; using SharpDX; using Color = SharpDX.Color; +using Half = SharpDX.Half; namespace CodeWalker { diff --git a/CodeWalker.ErrorReport/CodeWalker.ErrorReport.csproj b/CodeWalker.ErrorReport/CodeWalker.ErrorReport.csproj index f64066c..4301185 100644 --- a/CodeWalker.ErrorReport/CodeWalker.ErrorReport.csproj +++ b/CodeWalker.ErrorReport/CodeWalker.ErrorReport.csproj @@ -1,11 +1,9 @@  - WinExe - net48 + net8.0-windows true CW.ico CodeWalker Error Report Tool - \ No newline at end of file diff --git a/CodeWalker.Peds/CodeWalker.Peds.csproj b/CodeWalker.Peds/CodeWalker.Peds.csproj index 4e3ddb5..c085c98 100644 --- a/CodeWalker.Peds/CodeWalker.Peds.csproj +++ b/CodeWalker.Peds/CodeWalker.Peds.csproj @@ -1,8 +1,7 @@  - WinExe - net48 + net8.0-windows true CWPeds.ico dexyfex @@ -10,13 +9,10 @@ dexyfex CodeWalker Ped Viewer - x64 - - \ No newline at end of file diff --git a/CodeWalker.RPFExplorer/CodeWalker.RPFExplorer.csproj b/CodeWalker.RPFExplorer/CodeWalker.RPFExplorer.csproj index c31034a..6b66de5 100644 --- a/CodeWalker.RPFExplorer/CodeWalker.RPFExplorer.csproj +++ b/CodeWalker.RPFExplorer/CodeWalker.RPFExplorer.csproj @@ -1,8 +1,7 @@  - WinExe - net48 + net8.0-windows true true CWRPFExplorer.ico @@ -11,13 +10,10 @@ dexyfex CodeWalker RPF Explorer - x64 - - \ No newline at end of file diff --git a/CodeWalker.Vehicles/CodeWalker.Vehicles.csproj b/CodeWalker.Vehicles/CodeWalker.Vehicles.csproj index 4a32fe0..7cc16b4 100644 --- a/CodeWalker.Vehicles/CodeWalker.Vehicles.csproj +++ b/CodeWalker.Vehicles/CodeWalker.Vehicles.csproj @@ -1,8 +1,7 @@  - WinExe - net48 + net8.0-windows true CWVehicles.ico dexyfex @@ -10,13 +9,10 @@ dexyfex CodeWalker Vehicle Viewer - x64 - - \ No newline at end of file diff --git a/CodeWalker.WinForms/CodeWalker.WinForms.csproj b/CodeWalker.WinForms/CodeWalker.WinForms.csproj index e599f32..22a685b 100644 --- a/CodeWalker.WinForms/CodeWalker.WinForms.csproj +++ b/CodeWalker.WinForms/CodeWalker.WinForms.csproj @@ -1,15 +1,13 @@  - Library - net48 + net8.0-windows true + true - - + - \ No newline at end of file diff --git a/CodeWalker.WinForms/FormUtils.cs b/CodeWalker.WinForms/FormUtils.cs index 2f66c47..316555b 100644 --- a/CodeWalker.WinForms/FormUtils.cs +++ b/CodeWalker.WinForms/FormUtils.cs @@ -5,6 +5,9 @@ using System.Drawing; using System.Reflection; using System.Runtime.InteropServices; using System.Windows.Forms; + +using Microsoft.Win32; + using WeifenLuo.WinFormsUI.Docking; using Point = System.Drawing.Point; @@ -240,34 +243,18 @@ namespace CodeWalker { if (Environment.OSVersion.Version.Major >= 6) { - var ofd = new OpenFileDialog(); - ofd.Filter = "Folders|\n"; - ofd.AddExtension = false; - ofd.CheckFileExists = false; + var ofd = new OpenFolderDialog(); ofd.DereferenceLinks = true; ofd.Multiselect = false; ofd.InitialDirectory = fbd.SelectedPath; - int result = 0; - var ns = "System.Windows.Forms"; - var asmb = Assembly.GetAssembly(typeof(OpenFileDialog)); - var dialogint = GetType(asmb, ns, "FileDialogNative.IFileDialog"); - var dialog = Call(typeof(OpenFileDialog), ofd, "CreateVistaDialog"); - Call(typeof(OpenFileDialog), ofd, "OnBeforeVistaDialog", dialog); - var options = Convert.ToUInt32(Call(typeof(FileDialog), ofd, "GetOptions")); - options |= Convert.ToUInt32(GetEnumValue(asmb, ns, "FileDialogNative.FOS", "FOS_PICKFOLDERS")); - Call(dialogint, dialog, "SetOptions", options); - var pfde = New(asmb, ns, "FileDialog.VistaDialogEvents", ofd); - var parameters = new object[] { pfde, (uint)0 }; - Call(dialogint, dialog, "Advise", parameters); - var adviseres = Convert.ToUInt32(parameters[1]); - try { result = Convert.ToInt32(Call(dialogint, dialog, "Show", hWndOwner)); } - finally { Call(dialogint, dialog, "Unadvise", adviseres); } - GC.KeepAlive(pfde); + ofd.ValidateNames = true; - fbd.SelectedPath = ofd.FileName; + var result = ofd.ShowDialog() ?? false; - return (result == 0) ? DialogResult.OK : DialogResult.Cancel; + fbd.SelectedPath = ofd.FolderName; + + return result ? DialogResult.OK : DialogResult.Cancel; } else { diff --git a/CodeWalker/CodeWalker.csproj b/CodeWalker/CodeWalker.csproj index c2cba3a..8d9f514 100644 --- a/CodeWalker/CodeWalker.csproj +++ b/CodeWalker/CodeWalker.csproj @@ -1,8 +1,7 @@  - WinExe - net48 + net8.0-windows true true CW.ico @@ -10,14 +9,13 @@ dexyfex software dexyfex - x64 - - + + @@ -26,16 +24,10 @@ - - - - - - True @@ -43,12 +35,10 @@ Settings.settings - PublicSettingsSingleFileGenerator Settings.Designer.cs - \ No newline at end of file diff --git a/CodeWalker/Forms/RelForm.Designer.cs b/CodeWalker/Forms/RelForm.Designer.cs index 8307057..be4cf0c 100644 --- a/CodeWalker/Forms/RelForm.Designer.cs +++ b/CodeWalker/Forms/RelForm.Designer.cs @@ -30,9 +30,7 @@ { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RelForm)); - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend(); - System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series(); + OxyPlot.PlotModel plotView = new OxyPlot.PlotModel(); this.RelPropertyGrid = new CodeWalker.WinForms.PropertyGridFix(); this.MainTabControl = new System.Windows.Forms.TabControl(); this.XmlTabPage = new System.Windows.Forms.TabPage(); @@ -53,7 +51,7 @@ this.label2 = new System.Windows.Forms.Label(); this.SynthVariablesTextBox = new System.Windows.Forms.TextBox(); this.SynthOutputsTextBox = new System.Windows.Forms.TextBox(); - this.SynthBufferChart = new System.Windows.Forms.DataVisualization.Charting.Chart(); + this.plotView1 = new OxyPlot.WindowsForms.PlotView(); this.SynthPlayButton = new System.Windows.Forms.Button(); this.SynthCopyXMLButton = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); @@ -86,7 +84,7 @@ this.NameTableTabPage.SuspendLayout(); this.SearchTabPage.SuspendLayout(); this.SynthsTabPage.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.SynthBufferChart)).BeginInit(); + this.plotView1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.SynthTextBox)).BeginInit(); this.MainToolbar.SuspendLayout(); this.MainStatusStrip.SuspendLayout(); @@ -297,7 +295,7 @@ this.SynthsTabPage.Controls.Add(this.label2); this.SynthsTabPage.Controls.Add(this.SynthVariablesTextBox); this.SynthsTabPage.Controls.Add(this.SynthOutputsTextBox); - this.SynthsTabPage.Controls.Add(this.SynthBufferChart); + this.SynthsTabPage.Controls.Add(this.plotView1); this.SynthsTabPage.Controls.Add(this.SynthPlayButton); this.SynthsTabPage.Controls.Add(this.SynthCopyXMLButton); this.SynthsTabPage.Controls.Add(this.label1); @@ -360,23 +358,18 @@ // // SynthBufferChart // - this.SynthBufferChart.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.plotView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - chartArea1.Name = "ChartArea1"; - this.SynthBufferChart.ChartAreas.Add(chartArea1); - legend1.Name = "Legend1"; - this.SynthBufferChart.Legends.Add(legend1); - this.SynthBufferChart.Location = new System.Drawing.Point(363, 31); - this.SynthBufferChart.Name = "SynthBufferChart"; - series1.ChartArea = "ChartArea1"; - series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - series1.IsXValueIndexed = true; - series1.Legend = "Legend1"; - series1.Name = "Buffer"; - this.SynthBufferChart.Series.Add(series1); - this.SynthBufferChart.Size = new System.Drawing.Size(460, 112); - this.SynthBufferChart.TabIndex = 38; - this.SynthBufferChart.Text = "chart1"; + var plotModel = new OxyPlot.PlotModel(); + this.plotView1.Location = new System.Drawing.Point(363, 31); + this.plotView1.Name = "SynthBufferChart"; + plotModel.Series.Add(new OxyPlot.Series.LineSeries { Title = "Buffer", LegendKey = "Main" }); + plotModel.IsLegendVisible = true; + plotModel.Legends.Add(new OxyPlot.Legends.Legend { LegendPosition = OxyPlot.Legends.LegendPosition.RightMiddle, LegendPlacement = OxyPlot.Legends.LegendPlacement.Outside, LegendOrientation = OxyPlot.Legends.LegendOrientation.Horizontal, Key = "Main" }); + this.plotView1.Model = plotModel; + this.plotView1.Size = new System.Drawing.Size(460, 112); + this.plotView1.TabIndex = 38; + this.plotView1.Text = "chart1"; // // SynthPlayButton // @@ -649,7 +642,8 @@ this.SearchTabPage.PerformLayout(); this.SynthsTabPage.ResumeLayout(false); this.SynthsTabPage.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.SynthBufferChart)).EndInit(); + this.plotView1.ResumeLayout(false); + this.plotView1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.SynthTextBox)).EndInit(); this.MainToolbar.ResumeLayout(false); this.MainToolbar.PerformLayout(); @@ -704,7 +698,7 @@ private FastColoredTextBoxNS.FastColoredTextBox SynthTextBox; private System.Windows.Forms.Button SynthCopyXMLButton; private System.Windows.Forms.Button SynthPlayButton; - private System.Windows.Forms.DataVisualization.Charting.Chart SynthBufferChart; + private OxyPlot.WindowsForms.PlotView plotView1; private System.Windows.Forms.TextBox SynthOutputsTextBox; private System.Windows.Forms.TextBox SynthVariablesTextBox; private System.Windows.Forms.Label label3; diff --git a/CodeWalker/Forms/RelForm.cs b/CodeWalker/Forms/RelForm.cs index b011dfb..cdecf46 100644 --- a/CodeWalker/Forms/RelForm.cs +++ b/CodeWalker/Forms/RelForm.cs @@ -12,7 +12,8 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -using System.Windows.Forms.DataVisualization.Charting; +using OxyPlot; +using OxyPlot.Series; using System.Xml; using Range = FastColoredTextBoxNS.Range; using TextStyle = FastColoredTextBoxNS.TextStyle; @@ -750,12 +751,16 @@ namespace CodeWalker.Forms int i = synthesizer.Synth.OutputsIndices[0]; try { - var series = SynthBufferChart.Series.FindByName($"B{i}"); + var series = plotView1.Model.Series.FirstOrDefault(p => p.Title == $"B{i}") as LineSeries; if (series != null) { series.Points.Clear(); - foreach (var v in buffersCopy[i]) - series.Points.AddY(Math.Max(Math.Min(v, 2.0f), -2.0f));//make sure crazy accidental values don't crash it later + var thisBuffer = buffersCopy[i]; + for (int j = 0; j < thisBuffer.Length; j++) + { + series.Points.Add(new DataPoint(j, Math.Max(Math.Min(thisBuffer[j], 2.0f), -2.0f))); + } + plotView1.InvalidatePlot(true); } } catch { } @@ -763,12 +768,13 @@ namespace CodeWalker.Forms }; } - SynthBufferChart.Series.Clear(); + plotView1.Model.Series.Clear(); + //plotView1.Model.GetLegend("Main"); for (int i = 0; i < newSynth.BuffersCount; i++) { - var series = SynthBufferChart.Series.Add($"B{i}"); - series.IsXValueIndexed = true; - series.ChartType = SeriesChartType.FastLine; + + plotView1.Model.Series.Add(new LineSeries { Title = $"B{i}", RenderInLegend = true, LegendKey = $"Main" }); + //plotView1.Model.Legends.Add(new OxyPlot.Legends.Legend { LegendPosition = OxyPlot.Legends.LegendPosition.RightMiddle, LegendPlacement = OxyPlot.Legends.LegendPlacement.Outside, LegendOrientation = OxyPlot.Legends.LegendOrientation.Vertical, Key = $"B{i}" }); } SynthPlayButton.Enabled = false;