Show/Hide Toolbars

XSharp

This example converts the VOPAD AEF file from the C:\cavo28SP3\Samples\Controls\Richedit folder.

After converting it with the same options as the first example we will have a folder structure like

C:\XporterOutput\Examples\VoPad
C:\XporterOutput\Examples\VoPad\VoPad

 

File

Contains

VoPad.sln

VS Solution file

VoPad.viproj

XIDE project file

 

The project folder contains the following files:

File

Contains

!Readme!.prg

Module source code

image.IMAGE.rc

Image resource for VS

image.prg

Module source code

image.rc

Image resource for XIDE

Manifest.CREATEPROCESS_MANIFEST_RESOURCE_ID.rc

Manifest resource for VS

Manifest.prg

Module source code

Manifest.rc

Manifest resource for XIDE

PadHelp About.HelpAbout.rc

Help about resource for VS

PadHelp About.HELPABOUT.xsfrm

Help about form Binary for VS

PadHelp About.POWVOBMP.rc

Splash resource for VS

PadHelp About.prg

Module source code

PadHelp About.rc

Help resources for XIDE

PadMenus.StandardPadMenu.rc

Menu resource for VS

PadMenus.StandardPadMenu.xsmnu

Menu binary for VS

PadMenus.StandardPadMenu_Accelerator.rc

Accelerator resource for VS

PadMenus.prg

Module source code

PadMenus.rc

Resources for XIDE

PadShell.IDI_VOPADICON.rc

App Icon resource for VS

PadShell.prg

Module source code

PadShell.rc

App Icon resource for XIDE

PadStart.prg

Module source code

PadWin.oMarginDialog.rc

Form resource for VS

PadWin.oMarginDialog.xsfrm

Form binary for VS

PadWin.prg

Module source code

PadWin.rc

Form resource for XIDE

Vopad.viapp

XIDE Application

Vopad.xsproj

VS Project

Open the project in VS and compile. You will see the following errors/warnings:

 

PadWin.prg(473,1): warning XS1030: #warning: 'The following method did not include a CLASS declaration'

PadWin.prg(480,1): warning XS1030: #warning: 'The following method did not include a CLASS declaration'

PadHelp About.prg(78,3): error XS9046: Cannot assign to 'font' because it is a 'method'

PadHelp About.prg(81,8): error XS0119: 'TextControl.Font(params __Usual[])' is a method, which is not valid in the given context

PadHelp About.prg(88,3): error XS9046: Cannot assign to 'font' because it is a 'method'

PadHelp About.prg(91,8): error XS0119: 'TextControl.Font(params __Usual[])' is a method, which is not valid in the given context

PadWin.prg(166,19): error XS1061: 'RichEdit' does not contain a definition for 'RTFChangeFont' and no extension method 'RTFChangeFont' accepting a first argument of type 'RichEdit' could be found (are you missing a using directive or an assembly reference?)

 

Let's examine this by double clicking on the errors/warnings.

 

First, the warnings. These are generated by a #warning preprocessor statement inserted by XPorter, because it found problems in your code:

There was an ACCESS FilterIndex CLASS SaveAsDialog in the source. This adds an access to a class in the GUI Classes. This is not allowed in .Net.
The XPorter has created a special subclass of SaveAsDialog to hold this extra property. Fortunately, this ACCESS is no longer needed, because it has been added to the GUI Classes already. Therefore, we can completely delete that code.

There was a method RTFChangeFont CLASS RichEdit. This has the same problem as the SaveAsDialog:FilterIndex. In this case, the method is necessary. It has been moved to a subclass of RichEdit already. However, since the original code still points to the RichEdit class, there could be a runtime problem, because this method is not part of the richedit class.
There are two possible solutions here:

1.Change the method to an extension method.

2.Change the code that uses the RichEdit class to use the changed class.

Option 1 is preferable in this case, since we are not using any private or protected properties of the RichEdit class. To achieve that, change the code from

  CLASS RichEdit_external_class INHERIT RichEdit
  METHOD RTFChangeFont()
     etc

to

  STATIC CLASS RichEditExtensions
  STATIC METHOD RTFChangeFont( SELF oEdit as RichEdit) AS VOID
    LOCAL oFontDlg AS StandardFontDialog
     oFontDlg := StandardFontDialog{oEdit:Owner}
     oFontDlg:FontColor := oEdit:TextColor
     oFontDlg:Font      := oEdit:ControlFont
     oFontDlg:Show()
     oEdit:TextColor := oFontDlg:FontColor
     oEdit:ControlFont      := oFontDlg:Font
  END CLASS

Note

The Extension Method works great to enhance existing classes, but has one disadvantage: The Vulcan Runtime will not pick up these extension methods for late bound code.That is not a problem in this example, but may be a problem elsewhere.

 

Now we have added an extension method that can be used like a normal method.

This change also solves the error in PadWin.prg

Then, look at the other problems: they all have to do with a Font property in the TextControl class. Unfortunately, the VO class libraries have both a Font() method and a Font() Access/Assign for the TextControl class. Having a method and a property with the same name is not allowed in .Net.

When the VO Gui classes were ported to Vulcan, the decision was made to rename the Font property to Controlfont. Therefore, we need to make that change. Simply double click on the errors and change

 :Font

to

 :ControlFont

(4 times)

After that, the code should compile and run. Clicking the Font button on the toolbar should show the font dialog (from the RTFChangeFont extension method).

 

Some of the changes that were made to the code (omitting the ones that were also in example 1):

Manifest.prg is empty but included, because it had a dependent resource.

 

 

You will find the "code before" and "code after" in the XSharp Examples folder