private void ShowSelectedPicture(string path)
{
FileStream fs = File.OpenRead(path); //OpenRead
int filelength = ;
filelength = (int)fs.Length; //获得文件长度
Byte[] image = new Byte[filelength]; //建立一个字节数组
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.StreamSource =new MemoryStream(image );
bitmapImage.EndInit();
var pictureWindow = new PictureWindow();//自己创建的窗口
pictureWindow.myImage.Source = bitmapImage;//myImage窗口中的图片空间
//pictureWindow.myImage.Width = bitmapImage.PixelWidth;
//pictureWindow.myImage.Height = bitmapImage.PixelHeight;
pictureWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
pictureWindow.ShowDialog();
}

private void MyImage_OnMouseWheel(object sender, MouseWheelEventArgs e)
    {
         double ScaleX = 0;
         double ScaleY = 0;
         double dbl_ZoomX = ((ScaleTransform)(((TransformGroup)(((UIElement)(this.myImage)).RenderTransform)).Children[0])).ScaleX;
         double dbl_ZoomY = ((ScaleTransform)(((TransformGroup)(((UIElement)(this.myImage)).RenderTransform)).Children[0])).ScaleY;
        ((ScaleTransform)(((TransformGroup)(((UIElement)(this.myImage)).RenderTransform)).Children[0])).CenterX = e.GetPosition(this.myImage).X;
        ((ScaleTransform)(((TransformGroup)(((UIElement)(this.myImage)).RenderTransform)).Children[0])).CenterY = e.GetPosition(this.myImage).Y;


if (e.Delta < 0)
       {
          ScaleX = dbl_ZoomX - 0.1 < 0.2 ? 0.1 : dbl_ZoomX - 0.1;
          ScaleY = dbl_ZoomY - 0.1 < 0.2 ? 0.1 : dbl_ZoomY - 0.1;
       }
     else if (e.Delta > 0)
     {
        ScaleX = dbl_ZoomX + 0.1 > 10.0 ? 10.0 : dbl_ZoomX + 0.1;
        ScaleY = dbl_ZoomY + 0.1 > 10.0 ? 10.0 : dbl_ZoomY + 0.1;
     }


((ScaleTransform)(((TransformGroup)(((UIElement)(this.myImage)).RenderTransform)).Children[0])).ScaleX = ScaleX;
       ((ScaleTransform)(((TransformGroup)(((UIElement)(this.myImage)).RenderTransform)).Children[0])).ScaleY = ScaleY;
    }

 

C# 上传图片

 private void UploadImage(string Path)
{
FileStream fullfs;
string pictureName = GetPictureName();
string pictureFullPath = storePath;// GetPicturePath(rtdto.BusinessIndex, rtdto.ProviderIndex);
string pictureFullName = pictureFullPath + @"\" + pictureName;
fullfs = new FileStream(pictureFullName, FileMode.Create);
BinaryWriter fullbw = new BinaryWriter(fullfs);
fullbw.Write(pidto.PictureData);
fullbw.Close();
fullfs.Close();
}
private string GetPicturePath(int businessindex, int providerindex)
{
string currentPath = AppDomain.CurrentDomain.BaseDirectory + @"\Image";
if (!System.IO.Directory.Exists(currentPath))
{
try
{
System.IO.Directory.CreateDirectory(currentPath);
}
catch
{
currentPath = AppDomain.CurrentDomain.BaseDirectory;//创建目录失败,存入根目录中
}
}
string filePath = currentPath + @"\" + businessindex + "_" + providerindex;
if (!System.IO.Directory.Exists(filePath))
{
try
{
System.IO.Directory.CreateDirectory(filePath);
}
catch
{
filePath = currentPath;//创建目录失败,存入根目录中
} }
return filePath;
}
private string GetPictureName()
{
string imageGuid = Guid.NewGuid().ToString() + ".jpg";
return imageGuid;
}

窗口页面代码

<Window x:Class="App.Modules.PictureWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:uiControls="clr-namespace:Allegion.Components.UIControls;assembly=Allegion.Components.UIControls"
Title="PictureWindow"> <ScrollViewer x:Name="scrollViewer"
HorizontalScrollBarVisibility="Auto"
MouseWheel="ScrollViewer_OnMouseWheel"
VerticalScrollBarVisibility="Auto"> <Image Name="myImage" MouseWheel="MyImage_OnMouseWheel">
<Image.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="" ScaleY="" />
<SkewTransform />
<RotateTransform />
<TranslateTransform />
</TransformGroup>
</Image.RenderTransform>
</Image>
</ScrollViewer>
</Window>

