X-Sharp / XSharpPublic

Public repository for the source code for the XSharp Compiler, Runtime, Project System and Tools.
Apache License 2.0
89 stars 36 forks source link

Extension of the VOEditors / Designer / WindowCloneSelectDlg #1508

Open christianschmid200272 opened 5 days ago

christianschmid200272 commented 5 days ago

Hello, we are in the final stages of converting our programming from VO to X#. During the tests of the daily work steps by my colleagues, a very important point was noticed when creating new VO windows. Our application contains hundreds of VO window classes, when creating a new one, an existing window is usually used as the basis. Unfortunately, the function "Clone from other Window" only lists the .xsfrm files of the own Visual Studio project and the projects referenced in the project. By splitting the original project into small DLL projects in X#, "Clone from other Window" should deliver all .xsfrm files of the solution, or by browsing and selecting a directory which the user chooses.

Currently in the designer project the listed files are from file:Project:GetFilesOfType(XFileType.VOForm, TRUE).

You could also select a folder and list all "*.xsfrm" files from it, if you do not select a folder everything remains as it is.

Example of CLASS WindowCloneSelectDlg :

CONSTRUCTOR(File AS XFile, cFileName AS STRING)
     SUPER()
     SELF:InitializeForm()
     VAR fileNames := File:Project:GetFilesOfType(XFileType.VOForm, TRUE)

     // the extention
     begin using var fbd := new FolderBrowserDialog()
         local result as DialogResult
         result := fbd.ShowDialog{}
         if  result == DialogResult.OK .AND. !String.IsNullOrWhiteSpace(fbd.SelectedPath)
             //replace or add the files....
             fileNames = Directory.GetFiles(fbd.SelectedPath, "*.xsfrm")
         endif

     end using

     FOREACH VAR FileName IN fileNames
         // Suppress the frm that we are adding !
         IF !String.Equals(FileName, cFileName,StringComparison.OrdinalIgnoreCase)
             SELF:oFilesList:Items:Add(FileName)
         ENDIF
     NEXT
     RETURN

It has also been noticed that the list of *.xsfrm files to be selected in "Clone from other Window" can be very long, some kind of search or filtering in it would be very helpful. The used control System.Windows.Forms.ListBox knows a method FindString Listbox FindString

RobertvanderHulst commented 4 days ago

Christian, Please feel free to write this code and send us a pull request. We are an open source project and contributions like these are more than welcome!

cpyrgas commented 3 days ago

Guys, I have moved the window clone select dialog to a separate file in a new Dialogs folder, so you can edit it visually. Christian, please pull those changes and make your adjustments based on the new code. I think you'll need to temporarily revert your previous changes, but of course you can reapply them afterwards. I hope I have added everything correctly...