//绘制关闭按钮 private void RenderSkinFormCloseBoxInternal( Graphics g, Rectangle rect, ControlBoxState state, bool active, bool minimizeBox, bool maximizeBox) { Color baseColor = ColorTable.ControlBoxActive; //if (state == ControlBoxState.Pressed) //{ // baseColor = ColorTable.ControlCloseBoxPressed; //} //else if (state == ControlBoxState.Hover) //{ // baseColor = ColorTable.ControlCloseBoxHover; //} //else //{ baseColor = active ? ColorTable.ControlBoxActive : ColorTable.ControlBoxDeactive; //} RoundStyle roundStyle = minimizeBox || maximizeBox ? RoundStyle.BottomRight : RoundStyle.Bottom; using (AntiAliasGraphics antiGraphics = new AntiAliasGraphics(g)) { RenderHelper.RenderBackgroundInternal( g, rect, baseColor, baseColor, ColorTable.ControlBoxInnerBorder, roundStyle, 6, .38F, true, false, LinearGradientMode.Vertical); using (Pen pen = new Pen(Color.LightBlue)) { g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y); } ///画关闭按钮的X using (GraphicsPath path = CreateCloseFlagPath(rect)) { g.FillPath(state == ControlBoxState.Hover ? Brushes.Tomato :(state == ControlBoxState.Pressed ? Brushes.Red : Brushes.White), path); using (Pen pen = new Pen(baseColor)) { g.DrawPath(pen, path); } } } }
private void RenderSkinFormMaximizeBoxInternal( Graphics g, Rectangle rect, ControlBoxState state, bool active, bool minimizeBox, bool maximize) { Color baseColor = ColorTable.ControlBoxActive; if (state == ControlBoxState.Pressed) { baseColor = ColorTable.ControlBoxPressed; } else if (state == ControlBoxState.Hover) { baseColor = ColorTable.ControlBoxHover; } else { baseColor = active ? ColorTable.ControlBoxActive : ColorTable.ControlBoxDeactive; } RoundStyle roundStyle = minimizeBox ? RoundStyle.None : RoundStyle.BottomLeft; using (AntiAliasGraphics antiGraphics = new AntiAliasGraphics(g)) { RenderHelper.RenderBackgroundInternal( g, rect, baseColor, baseColor, ColorTable.ControlBoxInnerBorder, roundStyle, 6, .38F, true, false, LinearGradientMode.Vertical); using (Pen pen = new Pen(Color.LightBlue)) { g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y); } using (GraphicsPath path = CreateMaximizeFlafPath(rect, maximize)) { g.FillPath(Brushes.White, path); using (Pen pen = new Pen(baseColor)) { g.DrawPath(pen, path); } } } }
/// <summary> /// 绘制边框颜色 /// </summary> /// <param name="e"></param> protected override void OnRenderSkinFormBorder( SkinFormBorderRenderEventArgs e) { Graphics g = e.Graphics; using (AntiAliasGraphics antiGraphics = new AntiAliasGraphics(g)) { DrawBorder( g, e.ClipRectangle, e.SkinForm.RoundStyle, // RoundStyle.None, e.SkinForm.Radius); } }
//绘制背景颜色 protected override void OnRenderSkinFormBackground( SkinFormBackgroundRenderEventArgs e) { Graphics g = e.Graphics; Rectangle rect = e.ClipRectangle; SkinForm form = e.SkinForm; using (AntiAliasGraphics antiGraphics = new AntiAliasGraphics(g)) { //g.FillRectangle(Brushes.LightBlue, rect); //e.SkinForm.BackgroundImageLayout = ImageLayout.Stretch; //string imagei = Temp.Image; //Bitmap bt; //if (Temp.Image == "") //{ // bt = new Bitmap(Resource1.background);// new Bitmap(Image.FromFile(Globals.AppPath + "\\resource\\image\\background.jpg")); //} //else //{ // bt = new Bitmap(INIClass.GetImage(imagei), rect.Width, rect.Height); //} //g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; ////using (Brush brush = new TextureBrush(Image.FromFile(imagei))) //using (Brush brush = new TextureBrush(bt)) //{ // rect.X -= 1; // rect.Y -= 1; // rect.Width += 1; // rect.Height += 1; // using (GraphicsPath path = GraphicsPathHelper.CreatePath( // rect, form.Radius, form.RoundStyle, false)) // { // g.FillPath(brush, path); // } //} } // InitSkinForm(e.SkinForm); }
//绘制标题栏(包括标题栏图片,标题栏文字,标题栏背景色) 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; } }