Convert QT/C++ to C# - c#

This might seem a little ridiculous, but as some of you here may already know, I'm converting an application written in C++ to C#.
I've noticed that a lot of the code uses references to objects like "QObject", "QWidget", or "QFrame."
Because of this, I'm not quite sure if I should look up the source for QT and port the basic structure of that into a bunch of C# classes which essentially mimic the same functionality, or if there's any kind of framework out there which does the same thing and can be used as a replacement for this.
Also, could someone please explain to me what a slide and a slot is, and what it is I could do to mimic this in C# as well? I'm thinking delegates, but I'm not sure...

Have a look at Qyoto it might just drop in to you code with a few modifications.

The page that Oded recommended also gave a link to qt4dotnet - have you tried this?
If you can't use one of these bindings, you will probably want to start investigating how to port all Q* references in the codebase to WinForms, WPF, or Silverlight (depending on your application needs)

Related

How to use python code to create a universal windows platform application?

Converting python to C# is an option. Are there any ready-made converters to do this? Or are there any other ways to realize a uwp app from a python code? You help is very much appreciated.
There is a command line tool available on GItHub for this -
https://github.com/uxmal/pytocs
By the way you should ask these type of question first to google :P
There is IronPython, which is .NET implementation of Python 2.7 (http://ironpython.net/). I would venture if you start your Main() function as C# code, but transfer control to embedded IronPython interpreter, and continue with Python, it might work. Not all Python library would be available, I believe, due to sandboxing requirements of the UWP.
I think your best bet would be converting, and then learning a little. Based on the difficulty and how many different or new things you need to learn to alter the app, you should maybe just consider learning the language basics and then go from their creating it in C#, You'll gain some skills in another language. Who knows maybe like it more.
You could try one of many other converters, to another language that works or even convert to a language to convert. There is a C++ converter of some kind that may be a bit better, and then I guess perhaps you could convert from their with other tools, seriously may work better. More things are out their for C++ than C# and considering the commonalities, I bet a decent converter exists. Maybe convert to C or C++ or even Javascript because they have good conversion tools. With Java Script it would be kind easy to convert and learn a tiny bit to fix if you have a converter to C#.
Otherwise converter between the two Python and C# isn't a main priority for many people, if anyone at all. Since they are so similar yet the Syantax is so different, it must be hard to create, and usually people stick with one or the other, or learn both because they do a lot of Object Oriented Code. I mean just Syntax needs to be learned. Also the modules mentioned or packages probably wont ever convet to C#. I'm pretty sure they would just need to build the packages from the ground up for C#, witch is possible.
Is Python able to build universla windows apps?
The short answer: just for IOT devices. And the suggested programming language are C++, C#, Microsoft Visual Basic, and JavaScript within UWP. You could only build Python-based background applications on Windows 10 IoT Core devices with pyuwpsdk.vsix.

Unmanaged code in .Net

We have a custom Listview Treegrid in c++ project built on the Codeproject TreeGrid example from here. The code has been modified quite extensively over time.
I have a requirement to port the c++ project to C# Winforms. I'm thinking of creating a c++ dll for the Listview grid and interoperate with it in Winforms.
Am I asking for for trouble using an unmanaged Listview control in Winforms? Should I just port/rewrite the listview in Winforms? (A task I do not look forward too)
I think it would be best to re-write it in managed code.
Interoperability usually works, but there's a reason managed code is preferred. The runtime takes care of so many things for you, and it's just easier to maintain all around. Crossing the boundary can be problematic for some tasks. You also lose Code Access Security, for example. There's some good info here.
If you don't then you'll always need a .NET developer and a c++ developer to maintain it.
There's nothing wrong with c++/native code on its own, but mixing the two. I just think it's better long term not to mix unless you have to.
That said, there are time and budgetary constraints. Interop exists for a reason. If it would absolutely take too long to justify from a business sense, I'd retract the above recommendation.
If I were you, I would prefer rewriting the Listview in C# or looking for a free or paid Grid that was written in C# and is meant to be used in Winforms.
Don't forget that you will have to support the code after you do this job,
this probably includes fixing bugs and adding features.
It's better to know exactly how your code works and how to debug it.
You also gives you a chance to write a Listview that is better suited for your needs.
This will be quite difficult if you'll use this C++ Listview and use it in Winforms.
But if you decide using it, there are two options that I can think of:
Creating a wrapper for the Listview in C++/CLI that will hold the object and show the data in C#, this means that you will have to write a lot of conversion code to move the data from the Listview to the C# objects, but it should work.
Using DllImport and working with the ListView as a datasource, I'm not really sure how exactly you will be able to get all the data from it, but it prevents you from writing the ugly CLI code...
So to wrap it up, I recommend using a single language for UI code, and my language of choice for UI is C#, not C++.
Good luck...

PHP to ASP.Net 4.0

I am looking for a tool that can convert a PHP application into ASP.Net application either c# or VB.Net.
I tried using the 'PHP to ASP.NET Migration Assistant' from microsoft but it leaves a lot of code un coverted and doesn't even create proper codebehind files.
Any ideas or tools that you know?
It's not going to work, sorry. Not only are the languages very different (the biggest difference arguably being that one is dynamically typed and the other is statically typed), but the entire architecture of the environment is vastly different. No automated tool is going to overcome this.
Even if you can find a tool that claims to accomplish this, it's going to emit terrible .NET code. It probably won't use any of the server controls, or at least not use any of them correctly. It's going to force the .NET code to try to do things "the PHP way" and end up costing you a ton in performance and maintainability.
Basically, there's just no way, reasonable or otherwise, to do what you're trying to do. Think of it this way... Have you ever seen automated translations between vastly different spoken languages? The results are humorous to say the least, and they are not accurate representations of the target language.
You're going to need a developer (or team of developers) to do this.
I don't think you can convert automatically a full php application into dotnet, as SLaks said, these languages are very different.
I started dotnet a half year ago, after years in php, and it's really different. You cannot use common techs from php, but you can use anothers. It's a different approach with different advantages, so an automatic tool can't do this.
Maybe you can convert some general php structures with a tool, but it won't be as good as if you write it by hand. And a complete app is nearly impossible.
For example, how would you convert a native php template based view system automatically? Maybe you can achieve this (never say impossible), but you shouldn't waste your time.
You can finish it much faster by hand than searching for a probably non-existent (or not good enough) tool.
As others have stated, an automatic converter from php to c#/asp.net is going to leave a lot to be desired.
Your question got me thinking (well, googling) about php on .net. My search found this: Welcome to Phalanger 2.x.
I don't know how mature it is (though being at 2.x implies some level of maturity); but I'm thinking that with something like this you can port your code over time, while still having the app up and running and still making incremental improvements to the application.
You can now run PHP on .NET with interop using http://phalanger.codeplex.com Some genius dun it!

C# Script version of PyBinding for WPF

I wrote a CSharpScriptBinding roughly equivalent to the PyBinding on CodePlex. It uses the C# script engine from http://www.csscript.net.
After I wrote it, I kind of decided it might not really be something good to use. Although it caches the compiled script code as an already compiled Assembly, my concern is that I will have one temporary Assembly created each time I use the binding. Will this add up to a problem in the future? If so, maybe there is a way in the C# script engine that I don't know about to optimize this further...? Any thoughts to confirm my suspicion that this was just a bad idea (but useful excersise in learning more about bindings and converters)?
Ask them if they use the DLR? Without it, I wouldn't trust it.

C# GUI Frontend

Is is possible to make a GUI in C# but make the actually program in C or C++.
Like say I want to make a chat application. I want the interface to be in C#. But I want to make all the actual code in C.
Is this possible?
I found http://www.google.com/search?hl=en&q=P%2FInvoke&btnG=Google+Search&aq=f&oq=
does anyone have any better kind of information?
Absoluely! A c# winform can call into managed or unmaged C or C++ dll's. See P/Invoke for more information.
Edit: Turns out there's a good thread on P/Invoke on the front page. :)
You already have some answers here giving you the affirmative.
One suggestion tho: Premature optimization is the root of all evil (or something like that).
Unless you are creating a science project (doing something just to see if it can be done), just write the entire thing in C#.
Once complete, if you find you have parts of the project that are not performing well enough, rewrite those parts.
Basically, the part of the application that are slow are rarely where you thing they will be.
Incrementing on JP's totally correct previous answer, you can also expose your C++ code through COM interfaces and then consume them in C# via COM/Interop. Good luck, though.
Not only is it possible, it might very well be what you should do. There's no reason to rewrite all of your existing code for .NET.
In short, there are three ways to use existing (C/C++) code from C#: for easy access to a few simple APIs, P/Invoke works well. C++/CLI will give you the most flexibility. You third option is to use COM.
Everything you can do in C can be done in managed code. Why do you want to build one component in C# and the other one in C? Are you worried about sockets?
But to your question, you can absolutely do it as JP mentioned above.
Depending on how you want to distribute your application, you should consider the deployment requirements. If you have C++ modules, you will have a dependency on the C++ runtime libraries, in addition to the .Net framework. This is a non-issue if you are merely P/Invoking the Win32 API.
This may or may not matter to you, but it mattered to me - I got rid of the C++ layer in my app, and resorted to calling Win32 directly.

Categories

Resources