Bonjour les développeurs,

Gros projet actuellement mobilisant Imports System.ComponentModel.Design notamment; et 3 références DesignSurfaceExt2.dll DesignSurfaceManagerExt.dll pDesigner.dll (cela ne vous dit pas forcément quelque chose, pas d’inquiétude).

Pour mon projet assez personnel (vous allez voir) j'ai traduit un projet C# en VB.Net , ca fonctionne correctement et j'ai réussi à me débarasser du programme console qui lance l'application (le logiciel démarre directement).
Voici la source en C# (Il y a des infos sur DesignSurfaceExt2 et des screens)
https://www.codeproject.com/Articles...-Back-Together
Gardez à l'esprit que le contexte est important et que je préfère vous exposer le projet dans sa globalité, toutes mes interrogations étant liées entre elles j'aimerai enfin parvenir à mes objectifs après 5 ans de réflexions et de recommencements etc...
Vous l'aurez compris(ou non), il s'agit d'un logiciel permettant de créer une fenêtre et d'y ajouter des objets tout comme sur Visual Studio c'est le même principe.
Voici le concepteur que je code :
Nom : Tinyide1forum.png
Affichages : 488
Taille : 38,3 Ko

Sur Visual Studio lorsque vous créez une fenêtre, des objets, du code VB.Net est généré automatiquement (je ne vous apprend rien)
Clairement mon but dans un premier temps est de pouvoir à l'aide de mon concepteur générer du code CpcdosC+ (extension .CPC , langage très simple, extension cpc c'est pareil que l'extension .txt) (site web : http://cpcdos.net). ( forum https://www.developpez.net/forums/f2...stemes/cpcdos/).

Générer du code c'est bien mais que le concepteur sache récupérer des infos à partir d'un fichier CpcdosC+ c'est aussi important, surtout que la syntaxe du CpcdosC+ n'a rien de compliquée, c'est toujours pareil.
Je vous explique la syntaxe sur cette image
Nom : codecpcdoscplusforum.png
Affichages : 407
Taille : 43,6 Ko

Il serait donc intéréssant comme me l'a notifié le créateur du CpcdosC+ d'utiliser la manipulation de chaînes en VB.Net pour lire le fichier CpcdosC+ (qui je le rapelle se comporte comme un fichier texte) et extraire les données qui nous intéressent entre deux balises de déclaration d'objet (exemple : balise 1 = fenetre/ APP1 balise 2 = Fin/ fenetre).
A chaque fois que les balises "objet"/ nom du bouton et Fin/ "objet" reviennent dans le fichier CpcdosC+ le logiciel doit comprendre qu'il s'agit de nouveaux controles et pour chacun d'eux lire entre les deux balises et récupérer nos infos (encadré vert sur l'image) qui correspondent ligne par ligne au paramètre .parametre situé à gauche du égal (encadré kaki). De cette sorte à l'ouverture d'un fichier cpcdosc+, le concepteur windows form se génère automatiquement en lisant le code.
Voici l'explication détaillée des paramètres pour une fenêtre CpcdosC+ par exemple :
Nom : parametres.PNG
Affichages : 392
Taille : 17,5 Ko

Voici l'ensemble du code de la fenêtre principale pour vous faire une idée et comprendre :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
 
Imports System
Imports System.Collections.Generic
Imports System.Drawing
Imports System.Windows.Forms
Imports System.ComponentModel.Design
Imports System.Drawing.Design
 
Namespace pF.DesignSurfaceExt
    Public Partial Class MainForm
        Inherits Form
 
        Private _version As String = String.Empty
 
        Public ReadOnly Property Version As String
            Get
 
                If String.IsNullOrEmpty(_version) Then
                    '- Get the actual version of the file hosted in running assembly
                    Dim FVI As System.Diagnostics.FileVersionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location)
                    _version = FVI.ProductVersion
                End If
 
                Return _version
            End Get
        End Property
 
        Private _listOfDesignSurface As List(Of IDesignSurfaceExt2) = New List(Of IDesignSurfaceExt2)()
 
        Private Function GetCurrentIDesignSurface() As IDesignSurfaceExt2
            If Nothing Is _listOfDesignSurface Then Return Nothing
            If 0 = _listOfDesignSurface.Count Then Return Nothing
            Return _listOfDesignSurface(tabControl1.SelectedIndex)
        End Function
 
 
 
