• 大小: 3.76MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-10-03
  • 语言: 其他
  • 标签: 图片缩放  

资源简介

模仿QQ聊天中的图片查看器 1.支持鼠标缩放图片; 2.图片放大到大于查看器窗体时,可鼠标拖动查看局部放大图片; 3.双层窗体实现查看器半透明,图片不透明效果

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ImageViewer
{
    public partial class BackGroundForm : Form
    {
        public BackGroundForm()
        {
            InitializeComponent();
        }

        /// 
        /// 鼠标开始移动的点
        /// 

        private Point m_StarPoint = Point.Empty;

        /// 
        /// 窗体移动过标识
        /// 

        private bool FormIsMove = false;

        /// 
        /// 鼠标在当前窗体上方按下时
        /// 

        /// 
        /// 
        private void BackGroundForm_MouseDown(object sender MouseEventArgs e)
        {
            //光标样式变为手型
            Cursor = Cursors.Hand;
            //获取鼠标当前位置
            m_StarPoint = e.Location;
        }

        /// 
        /// 鼠标在当前窗体上方移动时
        /// 

        /// 
        /// 
        private void BackGroundForm_MouseMove(object sender MouseEventArgs e)
        {
            //获取移动距离
            int _PointX = m_StarPoint.X - e.X;
            int _PointY = m_StarPoint.Y - e.Y;
            if (Cursor == Cursors.Hand)
            {
                if (this.Location.X - _PointX <= 0) _PointX = 0;
                if (this.Location.Y - _PointY <= 0) _PointY = 0;
                this.Location = new Point(this.Location.X - _PointX this.Location.Y - _PointY);
                FormIsMove = true;
            }
        }

        /// 
        /// 鼠标在当前窗体上方释放按键时
        /// 

        /// 
        /// 
        private void BackGroundForm_MouseUp(object sender MouseEventArgs e)
        {
            Cursor = Cursors.Default;
            if (!FormIsMove)
            {
                this.OwnedForms[0].Close();
                return;
            }
            FormIsMove = false;
            this.OwnedForms[0].Focus();
        }

        /// 
        /// 窗体移动时
        /// 

        /// 
        /// 
        private void BackGroundForm_Move(object sender EventArgs e)
        {
            this.OwnedForms[0].Left = this.Left;
            this.OwnedForms[0].Top = this.Top;
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件         875  2015-08-20 14:43  ImageViewer\ImageViewer.sln
     文件       32768  2015-09-06 17:01  ImageViewer\ImageViewer.suo
     目录           0  2015-09-01 16:34  ImageViewer\ImageViewer\
     文件        2706  2015-09-06 16:42  ImageViewer\ImageViewer\BackGroundForm.cs
     文件        2006  2015-09-06 16:42  ImageViewer\ImageViewer\BackGroundForm.Designer.cs
     文件        5817  2015-09-06 16:42  ImageViewer\ImageViewer\BackGroundForm.resx
     目录           0  2015-08-20 14:50  ImageViewer\ImageViewer\bin\
     目录           0  2015-09-06 16:56  ImageViewer\ImageViewer\bin\Debug\
     文件      794624  2015-09-06 16:56  ImageViewer\ImageViewer\bin\Debug\ImageViewer.exe
     文件       36352  2015-09-06 16:56  ImageViewer\ImageViewer\bin\Debug\ImageViewer.pdb
     文件       11592  2015-09-06 16:58  ImageViewer\ImageViewer\bin\Debug\ImageViewer.vshost.exe
     目录           0  2015-09-06 16:56  ImageViewer\ImageViewer\bin\Debug\Resources\
     文件      777835  2015-08-20 14:54  ImageViewer\ImageViewer\bin\Debug\Resources\Penguins.jpg
     目录           0  2015-08-20 14:50  ImageViewer\ImageViewer\bin\Release\
     文件        4397  2015-09-06 16:56  ImageViewer\ImageViewer\ImageViewer.csproj
     文件       14758  2015-09-06 17:01  ImageViewer\ImageViewer\ImageViewerForm.cs
     文件        3734  2015-09-01 17:30  ImageViewer\ImageViewer\ImageViewerForm.Designer.cs
     文件        5817  2015-09-01 17:30  ImageViewer\ImageViewer\ImageViewerForm.resx
     目录           0  2015-08-20 14:43  ImageViewer\ImageViewer\obj\
     目录           0  2015-08-20 14:43  ImageViewer\ImageViewer\obj\x86\
     目录           0  2015-09-06 16:56  ImageViewer\ImageViewer\obj\x86\Debug\
     文件        4501  2015-08-21 09:01  ImageViewer\ImageViewer\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        6413  2015-09-06 16:56  ImageViewer\ImageViewer\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     文件         836  2015-09-06 16:56  ImageViewer\ImageViewer\obj\x86\Debug\GenerateResource.read.1.tlog
     文件         922  2015-09-06 16:56  ImageViewer\ImageViewer\obj\x86\Debug\GenerateResource.write.1.tlog
     文件         180  2015-09-06 16:56  ImageViewer\ImageViewer\obj\x86\Debug\ImageViewer.BackGroundForm.resources
     文件        2150  2015-09-06 16:58  ImageViewer\ImageViewer\obj\x86\Debug\ImageViewer.csproj.FileListAbsolute.txt
     文件      794624  2015-09-06 16:56  ImageViewer\ImageViewer\obj\x86\Debug\ImageViewer.exe
     文件         180  2015-09-06 16:56  ImageViewer\ImageViewer\obj\x86\Debug\ImageViewer.ImageViewerForm.resources
     文件       36352  2015-09-06 16:56  ImageViewer\ImageViewer\obj\x86\Debug\ImageViewer.pdb
     文件      778279  2015-09-06 16:56  ImageViewer\ImageViewer\obj\x86\Debug\ImageViewer.Properties.Resources.resources
............此处省略11个文件信息

评论

共有 条评论