Author Topic: Migrating Windows desktop app away from WinForms  (Read 2639 times)

0 Members and 1 Guest are viewing this topic.

57gmc

  • Bull Frog
  • Posts: 366
Migrating Windows desktop app away from WinForms
« on: December 20, 2023, 06:47:52 PM »
Although most AutoCAD apps will probably be intended for Windows desktops, it would be good to know how to make it platform independent, by replacing Windows Forms objects with something platform independent. Does anyone have any recommendations or experience with a replacement technology? Preferably something with an IDE or designer ui.

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2145
  • class keyThumper<T>:ILazy<T>
Re: Migrating Windows desktop app away from WinForms
« Reply #1 on: December 20, 2023, 07:18:05 PM »
I'm looking forward to trying .NET MAUI,

but not for a couple months.


first I'd investigate if the XAML from WPF is migratable  :)

Perhaps someone will drop past who actually knows from current experience.
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

57gmc

  • Bull Frog
  • Posts: 366
Re: Migrating Windows desktop app away from WinForms
« Reply #2 on: December 20, 2023, 07:22:47 PM »
Maui is something that I've only read the name of. Haven't checked into it yet, but it's at the top of the list.

MickD

  • King Gator
  • Posts: 3639
  • (x-in)->[process]->(y-out) ... simples!
Re: Migrating Windows desktop app away from WinForms
« Reply #3 on: December 20, 2023, 10:09:08 PM »
I'm working on a platform independent HTML/CSS/JS UI based in Tauri (an alternative to electron).
It's not quite as 'integrated' as native forms and is a standalone application that talks to your CAD plugin via web sockets for events and data. It works quite well but as I said, it's not 'a part of' your app or plugin but sits along side which may be a non starter for some.

The UI is built with HTML and CSS which is very flexible and easy to learn. The UX stuff is done in JavaScript, again, easy to learn and there's mountains of examples on the web to learn from.
Development is done in vscode which gives you full debugging in vscode and in the browser view's development tools (the same as in google chrome). You can also debug your CAD scripts as well, the scripting engine used is ClearSCriptV8 which allows for complete integration with .Net and the CAD systems API.

It's not up on a public repo just yet but let me know if you're interested and I'll provide some more info.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

57gmc

  • Bull Frog
  • Posts: 366
Re: Migrating Windows desktop app away from WinForms
« Reply #4 on: December 21, 2023, 11:31:54 AM »
Hi Mick
I'm having trouble picturing how that would work with AutoCAD. Would the windows still be able to implement modeless windows?

MickD

  • King Gator
  • Posts: 3639
  • (x-in)->[process]->(y-out) ... simples!
Re: Migrating Windows desktop app away from WinForms
« Reply #5 on: December 21, 2023, 03:08:16 PM »
Hi Mick
I'm having trouble picturing how that would work with AutoCAD. Would the windows still be able to implement modeless windows?

It basically is a modeless window, think of it as being able to use your web browser as the UI. That is essentially what it is, I actually had something working in a browser but due to its secure/sandboxed nature it was way too restrictive. Electron/Tauri et al are basically a host for a web browser view but still allow interaction with the OS etc for file handling and other tasks.
It's like driving AutoCAD from Excel say, they are 2 different app's that communicate via sockets.

The down side is it works the best with multiple monitors, the up side is you can build complete web applications that host databases on back end servers and talk with AutoCAD, build forms and do what ever you like, and with web sockets you could even have 'multi player' :)

I will be working on it over the next week or so as I need it for a project, I'll put something up soon. It won't be for everyone as they have different needs, it's a bit of overkill if you want to pop up a 2 field form with an OK button but if you have a lot of forms and config files and need to interact with databases and CAD it's a very viable option.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

57gmc

  • Bull Frog
  • Posts: 366
Re: Migrating Windows desktop app away from WinForms
« Reply #6 on: December 21, 2023, 03:13:03 PM »
Sounds interesting.

MickD

  • King Gator
  • Posts: 3639
  • (x-in)->[process]->(y-out) ... simples!
Re: Migrating Windows desktop app away from WinForms
« Reply #7 on: December 21, 2023, 03:26:12 PM »
Actually, I said there was an intermediary js layer but that's not necessary, I just wanted it for scripting CAD with js, you can talk directly with Tauri from C#. You would only need javascript for the UI though to handle some events and make the UI more user friendly. It also handles talking to your data server etc, this could be done by the host (Tauri) but you will need to know Rust.

The goal is to just have a standalone UI app to run the browser window and build your own functionality in a web application using the web tech stack.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

57gmc

  • Bull Frog
  • Posts: 366
Re: Migrating Windows desktop app away from WinForms
« Reply #8 on: December 21, 2023, 04:40:09 PM »
Sounds powerful. I just don't know if I'll be needing that any time soon. I am working on a C# Raspberry Pi solution that could use a web interface though. I was mostly looking for another different gui for designing windows. In VS Code, there's no gui designer, unless there's one I don't know about. I don't type real fast and typing the code for the controls is tedious.

