【小程序】用VB实现的简易图片查看器
acmilan2015/11/22软件综合 IP:四川
代码很简单,只有15行(添加了两个事件)→_→
<code class="lang-vb">Class MainWindow
    Private Sub button_Click(sender As Object, e As RoutedEventArgs) Handles button.Click
        Dim opendlg As New Microsoft.Win32.OpenFileDialog()
        If opendlg.ShowDialog() Then
            imagebox.Source = New BitmapImage(New Uri(opendlg.FileName))
        End If
    End Sub
               
    Private Sub MainWindow_Drop(sender As Object, e As DragEventArgs) Handles Me.Drop
        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
            Dim filelist As String() = e.Data.GetData(DataFormats.FileDrop)
            imagebox.Source = New BitmapImage(New Uri(filelist(0)))
        End If
    End Sub
End Class</code>

界面用的WPF,XAML标记如下(都是自动生成的):
<code class="lang-xml"><window x:class="MainWindow"         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"         xmlns:local="clr-namespace:picview"         mc:ignorable="d"         title="图片查看器" height="350" width="525" allowdrop="True">
    <grid>
        <button x:name="button" content="打开" horizontalalignment="Left" margin="10,10,0,0" verticalalignment="Top" width="75">
        <image x:name="imagebox" margin="10,40,10,10">
    </image></button></grid>
</window></code>

使用.NET 3.5编写并使用XXXXXXnfig补丁,Win7/8/8.1/10免运行库。XXXXXXnfig:
<code class="lang-xml"><?xml version="1.0" encoding="utf-8"?>
<configuration>
    <startup uselegacyv2runtimeactivationpolicy="true">
        <supportedruntime version="v4.0.30319">
        <supportedruntime version="v2.0.50727">
    </supportedruntime></supportedruntime></startup>
</configuration></code>

运行界面如图(可使用打开按钮打开,也可拖拽):

tupian.png

程序和源代码下载(工程是VS2015格式的):

attachment icon picview.rar 53.82KB RAR 52次下载

[修改于 8年6个月前 - 2015/11/22 11:00:21]

来自:计算机科学 / 软件综合
2
已屏蔽 原因:{{ notice.reason }}已屏蔽
{{notice.noticeContent}}
~~空空如也
acmilan 作者
8年6个月前 IP:四川
798214
XXXXXXnfig建议把4.0.30319(Win8+带的版本)放在前面,优先匹配.NET 4.x。如果把2.0.50727放前面,控件会变成Win7样式。
引用
评论
加载评论中,请稍候...
200字以内,仅用于支线交流,主线讨论请采用回复功能。
折叠评论
acmilan作者
8年6个月前 IP:四川
798220
用.NET3.5+XXXXXXnfig免库,适合编写小程序。编写大程序的话可以选择更高版本的.NET。
WPF原生支持高DPI,和Windows窗体不同,在高DPI时不会导致模糊或错位。
引用
评论
加载评论中,请稍候...
200字以内,仅用于支线交流,主线讨论请采用回复功能。
折叠评论

想参与大家的讨论?现在就 登录 或者 注册

所属专业
所属分类
上级专业
同级专业
acmilan
进士 学者 笔友
文章
461
回复
2934
学术分
4
2009/05/30注册,5年3个月前活动
暂无简介
主体类型:个人
所属领域:无
认证方式:邮箱
IP归属地:未同步
文件下载
加载中...
{{errorInfo}}
{{downloadWarning}}
你在 {{downloadTime}} 下载过当前文件。
文件名称:{{resource.defaultFile.name}}
下载次数:{{resource.hits}}
上传用户:{{uploader.username}}
所需积分:{{costScores}},{{holdScores}}下载当前附件免费{{description}}
积分不足,去充值
文件已丢失

当前账号的附件下载数量限制如下:
时段 个数
{{f.startingTime}}点 - {{f.endTime}}点 {{f.fileCount}}
视频暂不能访问,请登录试试
仅供内部学术交流或培训使用,请先保存到本地。本内容不代表科创观点,未经原作者同意,请勿转载。
音频暂不能访问,请登录试试
支持的图片格式:jpg, jpeg, png
插入公式
评论控制
加载中...
文号:{{pid}}
投诉或举报
加载中...
{{tip}}
请选择违规类型:
{{reason.type}}

空空如也

加载中...
详情
详情
推送到专栏从专栏移除
设为匿名取消匿名
查看作者
回复
只看作者
加入收藏取消收藏
收藏
取消收藏
折叠回复
置顶取消置顶
评学术分
鼓励
设为精选取消精选
管理提醒
编辑
通过审核
评论控制
退修或删除
历史版本
违规记录
投诉或举报
加入黑名单移除黑名单
查看IP
{{format('YYYY/MM/DD HH:mm:ss', toc)}}