C# 弹出窗口查看图片以及上传图片的更多相关文章

  1. jQuery弹出窗口浏览图片

    效果预览:http://keleyi.com/keleyi/phtml/jqtexiao/3.htm HTML文件代码: <!DOCTYPE HTML> <html> < ...

  2. chrome浏览器上传图片反应很慢,延迟很久才弹出窗口

    chrome浏览器上传图片反应很慢,延迟很久才弹出窗口 一个上传图片的控件,点击按钮上传图片,用chrome(谷歌浏览器)时,点击按钮后,要等好几秒才弹出文件选择窗口 可以试一下,把网络断开,这个问题 ...

  3. jQuery弹出窗口完整代码

    jQuery弹出窗口完整代码 效果体验:http://keleyi.com/keleyi/phtml/jqtexiao/1.htm 1 <!DOCTYPE html PUBLIC "- ...

  4. jQuery插件---轻量级的弹出窗口wBox

    Box Demo wBox——轻量级的弹出窗口jQuery插件,基于jQuery1.4.2开发,主要实现弹出框的效果,并且加入了很多有趣的功能,比如可img灯箱效果,callback函数,显示隐藏层, ...

  5. OAF_开发系列08_实现OAF通过Popup参数式弹出窗口(案例)

    20150711 Created By BaoXinjian

  6. ArcGIS API for Silverlight 当DataGrid选中项时,地图聚焦弹出窗口,并可以播放音频文件

    原文:ArcGIS API for Silverlight 当DataGrid选中项时,地图聚焦弹出窗口,并可以播放音频文件 先看效果图,然后上代码: <UserControl x:Class= ...

  7. js弹出窗口的学习和使用

    Thickbox Thickbox是基于Jquery的,因此使用Thickbox需要下面四个文件: Thickbox.js----Thickbox主文件 CSS文件----Thickbox.css 最 ...

  8. [selenium webdriver Java]处理弹出窗口

    Selenium WebDriver测试弹出窗口,包括识别弹出窗口,将driver转到新的窗口,在新的串钩中执行而是步骤,然后再转换到最初的窗口. 通过名称(name)识别和处理: Selenium ...

  9. Win8 弹出窗口不在最前端的解决方法

    Win8系统的使用者有很多会遇到弹出窗口不在最前端的情况(自动隐藏,点下页面又出来),比如另存为的时候 ,或是登录路由器时弹出的登录框时. 引起这个异常的原因是与系统输入法冲突引起,但又不可能不用第三 ...

随机推荐

  1. Stopwatch 类【转】

    一般我们想要测试使用那种方法或着那种类型效率更高,使用Stopwatch类进行测试就可以,我也是现在才知道,汗一个. 先来看个小示例,如下. 前提,先引用using System.Diagnostic ...

  2. Swift版音乐播放器(简化版),swift音乐播放器

    这几天闲着也是闲着,学习一下Swift的,于是到开源社区Download了个OC版的音乐播放器,练练手,在这里发扬开源精神, 希望对大家有帮助! 这个DEMO里,使用到了 AudioPlayer(对音 ...

  3. js判断的执行顺序

    js预编译是对每一个<script>标签片段进行的.预编译声明所有var变量(初始为undefined),解析定义式函数语句. 还有个关于 "window作用域下,a = 1和v ...

  4. BS常用方法备忘

    在B/S项目开发过程中总结的一些常用方法,如:常量.验证方法.服务器控件方法.html控件方法等. ///******************* 说明 ************************ ...

  5. Android编译错误——undefined reference to

    [错误描述] 未定义引用 提示如下:bootable/recovery/minzip/Zip.c:1122: error: undefined reference to 'selabel_lookup ...

  6. VMware下桥接设置

    操作环境 主机:Win7 X86 SP1 虚拟机:VMware station 8 虚拟机里的系统:Fedora 15 环境上,不管什么系统,什么版本的虚拟机,使用上都是大同小异的,毕竟核心是不变的. ...

  7. oracle 定义数据完整性

    1. 定义主键约束 1.1 在创建表时定义主键约束 create table student(name varchar2(8),studentid varchar2(10) primary key,s ...

  8. ubuntu 配置JDK环境变量

    ubuntu 配置JDK环境变量 (2011-11-25 16:45:59) 转载▼ 标签: ubuntu jdk 环境变量 杂谈 分类: Linux_Ubuntu_CentOs 过程如下: 1. 先 ...

  9. 使用 VB.NET 开发多线程

    摘要:.NET 框架提供了新的类,可以方便地创建多线程应用程序.本文介绍如何使用 Visual Basic® .NET 的多线程编程技术来开发效率更高.响应速度更快的应用程序. 目录 简介 多线程处理 ...

  10. oracle体系结构

    oracle体系结构有四个部分组成分别为:oracle 服务器.用户进程.服务器进程.其他关键文件.其中oracle服务器又有实例(instance)和database组成是一个数据库管理系统. 一. ...