资源简介
通过鼠标点击事件控制panel的自动滚动条移动,实现在触摸屏上的手指拖动效果
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp2
{
public partial class Form1 : Form
{
int x = 10;//x坐标
int y = 0;//y坐标
string direction = “0“;//方向
float _FlStateTime;//手指停留的时间
public Form1()
{
InitializeComponent();
}
private void panel1_Paint(object sender PaintEventArgs e)
{
this.panel1.AutoScroll = false;
}
private void panel1_MouseWheel(object sender EventArgs e)
{
// MessageBox.Show(“鼠标滚轮“);
}
private void panel1_MouseDown(object sender MouseEventArgs e)
{
//this.panel1.Focus();
//MessageBox.Show(“鼠标点击“);
this.x=e.X;
this.y = e.Y;
this._FlStateTime = float.Parse(DateTime.Now.Second.ToString());
}
private void panel1_MouseUp(object sender MouseEventArgs e)
{
//MessageBox.Show(“鼠标离开“);
int cx = e.X - this.x;
this._FlStateTime = float.Parse(DateTime.Now.Second.ToString())-_FlStateTime;
if (cx > 0)
{
this.direction = “右边“;
//MessageBox.Show(direction+“距离:“+ cx+“时间:“ +_FlStateTime);
// MessageBox.Show(panel1.AutoScrollPosition.X.ToString());
int ax = Math.Abs(panel1.AutoScrollPosition.X);//滑动前位置
int hx = Math.Abs(cx);//滑动距离
Point p = new Point(ax - hx 0);
this.panel1.AutoScrollPosition = p;
}
else if(cx == 0)
{
this.direction = “没动“;
MessageBox.Show(direction + “距离:“ + cx + “时间:“ + _FlStateTime);
}
else
{
this.direction = “左边“;
//MessageBox.Show(direction+ “距离:“ + cx + “时间:“ + _FlStateTime);
int ax = Math.Abs(panel1.AutoScrollPosition.X);//滑动前位置
int hx = Math.Abs(cx);//滑动距离
Point p = new Point(ax + hx 0);
this.panel1.AutoScrollPosition = p;
}
this.x = e.X;
this.y = e.Y;
}
private void button4_MouseDown(object sender MouseEventArgs e)
{
this.panel1_MouseDown(sendere);
//int index = this.button4.TabIndex;
this.button4.TabIndex=1;
}
private void button4_MouseUp(object sender MouseEventArgs e)
{
this.panel1_MouseUp(sender e);
}
private void button3_MouseDown(object sender MouseEventArgs e)
{
this.panel1_MouseDown(sender e);
}
private void button3_MouseUp(object sender M
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-03-29 08:53 WindowsFormsApp2\
目录 0 2019-03-29 08:53 WindowsFormsApp2\.vs\
目录 0 2019-03-29 08:53 WindowsFormsApp2\.vs\WindowsFormsApp2\
目录 0 2019-03-29 08:53 WindowsFormsApp2\.vs\WindowsFormsApp2\v15\
文件 47104 2019-03-29 08:53 WindowsFormsApp2\.vs\WindowsFormsApp2\v15\.suo
目录 0 2019-03-29 08:53 WindowsFormsApp2\.vs\WindowsFormsApp2\v15\Server\
目录 0 2019-03-29 08:53 WindowsFormsApp2\.vs\WindowsFormsApp2\v15\Server\sqlite3\
文件 0 2019-03-28 14:30 WindowsFormsApp2\.vs\WindowsFormsApp2\v15\Server\sqlite3\db.lock
文件 602112 2019-03-28 22:32 WindowsFormsApp2\.vs\WindowsFormsApp2\v15\Server\sqlite3\storage.ide
文件 32768 2019-03-29 08:50 WindowsFormsApp2\.vs\WindowsFormsApp2\v15\Server\sqlite3\storage.ide-shm
文件 4140632 2019-03-29 08:34 WindowsFormsApp2\.vs\WindowsFormsApp2\v15\Server\sqlite3\storage.ide-wal
目录 0 2019-03-29 08:53 WindowsFormsApp2\WindowsFormsApp2\
文件 1146 2019-03-28 14:30 WindowsFormsApp2\WindowsFormsApp2.sln
文件 189 2019-03-28 14:30 WindowsFormsApp2\WindowsFormsApp2\App.config
目录 0 2019-03-29 08:53 WindowsFormsApp2\WindowsFormsApp2\bin\
目录 0 2019-03-29 08:53 WindowsFormsApp2\WindowsFormsApp2\bin\Debug\
文件 168448 2019-03-29 08:26 WindowsFormsApp2\WindowsFormsApp2\bin\Debug\WindowsFormsApp2.exe
文件 189 2019-03-28 14:30 WindowsFormsApp2\WindowsFormsApp2\bin\Debug\WindowsFormsApp2.exe.config
文件 40448 2019-03-29 08:26 WindowsFormsApp2\WindowsFormsApp2\bin\Debug\WindowsFormsApp2.pdb
目录 0 2019-03-28 14:54 WindowsFormsApp2\WindowsFormsApp2\bin\Release\
文件 6080 2019-03-29 08:26 WindowsFormsApp2\WindowsFormsApp2\Form1.cs
文件 12365 2019-03-29 08:26 WindowsFormsApp2\WindowsFormsApp2\Form1.Designer.cs
文件 6019 2019-03-29 08:26 WindowsFormsApp2\WindowsFormsApp2\Form1.resx
目录 0 2019-03-29 08:53 WindowsFormsApp2\WindowsFormsApp2\obj\
目录 0 2019-03-29 08:53 WindowsFormsApp2\WindowsFormsApp2\obj\Debug\
文件 1443 2019-03-29 08:25 WindowsFormsApp2\WindowsFormsApp2\obj\Debug\DesignTimeResolveAssemblyReferences.cache
文件 7276 2019-03-28 14:54 WindowsFormsApp2\WindowsFormsApp2\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 0 2019-03-28 14:30 WindowsFormsApp2\WindowsFormsApp2\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
文件 0 2019-03-28 14:30 WindowsFormsApp2\WindowsFormsApp2\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
文件 0 2019-03-28 14:30 WindowsFormsApp2\WindowsFormsApp2\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
目录 0 2019-03-28 14:30 WindowsFormsApp2\WindowsFormsApp2\obj\Debug\TempPE\
............此处省略16个文件信息
- 上一篇:C#网络编程UDP广播
- 下一篇:C#实现磁盘调度的四种算法,图形化界面显示
相关资源
- SignalR 2.0 Winform版
- C# winform Socket大文件传输
- C#将Excel导入到Access数据库表(winFor
- winform图片标尺,画矩形
- C# 斑马标签打印 WEBWINFORM
- C#动画控件超炫
- WeifenLuo.WinFormsUI.Docking3.1.0
- Bunifu_Ui_WinForms_v1.10.0.0_Downloadly.ir.rar
- Winform可视化打印模板设计
- 最新9个C# .NET Winform的多线程进度条源
- Winform绘制圆形和椭圆形图章
- c# 图像旋转 winform 窗体 图片转动
- 优化C# WinForm从中国银行网站抓取汇率
- C#项目 网吧管理系统
- Winform通用经典快速开发CS框架-outloo
- 人事管理系统 winform代码
- 宾馆管理系统(c#2008access2003winform)
- C# Winform 酒店管理系统源代码及数据
- C# Winform 弹窗等待效果图
- winform自动更新程序
- winform c# mschart demo 范例
- WinForm 实现图片滚动
- c#winform做的hosts文件管理
- 控件重绘 C# WinForm控件美化扩展系列之
- .net winform插件大全 .net 控件大全.net插
- winform chart动态跟进式折线图
- WinForm C#Demo 会员与消费系统 进销存系
- c# 模仿windows扑克游戏
- 幸运52winform写的游戏
- winform 60种非常漂亮界面样式\\皮肤(
评论
共有 条评论