C#实现相似QQ的隐藏浮动窗口、消息闪动
功能简单介绍
当语音客服系统登录成功进入主界面时,本聊天工具将会自己主动隐藏在左下角位置,当鼠标移动到左下角时,自己主动弹出,当鼠标移开聊天窗口时,自己主动隐藏。假设想让聊天窗口固定在桌面。仅仅要拖动一下聊天窗口,让它不停留在边界位置就能够了。
隐藏和悬浮方式类型QQ。
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvem91eXVqaWUxMTI3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">
1. 系统主界面
当点击最小化button时,
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvem91eXVqaWUxMTI3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt=""> 在电脑右下角会显示任务图标,点击任务图标,将会在左下角位置弹出。
主界面各部分介绍:
a) 消息列表:该区域的功能主要是显示消息记录。
b) 发送消息:输入要发送的消息进行发送,默认群聊。输入消息后,按回车键或者点击“发送”button,将进行消息发送。
c) 坐席人员:显示全部已登录客服系统的坐席人员,显示方式:名称(状态)
d) 通知:记录坐席上下线记录
实现浮动:
#region 停靠悬浮
internal AnchorStyles StopDock = AnchorStyles.None;
private void StopRectTimer_Tick(object sender, EventArgs e)
{
//假设鼠标在窗口上。则依据停靠位置显示整个窗口
if (this.Bounds.Contains(Cursor.Position))
{
switch (this.StopDock)
{
case AnchorStyles.Top:
this.Location = new Point(this.Location.X, 0);
break;
case AnchorStyles.Bottom:
this.Location = new Point(this.Location.X, Screen.PrimaryScreen.Bounds.Height - this.Height);
break;
case AnchorStyles.Left:
this.Location = new Point(0, this.Location.Y);
break;
case AnchorStyles.Right:
this.Location = new Point(Screen.PrimaryScreen.Bounds.Width - this.Width, this.Location.Y);
break;
}
}
else //假设鼠标离开窗口,则依据停靠位置隐藏窗口,但须留出部分窗口边缘以便鼠标选中窗口
{
switch (this.StopDock)
{
case AnchorStyles.Top:
this.Location = new Point(this.Location.X, (this.Height - 3) * (-1));
break;
case AnchorStyles.Bottom:
this.Location = new Point(this.Location.X, Screen.PrimaryScreen.Bounds.Height - 5);
break;
case AnchorStyles.Left:
this.Location = new Point((-1) * (this.Width - 3), this.Location.Y);
break;
case AnchorStyles.Right:
this.Location = new Point(Screen.PrimaryScreen.Bounds.Width - 2, this.Location.Y);
break;
}
}
}
private void MainFrm_LocationChanged(object sender, EventArgs e)
{
if (this.Top <= 0)
{
this.StopDock = AnchorStyles.Top;
}
else if (this.Bottom >= Screen.PrimaryScreen.Bounds.Height)
{
this.StopDock = AnchorStyles.Bottom;
}
else if (this.Left <= 0)
{
this.StopDock = AnchorStyles.Left;
}
else if (this.Left >= Screen.PrimaryScreen.Bounds.Width - this.Width)
{
this.StopDock = AnchorStyles.Right;
}
else
{
this.StopDock = AnchorStyles.None;
}
}
#endregion
有消息来时,不断闪动图标。加入一个定时器,不断切换该图标,监听,消息列表,假设有文字改变。则开启定时器。
int i = 0; //先设置一个全局变量 i ,用来控制图片索引,然后创建定时事件,双击定时控件就能够编辑
private Icon ico1 = new Icon("img/q1.ico");
private Icon ico2 = new Icon("img/q2.ico"); //两个图标 切换显示 以达到消息闪动的效果 //定时器 不断闪动图标
private void timer1_Tick(object sender, EventArgs e)
{
//假设i=0则让任务栏图标变为透明的图标而且退出
if (i < 1)
{
this.notifyIcon1.Icon = ico2;
i++;
return;
}
//假设i!=0,就让任务栏图标变为ico1,并将i置为0;
else
this.notifyIcon1.Icon = ico1;
i = 0;
} //有消息来时 闪动
private void ChatRoomMsg_TextChanged(object sender, EventArgs e)
{
this.timer1.Enabled = true;
} private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
{
if (this.timer1.Enabled)
{
this.timer1.Enabled = false;
}
if (e.Button == MouseButtons.Left && this.WindowState == FormWindowState.Minimized)
{
//推断是否已经最小化于托盘
if (WindowState == FormWindowState.Minimized)
{
this.StopRectTimer.Enabled = false; StopDock = AnchorStyles.None;
//还原窗口显示
WindowState = FormWindowState.Normal;
//激活窗口并给予它焦点
//this.Activate();
//任务栏区显示图标
this.ShowInTaskbar = false;
//托盘区图标隐藏
//notifyIcon1.Visible = true; //默认显示 左下角
this.Left = 0;
this.Top = Screen.PrimaryScreen.WorkingArea.Height - this.Height;
}
}
}
C#实现相似QQ的隐藏浮动窗口、消息闪动的更多相关文章
- 7、菜单栏、工具栏、状态栏、浮动窗口、TextEdit
新建项目,基类选择QMainWindow,不勾选ui mainwindow.cpp代码: #include "mainwindow.h" #include <QMenu ...
- Jquery 类似新浪微博,鼠标移到头像,用浮动窗口显示用户信息,已做成一个jquery插件
请注意!!!!! 该插件demo PHP 的 demo下载 C#.NET的demo下载 需要如下图, 1.鼠标移动到头像DIV时,Ajax获取数据,并让浮动DIV显示出来. 2.鼠标可以移动到上面浮 ...
- Android 浮动窗口进阶——画中画,浮动视频(附Demo)
今天继续上一篇Android顶层窗口.浮动窗口的进阶应用.上一篇主要讲解了WindowManager服务和如何使用WindowManager编写一个顶层窗口.今天主要是讲讲如何在顶层窗口里面播放视频, ...
- Android 实现顶层窗口、浮动窗口(附Demo)
做过Window程序开发的朋友应该都知道,我们要把程序窗口置顶很简单,只要设置一些窗口属性即可.但是到了Android,你无法简单设置一个属性,就让Android的Activity置顶.因为只要有新的 ...
- 转载:隐藏bat窗口在后台运行(找了好久)
https://mp.weixin.qq.com/s?__biz=MzU4MjY1ODA3Nw==&mid=2247484277&idx=1&sn=8b5d98aab3827b ...
- 系统右键菜单添加剪贴板清空项(隐藏DOS窗口)
@color 0A @title 系统右键菜单添加剪贴板清空项(隐藏DOS窗口) by wjshan0808 @echo off echo 请输入右键菜单名称 set /p name= ::创建本机A ...
- WinForm------弹出MessageBox窗口的同时隐藏当前窗口
private void Btn_OK_Click(object sender, EventArgs e) { this.Hide(); //隐藏当前窗口 MessageBox.Show(" ...
- (转)JS浮动窗口(随浏览器滚动而滚动)
原文:http://hi.baidu.com/aiyayaztt/item/4201c55a6b729dced2e10c79 JS浮动窗口(随浏览器滚动而滚动) 往往用于一些联系方式,互动平台模块,随 ...
- C#隐式运行CMD命令(隐藏命令窗口)
原文 C#隐式运行CMD命令(隐藏命令窗口) 本文实现了C#隐式运行CMD命令的功能.下图是实例程序的主画面.在命令文本框输入DOS命令,点击"Run"按钮,在下面的文本框中输出运 ...
随机推荐
- Android之PowerManager&BatteryManager
PowerManager是Android平台中用于管理控制设备电源状态.重启.休眠状态.唤醒等,使用该API会影响到电池的待机时间,所以无非必要,一般不要使用. 在PowerManager中有几个比较 ...
- setw()函数使用
在C++中,setw(int n)用来控制输出间隔.例如:cout<<'s'<<setw(8)<<'a'<<endl;则在屏幕显示s a ...
- Cocos2d-x教程(31)-TableView的滚动栏
欢迎增加Cocos2d-x 交流群:193411763 转载时请注明原文出处 :http://blog.csdn.net/u012945598/article/details/38587659 在非常 ...
- 给MySQL中某表增加一个新字段,设为主键值为自动增长。
alter table test_tb add ID int(10) primary key AUTO_INCREMENT; 设定完成后,原有记录的该字段会增加并自动设上值.以后的值会在已有记录的最 ...
- ZH奶酪:VirtualBox虚拟机与主机ping不通
6.进入虚拟机的Ubuntu(以下简称VBUbuntu),在VBUbuntu中用ifconfig查看ip地址,在Windows7中用ipconfig查看ip地址. 在VBUbuntu中ping Win ...
- lnmp环境的使用教程
lnmp环境的使用 安装的软件都安装到了:/usr/local 管理nginx service nginx start|stop|restart|reload 管理mysql 直接执行mysql即可登 ...
- osx下查看jar文件
jar是java class的打包文件,我们能够将自己的项目打包为jar文件执行,也能够打包后当做第三方包查看,有时候我们须要查看一下一个jar文件里是否还有某个类以及对应的包,我们能够採用下面两种方 ...
- DOS批处理高级教程
转载-->http://blog.csdn.net/lanbing510/article/details/7461073 前言 本教程主要引用伤脑筋版主的系列文章,同时参考引用[英雄]教程等其他 ...
- spring boot更换日志为log4j2
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring- ...
- VC++程序员如何做好界面
本屌丝在新春放假期间闲来无事,在各大编程论坛溜达了一圈.发现年前的帖子中,有VC++程序员在界面开发方面遇到了很多苦恼,有抱怨界面工作不好做的,有抱怨用错了界面库的,也有紧急求得技术问题帮助的.看到这 ...