pkohut

  • Bull Frog
  • Posts: 483
Re: Migrating Windows desktop app away from WinForms
« Reply #9 on: December 21, 2023, 05:09:03 PM »
I've been looking at Flutter UI for cross platform stuff. 

https://flutter.dev/
New tread (not retired) - public repo at https://github.com/pkohut

MickD

  • King Gator
  • Posts: 3639
  • (x-in)->[process]->(y-out) ... simples!
Re: Migrating Windows desktop app away from WinForms
« Reply #10 on: January 01, 2024, 04:17:23 PM »
Another option similar to what I'm doing but more sophisticated and uses your standard web browser (in development, no C# yet)
https://github.com/webui-dev/webui

By using the normal web browser I'm wondering how they handle OS and file handling (in your preferred lang I'd say, not with the browser UI), this is sandboxed in normal web browsers for security.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

57gmc

  • Bull Frog
  • Posts: 366
Re: Migrating Windows desktop app away from WinForms
« Reply #11 on: January 01, 2024, 04:38:36 PM »
I wonder if that's similar to how MAUI works? I'm looking for some info on that since it's closely related to .NET.

MickD

  • King Gator
  • Posts: 3639
  • (x-in)->[process]->(y-out) ... simples!
Re: Migrating Windows desktop app away from WinForms
« Reply #12 on: January 01, 2024, 07:02:36 PM »
I wonder if that's similar to how MAUI works? I'm looking for some info on that since it's closely related to .NET.

I'm thinking yes. Microsoft, rather than using some standard technology seems to always try and invent their own (vendor lock-in??), XAML for WPF for instance. The first time I used it I thought "they just made HTML and CSS very hard!". The only upside of this was you can use .Net (C#, VBNet etc) instead of JavaScript in the 'code-behind' stuff.
Too much 'magic' for me :)

HTML/CSS/JS are a very easy combo to work with once you get going (stay away form React et al, much too heavy!) and using web sockets with JSON payloads that carry the event and data etc is the same as loading web pages and sending form data back/forth only much more simpler as you don't need to worry about headers and other http protocol stuff, it's just a text string :)

I'm going to watch that video at lunch and see how they're approaching it.
<EDIT>
I watched about half of the video, it's doing the same thing as Tauri/Electron but is using the host system web browser rather than a standalone WebView2 view in a stand alone .exe
A lot of it was explaining different approaches to get this done.
« Last Edit: January 01, 2024, 07:46:04 PM by MickD »
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

57gmc

  • Bull Frog
  • Posts: 366
Re: Migrating Windows desktop app away from WinForms
« Reply #13 on: January 01, 2024, 08:54:22 PM »
This is getting more complex than I thought. I like learning, but my age, the learning curve may be a little too steep. I've mostly done just desktop apps, not web stuff. I was hoping to find an IDE for developing forms. I appreciate you helping me find something that fits. There's so much out there, I don't know where to start. At least I know that winforms will continue to work for most of what I want to do.

MickD

  • King Gator
  • Posts: 3639
  • (x-in)->[process]->(y-out) ... simples!
Re: Migrating Windows desktop app away from WinForms
« Reply #14 on: January 01, 2024, 09:26:27 PM »
This is getting more complex than I thought. I like learning, but my age, the learning curve may be a little too steep. I've mostly done just desktop apps, not web stuff. I was hoping to find an IDE for developing forms. I appreciate you helping me find something that fits. There's so much out there, I don't know where to start. At least I know that winforms will continue to work for most of what I want to do.

I hear you :)
I was lucky in that I get paid to do web dev so I've learned a lot and probably take a lot for granted. Having said that, if you stick to vanilla HTML, CSS and JS and just build what you need incrementally then it is very easy and you see a lot more possibilities :)
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

57gmc

  • Bull Frog
  • Posts: 366
Re: Migrating Windows desktop app away from WinForms
« Reply #15 on: January 02, 2024, 10:11:03 AM »
I hear you :)
I was lucky in that I get paid to do web dev so I've learned a lot and probably take a lot for granted. Having said that, if you stick to vanilla HTML, CSS and JS and just build what you need incrementally then it is very easy and you see a lot more possibilities :)
On top of that, I have to get up to date on .NET Framework to .NET 8. I think I better start there first and then pick up on web forms.

57gmc

  • Bull Frog
  • Posts: 366
Re: Migrating Windows desktop app away from WinForms
« Reply #16 on: January 05, 2024, 04:23:30 PM »
Ive been sick, so I had some time to watch some episodes from .NET conf. I found a nice tutorial on MAUI. It's 4 hours, but worth it.
Here's the githup project for the video. www.aka.ms/maui-workshop.