/// <summary>
/// FunctionFormBase基窗体
/// 是构造EntryForm和SkinForm窗体的基础
/// </summary>
public partial class FunctionFormBase : FormBase
//
// ptbTopMiddle
//
this.ptbTopMiddle.Dock = System.Windows.Forms.DockStyle.Fill;
this.ptbTopMiddle.Location = new System.Drawing.Point(10, 0);
this.ptbTopMiddle.Name = "ptbTopMiddle";
this.ptbTopMiddle.Size = new System.Drawing.Size(669, 31);
this.ptbTopMiddle.TabIndex = 2;
this.ptbTopMiddle.TabStop = false;
// pnlBackGroup
//
this.pnlBackGroup.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.pnlBackGroup.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlBackGroup.Location = new System.Drawing.Point(0, 31);
this.pnlBackGroup.Name = "pnlBackGroup";
this.pnlBackGroup.Size = new System.Drawing.Size(689, 444);
this.pnlBackGroup.TabIndex = 9;
//
// ptbBottomMiddle
//
this.ptbBottomMiddle.Dock = System.Windows.Forms.DockStyle.Fill;
this.ptbBottomMiddle.Location = new System.Drawing.Point(10, 0);
this.ptbBottomMiddle.Name = "ptbBottomMiddle";
this.ptbBottomMiddle.Size = new System.Drawing.Size(669, 37);
this.ptbBottomMiddle.TabIndex = 3;
//
// pnlRight
//
this.pnlRight.Controls.Add(this.ptbRight);
this.pnlRight.Dock = System.Windows.Forms.DockStyle.Right;
this.pnlRight.Location = new System.Drawing.Point(687, 31);
this.pnlRight.Name = "pnlRight";
this.pnlRight.Size = new System.Drawing.Size(2, 444);
this.pnlRight.TabIndex = 7;
//
// ptbRight
//
this.ptbRight.Dock = System.Windows.Forms.DockStyle.Fill;
this.ptbRight.Location = new System.Drawing.Point(0, 0);
this.ptbRight.Name = "ptbRight";
this.ptbRight.Size = new System.Drawing.Size(2, 444);
this.ptbRight.TabIndex = 0;
this.ptbRight.TabStop = false;
//
// pnlLeft
//
this.pnlLeft.Controls.Add(this.ptbLeft);
this.pnlLeft.Dock = System.Windows.Forms.DockStyle.Left;
this.pnlLeft.Location = new System.Drawing.Point(0, 31);
this.pnlLeft.Name = "pnlLeft";
this.pnlLeft.Size = new System.Drawing.Size(2, 444);
this.pnlLeft.TabIndex = 6;
//
// ptbLeft
//
this.ptbLeft.Dock = System.Windows.Forms.DockStyle.Fill;
this.ptbLeft.Location = new System.Drawing.Point(0, 0);
this.ptbLeft.Name = "ptbLeft";
this.ptbLeft.Size = new System.Drawing.Size(2, 444);
this.ptbLeft.TabIndex = 0;
this.ptbLeft.TabStop = false;
//
// ptbBottomRight
//
this.ptbBottomRight.Dock = System.Windows.Forms.DockStyle.Right;
this.ptbBottomRight.Location = new System.Drawing.Point(679, 0);
this.ptbBottomRight.Name = "ptbBottomRight";
this.ptbBottomRight.Size = new System.Drawing.Size(10, 37);
this.ptbBottomRight.TabIndex = 2;
this.ptbBottomRight.TabStop = false;
//
// ptbBottomLeft
//
this.ptbBottomLeft.Dock = System.Windows.Forms.DockStyle.Left;
this.ptbBottomLeft.Location = new System.Drawing.Point(0, 0);
this.ptbBottomLeft.Name = "ptbBottomLeft";
this.ptbBottomLeft.Size = new System.Drawing.Size(10, 37);
this.ptbBottomLeft.TabIndex = 0;
this.ptbBottomLeft.TabStop = false;
this.pnlBackGroup.TabIndex = 9;
//
// lblText
//
this.lblText.BackColor = System.Drawing.Color.Transparent;
this.lblText.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblText.Location = new System.Drawing.Point(27, 3);
this.lblText.Name = "lblText";
this.lblText.Size = new System.Drawing.Size(273, 24);
this.lblText.TabIndex = 5;
this.lblText.Text = "Text";
this.lblText.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.lblText.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Caption_MouseMove);
this.lblText.MouseUp += new System.Windows.Forms.MouseEventHandler(this.caption_MouseUp); //
// lblText
//
this.lblText.BackColor = System.Drawing.Color.Transparent;
this.lblText.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblText.Location = new System.Drawing.Point(27, 3);
this.lblText.Name = "lblText";
this.lblText.Size = new System.Drawing.Size(273, 24);
this.lblText.TabIndex = 5;
this.lblText.Text = "Text";
this.lblText.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.lblText.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Caption_MouseMove);
this.lblText.MouseUp += new System.Windows.Forms.MouseEventHandler(this.caption_MouseUp);
//
// pnlCaption
//
this.pnlCaption.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.pnlCaption.Controls.Add(this.lblText);
this.pnlCaption.Controls.Add(this.btnMin);
this.pnlCaption.Controls.Add(this.btnClose);
this.pnlCaption.Controls.Add(this.ptbTopMiddle);
this.pnlCaption.Controls.Add(this.ptbTopRight);
this.pnlCaption.Controls.Add(this.ptbTopLeft);
this.pnlCaption.Dock = System.Windows.Forms.DockStyle.Top;
this.pnlCaption.Location = new System.Drawing.Point(0, 0);
this.pnlCaption.Name = "pnlCaption";
this.pnlCaption.Size = new System.Drawing.Size(689, 31);
this.pnlCaption.TabIndex = 5;
//
// btnMin
//
this.btnMin.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnMin.BackColor = System.Drawing.Color.Transparent;
this.btnMin.ImageTransparentColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(255)))));
this.btnMin.Location = new System.Drawing.Point(610, 0);
this.btnMin.MouseDownImage = null;
this.btnMin.MouseMoveImage = null;
this.btnMin.Name = "btnMin";
this.btnMin.NormalImage = null;
this.btnMin.Size = new System.Drawing.Size(31, 22);
this.btnMin.TabIndex = 4;
this.btnMin.ToolTip = "关闭";
this.btnMin.Click += new System.EventHandler(this.btnMin_Click);
//
// btnClose
//
this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnClose.ImageTransparentColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(255)))));
this.btnClose.Location = new System.Drawing.Point(642, 0);
this.btnClose.MouseDownImage = null;
this.btnClose.MouseMoveImage = null;
this.btnClose.Name = "btnClose";
this.btnClose.NormalImage = null;
this.btnClose.Size = new System.Drawing.Size(37, 22);
this.btnClose.TabIndex = 4;
this.btnClose.ToolTip = "关闭";
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// ptbTopMiddle
//
this.ptbTopMiddle.Dock = System.Windows.Forms.DockStyle.Fill;
this.ptbTopMiddle.Location = new System.Drawing.Point(10, 0);
this.ptbTopMiddle.Name = "ptbTopMiddle";
this.ptbTopMiddle.Size = new System.Drawing.Size(669, 31);
this.ptbTopMiddle.TabIndex = 2;
this.ptbTopMiddle.TabStop = false;
this.ptbTopMiddle.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Caption_MouseMove);
this.ptbTopMiddle.MouseUp += new System.Windows.Forms.MouseEventHandler(this.caption_MouseUp);
//
// ptbTopRight
//
this.ptbTopRight.Dock = System.Windows.Forms.DockStyle.Right;
this.ptbTopRight.Location = new System.Drawing.Point(679, 0);
this.ptbTopRight.Name = "ptbTopRight";
this.ptbTopRight.Size = new System.Drawing.Size(10, 31);
this.ptbTopRight.TabIndex = 1;
this.ptbTopRight.TabStop = false;
//
// ptbTopLeft
//
this.ptbTopLeft.Dock = System.Windows.Forms.DockStyle.Left;
this.ptbTopLeft.Location = new System.Drawing.Point(0, 0);
this.ptbTopLeft.Name = "ptbTopLeft";
this.ptbTopLeft.Size = new System.Drawing.Size(10, 31);
this.ptbTopLeft.TabIndex = 0;
this.ptbTopLeft.TabStop = false;
//
// pnlBottom
//
this.pnlBottom.Controls.Add(this.ptbBottomMiddle);
this.pnlBottom.Controls.Add(this.ptbBottomRight);
this.pnlBottom.Controls.Add(this.ptbBottomLeft);
this.pnlBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
this.pnlBottom.Location = new System.Drawing.Point(0, 475);
this.pnlBottom.Name = "pnlBottom";
this.pnlBottom.Size = new System.Drawing.Size(689, 37);
this.pnlBottom.TabIndex = 8;
//移除FormBase现有控件
this.Controls.Remove(this.pnlRight);
this.Controls.Remove(this.pnlLeft);
this.Controls.Remove(this.pnlBackGroup);
this.Controls.Remove(this.pnlCaption);
this.Controls.Remove(this.pnlBottom);
//标题
public override string Text
{
get
{
return base.Text;
}
set
{
base.Text = value;
if (this.lblText!=null)
this.lblText.Text = this.Text;
}
}
//最小化
private void btnMin_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}
//最小化
public new bool MinimizeBox
{
get
{
return base.MinimizeBox;
}
set
{
base.MinimizeBox = value;
this.btnMin.Visible = value;
}
}
//关闭按钮
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
//移动标题时
private void Caption_MouseMove(object sender, MouseEventArgs e)
{
((Control)sender).Cursor = Cursors.Default;
if (e.Button == MouseButtons.Left)
{
Win32.ReleaseCapture();
Win32.SendMessage(Handle, 274, 61440 + 9, 0);
}
}
//鼠标松开时
private void caption_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right && ((Control)sender).Cursor == Cursors.Default && e.Y <= SystemInformation.CaptionHeight)
{
Win32.TrackPopupMenu(Win32.GetSystemMenu(Handle, 0).ToInt32(), 2, Cursor.Position.X, Cursor.Position.Y, 0, Handle, 0);
}
}
/// <summary>
/// Windows消息处理
/// </summary>
/// <param name="m">Message</param>
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case Win32.WM_COMMAND:
Win32.SendMessage(Handle, Win32.WM_SYSCOMMAND, (int)m.WParam, (int)m.LParam);
break;
case Win32.WM_SYSCOMMAND:
base.WndProc(ref m);
if (m.WParam.ToInt64() == Win32.SC_RESTORE)
{
this.Height += 6;
this.Width += 6;
}
else if (m.WParam.ToInt64() == Win32.SC_MAXIMIZE)
{
Application.DoEvents();
}
break;
default:
base.WndProc(ref m);
break;
}
}
/// <summary>
/// 设置窗体样式
/// </summary>
public override void ReSetFormBitmap()
{
this.pnlCaption.BackgroundImage = Image.FromStream(Shared.AssemblyWinUI.GetManifestResourceStream("CRD.WinUI.Resources.Common.dialog2009.bordertm.bmp"));
this.ptbTopLeft.BackgroundImage = Image.FromStream(Shared.AssemblyWinUI.GetManifestResourceStream("CRD.WinUI.Resources.Common.dialog2009.bordertl.bmp"));
this.ptbTopMiddle.BackgroundImage = Image.FromStream(Shared.AssemblyWinUI.GetManifestResourceStream("CRD.WinUI.Resources.Common.dialog2009.bordertm.bmp"));
this.ptbTopRight.BackgroundImage = Image.FromStream(Shared.AssemblyWinUI.GetManifestResourceStream("CRD.WinUI.Resources.Common.dialog2009.bordertr.bmp"));
this.ptbLeft.BackgroundImage = Image.FromStream(Shared.AssemblyWinUI.GetManifestResourceStream("CRD.WinUI.Resources.Common.dialog2009.borderml.bmp"));
this.ptbRight.BackgroundImage = Image.FromStream(Shared.AssemblyWinUI.GetManifestResourceStream("CRD.WinUI.Resources.Common.dialog2009.bordermr.bmp"));
this.ptbBottomLeft.BackgroundImage = Image.FromStream(Shared.AssemblyWinUI.GetManifestResourceStream("CRD.WinUI.Resources.Common.dialog2009.borderbl.bmp"));
this.ptbBottomMiddle.BackgroundImage = Image.FromStream(Shared.AssemblyWinUI.GetManifestResourceStream("CRD.WinUI.Resources.Common.dialog2009.borderbm.bmp"));
this.ptbBottomRight.BackgroundImage = Image.FromStream(Shared.AssemblyWinUI.GetManifestResourceStream("CRD.WinUI.Resources.Common.dialog2009.borderbr.bmp"));
this.pnlBackGroup.BackgroundImage = Image.FromStream(Shared.AssemblyWinUI.GetManifestResourceStream("CRD.WinUI.Resources.Common.dialog2009.bg.bmp"));
Bitmap closeBitmap = new Bitmap(Bitmap.FromStream(Shared.AssemblyWinUI.GetManifestResourceStream("CRD.WinUI.Resources.MainWin.Button.CloseBtn.bmp")));
this.btnClose.NormalImage = closeBitmap.Clone(new Rectangle(0, 0, 37, 22), PixelFormat.Format64bppPArgb);
this.btnClose.MouseMoveImage = closeBitmap.Clone(new Rectangle(37, 0, 37, 22), PixelFormat.Format64bppPArgb);
this.btnClose.MouseDownImage = closeBitmap.Clone(new Rectangle(74, 0, 37, 22), PixelFormat.Format64bppPArgb);
Bitmap minBitmap = new Bitmap(Bitmap.FromStream(Shared.AssemblyWinUI.GetManifestResourceStream("CRD.WinUI.Resources.MainWin.Button.MinBtn.bmp")));
this.btnMin.NormalImage = minBitmap.Clone(new Rectangle(0, 0, 31, 22), PixelFormat.Format64bppPArgb);
this.btnMin.MouseMoveImage = minBitmap.Clone(new Rectangle(31, 0, 31, 22), PixelFormat.Format64bppPArgb);
this.btnMin.MouseDownImage = minBitmap.Clone(new Rectangle(62, 0, 31, 22), PixelFormat.Format64bppPArgb);
this.CurrentSkinColor = SkinColor.Default;
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CRD.Common;
using System.Drawing.Imaging;
namespace CRD.WinUI.Forms
{
/// <summary>
/// FunctionFormBase基窗体
/// 是构造EntryForm和SkinForm窗体的基础
/// </summary>
public partial class FunctionFormBase : FormBase
{
//构造器
public FunctionFormBase()
{
//设置默认的皮肤
this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
InitializeComponent();
//移除FormBase现有控件
this.Controls.Remove(this.pnlRight);
this.Controls.Remove(this.pnlLeft);
this.Controls.Remove(this.pnlBackGroup);
this.Controls.Remove(this.pnlCaption);
this.Controls.Remove(this.pnlBottom);
}
/// <summary>
/// Windows消息处理
/// </summary>
/// <param name="m">Message</param>
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case Win32.WM_COMMAND:
Win32.SendMessage(Handle, Win32.WM_SYSCOMMAND, (int)m.WParam, (int)m.LParam);
break;
case Win32.WM_SYSCOMMAND:
base.WndProc(ref m);
if (m.WParam.ToInt64() == Win32.SC_RESTORE)
{
this.Height += 6;
this.Width += 6;
}
else if (m.WParam.ToInt64() == Win32.SC_MAXIMIZE)
{
Application.DoEvents();
}
break;
default:
base.WndProc(ref m);
break;
}
}
/// <summary>
/// 设置窗体样式
/// </summary>
public override void ReSetFormBitmap()
{
this.pnlCaption.BackgroundImage = Image.FromStream(Shared.AssemblyWinUI.GetManifestResourceStream("CRD.WinUI.Resources.Common.dialog2009.bordertm.bmp"));
this.ptbTopLeft.BackgroundImage = Image.FromStream(Shared.AssemblyWinUI.GetManifestResourceStream("CRD.WinUI.Resources.Common.dialog2009.bordertl.bmp"));
this.ptbTopMiddle.BackgroundImage = Image.FromStream(Shared.AssemblyWinUI.GetManifestResourceStream("CRD.WinUI.Resources.Common.dialog2009.bordertm.bmp"));
this.ptbTopRight.BackgroundImage = Image.FromStream(Shared.AssemblyWinUI.GetManifestResourceStream("CRD.WinUI.Resources.Common.dialog2009.bordertr.bmp"));
this.ptbLeft.BackgroundImage = Image.FromStream(Shared.AssemblyWinUI.GetManifestResourceStream("CRD.WinUI.Resources.Common.dialog2009.borderml.bmp"));
this.ptbRight.BackgroundImage = Image.FromStream(Shared.AssemblyWinUI.GetManifestResourceStream("CRD.WinUI.Resources.Common.dialog2009.bordermr.bmp"));
this.ptbBottomLeft.BackgroundImage = Image.FromStream(Shared.AssemblyWinUI.GetManifestResourceStream("CRD.WinUI.Resources.Common.dialog2009.borderbl.bmp"));
this.ptbBottomMiddle.BackgroundImage = Image.FromStream(Shared.AssemblyWinUI.GetManifestResourceStream("CRD.WinUI.Resources.Common.dialog2009.borderbm.bmp"));
this.ptbBottomRight.BackgroundImage = Image.FromStream(Shared.AssemblyWinUI.GetManifestResourceStream("CRD.WinUI.Resources.Common.dialog2009.borderbr.bmp"));
this.pnlBackGroup.BackgroundImage = Image.FromStream(Shared.AssemblyWinUI.GetManifestResourceStream("CRD.WinUI.Resources.Common.dialog2009.bg.bmp"));
Bitmap closeBitmap = new Bitmap(Bitmap.FromStream(Shared.AssemblyWinUI.GetManifestResourceStream("CRD.WinUI.Resources.MainWin.Button.CloseBtn.bmp")));
this.btnClose.NormalImage = closeBitmap.Clone(new Rectangle(0, 0, 37, 22), PixelFormat.Format64bppPArgb);
this.btnClose.MouseMoveImage = closeBitmap.Clone(new Rectangle(37, 0, 37, 22), PixelFormat.Format64bppPArgb);
this.btnClose.MouseDownImage = closeBitmap.Clone(new Rectangle(74, 0, 37, 22), PixelFormat.Format64bppPArgb);
Bitmap minBitmap = new Bitmap(Bitmap.FromStream(Shared.AssemblyWinUI.GetManifestResourceStream("CRD.WinUI.Resources.MainWin.Button.MinBtn.bmp")));
this.btnMin.NormalImage = minBitmap.Clone(new Rectangle(0, 0, 31, 22), PixelFormat.Format64bppPArgb);
this.btnMin.MouseMoveImage = minBitmap.Clone(new Rectangle(31, 0, 31, 22), PixelFormat.Format64bppPArgb);
this.btnMin.MouseDownImage = minBitmap.Clone(new Rectangle(62, 0, 31, 22), PixelFormat.Format64bppPArgb);
this.CurrentSkinColor = SkinColor.Default;
}
/// <summary>
/// 重写的OnLoad
/// </summary>
protected override void OnLoad(EventArgs e)
{
this.Controls.Add(this.pnlRight);
this.Controls.Add(this.pnlLeft);
this.Controls.Add(this.pnlBackGroup);
this.Controls.Add(this.pnlCaption);
this.Controls.Add(this.pnlBottom);
if (!DesignMode)
{
this.Hide();
}
base.OnLoad(e);
Win32.SetWindowLong(this.Handle, -16,Win32.GetWindowLong(this.Handle,-16) -Win32.WS_MAXIMIZEBOX );
this.Show();
}
//关闭按钮
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
//最小化
private void btnMin_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}
//移动标题时
private void Caption_MouseMove(object sender, MouseEventArgs e)
{
((Control)sender).Cursor = Cursors.Default;
if (e.Button == MouseButtons.Left)
{
Win32.ReleaseCapture();
Win32.SendMessage(Handle, 274, 61440 + 9, 0);
}
}
//标题
public override string Text
{
get
{
return base.Text;
}
set
{
base.Text = value;
if (this.lblText!=null)
this.lblText.Text = this.Text;
}
}
//最小化
public new bool MinimizeBox
{
get
{
return base.MinimizeBox;
}
set
{
base.MinimizeBox = value;
this.btnMin.Visible = value;
}
}
//鼠标松开时
private void caption_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right && ((Control)sender).Cursor == Cursors.Default && e.Y <= SystemInformation.CaptionHeight)
{
Win32.TrackPopupMenu(Win32.GetSystemMenu(Handle, 0).ToInt32(), 2, Cursor.Position.X, Cursor.Position.Y, 0, Handle, 0);
}
}
}
}
fusheng 发表于 2013-7-10 13:32
那个皮肤类怎么用?
^陪妳ソ看日落 发表于 2013-10-16 21:39
皮肤是怎么做的的??
欢迎光临 苏飞论坛 (http://www.sufeinet.com/) | Powered by Discuz! X3.4 |