majorsilence / My-FyiReporting

Majorsilence Reporting, .NET report designer and viewer. Fork of fyireporting,
Apache License 2.0
347 stars 201 forks source link

cross platform, port engine and viewer to avalonia #235

Open majorsilence opened 6 months ago

majorsilence commented 6 months ago

Is your feature request related to a problem? Please describe. Make the engine and viewer truely crossplatform for at least windows, mac, and linux and possibly android and ios.

Describe the solution you'd like A clear and concise description of what you want to happen.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've consideredetoforms, mono, skiasharp for drawing, reviving drawing compat, uno, windows only support

Additional context GPT 4 ideas on how to proceed

Converting a WinForms application that uses System.Drawing to Avalonia involves several steps. Here is a guide to help you through the process:

1. Set Up Avalonia Project

First, create a new Avalonia application.

  1. Install Avalonia Templates:
    dotnet new -i Avalonia.Templates
  2. Create a new Avalonia Application:
    dotnet new avalonia.app -o YourAvaloniaApp
    cd YourAvaloniaApp
  3. Install Required NuGet Packages: Ensure you have the necessary Avalonia packages:
    dotnet add package Avalonia.Controls
    dotnet add package Avalonia.Desktop
    dotnet add package Avalonia.Themes.Fluent
    dotnet add package Avalonia.Diagnostics

2. Translate Forms and Controls

WinForms controls and their properties need to be mapped to their Avalonia counterparts.

Example:

3. Convert System.Drawing to Avalonia.Media

For drawing operations, you'll need to translate from System.Drawing to Avalonia.Media.

Example:

4. Replace Event Handlers

Event handlers in WinForms will need to be translated to Avalonia's event system.

Example:

5. Adjust Layouts

WinForms uses a different layout system than Avalonia. You need to translate the layout logic.

Example:

6. Style and Theme Adjustments

Avalonia uses XAML for defining UI components and their styles, which is different from the procedural code-based approach in WinForms.

7. Running the Application

Ensure your Program.cs is set up correctly to run an Avalonia application.

class Program
{
    // Initialization code. Don't use any Avalonia, third-party APIs or
    // any SynchronizationContext-reliant code before AppMain is called: things aren't initialized
    // properly until then.
    public static void Main(string[] args) => BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);

    // Avalonia configuration, don't remove; also used by visual designer.
    public static AppBuilder BuildAvaloniaApp()
        => AppBuilder.Configure<App>()
            .UsePlatformDetect()
            .LogToTrace();
}

8. Testing and Debugging

After translating your application, test it thoroughly to ensure that all functionality has been correctly ported and that there are no issues.

Summary

Converting a WinForms application to Avalonia involves translating forms, controls, drawing logic, event handlers, and layout management from WinForms and System.Drawing to their Avalonia equivalents. This process requires a detailed and methodical approach to ensure all aspects of the application are correctly migrated.