360 lines
9.5 KiB
C#
360 lines
9.5 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Reflection;
|
|||
|
|
using System.Windows.Forms;
|
|||
|
|
using System.Drawing;
|
|||
|
|
using System.Runtime.InteropServices;
|
|||
|
|
using ryControls;
|
|||
|
|
|
|||
|
|
namespace ryControls
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 类说明:帮助类
|
|||
|
|
/// </summary>
|
|||
|
|
public abstract class SkinHelp
|
|||
|
|
{
|
|||
|
|
private static SkinColor _currentSkinColor = SkinColor.Default;
|
|||
|
|
private static BackgroundStripe _currentStripe = BackgroundStripe.Default;
|
|||
|
|
//private static Assembly _assemblyWinUI = null;
|
|||
|
|
//private static Bitmap drawButton = null;
|
|||
|
|
//private static Bitmap scrollbarButton = null;
|
|||
|
|
|
|||
|
|
//private static Color defaultcontextMenuColor;
|
|||
|
|
|
|||
|
|
|
|||
|
|
//public static Assembly AssemblyWinUI
|
|||
|
|
//{
|
|||
|
|
// get
|
|||
|
|
// {
|
|||
|
|
// if (_assemblyWinUI == null)
|
|||
|
|
// {
|
|||
|
|
// _assemblyWinUI = Assembly.Load("bxyztSkin");
|
|||
|
|
// }
|
|||
|
|
|
|||
|
|
// return _assemblyWinUI;
|
|||
|
|
// }
|
|||
|
|
//}
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
public static string SkinFolder
|
|||
|
|
{
|
|||
|
|
get { return "ryControls.Controls."; }
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
public static SkinColor CurrentSkinColor
|
|||
|
|
{
|
|||
|
|
get { return _currentSkinColor; }
|
|||
|
|
set { _currentSkinColor = value; }
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
public static BackgroundStripe CurrentBackgroundStripe
|
|||
|
|
{
|
|||
|
|
get { return _currentStripe; }
|
|||
|
|
set { _currentStripe = value; }
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
public static bool UseGlobalSkin
|
|||
|
|
{
|
|||
|
|
get;
|
|||
|
|
set;
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
public static Color FormTitleLeaveBackColor = Color.OrangeRed;
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
public static Color FormTitleBackColor = SystemColors.Highlight;
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
public static Color ButtonColor=Color.FromArgb(12, 125, 182);
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
public static Color ButtonMouseOverColor = Color.DodgerBlue;
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
public static Color ButtonForeColor = Color.White;
|
|||
|
|
private static Color defalutborder = Color.FromArgb(213, 216, 223);
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
public static Color DefalutBorderColor
|
|||
|
|
{
|
|||
|
|
get { return SkinHelp.defalutborder; }
|
|||
|
|
set { SkinHelp.defalutborder = value; }
|
|||
|
|
}
|
|||
|
|
//public static Color ControlBorderBackColor
|
|||
|
|
//{
|
|||
|
|
// get
|
|||
|
|
// {
|
|||
|
|
// Bitmap bitmap = ButtonImages.ImageObject.GetResBitmap(SkinFolder + "FormImages.borderbm.bmp");
|
|||
|
|
// return bitmap.GetPixel(1, 3);
|
|||
|
|
// }
|
|||
|
|
//}
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
public static Color FontColor
|
|||
|
|
{
|
|||
|
|
get { return Color.FromArgb(22, 61, 101); }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//public static Bitmap ScrollBarButton
|
|||
|
|
//{
|
|||
|
|
// get
|
|||
|
|
// {
|
|||
|
|
// if (scrollbarButton == null)
|
|||
|
|
// {
|
|||
|
|
// scrollbarButton = new Bitmap(ryControl.Properties.Resources.scroll);
|
|||
|
|
// }
|
|||
|
|
// return scrollbarButton;
|
|||
|
|
// }
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
//public static Image ScrollBarUpButton
|
|||
|
|
//{
|
|||
|
|
// get { return ScrollBarButton.Clone(new Rectangle(0, 0, 16, 16), System.Drawing.Imaging.PixelFormat.Format32bppPArgb); }
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
//public static Bitmap DrawButton
|
|||
|
|
//{
|
|||
|
|
// get
|
|||
|
|
// {
|
|||
|
|
// if (drawButton == null)
|
|||
|
|
// {
|
|||
|
|
// drawButton = new Bitmap(ryControl.Properties.Resources.arrow);
|
|||
|
|
// }
|
|||
|
|
// return drawButton;
|
|||
|
|
// }
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
//public static Image NomalDrawButton
|
|||
|
|
//{
|
|||
|
|
// get { return DrawButton.Clone(new Rectangle(0, 0, 16, 16), System.Drawing.Imaging.PixelFormat.Format32bppPArgb); }
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
//public static Image MouseDownDrawButton
|
|||
|
|
//{
|
|||
|
|
// get { return DrawButton.Clone(new Rectangle(16, 0, 16, 16), System.Drawing.Imaging.PixelFormat.Format32bppPArgb); }
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
//public static Image MouseMoveDrawButton
|
|||
|
|
//{
|
|||
|
|
// get { return DrawButton.Clone(new Rectangle(32, 0, 16, 16), System.Drawing.Imaging.PixelFormat.Format32bppPArgb); }
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
//public static Image NotEnableDrawButton
|
|||
|
|
//{
|
|||
|
|
// get { return DrawButton.Clone(new Rectangle(48, 0, 16, 16), System.Drawing.Imaging.PixelFormat.Format32bppPArgb); }
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
#region ChangeSkinColor
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region FlushMemory
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
public static void GarbageCollect()
|
|||
|
|
{
|
|||
|
|
GC.Collect();
|
|||
|
|
GC.WaitForPendingFinalizers();
|
|||
|
|
GC.Collect();
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
public static void FlushMemory()
|
|||
|
|
{
|
|||
|
|
GarbageCollect();
|
|||
|
|
|
|||
|
|
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
|||
|
|
{
|
|||
|
|
Win32.SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Suspend / Resume Redraw
|
|||
|
|
|
|||
|
|
internal static void SuspendRedraw(Control control)
|
|||
|
|
{
|
|||
|
|
if (!control.IsHandleCreated) return;
|
|||
|
|
|
|||
|
|
IntPtr hWnd = control.Handle;
|
|||
|
|
IntPtr eventMask = IntPtr.Zero;
|
|||
|
|
|
|||
|
|
// Stop redrawing:
|
|||
|
|
Win32.SendMessage(hWnd, Win32.WM_SETREDRAW, 0, 0);
|
|||
|
|
|
|||
|
|
// Stop sending of events:
|
|||
|
|
Win32.SendMessage(hWnd, Win32.EM_GETEVENTMASK, 0, 0);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static void ResumeRedraw(Control control)
|
|||
|
|
{
|
|||
|
|
if (!control.IsHandleCreated) return;
|
|||
|
|
|
|||
|
|
IntPtr hWnd = control.Handle;
|
|||
|
|
IntPtr eventMask = IntPtr.Zero;
|
|||
|
|
|
|||
|
|
// turn on events
|
|||
|
|
Win32.SendMessage(hWnd, Win32.EM_SETEVENTMASK, 0, eventMask.ToInt32());
|
|||
|
|
|
|||
|
|
// turn on redrawing
|
|||
|
|
Win32.SendMessage(hWnd, Win32.WM_SETREDRAW, 1, 0);
|
|||
|
|
|
|||
|
|
control.Invalidate(true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static void LockWindowUpdate(Form form, bool lockUpdate)
|
|||
|
|
{
|
|||
|
|
if (lockUpdate)
|
|||
|
|
{
|
|||
|
|
Win32.LockWindowUpdate(form.Handle);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Win32.LockWindowUpdate(IntPtr.Zero);
|
|||
|
|
form.Invalidate(true);
|
|||
|
|
form.Update();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
/// <summary>
|
|||
|
|
/// 修改控件或窗体的边框,例如Textbox或是Form窗体
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="m">消息</param>
|
|||
|
|
/// <param name="control">控件对象</param>
|
|||
|
|
/// <param name="Nwidth">边框像素</param>
|
|||
|
|
/// <param name="objcolor">边框颜色</param>
|
|||
|
|
internal static void ResetBorderColor(Message m, Control control, int Nwidth, Color objcolor)
|
|||
|
|
{
|
|||
|
|
//根据颜色和边框像素取得一条线
|
|||
|
|
System.Drawing.Pen pen = pen = new Pen(objcolor, Nwidth);
|
|||
|
|
//得到当前的句柄
|
|||
|
|
IntPtr hDC = Win32.GetWindowDC(m.HWnd);
|
|||
|
|
if (hDC==IntPtr.Zero)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (pen != null)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//绘制边框
|
|||
|
|
System.Drawing.Graphics g = Graphics.FromHdc(hDC);
|
|||
|
|
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
|
|||
|
|
g.DrawRectangle(pen, 0, 0, control.Width - Nwidth, control.Height - Nwidth);
|
|||
|
|
pen.Dispose();
|
|||
|
|
g.Dispose();
|
|||
|
|
}
|
|||
|
|
catch { }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//释放
|
|||
|
|
Win32.ReleaseDC(m.HWnd, hDC);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
|
|||
|
|
public enum SkinColor
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
Default,
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
草莓,
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
橘子,
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
青草,
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
灰蓝,
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
紫罗兰,
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
巧克力,
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
OFFICE,
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
Undefault
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
|
|||
|
|
public enum BackgroundStripe
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
Default,
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
淡淡墨绿,
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
芙蓉轻粉,
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
荷叶嫩绿,
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
橘黄雪花,
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
清雅幽兰,
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
空灵淡蓝,
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
柔和雅灰,
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
腊梅飘香
|
|||
|
|
}
|
|||
|
|
}
|