From a510cf5804d923bb4dfa5ec4692431cd5733f827 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 19 Feb 2026 21:04:20 +0000 Subject: [PATCH 1/2] Initial plan From 0456e045f2700a325ce147dd3fc7abe369d89346 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 19 Feb 2026 21:13:35 +0000 Subject: [PATCH 2/2] Convert ADF application from VB.NET to C# .NET 8 Co-authored-by: rsodvd79 <42972185+rsodvd79@users.noreply.github.com> --- ADF.sln | 2 +- ADF/ADF.csproj | 31 ++++++ ADF/ADF.vbproj | 136 ------------------------- ADF/AdfForm.Designer.cs | 61 +++++++++++ ADF/AdfForm.cs | 134 ++++++++++++++++++++++++ ADF/ClassADF.cs | 111 ++++++++++++++++++++ ADF/ClassADF.vb | 113 -------------------- ADF/My Project/Application.Designer.vb | 38 ------- ADF/My Project/Application.myapp | 10 -- ADF/My Project/AssemblyInfo.vb | 35 ------- ADF/My Project/Resources.Designer.vb | 63 ------------ ADF/My Project/Resources.resx | 117 --------------------- ADF/My Project/Settings.Designer.vb | 73 ------------- ADF/My Project/Settings.settings | 7 -- ADF/Program.cs | 15 +++ ADF/adf.Designer.vb | 68 ------------- ADF/adf.resx | 120 ---------------------- ADF/adf.vb | 129 ----------------------- ADF/app.config | 23 ----- README.md | 45 ++++---- 20 files changed, 377 insertions(+), 954 deletions(-) create mode 100644 ADF/ADF.csproj delete mode 100644 ADF/ADF.vbproj create mode 100644 ADF/AdfForm.Designer.cs create mode 100644 ADF/AdfForm.cs create mode 100644 ADF/ClassADF.cs delete mode 100644 ADF/ClassADF.vb delete mode 100644 ADF/My Project/Application.Designer.vb delete mode 100644 ADF/My Project/Application.myapp delete mode 100644 ADF/My Project/AssemblyInfo.vb delete mode 100644 ADF/My Project/Resources.Designer.vb delete mode 100644 ADF/My Project/Resources.resx delete mode 100644 ADF/My Project/Settings.Designer.vb delete mode 100644 ADF/My Project/Settings.settings create mode 100644 ADF/Program.cs delete mode 100644 ADF/adf.Designer.vb delete mode 100644 ADF/adf.resx delete mode 100644 ADF/adf.vb delete mode 100644 ADF/app.config diff --git a/ADF.sln b/ADF.sln index 1685740..7ea4c59 100644 --- a/ADF.sln +++ b/ADF.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 -Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ADF", "ADF\ADF.vbproj", "{56AD8E06-E293-4B04-8D12-055FE7903D90}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ADF", "ADF\ADF.csproj", "{56AD8E06-E293-4B04-8D12-055FE7903D90}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/ADF/ADF.csproj b/ADF/ADF.csproj new file mode 100644 index 0000000..a8c5872 --- /dev/null +++ b/ADF/ADF.csproj @@ -0,0 +1,31 @@ + + + + WinExe + net8.0-windows + true + ADF + ADF + ADF + 1.0.0.0 + 1.0.0.0 + Copyright © 2009 + x86 + enable + true + + + + + Interop.MSScriptControl.dll + False + + + + + + Always + + + + diff --git a/ADF/ADF.vbproj b/ADF/ADF.vbproj deleted file mode 100644 index 9035df4..0000000 --- a/ADF/ADF.vbproj +++ /dev/null @@ -1,136 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {56AD8E06-E293-4B04-8D12-055FE7903D90} - WinExe - ADF.My.MyApplication - ADF - ADF - 512 - WindowsForms - v2.0 - On - Binary - Off - On - - - - - 3.5 - - - - true - full - true - true - bin\Debug\ - ADF.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022,42353,42354,42355 - x86 - - - pdbonly - false - true - true - bin\Release\ - ADF.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022,42353,42354,42355 - - - - .\Interop.MSScriptControl.dll - False - True - - - - - - - 3.5 - - - 3.5 - - - - - - - - - - - - - - - - Form - - - adf.vb - Form - - - - - True - Application.myapp - - - True - True - Resources.resx - - - True - Settings.settings - True - - - - - adf.vb - Designer - - - VbMyResourcesResXFileCodeGenerator - Resources.Designer.vb - My.Resources - Designer - - - - - - MyApplicationCodeGenerator - Application.Designer.vb - - - SettingsSingleFileGenerator - My - Settings.Designer.vb - - - - - Always - - - - - \ No newline at end of file diff --git a/ADF/AdfForm.Designer.cs b/ADF/AdfForm.Designer.cs new file mode 100644 index 0000000..886b285 --- /dev/null +++ b/ADF/AdfForm.Designer.cs @@ -0,0 +1,61 @@ +#nullable enable +namespace ADF; + +partial class AdfForm +{ + private System.ComponentModel.IContainer? components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && components != null) + components.Dispose(); + base.Dispose(disposing); + } + + private void InitializeComponent() + { + btnOk = new System.Windows.Forms.Button(); + lblTitolo = new System.Windows.Forms.Label(); + SuspendLayout(); + // + // btnOk + // + btnOk.Location = new System.Drawing.Point(12, 45); + btnOk.Name = "btnOk"; + btnOk.Size = new System.Drawing.Size(253, 41); + btnOk.TabIndex = 0; + btnOk.Text = "OK"; + btnOk.UseVisualStyleBackColor = true; + btnOk.Click += BtnOk_Click; + // + // lblTitolo + // + lblTitolo.AutoSize = true; + lblTitolo.Font = new System.Drawing.Font("Tahoma", 20.25f, System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, 0); + lblTitolo.Location = new System.Drawing.Point(12, 9); + lblTitolo.Name = "lblTitolo"; + lblTitolo.Size = new System.Drawing.Size(256, 33); + lblTitolo.TabIndex = 1; + lblTitolo.Text = "A.D.F ver. 0.1 Win"; + // + // AdfForm + // + AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f); + AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + ClientSize = new System.Drawing.Size(279, 99); + Controls.Add(lblTitolo); + Controls.Add(btnOk); + FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + MaximizeBox = false; + MinimizeBox = false; + Name = "AdfForm"; + StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + Text = "ADF"; + Load += AdfForm_Load; + ResumeLayout(false); + PerformLayout(); + } + + private System.Windows.Forms.Button btnOk = null!; + private System.Windows.Forms.Label lblTitolo = null!; +} diff --git a/ADF/AdfForm.cs b/ADF/AdfForm.cs new file mode 100644 index 0000000..f249e67 --- /dev/null +++ b/ADF/AdfForm.cs @@ -0,0 +1,134 @@ +using System; +using System.Linq; +using System.Windows.Forms; +using MSScriptControl; + +namespace ADF; + +public partial class AdfForm : Form +{ + private ScriptControlClass scrMain = new ScriptControlClass(); + + public AdfForm() + { + InitializeComponent(); + + AppDomain.CurrentDomain.UnhandledException += (sender, args) => + { + try + { + MessageBox.Show(((Exception)args.ExceptionObject).Message, "ADF", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + catch + { + // ignore + } + }; + } + + private void BtnOk_Click(object? sender, EventArgs e) + { + Close(); + } + + private void AdfForm_Load(object? sender, EventArgs e) + { + string strFL = string.Join(" ", Environment.GetCommandLineArgs().Skip(1)).Trim(); + + scrMain.Language = "VBScript"; + scrMain.AllowUI = true; + + if (!string.IsNullOrEmpty(strFL) && System.IO.File.Exists(strFL)) + { + var xmlFL = ClassADF.Carica(strFL); + + foreach (var xmlCon in xmlFL.CONTROLS) + CreaControl(this, ref scrMain, xmlCon); + + scrMain.AddCode(xmlFL.MODULO); + + Application.OpenForms.Cast
() + .FirstOrDefault(f => f.Name == xmlFL.PROPERTY.STARTCONTROL) + ?.ShowDialog(this); + } + + Close(); + } + + private void CreaControl(Control cltPadre, ref ScriptControlClass scrPadre, ClassADF.ClassCONTROL xmlControl) + { + if (xmlControl == null) return; + + Control? cltME = null; + + switch (xmlControl.PROPERTY.TYPE) + { + case ClassADF.ClassCONTROL.ClassControlPROPERTY.Types.FORM: + scrPadre = new ScriptControlClass + { + Language = "VBScript", + AllowUI = true + }; + cltME = new Form + { + Name = xmlControl.PROPERTY.NAME, + Text = xmlControl.PROPERTY.TEXT, + Width = xmlControl.PROPERTY.WIDTH, + Height = xmlControl.PROPERTY.HEIGHT + }; + cltME.Show(); + cltME.Hide(); + break; + + case ClassADF.ClassCONTROL.ClassControlPROPERTY.Types.BUTTON: + cltME = new Button + { + Name = xmlControl.PROPERTY.NAME, + Text = xmlControl.PROPERTY.TEXT, + Width = xmlControl.PROPERTY.WIDTH, + Height = xmlControl.PROPERTY.HEIGHT, + Top = xmlControl.PROPERTY.TOP, + Left = xmlControl.PROPERTY.LEFT, + Parent = cltPadre + }; + break; + } + + if (cltME != null) + { + scrPadre.AddObject(cltME.Name, cltME, true); + + if (!string.IsNullOrEmpty(xmlControl.EVENTS.CLICK)) + { + try + { + scrPadre.AddCode($"Sub {cltME.Name}_Click()\r\n{xmlControl.EVENTS.CLICK}\r\nEnd Sub\r\n"); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "ADF", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + cltME.Click += Clt_Click; + } + + foreach (var xmlCltCon in xmlControl.CONTROLS) + CreaControl(cltME, ref scrPadre, xmlCltCon); + + cltME.Tag = scrPadre; + } + } + + private void Clt_Click(object? sender, EventArgs e) + { + try + { + var ctrl = (Control)sender!; + ((ScriptControlClass)ctrl.Tag!).Run(ctrl.Name + "_Click"); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "ADF", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } +} diff --git a/ADF/ClassADF.cs b/ADF/ClassADF.cs new file mode 100644 index 0000000..a65fed8 --- /dev/null +++ b/ADF/ClassADF.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml; +using System.Xml.Serialization; + +namespace ADF; + +[Serializable] +[XmlRoot("ADF")] +public class ClassADF +{ + public class ClassMainPROPERTY + { + public string STARTCONTROL { get; set; } = string.Empty; + } + + public class ClassCONTROL + { + public class ClassControlPROPERTY + { + public enum Types + { + FORM, + BUTTON + } + + public Types TYPE = Types.FORM; + public string NAME = string.Empty; + public string TEXT = string.Empty; + public int WIDTH = 0; + public int HEIGHT = 0; + public int TOP = 0; + public int LEFT = 0; + } + + public class ClassEVENT + { + public string CLICK = string.Empty; + } + + public ClassControlPROPERTY PROPERTY; + public ClassEVENT EVENTS; + [XmlArrayItem(ElementName = "CONTROL")] + public List CONTROLS; + + public ClassCONTROL() + { + PROPERTY = new ClassControlPROPERTY(); + CONTROLS = new List(); + EVENTS = new ClassEVENT(); + } + } + + public ClassMainPROPERTY PROPERTY; + public string MODULO; + [XmlArrayItem(ElementName = "CONTROL")] + public List CONTROLS; + + public ClassADF() + { + PROPERTY = new ClassMainPROPERTY(); + MODULO = string.Empty; + CONTROLS = new List(); + } + + public ClassADF Clone() => (ClassADF)MemberwiseClone(); + + public bool Salva(string fileXML) + { + try + { + if (File.Exists(fileXML)) + File.Delete(fileXML); + + using var xmlWrt = XmlWriter.Create(fileXML, new XmlWriterSettings { Indent = true }); + var srlzr = new XmlSerializer(typeof(ClassADF)); + srlzr.Serialize(xmlWrt, this); + return true; + } + catch + { + throw; + } + } + + public static ClassADF Carica(string fileXML) + { + ClassADF? rtn = null; + try + { + if (File.Exists(fileXML)) + { + using var xmlRdr = XmlReader.Create(new StringReader(File.ReadAllText(fileXML))); + var srlzr = new XmlSerializer(typeof(ClassADF)); + if (srlzr.CanDeserialize(xmlRdr)) + rtn = (ClassADF)srlzr.Deserialize(xmlRdr)!; + } + else + { + rtn = new ClassADF(); + rtn.Salva(fileXML); + } + } + catch + { + throw; + } + return rtn!; + } +} diff --git a/ADF/ClassADF.vb b/ADF/ClassADF.vb deleted file mode 100644 index de9de9b..0000000 --- a/ADF/ClassADF.vb +++ /dev/null @@ -1,113 +0,0 @@ - - -Public Class ClassADF - - Public Class ClassMainPROPERTY - Public Property STARTCONTROL As String = String.Empty - End Class - - Public Class ClassCONTROL - Public Class ClassControlPROPERTY - Public Enum Types - FORM - BUTTON - End Enum - - Public [TYPE] As Types = Types.FORM - Public [NAME] As String = String.Empty - Public [TEXT] As String = String.Empty - Public [WIDTH] As Integer = 0 - Public [HEIGHT] As Integer = 0 - Public [TOP] As Integer = 0 - Public [LEFT] As Integer = 0 - End Class - - Public Class ClassEVENT - Public [CLICK] As String = String.Empty - End Class - - Public [PROPERTY] As ClassControlPROPERTY - Public [EVENTS] As ClassEVENT - - Public [CONTROLS] As List(Of ClassCONTROL) - - Public Sub New() - [PROPERTY] = New ClassControlPROPERTY - [CONTROLS] = New List(Of ClassCONTROL) - [EVENTS] = New ClassEVENT - End Sub - End Class - - Public [PROPERTY] As ClassMainPROPERTY - Public [MODULO] As String - - Public [CONTROLS] As List(Of ClassCONTROL) - - Public Sub New() - [PROPERTY] = New ClassMainPROPERTY - [MODULO] = String.Empty - [CONTROLS] = New List(Of ClassCONTROL) - End Sub - - Public Function Clone() As ClassADF - Return DirectCast(MemberwiseClone(), ClassADF) - End Function - - Public Function Salva(FileXML As String) As Boolean - - Try - Dim file As String = FileXML - - If IO.File.Exists(file) Then - IO.File.Delete(file) - End If - - Dim XmlWrt As Xml.XmlWriter = Xml.XmlWriter.Create(file, New Xml.XmlWriterSettings() With {.Indent = True}) - Dim Srlzr As New Xml.Serialization.XmlSerializer(GetType(ClassADF)) - Srlzr.Serialize(XmlWrt, Me) - XmlWrt.Flush() - XmlWrt.Close() - - Return True - - Catch ex As Exception - Throw - - End Try - - Return False - End Function - - Public Shared Function Carica(FileXML As String) As ClassADF - Dim rtn As ClassADF = Nothing - Dim file As String = FileXML - - Try - If IO.File.Exists(file) Then - Dim XmlRdr As Xml.XmlReader = Xml.XmlReader.Create(New IO.StringReader(IO.File.ReadAllText(file))) - - Dim Srlzr As New Xml.Serialization.XmlSerializer(GetType(ClassADF)) - ' AddHandler Srlzr.UnknownNode, AddressOf Srlzr_UnknownNode - ' AddHandler Srlzr.UnknownAttribute, AddressOf Srlzr_UnknownAttribute - - If Srlzr.CanDeserialize(XmlRdr) Then - rtn = DirectCast(Srlzr.Deserialize(XmlRdr), ClassADF) - - End If - - XmlRdr.Close() - - Else - rtn = New ClassADF() - rtn.Salva(FileXML) - - End If - - Catch ex As Exception - Throw - - End Try - - Return rtn - End Function -End Class diff --git a/ADF/My Project/Application.Designer.vb b/ADF/My Project/Application.Designer.vb deleted file mode 100644 index 1499c95..0000000 --- a/ADF/My Project/Application.Designer.vb +++ /dev/null @@ -1,38 +0,0 @@ -'------------------------------------------------------------------------------ -' -' Il codice è stato generato da uno strumento. -' Versione runtime:4.0.30319.18052 -' -' Le modifiche apportate a questo file possono provocare un comportamento non corretto e andranno perse se -' il codice viene rigenerato. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - - -Namespace My - - 'NOTA: il file è generato automaticamente e non può essere modificato direttamente. Per effettuare modifiche - ' o se vengono rilevati errori di compilazione nel file, andare alla Progettazione progetti - ' (aprire le proprietà del progetto o fare doppio clic sul nodo Progetto in - ' Esplora soluzioni) ed effettuare le modifiche nella scheda Applicazione. - ' - Partial Friend Class MyApplication - - _ - Public Sub New() - MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) - Me.IsSingleInstance = false - Me.EnableVisualStyles = true - Me.SaveMySettingsOnExit = true - Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses - End Sub - - _ - Protected Overrides Sub OnCreateMainForm() - Me.MainForm = Global.ADF.ADF - End Sub - End Class -End Namespace diff --git a/ADF/My Project/Application.myapp b/ADF/My Project/Application.myapp deleted file mode 100644 index 4cf75c3..0000000 --- a/ADF/My Project/Application.myapp +++ /dev/null @@ -1,10 +0,0 @@ - - - true - ADF - false - 0 - true - 0 - true - \ No newline at end of file diff --git a/ADF/My Project/AssemblyInfo.vb b/ADF/My Project/AssemblyInfo.vb deleted file mode 100644 index ed39ad8..0000000 --- a/ADF/My Project/AssemblyInfo.vb +++ /dev/null @@ -1,35 +0,0 @@ -Imports System -Imports System.Reflection -Imports System.Runtime.InteropServices - -' Le informazioni generali relative a un assembly sono controllate dal seguente -' insieme di attributi. Per modificare le informazioni associate a un assembly -' è necessario modificare i valori di questi attributi. - -' Controllare i valori degli attributi dell'assembly - - - - - - - - - - -'Se il progetto viene esposto a COM, il GUID seguente verrà utilizzato come ID della libreria dei tipi - - -' Le informazioni sulla versione di un assembly sono costituite dai seguenti quattro valori: -' -' Numero di versione principale -' Numero di versione secondario -' Numero build -' Revisione -' -' È possibile specificare tutti i valori oppure impostare i valori predefiniti per i numeri relativi alla revisione e alla build -' utilizzando l'asterisco (*) come descritto di seguito: -' - - - diff --git a/ADF/My Project/Resources.Designer.vb b/ADF/My Project/Resources.Designer.vb deleted file mode 100644 index 89ed064..0000000 --- a/ADF/My Project/Resources.Designer.vb +++ /dev/null @@ -1,63 +0,0 @@ -'------------------------------------------------------------------------------ -' -' Il codice è stato generato da uno strumento. -' Versione runtime:4.0.30319.18052 -' -' Le modifiche apportate a questo file possono provocare un comportamento non corretto e andranno perse se -' il codice viene rigenerato. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - -Imports System - -Namespace My.Resources - - 'Questa classe è stata generata automaticamente dalla classe StronglyTypedResourceBuilder. - 'tramite uno strumento quale ResGen o Visual Studio. - 'Per aggiungere o rimuovere un membro, modificare il file con estensione ResX ed eseguire nuovamente ResGen - 'con l'opzione /str oppure ricompilare il progetto VS. - ''' - ''' Classe di risorse fortemente tipizzata per la ricerca di stringhe localizzate e così via. - ''' - _ - Friend Module Resources - - Private resourceMan As Global.System.Resources.ResourceManager - - Private resourceCulture As Global.System.Globalization.CultureInfo - - ''' - ''' Restituisce l'istanza di ResourceManager nella cache utilizzata da questa classe. - ''' - _ - Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager - Get - If Object.ReferenceEquals(resourceMan, Nothing) Then - Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("ADF.Resources", GetType(Resources).Assembly) - resourceMan = temp - End If - Return resourceMan - End Get - End Property - - ''' - ''' Esegue l'override della proprietà CurrentUICulture del thread corrente per tutte le - ''' ricerche di risorse eseguite utilizzando questa classe di risorse fortemente tipizzata. - ''' - _ - Friend Property Culture() As Global.System.Globalization.CultureInfo - Get - Return resourceCulture - End Get - Set - resourceCulture = value - End Set - End Property - End Module -End Namespace diff --git a/ADF/My Project/Resources.resx b/ADF/My Project/Resources.resx deleted file mode 100644 index af7dbeb..0000000 --- a/ADF/My Project/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ADF/My Project/Settings.Designer.vb b/ADF/My Project/Settings.Designer.vb deleted file mode 100644 index 88dfac8..0000000 --- a/ADF/My Project/Settings.Designer.vb +++ /dev/null @@ -1,73 +0,0 @@ -'------------------------------------------------------------------------------ -' -' Il codice è stato generato da uno strumento. -' Versione runtime:4.0.30319.18052 -' -' Le modifiche apportate a questo file possono provocare un comportamento non corretto e andranno perse se -' il codice viene rigenerato. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - - -Namespace My - - _ - Partial Friend NotInheritable Class MySettings - Inherits Global.System.Configuration.ApplicationSettingsBase - - Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) - -#Region "Funzionalità di salvataggio automatico My.Settings" -#If _MyType = "WindowsForms" Then - Private Shared addedHandler As Boolean - - Private Shared addedHandlerLockObject As New Object - - _ - Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) - If My.Application.SaveMySettingsOnExit Then - My.Settings.Save() - End If - End Sub -#End If -#End Region - - Public Shared ReadOnly Property [Default]() As MySettings - Get - -#If _MyType = "WindowsForms" Then - If Not addedHandler Then - SyncLock addedHandlerLockObject - If Not addedHandler Then - AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings - addedHandler = True - End If - End SyncLock - End If -#End If - Return defaultInstance - End Get - End Property - End Class -End Namespace - -Namespace My - - _ - Friend Module MySettingsProperty - - _ - Friend ReadOnly Property Settings() As Global.ADF.My.MySettings - Get - Return Global.ADF.My.MySettings.Default - End Get - End Property - End Module -End Namespace diff --git a/ADF/My Project/Settings.settings b/ADF/My Project/Settings.settings deleted file mode 100644 index 85b890b..0000000 --- a/ADF/My Project/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/ADF/Program.cs b/ADF/Program.cs new file mode 100644 index 0000000..635d203 --- /dev/null +++ b/ADF/Program.cs @@ -0,0 +1,15 @@ +using System; +using System.Windows.Forms; + +namespace ADF; + +internal static class Program +{ + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new AdfForm()); + } +} diff --git a/ADF/adf.Designer.vb b/ADF/adf.Designer.vb deleted file mode 100644 index 31e7fd0..0000000 --- a/ADF/adf.Designer.vb +++ /dev/null @@ -1,68 +0,0 @@ - _ -Partial Class ADF - Inherits System.Windows.Forms.Form - - 'Form esegue l'override del metodo Dispose per pulire l'elenco dei componenti. - _ - Protected Overrides Sub Dispose(ByVal disposing As Boolean) - Try - If disposing AndAlso components IsNot Nothing Then - components.Dispose() - End If - Finally - MyBase.Dispose(disposing) - End Try - End Sub - - 'Richiesto da Progettazione Windows Form - Private components As System.ComponentModel.IContainer - - 'NOTA: la procedura che segue è richiesta da Progettazione Windows Form - 'Può essere modificata in Progettazione Windows Form. - 'Non modificarla nell'editor del codice. - _ - Private Sub InitializeComponent() - Me.btnOk = New System.Windows.Forms.Button - Me.lblTitolo = New System.Windows.Forms.Label - Me.SuspendLayout() - ' - 'btnOk - ' - Me.btnOk.Location = New System.Drawing.Point(12, 45) - Me.btnOk.Name = "btnOk" - Me.btnOk.Size = New System.Drawing.Size(253, 41) - Me.btnOk.TabIndex = 0 - Me.btnOk.Text = "OK" - Me.btnOk.UseVisualStyleBackColor = True - ' - 'lblTitolo - ' - Me.lblTitolo.AutoSize = True - Me.lblTitolo.Font = New System.Drawing.Font("Tahoma", 20.25!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic), System.Drawing.FontStyle), System.Drawing.GraphicsUnit.Point, CType(0, Byte)) - Me.lblTitolo.Location = New System.Drawing.Point(12, 9) - Me.lblTitolo.Name = "lblTitolo" - Me.lblTitolo.Size = New System.Drawing.Size(256, 33) - Me.lblTitolo.TabIndex = 1 - Me.lblTitolo.Text = "A.D.F ver. 0.1 Win" - ' - 'ADF - ' - Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) - Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(279, 99) - Me.Controls.Add(Me.lblTitolo) - Me.Controls.Add(Me.btnOk) - Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog - Me.MaximizeBox = False - Me.MinimizeBox = False - Me.Name = "ADF" - Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen - Me.Text = "ADF" - Me.ResumeLayout(False) - Me.PerformLayout() - - End Sub - Friend WithEvents btnOk As System.Windows.Forms.Button - Friend WithEvents lblTitolo As System.Windows.Forms.Label - -End Class diff --git a/ADF/adf.resx b/ADF/adf.resx deleted file mode 100644 index 19dc0dd..0000000 --- a/ADF/adf.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ADF/adf.vb b/ADF/adf.vb deleted file mode 100644 index 4726ad5..0000000 --- a/ADF/adf.vb +++ /dev/null @@ -1,129 +0,0 @@ - -Public Class ADF - - Dim scrMain As New MSScriptControl.ScriptControlClass - - Public Sub New() - - ' La chiamata è richiesta dalla finestra di progettazione. - InitializeComponent() - - ' Aggiungere le eventuali istruzioni di inizializzazione dopo la chiamata a InitializeComponent(). - AddHandler AppDomain.CurrentDomain.UnhandledException, - Sub(sender As Object, args As UnhandledExceptionEventArgs) - Try - MsgBox(DirectCast(args.ExceptionObject, Exception).Message, MsgBoxStyle.Critical, "ADF") - Catch ex As Exception - ' ignora - End Try - End Sub - - End Sub - - Private Sub btnOk_Click(sender As System.Object, e As System.EventArgs) Handles btnOk.Click - Me.Close() - End Sub - - Private Sub ADF_Load(sender As Object, e As System.EventArgs) Handles Me.Load - - Dim strFL As String = Command().Trim - - scrMain.Language = "VBScript" - scrMain.AllowUI = True - - If Not strFL.Equals(String.Empty) AndAlso System.IO.File.Exists(strFL) Then - - Dim xmlFL As ClassADF = ClassADF.Carica(strFL) - - For Each xmlCon As ClassADF.ClassCONTROL In xmlFL.CONTROLS - CreaControl(Me, scrMain, xmlCon) - - Next - - scrMain.AddCode(xmlFL.MODULO) - - My.Application.OpenForms.Item(xmlFL.PROPERTY.STARTCONTROL).ShowDialog(Me) - - End If - - Me.Close() - - End Sub - - Private Sub CreaControl(ByRef cltPadre As Control, ByRef scrPadre As MSScriptControl.ScriptControlClass, xmlControl As ClassADF.ClassCONTROL) - - If xmlControl IsNot Nothing Then - - Dim cltME As Control = Nothing - - Select Case xmlControl.PROPERTY.TYPE - Case ClassADF.ClassCONTROL.ClassControlPROPERTY.Types.FORM - - cltME = New Form With { - .Name = xmlControl.PROPERTY.NAME, - .Text = xmlControl.PROPERTY.TEXT, - .Width = xmlControl.PROPERTY.WIDTH, - .Height = xmlControl.PROPERTY.HEIGHT - } - - scrPadre = New MSScriptControl.ScriptControlClass With { - .Language = "VBScript", - .AllowUI = True - } - - cltME.Show() - cltME.Hide() - - Case ClassADF.ClassCONTROL.ClassControlPROPERTY.Types.BUTTON - - cltME = New Button With { - .Name = xmlControl.PROPERTY.NAME, - .Text = xmlControl.PROPERTY.TEXT, - .Width = xmlControl.PROPERTY.WIDTH, - .Height = xmlControl.PROPERTY.HEIGHT, - .Top = xmlControl.PROPERTY.TOP, - .Left = xmlControl.PROPERTY.LEFT, - .Parent = cltPadre - } - - End Select - - If cltME IsNot Nothing Then - - scrPadre.AddObject(cltME.Name, cltME, True) - - If Not String.IsNullOrEmpty(xmlControl.EVENTS.CLICK) Then - - Try - scrPadre.AddCode($"Sub {cltME.Name}_Click(){vbCrLf}{xmlControl.EVENTS.CLICK}{vbCrLf}End Sub{vbCrLf}") - Catch ex As Exception - MsgBox(ex.Message, MsgBoxStyle.Critical, "ADF") - End Try - - AddHandler cltME.Click, AddressOf clt_Click - - End If - - For Each xmlCltCon As ClassADF.ClassCONTROL In xmlControl.CONTROLS - CreaControl(cltME, scrPadre, xmlCltCon) - - Next - - cltME.Tag = scrPadre - - End If - End If - - End Sub - - Private Sub clt_Click(sender As System.Object, e As System.EventArgs) - - Try - CType(CType(sender, Control).Tag, MSScriptControl.ScriptControl).Run(CType(sender, Control).Name & "_Click") - Catch ex As Exception - MsgBox(ex.Message, MsgBoxStyle.Critical, "ADF") - End Try - - End Sub - -End Class diff --git a/ADF/app.config b/ADF/app.config deleted file mode 100644 index 0f250ea..0000000 --- a/ADF/app.config +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/README.md b/README.md index fdad8c1..b48c8ab 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # ADF -Programma per creare/automatizzare programmi e logiche partendo da un file XML e script VBScript (VBS), con interfaccia Windows Forms in VB.NET. +Programma per creare/automatizzare programmi e logiche partendo da un file XML e script VBScript (VBS), con interfaccia Windows Forms in C#. ## Descrizione -ADF è un progetto Visual Basic .NET che: +ADF è un progetto C# .NET 8 che: - legge definizioni/istruzioni da file XML; - esegue script VBScript per implementare la logica dinamica; - utilizza espressioni regolari tramite il motore VBScript RegExp; -- espone un’interfaccia grafica Windows Forms per interagire con i file e mostrare i risultati. +- espone un'interfaccia grafica Windows Forms per interagire con i file e mostrare i risultati. Il repository include un esempio di definizione (`CIAO.XML`) e le librerie di interoperabilità necessarie. @@ -16,22 +16,20 @@ Il repository include un esempio di definizione (`CIAO.XML`) e le librerie di in - Definizione dei flussi/operazioni tramite file XML. - Esecuzione di script VBS attraverso Microsoft Script Control. -- Supporto a espressioni regolari tramite “VBScript_RegExp_55”. -- Applicazione desktop Windows Forms (VB.NET). -- Configurazione tramite `app.config`. +- Supporto a espressioni regolari tramite "VBScript_RegExp_55". +- Applicazione desktop Windows Forms (C#). ## Struttura del progetto - Soluzione - [ADF.sln](https://github.com/rsodvd79/ADF/blob/master/ADF.sln) -- Progetto VB.NET (Windows Forms) - - [ADF/ADF.vbproj](https://github.com/rsodvd79/ADF/blob/master/ADF/ADF.vbproj) — file di progetto. - - [ADF/adf.vb](https://github.com/rsodvd79/ADF/blob/master/ADF/adf.vb) — form principale (logica). - - [ADF/adf.Designer.vb](https://github.com/rsodvd79/ADF/blob/master/ADF/adf.Designer.vb) — designer del form. - - [ADF/adf.resx](https://github.com/rsodvd79/ADF/blob/master/ADF/adf.resx) — risorse del form. - - [ADF/ClassADF.vb](https://github.com/rsodvd79/ADF/blob/master/ADF/ClassADF.vb) — classe core per la gestione di XML/VBS. - - [ADF/app.config](https://github.com/rsodvd79/ADF/blob/master/ADF/app.config) — configurazione dell’app. +- Progetto C# .NET 8 (Windows Forms) + - [ADF/ADF.csproj](https://github.com/rsodvd79/ADF/blob/master/ADF/ADF.csproj) — file di progetto. + - [ADF/Program.cs](https://github.com/rsodvd79/ADF/blob/master/ADF/Program.cs) — punto di ingresso dell'applicazione. + - [ADF/AdfForm.cs](https://github.com/rsodvd79/ADF/blob/master/ADF/AdfForm.cs) — form principale (logica). + - [ADF/AdfForm.Designer.cs](https://github.com/rsodvd79/ADF/blob/master/ADF/AdfForm.Designer.cs) — designer del form. + - [ADF/ClassADF.cs](https://github.com/rsodvd79/ADF/blob/master/ADF/ClassADF.cs) — classe core per la gestione di XML/VBS. - Esempi/risorse - [ADF/CIAO.XML](https://github.com/rsodvd79/ADF/blob/master/ADF/CIAO.XML) — esempio di definizione XML. @@ -44,8 +42,8 @@ Il repository include un esempio di definizione (`CIAO.XML`) e le librerie di in ## Prerequisiti - Windows. -- .NET Framework (versione target come da progetto VB.NET). -- Visual Studio (edizione con supporto a Visual Basic .NET). +- .NET 8 SDK o Runtime. +- Visual Studio 2022 (o versione con supporto a .NET 8 e C#). - Componenti COM disponibili nel sistema: - Microsoft Script Control 1.0 (MSScriptControl). - Microsoft VBScript Regular Expressions 5.5. @@ -61,29 +59,34 @@ Se i riferimenti alle DLL Interop non si risolvono automaticamente, rimuoverli e git clone https://github.com/rsodvd79/ADF.git ``` 2. Apri la soluzione in Visual Studio: `ADF.sln`. -3. Verifica i riferimenti alle DLL di interoperabilità (COM) e l’architettura di compilazione (preferibilmente x86). +3. Verifica i riferimenti alle DLL di interoperabilità (COM) e l'architettura di compilazione (preferibilmente x86). 4. Compila ed esegui il progetto `ADF`. +In alternativa, da riga di comando: +```bash +dotnet build ADF/ADF.csproj +dotnet run --project ADF/ADF.csproj +``` + ## Uso -- Avvia l’applicazione e carica un file XML di definizione (puoi partire da `ADF/CIAO.XML`) per vedere come vengono interpretate le istruzioni e gli script. +- Avvia l'applicazione e carica un file XML di definizione (puoi partire da `ADF/CIAO.XML`) per vedere come vengono interpretate le istruzioni e gli script. - Adatta o crea nuovi file XML e script VBS per modellare la logica desiderata. -- Configura eventuali parametri in `app.config` se necessario. ## Note -- Le DLL Interop incluse servono a facilitare l’uso di componenti COM da .NET. Su alcuni sistemi potrebbe essere necessario registrare i componenti COM o installarli se mancanti. +- Le DLL Interop incluse servono a facilitare l'uso di componenti COM da .NET. Su alcuni sistemi potrebbe essere necessario registrare i componenti COM o installarli se mancanti. - Se incontri problemi con MSScriptControl su sistemi a 64 bit, assicurati di: - usare il target x86; - avere il componente COM disponibile sul sistema. ## Stato del progetto -Repository senza licenza dichiarata e senza issue/roadmap pubbliche. È un esempio/prototipo utile per mostrare come integrare XML + VBScript in un’app VB.NET. +Repository senza licenza dichiarata e senza issue/roadmap pubbliche. È un esempio/prototipo utile per mostrare come integrare XML + VBScript in un'app C# .NET 8. ## Licenza -Non è presente un file di licenza. Se intendi usare, modificare o distribuire il software, contatta l’autore o aggiungi una licenza appropriata al repository. +Non è presente un file di licenza. Se intendi usare, modificare o distribuire il software, contatta l'autore o aggiungi una licenza appropriata al repository. ## Autore