基本信息
源码名称:C# 虚拟桌面(实现多个虚拟桌面并行运行)
源码大小:0.45M
文件格式:.rar
开发语言:C#
更新时间:2015-09-22
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
还有休眠、待机等功能
还有休眠、待机等功能
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace VirtualDesktop
{
public partial class frmMain : Form
{
private VirtualDesktopHelper vdtHelper;
public frmMain()
{
InitializeComponent();
vdtHelper = new VirtualDesktopHelper(this);
//注册系统热键
vdtHelper.RegisterHotKey(VirtualDesktopHelper.ModifyKeys.Ctrl);
this.Opacity = 0f;
}
private void btnClick(object sender, EventArgs e)
{
int targetGroupIndex = 0;
if (sender is Button)
{
Button clickedBtn = sender as Button;
switch (clickedBtn.Text)
{
case "休眠":
Application.SetSuspendState(PowerState.Hibernate, true, false);
break;
case "待机":
Application.SetSuspendState(PowerState.Suspend, true, false);
break;
default:
targetGroupIndex = Int32.Parse(clickedBtn.Text) - 1;
break;
}
}
else if (sender is ToolStripMenuItem)
{
ToolStripMenuItem tsmItem = sender as ToolStripMenuItem;
targetGroupIndex = Int32.Parse(tsmItem.Text.Replace("桌面","")) - 1;
}
vdtHelper.SwitchGroup(targetGroupIndex);
}
private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
{
//缷载系统热键
vdtHelper.UnRegisterHotKey();
//恢复显示所有虚拟桌面组内的窗体
vdtHelper.Dispose();
}
protected override void WndProc(ref Message m)//监视Windows消息
{
const int WM_HOTKEY = 0x0312;//按快捷键
switch (m.Msg)
{
case WM_HOTKEY:
int pc = m.WParam.ToInt32() - VirtualDesktopHelper.HotKeyID;
if (pc >= 0 && pc < 9)
{
vdtHelper.SwitchGroup(pc);
}
else if (pc == -1)
{
if (this.Opacity==1f)
{
this.Visible = false;
this.Opacity = 0f;
}
else
{
this.Visible = true;
this.Opacity = 1f;
}
}
//else if (pc == -2)
//{
// Application.SetSuspendState(PowerState.Hibernate, true, false);
//}
//else if (pc == -3)
//{
// Application.SetSuspendState(PowerState.Suspend, true, false);
//}
break;
}
base.WndProc(ref m);
}
private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void contextMenuStrip_Opening(object sender, CancelEventArgs e)
{
this.桌面1ToolStripMenuItem.Checked = vdtHelper.CurrentID == 0 ? true : false;
this.桌面2ToolStripMenuItem.Checked = vdtHelper.CurrentID == 1 ? true : false;
this.桌面3ToolStripMenuItem.Checked = vdtHelper.CurrentID == 2 ? true : false;
this.桌面4ToolStripMenuItem.Checked = vdtHelper.CurrentID == 3 ? true : false;
this.桌面5ToolStripMenuItem.Checked = vdtHelper.CurrentID == 4 ? true : false;
this.桌面6ToolStripMenuItem.Checked = vdtHelper.CurrentID == 5 ? true : false;
this.桌面7ToolStripMenuItem.Checked = vdtHelper.CurrentID == 6 ? true : false;
this.桌面8ToolStripMenuItem.Checked = vdtHelper.CurrentID == 7 ? true : false;
this.桌面9ToolStripMenuItem.Checked = vdtHelper.CurrentID == 8 ? true : false;
}
private void ShowFormMenuItem_Click(object sender, EventArgs e)
{
if (this.Opacity == 1f)
{
this.Visible = false;
this.Opacity = 0f;
}
else
{
this.Visible = true;
this.Opacity = 1f;
}
}
}
}