先放2张图来晒晒

左边的一张是2009的效果,右边的个是2010效果.

首先做好准备工作.将System.Windows.Forms.UI.dll 添加到项目引用.

Steup 1:在命名空间中加入using System.Windows.Forms.UI;在窗体的构造器中加入以下代码:

Control.CheckForIllegalCrossThreadCalls = false;
base.TopMost = true;
base.DoubleBuffered = true;
base.Size = new Size(235, 329);
base.MinimumSize = new Size(235, 329);
base.Text = "QQ2009";

注意:以上代码需要放在 InitializeComponent(); 之后.

Steup 2:开始我们的山寨工作^_^

添加一个私有字段.private UIForm guifundation;

重新窗体的OnLoad事件如入以下代码:

guifundation = new UIForm(
this,
new Rectangle(38, 122, 70, 142),
Res.SYS_MAIN_BACK,
Res.SYS_CLOSE,
Res.SYS_MIN,
Res.SYS_MAX,
Res.SYS_RESTORE);

在这里初始化窗口界面,第一个参数是当前窗体.

第二个参数是一个绘图区域(x,y)点交叉点和(W,H)交叉点

第三个参数就是窗体的背景图片.就是上面那个(需去掉线条的文字的)

第四个参数是关闭按钮图片图片状态为4个状态(正常,悬浮,按下,失效)

如果要显示最小化按钮则设置第五个参数,否则为null,六七参数则是最大化和还原按钮.

好了现在窗口初始化完毕了.现在开始添加窗体上的各个控件.

由于代码挺多的我就写一个案例就好了.

添加一个头像:

UIImageAnimator head = new UIImageAnimator();
head.SetBounds(new Rectangle(5, 23, 52, 52));
head.Image = Res.BUTTON_HEAD;//头像图片
head.AnimateBitmap = Res.DEFAULT_HEAD;//头像边框[2个状态] 
head.ToolTipText = "修改个人资料";
guifundation.Controls.Add(head);

登录密码框:

UIExtendComboBox comboxpwd = new UIExtendComboBox();
comboxpwd.CanPressIcon = true;
comboxpwd.UseSystemPasswordChar = true;//设置为密码显示
comboxpwd.DropDownStyle = ComboBoxStyle.Simple;//组合控件的下拉样式
comboxpwd.SetBounds(new Rectangle(62, 115, 186, 24));
comboxpwd.ArrowImage = Res.EXPEND_INPUT_COMBOX_ARROW;//按钮图片(四个状态和关闭按钮一样)
comboxpwd.Image = IRes.RES_KEYBOARD;//最左边的屏幕键盘图标
comboxpwd.BackImage = Res.FRAME_BORDER;//边框图片(2个状态1:正常,2:激活)
guifoudation.Controls.Add(comboxpwd);

using System; using System.Drawing; using System.Windows.Forms; using System.ComponentModel; using System.Windows.Forms.UI; using System.Collections.Generic; namespace TXGUIFundation { public class UIMAINFORM : Form { public UIMAINFORM() { InitializeComponent(); Control.CheckForIllegalCrossThreadCalls = false; base.TopMost = true; base.DoubleBuffered = true; base.Size = new Size(235, 329); base.MinimumSize = new Size(235, 329); base.Text = "QQ2009"; DeskPanel.Icon = Icon.FromHandle(IRes.RES_MGR.GetHbitmap()); guifundation = new UIForm( this, new Rectangle(38, 122, 70, 142), Res.SYS_MAIN_BACK, Res.SYS_CLOSE, Res.SYS_MIN, Res.SYS_MAX, Res.SYS_RESTORE); UIImageAnimator head = new UIImageAnimator(); head.SetBounds(new Rectangle(5, 23, 52, 52)); head.Image = Res.BUTTON_HEAD; head.AnimateBitmap = Res.DEFAULT_HEAD; head.ToolTipText = "修改个人资料"; guifundation.Controls.Add(head); UIButton btnmail = new UIButton(); btnmail.TabStop = false; btnmail.SetBounds(new Rectangle(9, 74, 18, 18)); btnmail.ImageCount = 3; btnmail.Image = Res.ICON_BUTTON; btnmail.ToolTipText = "打开我的邮箱"; btnmail.Icon = Res.EMAIL; guifundation.Controls.Add(btnmail); UIButton btnmsgbox = new UIButton(); btnmsgbox.TabStop = false; btnmsgbox.SetBounds(new Rectangle(190, 74, 18, 18)); btnmsgbox.ImageCount = 3; btnmsgbox.Image = Res.ICON_BUTTON; btnmsgbox.ToolTipText = "打开消息盒子"; btnmsgbox.Icon = Res.MSG_BOX; btnmsgbox.Anchor = AnchorStyles.Top | AnchorStyles.Right; guifundation.Controls.Add(btnmsgbox); UIButton btnskin = new UIButton(); btnskin.TabStop = false; btnskin.SetBounds(new Rectangle(212, 74, 18, 18)); btnskin.ImageCount = 3; btnskin.Image = Res.ICON_BUTTON; btnskin.ToolTipText = "更改外观"; btnskin.Icon = Res.COLOUR; btnskin.Anchor = AnchorStyles.Top | AnchorStyles.Right; guifundation.Controls.Add(btnskin); UIButtonText btntext = new UIButtonText(); btntext.SetBounds(new Rectangle(58, 46, 133, 21)); btntext.ImageCount = 3; btntext.Image = Res.ICON_BUTTON; btntext.Text = "Teens Against Tabacco Use"; btntext.ToolTipText = "Teens Against Tabacco Use"; btntext.Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left; guifundation.Controls.Add(btntext); UIMenuButton btnmenu = new UIMenuButton(); btnmenu.SetBounds(new Rectangle(56, 26, 30, 20)); btnmenu.ImageCount = 3; btnmenu.Image = Res.ICON_BUTTON; btnmenu.Icon = Res.STATUS_ONLINE; btnmenu.ArrowImage = Res.MENU_ARROW; btnmenu.ToolTipText = "声音:开启/r/n消息提醒框:关闭/r/n会话消息:任务栏头像闪动"; guifundation.Controls.Add(btnmenu); UIFoundation foundation = new UIFoundation(); foundation.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom; foundation.ScrollBar.ScrollBack = Res.SCROLL_BACK; foundation.ScrollBar.ScrollButton = Res.SCROLL_ARROW; foundation.ScrollBar.ScrollThumb = Res.SCROLL_THUMB; foundation.SetBounds(new Rectangle(34, 148, 200, 126)); guifundation.Controls.Add(foundation); #region <-WEATHER-> UIPictureBox weather = new UIPictureBox(); weather.Anchor = AnchorStyles.Top | AnchorStyles.Right; weather.SetBounds(new Rectangle(173, 22, 58, 46)); weather.Image = IRes.Big_1; weather.BorderColor = Color.Transparent; guifundation.Controls.Add(weather); #region <-WEATHER POPUP-> UIVisualPopup weatherhost = new UIVisualPopup(); UIWeatherPopup weatherpopu = new UIWeatherPopup(weather); weatherhost.Controls.Add(weatherpopu); weatherpopu.UpdateWeather(); weather.MouseEnter += delegate(object sender, EventArgs e) { if (!weatherhost.Droped) { weatherhost.Show(guifundation, ToolStripDropDownDirection.Right); } }; #endregion #endregion #region <-TIP WINDOW-> UIToolTipWindow tipwindow = new UIToolTipWindow(); tipwindow.Image = Res.CONTACT_TIP_BACK; tipwindow.ImageBound = new Rectangle(); UIRefreshPictureBox rereshpic = new UIRefreshPictureBox(); rereshpic.SetBounds(new Rectangle(6, 6, 80, 130)); rereshpic.Image = Res.DEFAULT_MAN_SHOW; rereshpic.ButtonImage = Res.REFRES_BUTTON; tipwindow.Controls.Add(rereshpic); head.MouseEnter += delegate(object sender, EventArgs e) { tipwindow.Show(head, ToolStripDropDownDirection.Left); }; #endregion #region<-FOUNDATION-> for (int i = 0; i < 10; i++) { FoundationNode node = new FoundationNode(); node.ArrowImage = Res.RES_FOLDER_ARROW; node.Text = "测试节点" + i; for (int j = 0; j < 5; j++) { FoundationChildNode childnode = new FoundationChildNode(); UIImageAnimator animator = new UIImageAnimator(); animator.AnimateBitmap = Res.DEFAULT_HEAD; animator.Image = Res.BUTTON_HEAD; animator.SetBounds(new Rectangle(5, 5, 45, 45)); childnode.Controls.Add(animator); childnode.MouseEnter += delegate(object sender, EventArgs e) { if (base.WindowState != FormWindowState.Maximized) { tipwindow.Show(sender as UIElement, ToolStripDropDownDirection.Left); } }; UILable link = new UILable(); link.SetBounds(new Rectangle(50, 0, 100, 20)); link.Text = "RedAlert" + i + "-" + j; if (j % 2 == 0) { link.ForeColor = Color.Red; } childnode.Controls.Add(link); UILable lable = new UILable(); lable.ForeColor = Color.Gray; lable.SetBounds(new Rectangle(50, 16, 100, 20)); lable.Text = "Teens Against Tabacco Use" + i + "-" + j; childnode.Controls.Add(lable); FoundationItem funmes = new FoundationItem(); funmes.SetBounds(new Rectangle(52, 33, 18, 18)); funmes.ToolTipText = "发送短信"; funmes.Image = IRes.RES_S_MOBILE; childnode.Controls.Add(funmes); FoundationItem funemail = new FoundationItem(); funemail.SetBounds(new Rectangle(70, 33, 18, 18)); funemail.ToolTipText = "发送邮件"; funemail.Image = IRes.RES_S_EMAIL; childnode.Controls.Add(funemail); node.Controls.Add(childnode); } foundation.Controls.Add(node); } #endregion #region<-TABLE-> UIFoundationTable table = new UIFoundationTable(); table.Image = Res.TABLE_BUTTON; table.ImageCount = 3; table.SetBounds(new Rectangle(37, 121, 197, 28)); table.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; guifundation.Controls.Add(table); UITableItem constact = new UITableItem(); constact.ImageArrow = Res.TAB_ARROW; constact.ImageCount = 3; constact.Icon = Res.CONTACT_ICON; constact.IconCount = 2; constact.ToolText = "联系人"; table.Items.Add(constact); UITableItem group = new UITableItem(); group.ImageArrow = Res.TAB_ARROW; group.ImageCount = 3; group.Icon = Res.GROUP_ICON; group.IconCount = 2; group.ToolText = "群/讨论组/社区"; table.Items.Add(group); UITableItem last = new UITableItem(); last.ImageArrow = Res.TAB_ARROW; last.ImageCount = 3; last.Icon = Res.RECE_ICON; last.IconCount = 2; last.ToolText = "最近联系人"; table.Items.Add(last); constact.ItemClick += delegate(object sender, EventArgs e) { if (!foundation.Visible) { foundation.Visible = true; foundation.Invalidate(); return; } if (foundation.Collapsed) { foundation.ExpandAll(); } else { foundation.CollapseAll(); } }; group.ItemClick += delegate(object sender, EventArgs e) { foundation.Visible = false; foundation.Invalidate(); }; group.ArrowClick += delegate(object sender, EventArgs e) { }; last.ItemClick += delegate(object sender, EventArgs e) { foundation.Visible = false; foundation.Invalidate(); }; last.ArrowClick += delegate(object sender, EventArgs e) { }; #endregion #region<-STANDER BAR-> UIStanderBar standerbar = new UIStanderBar(); standerbar.SetBounds(new Rectangle(2, 121, 33, 153)); standerbar.Image = Res.STANDER_BAR_BACK; standerbar.ItemImage = Res.STANDER_BUTTON; standerbar.ImageCount = 3; standerbar.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom; standerbar.Items.Add(new StanderItem(Res.QQBTN, "QQ好友面板")); standerbar.Items.Add(new StanderItem(Res.QQBTN, "网络硬盘")); standerbar.Items.Add(new StanderItem(Res.QQBTN, "财富控件")); standerbar.Items.Add(new StanderItem(Res.QQBTN, "滔滔面板")); standerbar.Items.Add(new StanderItem(Res.PANEL_CENTER, "界面管理器")); guifundation.Controls.Add(standerbar); UICheckBox btnhiden = new UICheckBox(); btnhiden.SetBounds(new Rectangle(2, 272, 15, 15)); btnhiden.Image = Res.TOOL_BAR_HIDEN_BUTTON; btnhiden.ImageCount = 8; btnhiden.Checked = true; btnhiden.ToolTipText = "收起侧边栏"; btnhiden.Anchor = AnchorStyles.Left | AnchorStyles.Bottom; guifundation.Controls.Add(btnhiden); btnhiden.Click += delegate(object sender, EventArgs e) { btnhiden.ToolTipText = btnhiden.Checked ? "收起侧边栏" : "展开侧边栏"; standerbar.Visible = btnhiden.Checked; standerbar.Invalidate(); table.Left = (btnhiden.Checked ? table.Left + standerbar.Width : table.Left - standerbar.Width); table.Width = (btnhiden.Checked ? table.Width - standerbar.Width : table.Width + standerbar.Width); table.Invalidate(); foundation.Left = table.Left; foundation.Width = table.Width; foundation.Invalidate(); if (btnhiden.Checked) { this.OnResize(EventArgs.Empty); } }; #endregion #region<-STATUS MENU-> UIContextMenu statumenu = new UIContextMenu(); TencentMenuRender render = new TencentMenuRender(); statumenu.Render = render; UIMenuItem menuline = new UIMenuItem("我在线上", Res.STATUS_ONLINE); menuline.ToolTipText = "表示希望好友看到您在线。/r/n声音:开启/r/n消息提醒框:开启/r/n会话消息:任务栏头像闪动"; UIMenuItem menuqme = new UIMenuItem("Q我吧", Res.STATUS_QME); menuqme.ToolTipText = "表示希望好友主动联系您。/r/n声音:开启/r/n消息提醒框:开启/r/n会话消息:自动弹出会话窗口"; UIMenuItem menuaway = new UIMenuItem("离开", Res.STATUS_AWAY); menuaway.ToolTipText = "表示离开,暂时无法处理消息。/r/n声音:开启/r/n消息提醒框:开启/r/n会话消息:任务栏头像闪动"; UIMenuItem menubusy = new UIMenuItem("忙碌", Res.STATUS_BUSY); menubusy.ToolTipText = "表示忙碌,不会及时处理消息。/r/n声音:开启/r/n消息提醒框:开启/r/n会话消息:任务栏显示气泡"; UIMenuItem menumute = new UIMenuItem("请勿打扰", Res.STATUS_MUTE); menumute.ToolTipText = "表示不想被打扰。/r/n声音:关闭/r/n消息提醒框:关闭/r/n会话消息:任务栏显示气泡"; UIMenuItem menuhide = new UIMenuItem("隐身", Res.STATUS_INVISIBLE); menuhide.ToolTipText = "表示好友看到您是离线的。/r/n声音:开启/r/n消息提醒框:开启/r/n会话消息:任务栏头像闪动"; UIMenuItem menuoffline = new UIMenuItem("离线", Res.STATUS_OFFLINE); menuoffline.ToolTipText = "端口与服务器的连接。"; UIMenuItem menuclosevoice = new UIMenuItem("关闭所有声音"); UIMenuItem menulock = new UIMenuItem("锁定QQ CTL+ALT+L", IRes.MAINMENU_LOCK); UIMenuItem menusysset = new UIMenuItem("系统设置..."); UIMenuItem menumyinfo = new UIMenuItem("我的资料..."); statumenu.Controls.Add(menuline); statumenu.Controls.Add(menuqme); statumenu.Controls.Add(menuaway); statumenu.Controls.Add(menumute); statumenu.Controls.Add(menuhide); statumenu.Controls.Add(menuoffline); statumenu.Controls.Add(new UIMenuSeparator()); statumenu.Controls.Add(menuclosevoice); statumenu.Controls.Add(new UIMenuSeparator()); statumenu.Controls.Add(menulock); statumenu.Controls.Add(new UIMenuSeparator()); statumenu.Controls.Add(menusysset); statumenu.Controls.Add(menumyinfo); btnmenu.Click += delegate(object sender, EventArgs e) { statumenu.Show(btnmenu.PointToScreen(new Point(btnmenu.Left, btnmenu.Bottom + 2))); }; #endregion #region <-TABLE CONSTACT MENU-> UIContextMenu constactmenu = new UIContextMenu(); constactmenu.Render = render; UIMenuItem constactshowhead = new UIMenuItem("头像显示"); UIMenuItem constactshowname = new UIMenuItem("名称显示"); UIMenuItem constactshowlist = new UIMenuItem("列表显示"); UIMenuItem constactshowsort = new UIMenuItem("排序显示"); UIMenuItem constactrefresh = new UIMenuItem("刷新好友列表"); UIMenuItem constactshowall = new UIMenuItem("显示全部联系人", true); UIMenuItem constactshowstrange = new UIMenuItem("显示陌生人分组", true); UIMenuItem constactshowblack = new UIMenuItem("显示黑名单", true); constactmenu.Controls.Add(constactshowhead); constactmenu.Controls.Add(constactshowname); constactmenu.Controls.Add(constactshowlist); constactmenu.Controls.Add(new UIMenuSeparator()); constactmenu.Controls.Add(constactshowsort); constactmenu.Controls.Add(constactrefresh); constactmenu.Controls.Add(new UIMenuSeparator()); constactmenu.Controls.Add(constactshowall); constactmenu.Controls.Add(new UIMenuSeparator()); constactmenu.Controls.Add(constactshowstrange); constactmenu.Controls.Add(constactshowblack); constact.ArrowClick += delegate(object sender, EventArgs e) { Point point = new Point(constact.ArrowBounds.Left, constact.ArrowBounds.Bottom); point = PointToScreen(point); constactmenu.Show(point); }; #endregion #region <-MAIN MENU-> UIVisualPopup mainmenu = new UIVisualPopup(); mainmenu.Render = new TencentMainMenuRender(); UIToolStripMenu stripmenu = new UIToolStripMenu(); stripmenu.SetBounds(new Rectangle(0, 0, 132, 285)); mainmenu.Controls.Add(stripmenu); UIMenuItem mainallservice = new UIMenuItem("所有服务", IRes.MAINMENI_ALLSERVICE); UIMenuItem mainvip = new UIMenuItem("QQ会员", IRes.MAINMENU_VIPHEAD); UIMenuItem maintool = new UIMenuItem("工具", IRes.MAINMENU_TOOLS); UIMenuItem mainsysset = new UIMenuItem("系统设置", IRes.MAINMENU_SETTING); UIMenuItem mainsafe = new UIMenuItem("安全中心", IRes.MAINMENU_SAFE); UIMenuItem mainhelp = new UIMenuItem("帮助", IRes.MAINMENU_HELPS); UIMenuItem mainoutlogin = new UIMenuItem("更改用户", IRes.MAINMENU_SWITCH); UIMenuItem mainlock = new UIMenuItem("锁定QQ", IRes.MAINMENU_LOCK); UIMenuItem mainclose = new UIMenuItem("退出", IRes.MAINMENU_EXIT); stripmenu.Controls.Add(mainallservice); stripmenu.Controls.Add(mainvip); stripmenu.Controls.Add(new UIMenuSeparator()); stripmenu.Controls.Add(maintool); stripmenu.Controls.Add(mainsysset); stripmenu.Controls.Add(new UIMenuSeparator()); stripmenu.Controls.Add(mainsafe); stripmenu.Controls.Add(mainhelp); stripmenu.Controls.Add(new UIMenuSeparator()); stripmenu.Controls.Add(mainoutlogin); stripmenu.Controls.Add(mainlock); stripmenu.Controls.Add(mainclose); #region <-ALL SERVICE-> UIMenuItem servicetencent = new UIMenuItem("腾讯网"); UIMenuItem serviceqzone = new UIMenuItem("QQ空间"); UIMenuItem servicepaipai = new UIMenuItem("拍拍购物"); UIMenuItem servicesoso = new UIMenuItem("SOSO搜索"); mainallservice.SubMenus.Add(servicetencent); mainallservice.SubMenus.Add(serviceqzone); mainallservice.SubMenus.Add(servicepaipai); mainallservice.SubMenus.Add(servicesoso); #endregion UIButton btnmainmenu = new UIButton(); btnmainmenu.SetBounds(new Rectangle(2, 286, 42, 42)); btnmainmenu.ImageCount = 3; btnmainmenu.TabStop = false; btnmainmenu.Image = Res.MENU_BUTTON; btnmainmenu.ToolTipText = "主菜单"; btnmainmenu.Anchor = AnchorStyles.Left | AnchorStyles.Bottom; guifundation.Controls.Add(btnmainmenu); btnmainmenu.Click += delegate(object sender, EventArgs e) { mainmenu.Show(btnmainmenu, ToolStripDropDownDirection.AboveLeft); }; #endregion } #region <-SubClass-> public class UIWeatherPopup : UIElement { public UIWeatherPopup(UIPictureBox ownerpopup) { this.ownerpopup = ownerpopup; Weather.WeatherProvider.ReadWeatherCompleted += new Weather.ReadWeatherEventHandler(ReadWeatherCompleted); base.Size = new Size(240, 210); datelink = new UILinkLable(); datelink.TextAlign = ContentAlignment.MiddleLeft; datelink.Text = "8月13日 农历七月初四 左撇子节"; datelink.SetBounds(new Rectangle(28, 7, 190, 16)); citylink = new UILinkLable(); citylink.TextAlign = ContentAlignment.MiddleLeft; citylink.SetBounds(new Rectangle(29, 30, 40, 16)); citylink.Text = "成都"; UILinkLable reportlink = new UILinkLable(); reportlink.TextAlign = ContentAlignment.MiddleLeft; reportlink.SetBounds(new Rectangle(8, 189, 120, 16)); reportlink.Text = "报告错误地理信息"; UILinkLable morelink = new UILinkLable(); morelink.TextAlign = ContentAlignment.MiddleLeft; morelink.SetBounds(new Rectangle(156, 189, 85, 16)); morelink.Text = "更多城市天气"; todaytem = new UILable(); todaytem.Text = "29℃"; todaytem.SetBounds(new Rectangle(91, 26, 150, 25)); todaytem.Font = new Font("Segoe UI", 14, FontStyle.Bold); todayweather = new UILable(); todayweather.Text = "阴"; todayweather.SetBounds(new Rectangle(91, 55, 150, 16)); todaywind = new UILable(); todaywind.Text = "北风"; todaywind.SetBounds(new Rectangle(91, 74, 150, 16)); UILable todaynoty = new UILable(); todaynoty.Text = "QQ提醒您:"; todaynoty.SetBounds(new Rectangle(7, 98, 65, 16)); scrolltext = new UIScrollText(); scrolltext.ScrollTitle = false; scrolltext.ForeColor = Color.Gray; scrolltext.Text = "白天以阴或多云天气为主,但稍会让您感到有点儿热 "; scrolltext.Enabled = true; scrolltext.SetBounds(new Rectangle(71, 98, 164, 16)); todaypic = new UIPictureBox(); todaypic.BorderColor = Color.Transparent; todaypic.SetBounds(new Rectangle(14, 49, 58, 46)); todaypic.Image = IRes.Big_1; WeatherItem todayitem = new WeatherItem(); todayitem.Image = Res.WEATHER_HOVER; todayitem.SetBounds(new Rectangle(2, 121, 78, 61)); #region <-DAY1-> picd1 = new UIPictureBox(); picd1.BorderColor = Color.Transparent; picd1.Image = IRes.Mid_1; picd1.SetBounds(new Rectangle(4, 127, 39, 40)); labd1 = new UILable(); labd1.Text = "今天"; labd1.SetBounds(new Rectangle(46, 133, 31, 16)); labtemd1 = new UILable(); labtemd1.Text = "25℃~31℃"; labtemd1.SetBounds(new Rectangle(10, 165, 70, 25)); todayitem.Controls.Add(labd1); todayitem.Controls.Add(picd1); todayitem.Controls.Add(labtemd1); #endregion WeatherItem tomoryitem = new WeatherItem(); tomoryitem.SetBounds(new Rectangle(80, 121, 78, 61)); #region <-DAY2-> picd2 = new UIPictureBox(); picd2.BorderColor = Color.Transparent; picd2.Image = IRes.Mid_2; picd2.SetBounds(new Rectangle(83, 127, 39, 40)); labd2 = new UILable(); labd2.Text = "明天"; labd2.SetBounds(new Rectangle(126, 133, 31, 16)); labtemd2 = new UILable(); labtemd2.Text = "23℃~27℃"; labtemd2.SetBounds(new Rectangle(87, 165, 70, 25)); tomoryitem.Controls.Add(labd2); tomoryitem.Controls.Add(picd2); tomoryitem.Controls.Add(labtemd2); #endregion WeatherItem nexttomoryitem = new WeatherItem(); nexttomoryitem.Image = Res.WEATHER_HOVER; nexttomoryitem.SetBounds(new Rectangle(161, 121, 76, 61)); #region <-DAY3-> picd3 = new UIPictureBox(); picd3.BorderColor = Color.Transparent; picd3.Image = IRes.Mid_3; picd3.SetBounds(new Rectangle(162, 127, 39, 40)); labd3 = new UILable(); labd3.Text = "后天"; labd3.SetBounds(new Rectangle(205, 133, 31, 16)); labtemd3 = new UILable(); labtemd3.Text = "22℃~29℃"; labtemd3.SetBounds(new Rectangle(167, 165, 70, 25)); nexttomoryitem.Controls.Add(labd3); nexttomoryitem.Controls.Add(picd3); nexttomoryitem.Controls.Add(labtemd3); #endregion base.Controls.Add(datelink); base.Controls.Add(citylink); base.Controls.Add(reportlink); base.Controls.Add(morelink); base.Controls.Add(todaytem); base.Controls.Add(todayweather); base.Controls.Add(todaywind); base.Controls.Add(todaynoty); base.Controls.Add(scrolltext); base.Controls.Add(todaypic); base.Controls.Add(todayitem); base.Controls.Add(tomoryitem); base.Controls.Add(nexttomoryitem); } #region<-Instance Fields-> private UILinkLable datelink; private UILinkLable citylink; private UILable todaytem; private UILable todayweather; private UILable todaywind; private UIScrollText scrolltext; private UIPictureBox todaypic; private UIPictureBox picd1; private UILable labd1; private UILable labtemd1; private UIPictureBox picd2; private UILable labd2; private UILable labtemd2; private UIPictureBox picd3; private UILable labd3; private UILable labtemd3; private UIPictureBox ownerpopup; #endregion #region<-Methodes-> public class WeatherItem : UIElement { protected override void OnMouseEnter(EventArgs e) { base.OnMouseEnter(e); ElementState = PaletteState.Tracking; base.Invalidate(); } protected override void OnMouseLeave(EventArgs e) { base.OnMouseLeave(e); ElementState = PaletteState.Normal; base.Invalidate(); } protected override void OnPaint(PaintEventArgs e) { if (ElementState == PaletteState.Tracking) { if (base.Image != null) { e.Graphics.DrawImage(base.Image, ClientRectangle); } } base.OnPaint(e); } } private void ReadWeatherCompleted(List<Weather.WeatherData> datalist) { if (datalist == null) return; datelink.Text = string.Format("{0} {1}", datalist[0].Time, datalist[0].DateName); citylink.Text = datalist[0].CityName; todaytem.Text = datalist[0].MaxTemperature; todayweather.Text = datalist[0].Weather; todaywind.Text = datalist[0].Wind; scrolltext.Text = datalist[0].Remark; todaypic.Image = IRes.ResourceManager.GetObject("Big_" + (datalist[0].ImageIndex)) as Image; if (ownerpopup != null) { ownerpopup.Image = todaypic.Image; } picd1.Image = IRes.ResourceManager.GetObject("Mid_" + (datalist[0].ImageIndex)) as Image; labtemd1.Text = datalist[0].Temperature; picd2.Image = IRes.ResourceManager.GetObject("Mid_" + (datalist[1].ImageIndex)) as Image; labtemd2.Text = datalist[1].Temperature; picd3.Image = IRes.ResourceManager.GetObject("Mid_" + (datalist[2].ImageIndex)) as Image; labtemd3.Text = datalist[2].Temperature; } private void OnLoadWeather(object sender, EventArgs e) { Weather.WeatherProvider.ReadWeatherAsync(); } private void AsyncHandler(IAsyncResult ar) { EventHandler handler = ar.AsyncState as EventHandler; if (handler != null) handler.EndInvoke(ar); } public void UpdateWeather() { EventHandler handler = new EventHandler(OnLoadWeather); AsyncCallback callback = new AsyncCallback(AsyncHandler); handler.BeginInvoke(null, null, callback, handler); } protected override void OnPaint(PaintEventArgs e) { using (Bitmap bmp = Res.WEATHER_TIPBGK) { if (base.Parent is UIVisualPopup) { ((UIVisualPopup)base.Parent).Region = Render.CalculateRegion(bmp, Color.Fuchsia); } e.Graphics.DrawImage(bmp, e.ClipRectangle); } base.OnPaint(e); } #endregion } #endregion #region <-Instance Fields-> private UIForm guifundation; private NotifyIcon DeskPanel; private IContainer components = null; #endregion #region <-Events-> #endregion #region <-Properties-> #endregion #region <-Methodes-> /// <summary> /// 设计器支持所需的方法 - 不要 /// 使用代码编辑器修改此方法的内容。 /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.DeskPanel = new System.Windows.Forms.NotifyIcon(this.components); this.SuspendLayout(); // // DeskPanel // this.DeskPanel.Text = "GUIFoundation"; this.DeskPanel.Visible = true; // // MAINFORM // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.ClientSize = new System.Drawing.Size(284, 262); this.DoubleBuffered = true; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Name = "MAINFORM"; this.ShowIcon = false; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.ResumeLayout(false); } /// <summary> /// 清理所有正在使用的资源。 /// </summary> /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } protected override void OnPaint(PaintEventArgs e) { using (Bitmap bmp = (guifundation.Active ? Res.TITLE_ACTIVE : Res.TITLE_NOACTIVE)) { e.Graphics.DrawImage(bmp, new Rectangle(4, 4, bmp.Width, bmp.Height)); } using (Font font = new Font("Tahoma", 9, FontStyle.Bold)) { using (Brush brush = new SolidBrush(ForeColor)) { e.Graphics.DrawString(Text, font, brush, new PointF(92, 28)); } } Graphics g = e.Graphics; using (Bitmap bmp = Res.AIO) { g.DrawImage(bmp, new Rectangle(Width - bmp.Width, SystemInformation.CaptionHeight - 5, bmp.Width, bmp.Height)); } using (Bitmap bmp = Res.MAIN_DOWN) { g.DrawImage(bmp, new Rectangle(Width - bmp.Width, Height - bmp.Height - 5, bmp.Width, bmp.Height)); } using (Bitmap bmp = Res.MAIN_CUTLINE) { g.DrawImage(bmp, new Rectangle(44, Height - 30, Width - 54, bmp.Height), 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel); } base.OnPaint(e); } #endregion } public class TencentMenuRender : UIToolStripRenderer { protected override void OnUIRenderToolStripBackground(UIToolStripRenderEventArgs e) { using (Bitmap bmp = base.RenderFrame( e.AffectedBounds, new Rectangle(30, 10, 37, 140), Res.MENU_BACK)) { if (e.ToolStrip is UIContextMenu) { ((UIContextMenu)e.ToolStrip).Region = base.CalculateRegion(bmp, Color.Fuchsia); e.Graphics.DrawImage(bmp, 0, 0); } } } protected override void OnUIRenderItemText(UIToolStripItemTextRenderEventArgs e) { if (e.Item is UIMenuItem) { Rectangle bound = e.TextRectangle; bound.X += 10; OnRenderText(e.Graphics, bound, e.Text, e.TextFont, e.TextColor, e.TextFormat); } } protected override void OnUIRenderMenuItemBackground(UIToolStripItemRenderEventArgs e) { if (e.Item is UIElement) { UIMenuItem item = e.Item as UIMenuItem; if (item == null) return; if (item.ElementState == PaletteState.Tracking || item.ElementState == PaletteState.Pressed) { Rectangle bound = item.ClientRectangle; bound.Inflate(-2, -2); base.RenderFrame(e.Graphics, bound, Res.MENU_SELECTED); } } } protected override void OnUIRenderArrow(UIToolStripArrowRenderEventArgs e) { e.Graphics.DrawImage(Res.MENU_ARROW, e.ArrowRectangle); } protected override void OnUIRenderItemCheck(UIToolStripItemImageRenderEventArgs e) { Rectangle bound = e.ImageRectangle; bound.X += 4; using (Bitmap bmp = Res.MENU_CHECK) { bmp.MakeTransparent(Color.Fuchsia); e.Graphics.DrawImage(bmp, bound); } } protected override void OnUIRenderItemImage(UIToolStripItemImageRenderEventArgs e) { if (e.Image != null) { int w = e.Image.Width; int h = e.Image.Height; Rectangle bound = e.ImageRectangle; Point point = new Point( bound.X + (bound.Width - w) / 2, bound.Y + (bound.Height - h) / 2); point.X += 4; point.Y += 2; e.Graphics.DrawImage(e.Image, point.X, point.Y, w, h); } } protected override void OnUIRenderSeparator(UIToolStripSeparatorRenderEventArgs e) { if (e.Item is UIElement) { UIMenuSeparator item = e.Item as UIMenuSeparator; if (item == null) return; Rectangle bound = item.ClientRectangle; bound.X += 25; bound.Width -= 25; bound.Y += 1; bound.Height -= 1; base.RenderFrame(e.Graphics, bound, Res.MENU_SEPERATOR); } } } public class TencentMainMenuRender : UIToolStripRenderer { protected override void OnUIRenderToolStripBackground(UIToolStripRenderEventArgs e) { using (Bitmap bmp = base.RenderFrame( e.AffectedBounds, new Rectangle(56, 11, 71, 195), Res.MAIN_MENU_TOP_RIGHT)) { if (e.ToolStrip is UIVisualPopup) { ((UIVisualPopup)e.ToolStrip).Region = base.CalculateRegion(bmp, Color.Fuchsia); e.Graphics.DrawImage(bmp, 0, 0); } } } protected override void OnUIRenderItemText(UIToolStripItemTextRenderEventArgs e) { if (e.Item is UIMenuItem) { Rectangle bound = e.TextRectangle; bound.X += 10; OnRenderText(e.Graphics, bound, e.Text, e.TextFont, e.TextColor, e.TextFormat); } } protected override void OnUIRenderMenuItemBackground(UIToolStripItemRenderEventArgs e) { if (e.Item is UIElement) { UIMenuItem item = e.Item as UIMenuItem; if (item == null) return; if (item.ElementState == PaletteState.Tracking || item.ElementState == PaletteState.Pressed) { Rectangle bound = item.ClientRectangle; bound.Inflate(-1, -1); base.RenderFrame(e.Graphics, bound, Res.MENU_SELECTED); } } } protected override void OnUIRenderArrow(UIToolStripArrowRenderEventArgs e) { using (Bitmap bmp = Res.MENU_ARROW) { bmp.MakeTransparent(Color.Fuchsia); Point point = new Point( e.ArrowRectangle.Left + (e.ArrowRectangle.Width - bmp.Width) / 2, e.ArrowRectangle.Top + (e.ArrowRectangle.Height - bmp.Height) / 2); e.Graphics.DrawImage(bmp, new Rectangle(point, bmp.Size)); } } protected override void OnUIRenderItemCheck(UIToolStripItemImageRenderEventArgs e) { } protected override void OnUIRenderItemImage(UIToolStripItemImageRenderEventArgs e) { if (e.Image != null) { int w = e.Image.Width; int h = e.Image.Height; Rectangle bound = e.ImageRectangle; Point point = new Point( bound.X + (bound.Width - w) / 2, bound.Y + (bound.Height - h) / 2); point.X += 4; e.Graphics.DrawImage(e.Image, point.X, point.Y, w, h); } } protected override void OnUIRenderSeparator(UIToolStripSeparatorRenderEventArgs e) { if (e.Item is UIElement) { UIMenuSeparator item = e.Item as UIMenuSeparator; if (item == null) return; Rectangle bound = item.ClientRectangle; bound.X += 25; bound.Width -= 25; bound.Y += 1; bound.Height -= 1; base.RenderFrame(e.Graphics, bound, Res.MENU_SEPERATOR); } } } }

Demo文件在此处下载:http://tkggwcwt.download.csdn.net/

如何使用.NET来打造一个QQ界面相关推荐

  1. 亲手打造一个QQ恶作剧程序

    程序原理:获取系统中的所有进程,并保存在一个数组中,然后在数组中查找含有QQ,oicq,qq,OICQ字样的进程,如果找到就立即杀掉该进程.这样你一运行QQ,QQ进程就会被立即杀掉,也就是说如果该恶作 ...

  2. bootstrap设计登录页面_前端小白如何在10分钟内打造一个爆款Web响应式登录界面?...

    对于前端小白(例如:专注后端代码N年的攻城狮),自己编写一个漂亮的Web登录页面似乎在设计上有些捉襟见肘,不懂UI设计,颜色搭配极度的混乱(主色,辅助色,配色,色彩渐变,动画效果等等,看起来一堆乱七八 ...

  3. java qq聊天界面_【附源码】用Java写了一个类QQ界面聊天小项目,可在线聊天!...

    原标题:[附源码]用Java写了一个类QQ界面聊天小项目,可在线聊天! 目录: 1.功能实现 2.模块划分 3.使用到知识 4.部分代码实现 5.运行例图 1.功能实现 1.修改功能(密码.昵称.个性 ...

  4. java qq ui界面_java swing 创建一个简单的QQ界面教程

    记录自己用java swing做的第一个简易界面. LoginAction.java package com.QQUI0819; import javax.swing.*; import java.a ...

  5. 转一个仿QQ界面(VC实现)

    转一个仿QQ界面(VC实现) 摘自:http://topic.csdn.net/u/20100519/21/05d4822d-c59c-413d-abd3-6c26149b8dd9.html 循序渐进 ...

  6. CollapsingToolbarLayout+FloatingActionButton 打造精美详情界面

    博主声明: 转载请在开头附加本文链接及作者信息,并标记为转载.本文由博主 威威喵 原创,请多支持与指教. 本文首发于此   博主:威威喵  |  博客主页:https://blog.csdn.net/ ...

  7. Python分布式爬虫打造搜索引擎完整版-基于Scrapy、Redis、elasticsearch和django打造一个完整的搜索引擎网站

    Python分布式爬虫打造搜索引擎 基于Scrapy.Redis.elasticsearch和django打造一个完整的搜索引擎网站 https://github.com/mtianyan/Artic ...

  8. 打造一个高逼格的android开源项目——小白攻略

    小引子 在平时的开发过程中,我们经常会查阅很多的资料,最常参考的是 github 的开源项目.通常在项目的主页面能看到项目的简介和基本使用,并且时不时能看到页面汇中有好多的彩色标签,看起来很酷,很专业 ...

  9. 仿qq左滑删除listview_Java基于Swing和Netty仿QQ界面聊天小项目

    点击上方 好好学java ,选择 星标 公众号 重磅资讯.干货,第一时间送达 今日推荐:硬刚一周,3W字总结,一年的经验告诉你如何准备校招! 个人原创100W+访问量博客:点击前往,查看更多 来源:b ...

最新文章

  1. app服务器一种什么样的服务器
  2. java信用分秒杀系统设计思路,秒杀系统设计思路
  3. sqlite to mysql_SqliteToMysql
  4. jfinal 任务调度与jsoup 爬虫
  5. objective-c 2.0编程语言,Objective-C 2.0编程快速上手 EXE版[12MB]
  6. Python学习笔记010——匿名函数lambda
  7. mybatis 中collection中需要 open close separator
  8. 高质量图片缩略图生成(编程笔记)
  9. 流浪宠物管理系统-基于SSM
  10. 短视频适合做什么赚钱?短视频暴利赚钱商机,疫情期间实体商家必备拓客软件
  11. java 传值为不可变_Java函数传参(String的不可变性)
  12. 总结一下:运维工程师面试
  13. Word中常见的论文三线表(表格)制作
  14. Java 进程启停及诊断 Jarboot大改版、焕然一新
  15. linux的qt下wsadata,Qtcpserver仅在调试器下返回listen函数的未知错误
  16. 树莓派-nginx+php-fpm +sqlite+wordpress
  17. 用esp8266驱动0.96寸OLED屏幕 太空人动画
  18. 2022 世界人工智能大会,都讲了些啥?
  19. oracle中索引的使用
  20. 数据标准化的原因及方法

热门文章

  1. 匈牙利算法解决指派问题清晰流程
  2. java搜索拉钩_java实现拉钩网上的FizzBuzzWhizz问题示例
  3. 如何快速将pdf转换成excel转换器
  4. MongoDB 学习笔记八 复制、分片、备份与恢复、监控
  5. CRM一站式管理,助力健身会所C位出道!
  6. DML、DDL、DCL、CRUD指什么?
  7. 电脑录屏按哪个键?您可以这样操作!
  8. 添加指定的元素,到指定的位置,后面的元素整体后移一位
  9. PHPstudy的下载与安装。
  10. 阿里云服务器数据迁移