图片的切换与位置的移动
2012-04-06 09:32
204 查看
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Left:
Y -= Math.Sin(Q) * 10;
X -= Math.Cos(Q) * 10;
this.pictureBox1.Location = new Point((int)X ,(int)Y); break;
//case Keys.Right:
// this.pictureBox1.Location.X += 45; break;
//case Keys.Up:
// this.pictureBox1.Location.Y -= 45; break;
//case Keys.Down:
// this.pictureBox1.Location.Y += 45; break;
//default:
// break;
}
}
private void Form1_Load(object sender, EventArgs e)
{
this.pictureBox1.Location = new Point(0, 0);
}
static double X = 1;
static double Y = 1;
static int Q = 45;
static bool flag = true;
private void button1_Click(object sender, EventArgs e)
{
Y += Math.Sin(Q)*10;
X += Math.Cos(Q)*10;
this.pictureBox1.Location = new Point((int)X, (int)Y);
if (flag==true)
{
pictureBox1.Image = imageList1.Images[0];
flag = false;
}
else
{
flag = true;
pictureBox1.Image = imageList1.Images[1];
}
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Left:
Y -= Math.Sin(Q) * 10;
X -= Math.Cos(Q) * 10;
this.pictureBox1.Location = new Point((int)X ,(int)Y); break;
//case Keys.Right:
// this.pictureBox1.Location.X += 45; break;
//case Keys.Up:
// this.pictureBox1.Location.Y -= 45; break;
//case Keys.Down:
// this.pictureBox1.Location.Y += 45; break;
//default:
// break;
}
}
private void Form1_Load(object sender, EventArgs e)
{
this.pictureBox1.Location = new Point(0, 0);
}
static double X = 1;
static double Y = 1;
static int Q = 45;
static bool flag = true;
private void button1_Click(object sender, EventArgs e)
{
Y += Math.Sin(Q)*10;
X += Math.Cos(Q)*10;
this.pictureBox1.Location = new Point((int)X, (int)Y);
if (flag==true)
{
pictureBox1.Image = imageList1.Images[0];
flag = false;
}
else
{
flag = true;
pictureBox1.Image = imageList1.Images[1];
}
}
}
}
相关文章推荐
- 【Android】一个浏览图片的Android库的实现,可以移动、缩放图片以及滑动切换
- 【Ubuntu】Ubuntu16.04移动Unity位置和点击图片最小化
- 点击图片随机移动位置
- 移动View位置时,修改图片资源导致View在原位置闪烁的问题
- JQuery实现移动9宫格图片自由切换移动
- 双击放大图片 手指移动图片位置
- js图片库(无缝循环切换,左右移动效果)
- android 控件的位置移动处理,利用bitmap来不断更新图片位置
- 在WPF里面实现以鼠标位置为中心缩放移动图片
- HTML里如何移动图片位置
- JavaScript 控制图片改变重叠顺序的代码(鼠标移动切换)
- 移动手机APP手指滑动切换图片特效附源码下载
- 切换同一个位置上的图片setCompoundDrawables
- 让图片直线移动到鼠标点击位置,类似游戏里的人物走动!
- Android的AnimationSet动画实现图片的轮播,移动和切换可以自定义时间
- 鼠标移动到一个位置,显示图片(类似qq的隐藏显示功能)
- 页面同一位置重叠多张图片,鼠标点击切换特效
- 移动手机APP手指滑动切换图片特效附源码下载
- winform中图片的左移 右移并记忆移动的位置
- Qt drag(拖动图片)时如何设置图片某个位置与鼠标绑定在一起移动