#Region "Init"
 
        '- ctor
        Public Sub New()
            InitializeComponent()
 
            '- Add the toolboxItems to the future toolbox 
            '- the pointer
            Dim toolPointer As ToolboxItem = New ToolboxItem()
            toolPointer.DisplayName = "<Pointer>"
            toolPointer.Bitmap = New Bitmap(16, 16)
            listBox1.Items.Add(toolPointer)
            '- the control
            listBox1.Items.Add(New ToolboxItem(GetType(Button)))
            listBox1.Items.Add(New ToolboxItem(GetType(ListView)))
            listBox1.Items.Add(New ToolboxItem(GetType(TreeView)))
            listBox1.Items.Add(New ToolboxItem(GetType(TextBox)))
            listBox1.Items.Add(New ToolboxItem(GetType(Label)))
            listBox1.Items.Add(New ToolboxItem(GetType(TabControl)))
            listBox1.Items.Add(New ToolboxItem(GetType(OpenFileDialog)))
            listBox1.Items.Add(New ToolboxItem(GetType(CheckBox)))
            listBox1.Items.Add(New ToolboxItem(GetType(ComboBox)))
            listBox1.Items.Add(New ToolboxItem(GetType(GroupBox)))
            listBox1.Items.Add(New ToolboxItem(GetType(ImageList)))
            listBox1.Items.Add(New ToolboxItem(GetType(Panel)))
            listBox1.Items.Add(New ToolboxItem(GetType(ProgressBar)))
            listBox1.Items.Add(New ToolboxItem(GetType(ToolBar)))
            listBox1.Items.Add(New ToolboxItem(GetType(ToolTip)))
            listBox1.Items.Add(New ToolboxItem(GetType(StatusBar)))
        End Sub
 
        Private Sub MainForm_Load(ByVal sender As Object, ByVal e As EventArgs)
            AddHandler tabControl1.Selected, New TabControlEventHandler(AddressOf OnTabPageSelected)
        End Sub
 
        Private Sub OnTabPageSelected(ByVal sender As Object, ByVal e As TabControlEventArgs)
            '- select into the propertygrid the current Form 
            SelectRootComponent()
        End Sub
 
 
