📄 fdictbase.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Qeb.Control;
using Qeb.Resource;
using Qeb.Support.Common;
namespace Qeb.GY
{
public partial class FDictBase : FBase
{
protected UCDictBase m_CurrentUC = null;
private TagInfo m_TagInfo;
public FDictBase()
{
InitializeComponent();
this.Init();
}
#region 初始化
private void Init()
{
this.picLookUpTree.Image = Resource.Resource.GetImage("Btn_Query");
this.txtLookUpTree.LoopUpPrompt = "不支持快速定位";
this.picLookUpDW.Image = Resource.Resource.GetImage("Btn_Query");
this.txtLookUpTree.LoopUpPrompt = "不支持快速定位";
}
/// <summary>
/// 初始化树
/// </summary>
protected virtual void InitTreeView()
{
}
#endregion
#region 快速定位
private void picLookUpTree_Click(object sender, EventArgs e)
{
FindInTree(this.txtLookUpTree.Text);
}
private void picLookUpDW_Click(object sender, EventArgs e)
{
if (m_CurrentUC != null)
m_CurrentUC.FindInDw(this.txtLookUpDW.Text);
}
/// <summary>
/// 查找树
/// </summary>
/// <param name="findText">要查找的文字</param>
protected virtual void FindInTree(string findText)
{
//this.tvCatalog.Nodes.IndexOf(
}
/// <summary>
///设置数据窗口顶部信息
/// </summary>
protected void SetDWTitle(string message)
{
this.lbMsg.Text = message;
}
#endregion
#region TreeView事件
/// <summary>
/// 在展开树节点后发生
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void tvCatalog_AfterExpand(object sender, TreeViewEventArgs e)
{
}
/// <summary>
/// 在折叠树节点后发生
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void tvCatalog_AfterCollapse(object sender, TreeViewEventArgs e)
{
}
/// <summary>
/// 在选定树节点后发生的事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void tvCatalog_AfterSelect(object sender, TreeViewEventArgs e)
{
if (m_TagInfo.ControlName == "")
{
return;
}
else
{
try
{
//当前控件不变,检索参数有变
if (m_CurrentUC != null && m_CurrentUC.GetType().Name == m_TagInfo.ControlName)
{
if (m_TagInfo.RefreshParam != "")
{
//发送消息(消息接收者需根据检索参数、上一次检索参数来确定是否需要刷新)
UIMessageEventArgs eventArgs = new UIMessageEventArgs(this, m_TagInfo);
UIMessageManager.FireEvent(MsgEventDefine.Dict_RefreshWithParam, eventArgs);
//lbTitle2.Text = e.Node.ToolTipText;
}
return;
}
//设置字典信息标题
lbTitle2.Text = e.Node.ToolTipText;
//装载新的控件
string moduleName = this.GetType().Module.Name;
if (moduleName.EndsWith(".dll"))
{
moduleName = moduleName.Remove(moduleName.Length - 4, 4);
}
string typeName = moduleName + "." + m_TagInfo.ControlName;
//Type type = Type.GetType(typeName, true, true);
//m_CurrentUC = (UCDictBase)Activator.CreateInstance(type, null);
m_CurrentUC = (UCDictBase)this.GetType().Assembly.CreateInstance(typeName);
this.panelUC.Controls.Add(m_CurrentUC);
m_CurrentUC.Dock = DockStyle.Fill;
if (string.IsNullOrEmpty(m_CurrentUC.LookUpPromptText))
this.txtLookUpDW.LoopUpPrompt = "不支持快速定位";
else
this.txtLookUpDW.LoopUpPrompt = m_CurrentUC.LookUpPromptText;
//发送消息(如果控件订阅了消息,则根据检索参数刷新数据,否则自行控制数据检索)
UIMessageEventArgs ee = new UIMessageEventArgs(this, m_TagInfo);
UIMessageManager.FireEvent(MsgEventDefine.Dict_RefreshWithParam, ee);
}
catch (Exception ex)
{
m_CurrentUC = null;
MessageBox.Show("创建实例出错:" + ex.Message + "\n详细信息:" + ex.ToString());
}
finally
{
//
}
}
}
/// <summary>
/// 在展开树节点前发生的事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void tvCatalog_BeforeExpand(object sender, TreeViewCancelEventArgs e)
{
}
/// <summary>
/// 在折叠树节点前发生的事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void tvCatalog_BeforeCollapse(object sender, TreeViewCancelEventArgs e)
{
}
/// <summary>
/// 在选定树节点前发生的事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected virtual void tvCatalog_BeforeSelect(object sender, TreeViewCancelEventArgs e)
{
//分割Tag
m_TagInfo = this.SplitNodeTag(e.Node.Tag);
if (m_TagInfo.ControlName == "")
{
return;
}
else
{
if (m_CurrentUC != null)
{
//使用相同控件,但检索参数不同的,不需要将控件卸载
if (m_CurrentUC.GetType().Name == m_TagInfo.ControlName)
{
return;
}
//卸载控件,AfterSelect事件需要装载新的控件
DialogResult result = DialogResult.No;
if (m_CurrentUC.IsModified)
{
result = MessageBox.Show(this, "数据已修改,是否需要保存?", MsgTitle.Prompt, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
}
if (result == DialogResult.Yes)
{
e.Cancel = true;
return;
}
else
{
UnLoadControl(m_CurrentUC);
}
}
}
}
#endregion
public struct TagInfo
{
public string ControlName;
public string RefreshParam;
}
private TagInfo SplitNodeTag(object tag)
{
TagInfo tagInfo;
if (tag == null || tag.ToString() == "")
{
tagInfo.ControlName = "";
tagInfo.RefreshParam = "";
}
else
{
string temp = tag.ToString();
int index = temp.IndexOf("|||");
if (index > -1)
{
tagInfo.ControlName = temp.Substring(0, index);
tagInfo.RefreshParam = temp.Substring(index + 3);
}
else
{
tagInfo.ControlName = temp;
tagInfo.RefreshParam = "";
}
}
return tagInfo;
}
protected void LoadControl(UCDictBase uc)
{
this.panelUC.Controls.Add(uc);
m_CurrentUC = uc;
}
protected void UnLoadControl(UCDictBase uc)
{
uc.Dispose();
this.panelUC.Controls.Remove(uc);
m_CurrentUC = null;
}
private void FDictBase_Load(object sender, EventArgs e)
{
this.InitTreeView();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -