[不是问题]创建用于配置的图形工具 [英] [Not a question] Creating a graphical tool for configuration

查看:81
本文介绍了[不是问题]创建用于配置的图形工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道如何开始开发图形工具/用户界面。该程序需要能够创建必要的配置。我在visual studio中使用C#。



重新封装:我们需要制作一个应用程序(图形工具)来更改应用程序中的数据。所以结果应该更准确。所以应用程序应该能够读取文件并创建新文件。



old file.ini(con​​figuration)---->你的应用程序----> new file.ini(配置)



图形工具可以拖放。



请帮忙!

I need to know how to start on developing a graphical tool/user interface. The program needs to be able to create the necessary configuration. I am using C# in visual studio.

Recapping: we need to make an application (graphical tool) to change the data from the application. So the result should be more accurate. So the application should be able to read the file and create the new one.

old file.ini (configuration) ----> your apps ----> new file.ini (configuration)

The graphical tools to be drag and drop.

Please help!

推荐答案

首先,使用.NET的.INI格式是一个非常糟糕的主意。这种格式过于陈旧且不灵活。考虑使用XML(或JSON,如果由于某些原因你发现它更方便)。使用.NET FCL,您不需要直接使用XML,JSON,文件或流,您只需使用 Data Contract http://msdn.microsoft.com/en-us/library/ms733127.aspx [ ^ ]。



这种方法是最容易使用和非侵入性。您可以通过编写一些数据类或结构来定义合同,按照您的方式执行:无需实现任何特定接口或从任何特定类继承。您只需将一些.NET属性添加到要作为合同一部分保留的类型和成员中。并且序列化器只是将内存中的任何对象图存储到文件或任何其他流中,以便按照以前的方式将其恢复。



请查看我的过去答案:

如何在表单应用程序中使用XML文件编写器和阅读器? [ ^ ],

创建属性文件...... [ ^ ],

解析json字符串数组 [ ^ ]。



现在, UI。您可以遵循非常类似的方法,也对特定数据类型不可知。您可以使用基于 System.Windows.Forms 的Windows应用程序类型。然后,您可以使用此控件以类型无关的方式编辑任何内容: http://msdn.microsoft.com/en-us/library/system.windows.forms.propertygrid.aspx [ ^ ]。



祝你好运,

-SA
First of all, using .INI format for .NET is a really bad idea. This format is way too obsolete and not flexible. Consider using XML (or JSON, if by some reasons you find it more convenient). With .NET FCL, you don't need to work with XML, JSON, files or streams directly, you can just use Data Contract: http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].

This approach is the easiest to use and non-intrusive. You define the contract by writing some data classes or structures, doing it your way: no need to implement any particular interfaces or inherit from any particular classes. You just add some .NET attributes to the types and members you want to persist as a part of the contract. And the serializer simply stores any object graph from memory to a file or any other stream, to restore it on your request the way it was before.

Please see my past answers:
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating property files...[^],
deseralize a json string array[^].

Now, the UI. You can follow a pretty similar approach, also agnostic to particular data types. You can use the Windows application type based on System.Windows.Forms. Then, you can use this control for editing anything at all in a type-agnostic manner: http://msdn.microsoft.com/en-us/library/system.windows.forms.propertygrid.aspx[^].

Good luck,
—SA


这篇关于[不是问题]创建用于配置的图形工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