#End Region
 
 
 
        '- When the selection changes this sets the PropertyGrid's selected component
        Private Sub OnSelectionChanged(ByVal sender As Object, ByVal e As EventArgs)
            Dim isurf As IDesignSurfaceExt = GetCurrentIDesignSurface()
 
            If Nothing IsNot isurf Then
                Dim selectionService As ISelectionService = Nothing
                selectionService = TryCast(isurf.GetIDesignerHost().GetService(GetType(ISelectionService)), ISelectionService)
                propertyGrid.SelectedObject = selectionService.PrimarySelection
 
            End If
        End Sub
 
        Private Sub SelectRootComponent()
            '- find out the DesignSurfaceExt control hosted by the TabPage
            Dim isurf As IDesignSurfaceExt = GetCurrentIDesignSurface()
            If Nothing IsNot isurf Then propertyGrid.SelectedObject = isurf.GetIDesignerHost().RootComponent
        End Sub
 
        Private Sub undoToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
            Dim isurf As IDesignSurfaceExt = GetCurrentIDesignSurface()
            If Nothing IsNot isurf Then isurf.GetUndoEngineExt().Undo()
        End Sub
 
        Private Sub redoToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
            Dim isurf As IDesignSurfaceExt = GetCurrentIDesignSurface()
            If Nothing IsNot isurf Then isurf.GetUndoEngineExt().Redo()
        End Sub
 
        Private Sub OnAbout(ByVal sender As Object, ByVal e As EventArgs)
            MessageBox.Show("Tiny Form IDE coded by Paolo Foti " & Microsoft.VisualBasic.Constants.vbCrLf & "Version is: " & Version, "Tiny Form IDE", MessageBoxButtons.OK, MessageBoxIcon.Question)
        End Sub
 
        Private Sub toolStripMenuItemTabOrder_Click(ByVal sender As Object, ByVal e As EventArgs)
            Dim isurf As IDesignSurfaceExt = GetCurrentIDesignSurface()
            If Nothing IsNot isurf Then isurf.SwitchTabOrder()
        End Sub
 
        Private Sub OnMenuClick(ByVal sender As Object, ByVal e As EventArgs)
            Dim isurf As IDesignSurfaceExt = GetCurrentIDesignSurface()
 
            If Nothing IsNot isurf Then isurf.DoAction(TryCast(sender, ToolStripMenuItem).Text)
        End Sub
 
        Private Sub newFormUseSnapLinesMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
            Dim tp As TabPage = New TabPage("Use SnapLines")
            tabControl1.TabPages.Add(tp)
            Dim iTabPageSelectedIndex As Integer = tabControl1.SelectedIndex
            '- steps.1.2.3
            Dim surface As DesignSurfaceExt2 = CreateDesignSurface()
            '- step.4
            '- choose an alignment mode...
            CType(surface, DesignSurfaceExt2).UseSnapLines()
 
            '- step.5
            '- create the Root compoment, in these cases a Form
            Try
                Dim rootComponent As Form = Nothing
                rootComponent = CType(surface.CreateRootComponent(GetType(Form), New Size(400, 400)), Form)
                rootComponent.Text = "Root Component hosted by the DesignSurface N." & iTabPageSelectedIndex
                rootComponent.BackColor = Color.Yellow
                '-
                '-
                '- step.4
                '- display the DesignSurface
                Dim view As Control = surface.GetView()
                If Nothing Is view Then Return
                '- change some properties
                view.Text = "Test Form N. " & iTabPageSelectedIndex
                view.Dock = DockStyle.Fill
                '- Note these assignments
                view.Parent = tp
                '- finally enable the Drag&Drop on RootComponent
                CType(surface, DesignSurfaceExt2).EnableDragandDrop() 'end_try
            Catch ex As Exception
                Console.WriteLine(Name & " the DesignSurface N. " & iTabPageSelectedIndex & " has generated errors during loading!Exception: " & ex.Message)
                Return
            End Try 'end_catch
        End Sub
 
        Private Sub newFormUseGridandSnapMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
            Dim tp As TabPage = New TabPage("Use Grid (Snap to the grid)")
            tabControl1.TabPages.Add(tp)
            Dim iTabPageSelectedIndex As Integer = tabControl1.SelectedIndex
            '- steps.1.2.3
            Dim surface As DesignSurfaceExt2 = CreateDesignSurface()
            '- step.4
            '- choose an alignment mode...
            CType(surface, DesignSurfaceExt2).UseGrid(New Size(32, 32))
 
            '- step.5
            '- create the Root compoment, in these cases a Form
            Try
                Dim rootComponent As Form = Nothing
                rootComponent = CType(surface.CreateRootComponent(GetType(Form), New Size(400, 400)), Form)
                rootComponent.Text = "Root Component hosted by the DesignSurface N." & iTabPageSelectedIndex
                rootComponent.BackColor = Color.YellowGreen
                '-
                '-
                '- step.4
                '- display the DesignSurface
                Dim view As Control = surface.GetView()
                If Nothing Is view Then Return
                '- change some properties
                view.Text = "Test Form N. " & iTabPageSelectedIndex
                view.Dock = DockStyle.Fill
                '- Note these assignments
                view.Parent = tp 'end_try
            Catch ex As Exception
                Console.WriteLine(Name & " the DesignSurface N. " & iTabPageSelectedIndex & " has generated errors during loading!Exception: " & ex.Message)
                Return
            End Try 'end_catch
        End Sub
 
        Private Sub newFormUseGridMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
            Dim tp As TabPage = New TabPage("Use Grid")
            tabControl1.TabPages.Add(tp)
            Dim iTabPageSelectedIndex As Integer = tabControl1.SelectedIndex
            '- steps.1.2.3
            Dim surface As DesignSurfaceExt2 = CreateDesignSurface()
            '- step.4
            '- choose an alignment mode...
            CType(surface, DesignSurfaceExt2).UseGridWithoutSnapping(New Size(16, 16))
 
            '- step.5
            '- create the Root compoment, in these cases a Form
            Try
                Dim rootComponent As Form = Nothing
                rootComponent = CType(surface.CreateRootComponent(GetType(Form), New Size(600, 400)), Form)
                rootComponent.Text = "Root Component hosted by the DesignSurface N." & iTabPageSelectedIndex
                rootComponent.BackColor = Color.LightGreen
                '-
                '-
                '- step.4
                '- display the DesignSurface
                Dim view As Control = surface.GetView()
                If Nothing Is view Then Return
                '- change some properties
                view.Text = "Test Form N. " & iTabPageSelectedIndex
                view.Dock = DockStyle.Fill
                '- Note these assignments
                view.Parent = tp 'end_try
            Catch ex As Exception
                Console.WriteLine(Name & " the DesignSurface N. " & iTabPageSelectedIndex & " has generated errors during loading!Exception: " & ex.Message)
                Return
            End Try 'end_catch
        End Sub
 
        Private Sub newFormAlignControlByhandMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
            Dim tp As TabPage = New TabPage("Align control by hand")
            tabControl1.TabPages.Add(tp)
            Dim iTabPageSelectedIndex As Integer = tabControl1.SelectedIndex
            '- steps.1.2.3
            Dim surface As DesignSurfaceExt2 = CreateDesignSurface()
            '- step.4
            '- choose an alignment mode...
            CType(surface, DesignSurfaceExt2).UseNoGuides()
 
            '- step.5
            '- create the Root compoment, in these cases a Form
            Try
                Dim rootComponent As Form = Nothing
                rootComponent = CType(surface.CreateRootComponent(GetType(Form), New Size(400, 400)), Form)
                rootComponent.Text = "Root Component hosted by the DesignSurface N." & iTabPageSelectedIndex
                rootComponent.BackColor = Color.LightGray
                '-
                '-
                '- step.4
                '- display the DesignSurface
                Dim view As Control = surface.GetView()
                If Nothing Is view Then Return
                '- change some properties
                view.Text = "Test Form N. " & iTabPageSelectedIndex
                view.Dock = DockStyle.Fill
                '- Note these assignments
                view.Parent = tp 'end_try
            Catch ex As Exception
                Console.WriteLine(Name & " the DesignSurface N. " & iTabPageSelectedIndex & " has generated errors during loading!Exception: " & ex.Message)
                Return
            End Try 'end_catch
        End Sub
 
        Private Function CreateDesignSurface() As DesignSurfaceExt2
            '- step.0
            '- create a DesignSurface and put it inside a Form in DesignTime
            Dim surface As DesignSurfaceExt2 = New DesignSurfaceExt2()
            '-
            '-
            Dim isurf As IDesignSurfaceExt2 = surface
            _listOfDesignSurface.Add(isurf)
            '- step.1
            '- enable the UndoEngines
            isurf.GetUndoEngineExt().Enabled = True
            '- step.2
            '- try to get a ptr to ISelectionService interface
            '- if we obtain it then hook the SelectionChanged event
            Dim selectionService As ISelectionService = CType((isurf.GetIDesignerHost().GetService(GetType(ISelectionService))), ISelectionService)
            If Nothing IsNot selectionService Then AddHandler selectionService.SelectionChanged, New EventHandler(AddressOf OnSelectionChanged)
            '- step.3
            '- Select the service IToolboxService
            '- and hook it to our ListBox
            Dim tbox As ToolboxServiceImp = TryCast(isurf.GetIToolboxService(), ToolboxServiceImp)
            If Nothing IsNot tbox Then tbox.Toolbox = listBox1
            '-
            '- finally return the Designsurface
            Return surface
        End Function
 
        Private Sub MainForm_Load_1(sender As Object, e As EventArgs) Handles MyBase.Load
 
        End Sub
        Dim rootComponent As Form = Nothing
        Dim surface As DesignSurfaceExt2
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim tp As TabPage = New TabPage("Use SnapLines")
            tabControl1.TabPages.Add(tp)
            Dim iTabPageSelectedIndex As Integer = tabControl1.SelectedIndex
            '- steps.1.2.3
            Dim surface As DesignSurfaceExt2 = CreateDesignSurface()
            '- step.4
            '- choose an alignment mode...
            CType(surface, DesignSurfaceExt2).UseSnapLines()
 
            '- step.5
            '- create the Root compoment, in these cases a Form
            Try
 
                rootComponent = CType(surface.CreateRootComponent(GetType(Form), New Size(400, 400)), Form)
                rootComponent.Text = "Root Component hosted by the DesignSurface N." & iTabPageSelectedIndex
                rootComponent.BackColor = Color.Yellow
                '-
                '-
                '- step.4
                '- display the DesignSurface
                Dim view As Control = surface.GetView()
                If Nothing Is view Then Return
                '- change some properties
                view.Text = "Test Form N. " & iTabPageSelectedIndex
                view.Dock = DockStyle.Fill
                '- Note these assignments
                view.Parent = tp
                '- finally enable the Drag&Drop on RootComponent
                CType(surface, DesignSurfaceExt2).EnableDragandDrop() 'end_try
            Catch ex As Exception
                Console.WriteLine(Name & " the DesignSurface N. " & iTabPageSelectedIndex & " has generated errors during loading!Exception: " & ex.Message)
                Return
            End Try 'end_catch
        End Sub
 
    End Class
