简体   繁体   English

用于UI的C#,用于库的c ++

[英]C# for UI, c++ for library

I have a numerical library coded in C++. 我有一个用C ++编码的数值库。

I am going to make a UI for the library. 我将为库创建一个UI。 I know some MFC. 我知道一些MFC。 So one solution is to use MFC and make a native application. 因此,一种解决方案是使用MFC并生成本机应用程序。

The alternative is C#. 另一种选择是C#。 I know nothing about C#. 我对C#一无所知。 But I think it should be easy to learn. 但我认为它应该很容易学习。

Some tutorial for mixed programming of C++ and C# would be very helpful to me. 一些C ++和C#混合编程教程对我很有帮助。

Thanks! 谢谢!

Yin

I would recommend using Windows Forms or WPF via C# for your GUI. 我建议您通过C#使用Windows Forms或WPF作为GUI。

Take your numerical library, and use C++/CLI to make a .NET wrapper for it. 拿你的数值库,并使用C ++ / CLI为它创建一个.NET包装器。 This makes it trivial to use from C# (it looks like any other C# library). 这使得从C#中使用它变得微不足道(它看起来像任何其他C#库)。

I highly recommend Nishant Sivakumar's C++/CLI articles on CodeProject for learning about C++/CLI and how to wrap C++ libraries. 我强烈推荐Nishant Sivakumar在CodeProject上的C ++ / CLI文章 ,以了解C ++ / CLI以及如何包装C ++库。 They're fairly well written. 他们写得很好。

MSDN is a good reference for how to use Windows Forms from C# . MSDN是如何使用C#中的Windows窗体的一个很好的参考。

Write your GUI in C# using WinForms or WPF , and call your native code through Platform Invoke . 使用WinForms或WPF在C#中编写GUI,并通过Platform Invoke调用本机代码。

Instead of P/Invoke, you might want to consider C++/CLI to make a .NET wrapper for your native library. 您可能希望考虑使用C ++ / CLI为您的本机库创建.NET包装,而不是P / Invoke。

IMHO using C# is MUCH more easier than MFC, so you are on the right track. 使用C#的恕我直言比MFC更容易,所以你走在正确的轨道上。

You can use C# very easily to make the UI. 您可以非常轻松地使用C#来创建UI。 You'll need to write a simple wrapper class to call your unmanaged dll, but that is straightforward. 你需要编写一个简单的包装类来调用你的非托管dll,但这很简单。 check out the msdn page on that subject 查看该主题的msdn页面

Go with C#. 去C#。 MFC is somewhat dated, so if you need to learn something - go for newer technology, do not waste your time with MFC. MFC有点过时了,所以如果你需要学习一些东西 - 去寻求更新的技术,不要浪费你的时间在MFC上。 I'd go for WPF, learning curve is rather steep, but its fun. 我会去WPF,学习曲线相当陡峭,但很有趣。

I'd suggest looking into SWIG . 我建议调查SWIG You can write the core part of your code in C++ as a dll, then have a C# UI link against it. 你可以用C ++编写代码的核心部分作为dll,然后有一个C#UI链接。

If you have the source to your C++ numerical library, you can modify it to compile as C++/CLI then you can link to it just like any other .NET library. 如果您拥有C ++数值库的源代码,则可以将其修改为C ++ / CLI编译,然后就可以像任何其他.NET库一样链接到它。 It shouldn't require a large amount of work to modify the source with #defines for C++/CLI conditional compiling. 使用#defines进行C ++ / CLI条件编译不需要大量工作来修改源代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM