// 绘制窗体标题栏(标题图片及文字) public void DrawSkinFormCaption( SkinFormCaptionRenderEventArgs e) { OnRenderSkinFormCaption(e); SkinFormCaptionRenderEventHandler handle = Events[EventRenderSkinFormCaption] as SkinFormCaptionRenderEventHandler; if (handle != null) { handle(this, e); } }
// 绘制窗体标题栏 protected abstract void OnRenderSkinFormCaption( SkinFormCaptionRenderEventArgs e);
//绘制标题栏(包括标题栏图片,标题栏文字,标题栏背景色) protected override void OnRenderSkinFormCaption( SkinFormCaptionRenderEventArgs e) { Graphics g = e.Graphics; //新建一个画刷 Rectangle rect = e.ClipRectangle; //矩形 SkinForm form = e.SkinForm; Rectangle iconRect = form.IconRect; //标题栏图标位置宽度 Rectangle textRect = Rectangle.Empty; bool closeBox = form.ControlBox; //标题栏关闭按钮 bool minimizeBox = form.ControlBox && form.MinimizeBox; //最大化最小化按钮 bool maximizeBox = form.ControlBox && form.MaximizeBox; int textWidthDec = 0; if (closeBox) { textWidthDec += form.CloseBoxSize.Width + form.ControlBoxOffset.X; } if (maximizeBox) { textWidthDec += form.MaximizeBoxSize.Width + form.ControlBoxSpace; } if (minimizeBox) { textWidthDec += form.MinimizeBoxSize.Width + form.ControlBoxSpace; } textRect = new Rectangle( iconRect.Right + 3, form.BorderWidth, rect.Width - iconRect.Right - textWidthDec - 6, rect.Height - form.BorderWidth); using (AntiAliasGraphics antiGraphics = new AntiAliasGraphics(g)) { //DrawCaptionBackground(//重绘标题栏背景颜色,暂时过滤掉标题栏背景颜色,用图片作为整体的背景,当需要时放开即可 // g, // rect, // e.Active); //绘制标题图片 if (form.ShowIcon && form.Icon != null) { DrawIcon(g, iconRect, form.Icon); } //绘制文字 if (!string.IsNullOrEmpty(form.Text)) { DrawCaptionText( g, textRect, form.Text, form.CaptionFont); } } //实时监控背景颜色的改变 InitSkinForm(e.SkinForm); //监控透明度的变化 double value = 100; if (Temp.Open == "True") { value = double.Parse(Temp.Opacity); e.SkinForm.Opacity = (100 - value) / 100.0; } else { e.SkinForm.Opacity = 1; } }