//画边框 private void DrawBorder( Graphics g, Rectangle rect, RoundStyle roundStyle, int radius, CCSkinMain frm) { g.SmoothingMode = SmoothingMode.HighQuality; //高质量 rect.Width -= 1; rect.Height -= 1; using (GraphicsPath path = GraphicsPathHelper.CreatePath( rect, radius, roundStyle, false)) { using (Pen pen = new Pen(ColorTable.Border)) { g.DrawPath(pen, path); } } rect.Inflate(-1, -1); using (GraphicsPath path = GraphicsPathHelper.CreatePath( rect, radius, roundStyle, false)) { using (Pen pen = new Pen(ColorTable.InnerBorder)) { g.DrawPath(pen, path); } } }
public override Region CreateRegion(CCSkinMain form) { Rectangle rect = new Rectangle(Point.Empty, form.Size); using (GraphicsPath path = GraphicsPathHelper.CreatePath(rect, form.Radius, form.RoundStyle, false)) { return new Region(path); } }
public SkinFormBackgroundRenderEventArgs( CCSkinMain skinForm, Graphics g, Rectangle clipRect) : base(g, clipRect) { _skinForm = skinForm; }
public SkinFormControlBoxRenderEventArgs(CCSkinMain form, Graphics graphics, Rectangle clipRect, bool active, CCWin.ControlBoxStyle controlBoxStyle, ControlBoxState controlBoxState) : base(graphics, clipRect) { this._form = form; this._active = active; this._controlBoxState = controlBoxState; this._controlBoxStyle = controlBoxStyle; }
//画窗体按钮 protected override void OnRenderSkinFormControlBox( SkinFormControlBoxRenderEventArgs e) { CCSkinMain form = e.Form; Graphics g = e.Graphics; Rectangle rect = e.ClipRectangle; ControlBoxState state = e.ControlBoxtate; CmSysButton cmSysButton = e.CmSysButton; bool active = e.Active; bool minimizeBox = form.ControlBox && form.MinimizeBox; bool maximizeBox = form.ControlBox && form.MaximizeBox; switch (e.ControlBoxStyle) { case ControlBoxStyle.Close: RenderSkinFormCloseBoxInternal( g, rect, state, active, minimizeBox, maximizeBox, form); break; case ControlBoxStyle.Maximize: RenderSkinFormMaximizeBoxInternal( g, rect, state, active, minimizeBox, form.WindowState == FormWindowState.Maximized, form); break; case ControlBoxStyle.Minimize: RenderSkinFormMinimizeBoxInternal( g, rect, state, active, form); break; case ControlBoxStyle.CmSysBottom: RenderSkinFormCmSysBottomInternal( g, rect, state, active, form, cmSysButton); break; } }
//带参构造 public CCSkinForm(CCSkinMain main) { //将控制层传值过来 this.Main = main; InitializeComponent(); //减少闪烁 SetStyles(); //初始化 Init(); }
public SkinFormBorderRenderEventArgs( CCSkinMain skinForm, Graphics g, Rectangle clipRect, bool active) : base(g, clipRect) { _skinForm = skinForm; _active = active; }
//画圆角 public override Region CreateRegion(CCSkinMain form) { Rectangle rect = new Rectangle(Point.Empty, form.Size); using (GraphicsPath path = GraphicsPathHelper.CreatePath( rect, form.Radius, form.RoundStyle, false)) { return(new Region(path)); } }
public SkinFormControlBoxRenderEventArgs( CCSkinMain form, Graphics graphics, Rectangle clipRect, bool active, ControlBoxStyle controlBoxStyle, ControlBoxState controlBoxState, CmSysButton cmSysbutton = null) : base(graphics, clipRect) { _form = form; _active = active; _controlBoxState = controlBoxState; _controlBoxStyle = controlBoxStyle; _CmSysbutton = cmSysbutton; }
public void Dispose() { this._owner = null; }
public abstract void InitSkinForm(CCSkinMain form);
public abstract Region CreateRegion(CCSkinMain form);
public override void InitSkinForm(CCSkinMain form) { form.BackColor = this.ColorTable.Back; }
private CCSkinMain owner; //所属的控件 public CustomSysButtonCollection(CCSkinMain owner) { this.owner = owner; }
//画关闭按钮 private void RenderSkinFormCloseBoxInternal( Graphics g, Rectangle rect, ControlBoxState state, bool active, bool minimizeBox, bool maximizeBox, CCSkinMain form) { Bitmap btm = null; Color baseColor = ColorTable.ControlBoxActive; if (state == ControlBoxState.Pressed) { btm = (Bitmap)form.CloseDownBack; baseColor = ColorTable.ControlCloseBoxPressed; } else if (state == ControlBoxState.Hover) { btm = (Bitmap)form.CloseMouseBack; baseColor = ColorTable.ControlCloseBoxHover; } else { btm = (Bitmap)form.CloseNormlBack; baseColor = active ? ColorTable.ControlBoxActive : ColorTable.ControlBoxDeactive; } //绘制图片样式 if (btm != null) { g.DrawImage(btm, rect); } else //绘制默认样式 { 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(ColorTable.Border)) { g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y); } using (GraphicsPath path = CreateCloseFlagPath(rect)) { g.FillPath(Brushes.White, path); using (Pen pen = new Pen(baseColor)) { g.DrawPath(pen, path); } } } } }
//画自定义系统按钮集合 private void RenderSkinFormCmSysBottomInternal(Graphics g, Rectangle rect, ControlBoxState state, bool active, CCSkinMain form, CmSysButton cmSysButton) { Bitmap btm = null; Color baseColor = ColorTable.ControlBoxActive; if (cmSysButton.BoxState == ControlBoxState.Pressed) { btm = (Bitmap)cmSysButton.SysButtonDown; baseColor = ColorTable.ControlBoxPressed; } else if (state == ControlBoxState.Hover) { btm = (Bitmap)cmSysButton.SysButtonMouse; baseColor = ColorTable.ControlBoxHover; } else { btm = (Bitmap)cmSysButton.SysButtonNorml; baseColor = active ? ColorTable.ControlBoxActive : ColorTable.ControlBoxDeactive; } //绘制图片样式 if (btm != null) { g.DrawImage(btm, rect); } else //绘制默认样式 { RoundStyle roundStyle = 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(ColorTable.Border)) { g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y); } } } }
public override System.Drawing.Region CreateRegion(CCSkinMain form) { throw new NotImplementedException(); }
public void Dispose() { _owner = null; }
public override void InitSkinForm(CCSkinMain form) { form.BackColor = ColorTable.Back; }
public ControlBoxManager(CCSkinMain owner) { _owner = owner; }
public override void InitSkinForm(CCSkinMain form) { throw new NotImplementedException(); }
//画最小化按钮 private void RenderSkinFormMinimizeBoxInternal( Graphics g, Rectangle rect, ControlBoxState state, bool active, CCSkinMain form) { Bitmap btm = null; Color baseColor = ColorTable.ControlBoxActive; if (state == ControlBoxState.Pressed) { btm = (Bitmap)form.MiniDownBack; baseColor = ColorTable.ControlBoxPressed; } else if (state == ControlBoxState.Hover) { btm = (Bitmap)form.MiniMouseBack; baseColor = ColorTable.ControlBoxHover; } else { btm = (Bitmap)form.MiniNormlBack; baseColor = active ? ColorTable.ControlBoxActive : ColorTable.ControlBoxDeactive; } //绘制图片样式 if (btm != null) { g.DrawImage(btm, rect); } else //绘制默认样式 { RoundStyle roundStyle = RoundStyle.BottomLeft; //g.DrawImage(btm,rect); 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(ColorTable.Border)) { g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y); } using (GraphicsPath path = CreateMinimizeFlagPath(rect)) { g.FillPath(Brushes.White, path); using (Pen pen = new Pen(baseColor)) { g.DrawPath(pen, path); } } } } }
private void RenderSkinFormSysBottomInternal(Graphics g, Rectangle rect, ControlBoxState state, bool active, CCSkinMain form) { Bitmap btm = null; Color baseColor = this.ColorTable.ControlBoxActive; if (state == ControlBoxState.Pressed) { btm = (Bitmap) form.SysBottomDown; baseColor = this.ColorTable.ControlBoxPressed; } else if (state == ControlBoxState.Hover) { btm = (Bitmap) form.SysBottomMouse; baseColor = this.ColorTable.ControlBoxHover; } else { btm = (Bitmap) form.SysBottomNorml; baseColor = active ? this.ColorTable.ControlBoxActive : this.ColorTable.ControlBoxDeactive; } if (btm != null) { g.DrawImage(btm, rect); } else { RoundStyle roundStyle = RoundStyle.BottomLeft; using (new AntiAliasGraphics(g)) { RenderHelper.RenderBackgroundInternal(g, rect, baseColor, baseColor, this.ColorTable.ControlBoxInnerBorder, roundStyle, 6, 0.38f, true, false, LinearGradientMode.Vertical); using (Pen pen = new Pen(this.ColorTable.Border)) { g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y); } } } }
public SkinFormCaptionRenderEventArgs(CCSkinMain skinForm, Graphics g, Rectangle clipRect, bool active) : base(g, clipRect) { this._skinForm = skinForm; this._active = active; }
private CCSkinMain owner; //所属的控件 #endregion Fields #region Constructors public CustomSysButtonCollection(CCSkinMain owner) { this.owner = owner; }
//画标题和ICO protected override void OnRenderSkinFormCaption( SkinFormCaptionRenderEventArgs e) { Graphics g = e.Graphics; Rectangle rect = e.ClipRectangle; CCSkinMain 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.MaxSize.Width + form.ControlBoxSpace; } if (minimizeBox) { textWidthDec += form.MiniSize.Width + form.ControlBoxSpace; } foreach (CmSysButton item in form.ControlBoxManager.SysButtonItems) { if (form.ControlBox && item.Visibale) { textWidthDec += item.Size.Width + form.ControlBoxSpace; } } textRect = new Rectangle( iconRect.Right + 3, form.BorderPadding.Left, rect.Width - iconRect.Right - textWidthDec - 6, rect.Height - form.BorderPadding.Left); using (AntiAliasGraphics antiGraphics = new AntiAliasGraphics(g)) { DrawCaptionBackground( g, rect, e.Active); if (form.ShowDrawIcon && form.Icon != null) { DrawIcon(g, iconRect, form.Icon); } if (!string.IsNullOrEmpty(form.Text)) { Color EfColor = form.EffectBack; Color TitleColor = form.TitleColor; //判断是否根据背景色适应颜色 if (form.TitleSuitColor) { //如果背景色为暗色 if (SkinTools.ColorSlantsDarkOrBright(form.BackColor)) { TitleColor = Color.White; EfColor = Color.Black; } else//如果背景色为亮色 { TitleColor = Color.Black; EfColor = Color.White; } } DrawCaptionText( g, textRect, form.Text, form.CaptionFont, form.EffectCaption, EfColor, form.EffectWidth, TitleColor, form.TitleOffset); } } }
private void DrawBorder(Graphics g, Rectangle rect, RoundStyle roundStyle, int radius, CCSkinMain frm) { g.SmoothingMode = SmoothingMode.HighQuality; rect.Width--; rect.Height--; using (GraphicsPath path = GraphicsPathHelper.CreatePath(rect, radius, roundStyle, false)) { using (Pen pen = new Pen(this.ColorTable.Border)) { g.DrawPath(pen, path); } } rect.Inflate(-1, -1); using (GraphicsPath path = GraphicsPathHelper.CreatePath(rect, radius, roundStyle, false)) { using (Pen pen = new Pen(this.ColorTable.InnerBorder)) { g.DrawPath(pen, path); } } }
private void RenderSkinFormMaximizeBoxInternal(Graphics g, Rectangle rect, ControlBoxState state, bool active, bool minimizeBox, bool maximize, CCSkinMain form) { Bitmap btm = null; Color baseColor = this.ColorTable.ControlBoxActive; if (state == ControlBoxState.Pressed) { btm = maximize ? ((Bitmap) form.RestoreDownBack) : ((Bitmap) form.MaxDownBack); baseColor = this.ColorTable.ControlBoxPressed; } else if (state == ControlBoxState.Hover) { btm = maximize ? ((Bitmap) form.RestoreMouseBack) : ((Bitmap) form.MaxMouseBack); baseColor = this.ColorTable.ControlBoxHover; } else { btm = maximize ? ((Bitmap) form.RestoreNormlBack) : ((Bitmap) form.MaxNormlBack); baseColor = active ? this.ColorTable.ControlBoxActive : this.ColorTable.ControlBoxDeactive; } if (btm != null) { g.DrawImage(btm, rect); } else { RoundStyle roundStyle = minimizeBox ? RoundStyle.None : RoundStyle.BottomLeft; using (new AntiAliasGraphics(g)) { RenderHelper.RenderBackgroundInternal(g, rect, baseColor, baseColor, this.ColorTable.ControlBoxInnerBorder, roundStyle, 6, 0.38f, true, false, LinearGradientMode.Vertical); using (Pen pen = new Pen(this.ColorTable.Border)) { g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y); } using (GraphicsPath path = this.CreateMaximizeFlafPath(rect, maximize)) { g.FillPath(Brushes.White, path); using (Pen pen = new Pen(baseColor)) { g.DrawPath(pen, path); } } } } }