桌面小宠物项目开发_C# 桌面宠物 示例源码(透明窗体)
【实例简介】
可以按时叫你吃饭可以控制在桌面上行走等等等等。。。。。。。。。。。。
【实例截图】
【核心代码】
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Media;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using SpeechLib;
using System.Threading;
namespace 不做单身狗__桌面宠物
{
public partial class cw : Form
{
private string a;
bool run = false,bf=false ;
SoundPlayer zl;
Form1 f = new Form1();
public cw(string str)
{
InitializeComponent();
this.a = str;
TransparencyKey = BackColor;
pictureBox1.Focus();
}//构造函数
private void cw_Load(object sender, EventArgs e)//加载宠物
{
zheng();
ts.Start();
}
#region 宠物动作
public void qian()
{
if (run == false)
{
System.Reflection.Assembly assembly;
assembly = System.Reflection.Assembly.GetExecutingAssembly();
zl = new SoundPlayer(Properties.Resources.走路);
zl.PlayLooping();//循环播放
if (a == "男1") { pictureBox1.Image = Properties.Resources.男1前; }
if (a == "男2") { pictureBox1.Image = Properties.Resources.男2前; }
if (a == "男3") { pictureBox1.Image = Properties.Resources.男3前; }
if (a == "女1") { pictureBox1.Image = Properties.Resources.女1前; }
if (a == "女2") { pictureBox1.Image = Properties.Resources.女2前; }
if (a == "女3") { pictureBox1.Image = Properties.Resources.女3前; }
run = true;
}
//pictureBox1.Top = pictureBox1.Top -1;
panel1.Top = panel1.Top -1;
}
public void hou()
{
if (run == false)
{
System.Reflection.Assembly assembly;
assembly = System.Reflection.Assembly.GetExecutingAssembly();
zl = new SoundPlayer(Properties.Resources.走路);
zl.PlayLooping();//循环播放
bf = true;
if (a == "男1") { pictureBox1.Image = Properties.Resources.男1后; }
if (a == "男2") { pictureBox1.Image = Properties.Resources.男2后; }
if (a == "男3") { pictureBox1.Image = Properties.Resources.男3后; }
if (a == "女1") { pictureBox1.Image = Properties.Resources.女1后; }
if (a == "女2") { pictureBox1.Image = Properties.Resources.女2后; }
if (a == "女3") { pictureBox1.Image = Properties.Resources.女3后; }
run = true;
}
//pictureBox1.Top = pictureBox1.Top 1;
panel1.Top =panel1 .Top 1;
}
public void zuo()
{
if (run == false)
{
System.Reflection.Assembly assembly;
assembly = System.Reflection.Assembly.GetExecutingAssembly();
zl = new SoundPlayer(Properties.Resources.走路);
zl.PlayLooping();//循环播放
bf = true;
if (a == "男1") { pictureBox1.Image = Properties.Resources.男1左; }
if (a == "男2") { pictureBox1.Image = Properties.Resources.男2左; }
if (a == "男3") { pictureBox1.Image = Properties.Resources.男3左; }
if (a == "女1") { pictureBox1.Image = Properties.Resources.女1左; }
if (a == "女2") { pictureBox1.Image = Properties.Resources.女2左; }
if (a == "女3") { pictureBox1.Image = Properties.Resources.女3左; }
run = true;
}
//pictureBox1.Left = pictureBox1.Left - 1;
panel1.Left = panel1.Left - 1;
}
public void you()
{
if (run == false)
{
System.Reflection.Assembly assembly;
assembly = System.Reflection.Assembly.GetExecutingAssembly();
zl = new SoundPlayer(Properties.Resources.走路);
zl.PlayLooping();//循环播放
bf = true;
if (a == "男1") { pictureBox1.Image = Properties.Resources.男1右; }
if (a == "男2") { pictureBox1.Image = Properties.Resources.男2右; }
if (a == "男3") { pictureBox1.Image = Properties.Resources.男3右; }
if (a == "女1") { pictureBox1.Image = Properties.Resources.女1右; }
if (a == "女2") { pictureBox1.Image = Properties.Resources.女2右; }
if (a == "女3") { pictureBox1.Image = Properties.Resources.女3右; }
run = true;
}
//pictureBox1.Left = pictureBox1.Left 1;
panel1.Left = panel1.Left 1;
}
public void zheng()
{
if (a == "男1") { pictureBox1.Image = Properties.Resources.男1正; }
if (a == "男2") { pictureBox1.Image = Properties.Resources.男2正; }
if (a == "男3") { pictureBox1.Image = Properties.Resources.男3正; }
if (a == "女1") { pictureBox1.Image = Properties.Resources.女1正; }
if (a == "女2") { pictureBox1.Image = Properties.Resources.女2正; }
if (a == "女3") { pictureBox1.Image = Properties.Resources.女3正; }
}
public void fa()
{
if (run == false)
{
System.Reflection.Assembly assembly;
assembly = System.Reflection.Assembly.GetExecutingAssembly();
zl = new SoundPlayer(Properties.Resources.Q);
zl.PlayLooping();//循环播放
bf = true;
if (a == "男1") { pictureBox1.Image = Properties.Resources.男1法; }
if (a == "男2") { pictureBox1.Image = Properties.Resources.男2法; }
if (a == "男3") { pictureBox1.Image = Properties.Resources.男3法; }
if (a == "女1") { pictureBox1.Image = Properties.Resources.女1法; }
if (a == "女2") { pictureBox1.Image = Properties.Resources.女2法; }
if (a == "女3") { pictureBox1.Image = Properties.Resources.女3法; }
run = true;
}
}
#endregion
#region 拖动宠物
//是否正在拖拽
bool isDrag = false;
//鼠标按下坐标(control控件的相对坐标)
Point mouseDownPoint = Point.Empty;
//将被拖动的控件
private Control control;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
isDrag = true;
control = panel1; //pictureBox1;
if (e.Button == MouseButtons.Left)
{
mouseDownPoint = panel1.Location;
}
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (isDrag)
{
Point mousePos = new Point(control.Location.X, control.Location.Y);
mousePos.Offset(e.X, e.Y);
mousePos.X -= this.control.Width / 7;
mousePos.Y -= this.control.Height / 7;
control.Location = mousePos;
}
}
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
if (isDrag)
{
isDrag = false;
}
}
#endregion
private void cw_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)//执行动作
{
if (e.KeyValue == 87) { qian(); }
if (e.KeyValue == 83) { hou (); }
if (e.KeyValue == 65) { zuo (); }
if (e.KeyValue == 68) { you (); }
if (e.KeyValue == 81) { fa (); }
if (e.KeyValue == 27) {Application.Exit();ts.Abort(); }
}
private void cw_KeyUp(object sender, KeyEventArgs e)//结束动作
{
zheng();
if (bf == true)
{ zl.Stop();}
run = false ;
}
Thread ts = new Thread(Function.Ts);//按时提示功能
private void pictureBox1_DoubleClick(object sender, EventArgs e)//对话
{
SpVoice voice = new SpVoice();
voice.Voice = voice.GetVoices(string.Empty, string.Empty).Item(0);
voice.Speak("亲爱的,好期待和您讲话啊!再耐心等等吧!等我爸爸给我这个功能!", SpeechVoiceSpeakFlags.SVSFDefault);
}
}
}
桌面小宠物项目开发_C# 桌面宠物 示例源码(透明窗体)相关推荐
- Java项目开发—坦克大战(附源码)
今天给小伙伴们分享一个坦克大战游戏的详细编写流程,即使你是刚入门java的新手,只要你简单掌握了该游戏所需要的javase基础知识,便可以跟随教程视频完成属于你自己的坦克大战游戏!同时还可以加深和巩固 ...
- Java项目开发——家教系统(附源码)
该系统是一款专门为家教中介开发的管理软件,它功能相对完善,分类合理. 包括教员管理 顾客管理 试教管理 授课管理 回访管理 积分评优六个模块 可以有效提高工作效率.此外系统界面简洁优美,操作直观简单. ...
- 多人对战小游戏快速开发实例分享(附源码)
前言:该游戏项目主要是基于前端引擎Cocos Creator开发,涉及后端联网的部分,则通过接入Matchvs SDK完成快速开发工作. 准备工作:相关引擎工具引擎下载及指南 Matchvs Java ...
- 微信小程序云开发打车系统实现附源码
功能介绍: 实现用户,司机端,用户微信授权登录,司机注册,在线约车,位置定位,订单管理,司机抢单等 部分功能截图: 主页预约界面: 预约界面 订单界面 个人界面 源代码获取: 毕业设计,一周类做完,毕 ...
- [转载]小软件项目开发的管理(好长)
小软件项目开发的管理 创建成功的工程 成功项目管理的秘密 更好地领导一个项目的诀窍 参与变革,走向成功 CMM/TSP/PSP讲义稿 开发流程中的可用性 软件开发的管理和控制 如何组织软件开发团队 软 ...
- DAY10微信小程序项目开发技术总结
一.每日实习任务 1.网页基础知识(html,css,js) 今天老师为我们介绍讲解了网页基础知识(html,css,js).首先,我们安装了谷歌浏览器及sublime text.老师为我们介绍了ht ...
- 基于 uni-app 和 uni-cloud 小程序项目开发实战
基于 uni-app 和 uni-cloud 小程序项目开发实战 前言 一.技术栈 二.环境搭建 三.项目功能介绍 1.地图地点搜索及路线规划 2.uniCloud服务空间 3.AI识图 4.上拉框组 ...
- 微信小程序项目开发知识点
小程序项目开发-商品详情跳转 介绍 商品列表跳转 url传参 代码示例 返回示例 返回参数说明 小知识点 第二步:设定商品详情的js,来获取到cid的参数 微信开发者工具设置 总结 介绍 本文讲解小程 ...
- 微信小程序项目开发实战:用WePY、mpvue、Taro打造高效的小程序》(笔记4)支持React.js语法的Taro框架
Taro的编写代码方式和mpvue.WePY框架最大的一个差别就是,Taro并不是基于Vue.js的语法规范,而是遵循React语法规范,它采用与React一致的组件化思想,组件生命周期与React保 ...
最新文章
- php 将数组导出excel,#php 怎样将 数组导出excel文件#前端导出excel表格
- php cgi漏洞,CGI漏洞攻击合集上
- ValueError: Unknown initializer: GlorotUniform
- C++ 类模板二(类模版与友元函数)
- Mybatis高级-resultMap之collection聚集
- (STL,set)安迪的第一个字典
- 那些不是秘密的微信earning方法
- UVA 10886 Standard Deviation
- python operator 多属性排序_Python爬取高颜值美女(爬虫+人脸检测+颜值检测)你能打几分?...
- 模板之家php mysql_PHP+APACHE+MYSQL安装方法
- 全国python一级考试_全国青少年软件编程(python)等级考试试卷(一级)
- Vue前后端交互实现图书管理功能
- dubbo与zookeeper
- 乔安监控电脑客户端_公司上网监控使用安装电脑监控软件?
- iPXE部署Ubuntu无盘系统
- Houdini vex用勾股定理推算椭圆运动轨迹
- 20162327WJH《程序设计与数据结构》课程总结
- gsm 收发短信 打电话
- 量化学习:大数据时代的学习方式
- 计算机专业考研面试题大全———持续更新中
热门文章
- 开帖:做网络试验如何选择模拟器eNSP,PNET,EVE-NG,GNS3,cisco
- 讨论▍数据分析师(非数据挖掘,偏业务)是青春饭吗?
- android 画图 出界,android:字符串索引出界
- 选股绝招[如何抓住狂涨的黑马]
- 自然语言处理NLP星空智能对话机器人系列:深入理解Transformer自然语言处理 Matching datasets and tokenizers
- XML 文件加密与解密
- 基于部分卷积Pconv的图片修复
- JavaScript实现令人放松的小游戏_艾孜尔江撰
- 【获取路径grob()】学习笔记
- java多用户商城 微商城 大型B2B2C商城平台系统源码