End Namespace
La propertygrid (grille des propriétés) à droite ne m'arrange pas, effectivement elle rassemble beaucoup trop de paramètres dont la plupart uniquement disponibles sur le système d'exploitation windows et certains pas adaptés aux paramètres cpcdosc+ comme par exemple l'opacité qui est en pourcentage sur windows et de 0 à 255 sur le kernel Cpcdos. J'ai imaginé un système de clique droit, dès que l'utilisateur sélectionne un objet et fait un clique droit alors un menu lui propose en plus de copier coller etc... d'éditer les propriétés de l'objet. Quand il clique dans le menu sur éditer les propriétés alors une fenetre doit s'ouvrir en fonction du type d'objet ce ne sera pas la même et cette fenêtre comporte des textboxs etc permettant de modifier les propriétés de l'objet et quand on clique sur un bouton "appliquer" la fenetre se ferme et les modifications sont apportées à l'objet et au code cpcdosc+.
Par exemple pour une fenetre ça ressemble à ça (c'est pas complet car c'est un ancien screen)
Nom : Capture2.PNG
Affichages : 367
Taille : 88,8 Ko

Je résume : Savoir dans un premier temps générer du code CpcdosC+, donc avoir des mises à jour constantes du code dès que un objet est modifié ou bien simplement déplacé sur le concepteur, et idem pour la fenêtre en elle même.
Dans un deuxième temps pour compléter la génération de code, le concepteur doit pouvoir lire un fichier CpcdosC+ avec la méthode évoquée plus haut ou une autre de sorte à pouvoir réouvrir une fenêtre déjà générée par le concepteur ou bien déjà codée en dehors du logiciel et pouvoir continuer son travail.

Vous pouvez me présenter du code C# ou VB.Net(de préférence) car je sais les traduires entre eux.
Je vous remercie pour l'attention que vous apporterez à mes interrogations et j'espère les combler au maximum, essayez d'y réfléchir la moindre petite aide ou suggestion de près ou de loin est entièrement la bienvenue !