📄 fbase.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using Qeb.Support.UI;
using Qeb.Support.Common;
namespace Qeb.Control
{
public partial class FBase : Form
{
/// <summary>
/// 消息处理者代理
/// </summary>
protected UIMessageEventHandler m_MsgEventHandler;
private Hashtable m_MsgId = new Hashtable();
//入口菜单ID
private string m_MenuId = "";
private bool m_ShowGradient = false;
//private Color m_StartColor = Color.White;
//private Color m_EndColor = Color.LightSteelBlue;
//private Color m_StartColor = Color.FromArgb(196, 219, 249);//word title
//private Color m_EndColor = Color.FromArgb(102, 144, 224);
private Color m_StartColor = Color.FromArgb(200, 223, 251);
private Color m_EndColor = Color.FromArgb(125, 165, 224);
private LinearGradientMode m_LinearGradientMode = LinearGradientMode.Horizontal;
//private Brush m_BaseBackground = null;
[Description("渐变色开始颜色"), Category("窗体背景")]
public Color StartColor
{
get { return m_StartColor; }
set { m_StartColor = value; }
}
[Description("渐变色终止颜色"), Category("窗体背景")]
public Color EndColor
{
get { return m_EndColor; }
set { m_EndColor = value; }
}
[Description("渐变色绘制方向"), Category("窗体背景")]
public LinearGradientMode LinearGradientMode
{
get { return m_LinearGradientMode; }
set { m_LinearGradientMode = value; }
}
[Description("是否绘制渐变色,启用此项窗体背景图和背景将失效"), Category("窗体背景")]
public bool ShowGradient
{
get { return m_ShowGradient; }
set
{
m_ShowGradient = value;
}
}
public FBase()
{
InitializeComponent();
this.SetStyle(ControlStyles.ResizeRedraw, true);
m_MsgEventHandler += new UIMessageEventHandler(ProcessUIMessage);
}
protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent)
{
if (!m_ShowGradient)
{
base.OnPaintBackground(pevent);
}
else
{
if (this.Disposing) return;
if (ClientRectangle.IsEmpty) return;
LinearGradientBrush linearGradientBrush = new LinearGradientBrush(ClientRectangle, m_StartColor, m_EndColor, m_LinearGradientMode);
pevent.Graphics.FillRectangle(linearGradientBrush, ClientRectangle);
pevent.Graphics.Flush();
linearGradientBrush.Dispose();
}
}
private void FBase_FormClosed(object sender, FormClosedEventArgs e)
{
//取消在MDI窗体中的注册
if (this.MdiParent != null)
{
try
{
if (!string.IsNullOrEmpty(m_MenuId))
((IMainForm)this.MdiParent).UNRegChildForm(m_MenuId);
}
catch(Exception ex)
{
System.Diagnostics.Debug.WriteLine("UNRegChildForm出错:"+ex.ToString());
AppError err = new AppError(ex.Message, "UNRegChildForm", this.GetType(), ex);
AppLog.Add(err);
}
}
//取消消息注册
this.UnSubscribeEvent();
}
//消息订阅
protected int SubscribeEvent(string msgId)
{
if (msgId == null || msgId.Trim() == "")
return -1;
m_MsgId.Add(msgId, null);
return UIMessageManager.SubscribeEvent(msgId, this, this.m_MsgEventHandler);
}
//取消消息订阅
private void UnSubscribeEvent()
{
foreach(string key in m_MsgId.Keys)
{
UIMessageManager.UnSubscribeEvent(key, this.m_MsgEventHandler);
}
m_MsgId.Clear();
}
//取消消息订阅
protected void UnSubscribeEvent(string msgId)
{
if (m_MsgId.Contains(msgId))
{
UIMessageManager.UnSubscribeEvent(msgId, this.m_MsgEventHandler);
m_MsgId.Remove(msgId);
}
}
private void FBase_Load(object sender, EventArgs e)
{
m_MsgEventHandler += new UIMessageEventHandler(ProcessUIMessage);
}
#region 消息处理
/// <summary>
/// 消息处理
/// </summary>
/// <param name="messageId"></param>
/// <param name="e"></param>
public virtual void ProcessUIMessage(string messageId, UIMessageEventArgs e)
{
}
#endregion
public string MenuId
{
get { return m_MenuId; }
set { m_MenuId = value; }
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -