创建新的保存文件对话框
经过深思熟虑和谷歌搜索后,我一心想创建自己的 SaveFileDialog。
但我不知道从哪里开始,因为我在网上没有看到任何内容,我想知道以前是否有人这样做过,我应该调查什么,或者我如何去做呢?
我想构建一个新的 SaveFileDialog 因为我觉得需要(或想要)为其添加更多功能。而且我还觉得,如果我构建一个新的,我将了解更多有关 C# 以及 SaveFileDialog 如何在幕后工作的知识
说实话,我不喜欢当前的 SaveFileDialog(是的,它可以完成这项工作),但是我真的很想为其添加额外的功能。
啊,我不认为有任何限制。我不能肯定地说,因为我是新手,不知道需要什么或......
After a lot of thought and consideration, and Google-ing, I'm hell-bent on creating my own SaveFileDialog.
But I do not know where to start and since I haven't seen anything around the web, I would like to know if anybody has done this before, and what I should look into, or how I might go about doing this?
I am wanting to build a new SaveFileDialog because I feel the need (or want) to add more functionality to it. And I also feel that if I build a new one, I'll learn alot more about C# and how the SaveFileDialog works behind the scenes
To be quite honest, I don't like the current SaveFileDialog (Yes, it does the job) but I really do want to add extra functionality to it.
Ah, I don't think that there are any restrictions. I can't say for sure because I'm new to this and don't know what is required or...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
为什么不扩展它而不是从头开始创建?
Why not extend it instead of creating from scratch?
好吧,对话框只是一种形式。从表单开始,添加文件系统浏览组件(列表视图、下拉菜单)等,然后在后面添加代码。这并不困难,但可能很乏味,但我想说这是一个很好的教育练习,您将了解为什么您可能只想使用内置的练习。
Well a dialog is just a form. Start with a form, add the file system browsing components (listview, drop downs) etc, add your code behind. Its not that difficult but may be tedious, but I'd say a good educational exercise where the you'll learn why you may want to just use the built in one.
如果您确实确定要创建自己的 SaveFileDialog 版本,我建议您不要只是克隆现有版本。如果你让它看起来像标准的,人们会期望它的行为像标准的,但有很多小细节,你可能无法全部了解。
您想避免用户界面的恐怖谷,所以你应该明确它并不是试图成为 SaveFileDialog + some-new-bits。它应该实现相同的目标(即选择保存某些内容的位置)。
如果您确实想创建 SaveFileDialog + some-new-bits,则沿着 的路径前进正如 Shoban 所说,扩展对话是正确的方法。
注意:如果您只想构建自己的学习目的,然后在使用时将其扔掉,那么这一切都不适用。但如果您想在实际项目中使用它,那么您应该记住这一点。
If you are really really sure you want to create your own version of a SaveFileDialog, I'd recommend not just cloning the existing one. If you make it look like the standard one, people will expect it to behave like the standard one, but there's lots of little details and you probably won't get them all.
You want to avoid The Uncanny Valley of User Interface, so you should make it clear that it isn't trying to be the SaveFileDialog + some-new-bits. It should just achieve the same goal (i.e. choosing where to save something).
If you do want to create SaveFileDialog + some-new-bits, then going down the path of extending the dialog as Shoban says is the way to go.
NOTE: None of this really applies if all you want to do is build your own for learning purposes, and then throw it away when you're doing. But if you ever want to use it a real project, then you should keep this in mind.
SaveFileDialog
是操作系统的一部分,实际上在不同版本的操作系统上看起来会有所不同。有很多方法可以自定义它,但在 Windows 窗体项目中并不那么容易。它仍然可以完成,但您必须连接到本机 Win32 API。如果您只是想使用 Windows 窗体和 C#,您可以继续设计一个看起来像SaveFileDialog
的窗体,但您会错过本机对话框的所有优点。您可以阅读有关常见打开和另存为对话框的更多信息在 MSDN 上,但如果您习惯了 Windows 窗体编程,您可能会对本机 Win32 API 感到疏远。 Window Vista 引入了新的常用项目对话框基于 COM 的 API 使其更易于在 Windows 窗体应用程序中使用。
The
SaveFileDialog
is part of the operating system and will actually look different on different versions of the OS. There are a lot of ways to customize it, but that is not so easy in a Windows Forms project. It can still be done, but you have to hook into the native Win32 API. If you simply want to play around with Windows Forms and C# you can go ahead and design a form that looks like aSaveFileDialog
but you will miss all the goodness of the native dialog.You can read more about the common open and save as dialog boxes on MSDN, but if you are used to Windows Forms programming you may feel alienated by the native Win32 API. Window Vista has introduced a new common item dialog and the COM based API makes it easier to use in a Windows Forms application.