在项目中插入图片最好的是什么:项目重新生成文件或本地恢复? [英] what is best for insert picture in project : project resurces file or local resurce ?

查看:69
本文介绍了在项目中插入图片最好的是什么:项目重新生成文件或本地恢复?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



i希望将图片设置为我项目中的某个按钮...



和我希望他们在发布设置文件后留下来...



什么是最佳解决方案:



1次使用项目恢复文件

2本地恢复?




请帮帮我...



非常感谢

hi all

i want set image to some button in my project ...

and i want they are stay after publishing setup file ...

what is a best solution :

1-use project resurces file
2-local resurce ?


please help me ...

thanks a lot

推荐答案

没有最好的 - 他们会做不同的事情。



但是在你的情况下,使用按钮图像我通常会将图像放入项目资源文件中,并将其属性Build Action设置为Embedded Resource这样可以确保它成为EXE文件的一个组成部分,不会被意外移动或删除。
There is no "best" - they do different things.

But in your case, with a button image I normally put the images into the project resource file, and set it''s property "Build Action" to "Embedded Resource" This ensures that it becomes a integral part of the EXE file and can''t be accidentally moved or deleted.


我不明白1-2你的选择是什么意思。在大多数情况下,它将是项目中包含的* .resx文件。只有一个建议:不要嵌入图像,使用添加现有文件。这样,图像文件将被添加到两个项目中(不将其复制到输出目录)并在资源文件中引用。在这样的设置中,您可以使用您选择的任何编辑器单独编辑文件。



在WPF中,您可以使用此选项(需要)将图像转换为WPF位图,这是一个缺点,请参阅此CodeProject文章: Bitmap to BitmapSource [ ^ ]),或者您可以使用XAML资源,这是WPF的原生方式。请参阅:

http://msdn.microsoft.com/en-us /library/ms742538.aspx [ ^ ]。



-SA
I don''t understand what do you options 1-2 mean. In most cases, it would be a *.resx file included in your project. Just one advice: don''t embed the image, use "Add existing file". This way, the image file will be added to both project (without copying it to output directory) and referenced in the resource file. In such settings, you will be able to edit the file separately, with any editor of your choice.

In WPF, you can use this option we well (will need to convert the image to the WPF bitmap, which is a disadvantage, please see this CodeProject article: Bitmap to BitmapSource[^]), or you can use XAML resources, which is a way native to WPF. Please see:
http://msdn.microsoft.com/en-us/library/ms742538.aspx[^].

—SA


这篇关于在项目中插入图片最好的是什么:项目重新生成文件或本地恢复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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