|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using ICSharpCode.Core;
|
|
|
|
|
using Mesnac.PlugIn.Pad;
|
|
|
|
|
using Mesnac.PlugIn.View;
|
|
|
|
|
using Mesnac.PlugIn.Workbench;
|
|
|
|
|
using Mesnac.Gui.PlugIn;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Gui.Run.Pad
|
|
|
|
|
{
|
|
|
|
|
public partial class FrmSysFunction : DefaultPadContent
|
|
|
|
|
{
|
|
|
|
|
public FrmSysFunction()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
Workbench.WorkbenchSingleton.Workbench.AfterRefreshPlugIn += new EventHandler(Workbench_AfterRefreshPlugIn); //刷新插件事件处理
|
|
|
|
|
Mesnac.Basic.LanguageHelper.LanguageChanged += LanguageHelper_LanguageChanged; //语言切换事件
|
|
|
|
|
Mesnac.Basic.UserInfo.Instance.OnReLogin += Instance_OnReLogin; //用户登录事件
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 用户登录事件处理程序
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void Instance_OnReLogin(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this.InvokeRequired)
|
|
|
|
|
{
|
|
|
|
|
Delegate d = new Mesnac.Basic.InvokeHelper.DoWork(this.ProcessReLogin);
|
|
|
|
|
this.BeginInvoke(d);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.ProcessReLogin();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ProcessReLogin()
|
|
|
|
|
{
|
|
|
|
|
TreeNode tnPlugin = Mesnac.Basic.TreeViewHelper.GetFirstNodeByNodeName(this.treeView1, "tnPlugin");
|
|
|
|
|
this.BindData();
|
|
|
|
|
|
|
|
|
|
if (tnPlugin != null && tnPlugin.Nodes.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
this.treeView1.Nodes.Add(tnPlugin);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 语言切换事件处理程序
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void LanguageHelper_LanguageChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TreeNode tnPlugin = Mesnac.Basic.TreeViewHelper.GetFirstNodeByNodeName(this.treeView1, "tnPlugin");
|
|
|
|
|
|
|
|
|
|
this.BindData();
|
|
|
|
|
|
|
|
|
|
if (tnPlugin != null && tnPlugin.Nodes.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
this.treeView1.Nodes.Add(tnPlugin);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 插件刷新事件处理
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void Workbench_AfterRefreshPlugIn(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
#region 加载菜单功能
|
|
|
|
|
|
|
|
|
|
this.BindData();
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 加载插件功能
|
|
|
|
|
|
|
|
|
|
TreeNode tnPlugin = new TreeNode();
|
|
|
|
|
tnPlugin.Name = "tnPlugIn";
|
|
|
|
|
tnPlugin.Text = StringParser.Parse(ResourceService.GetString("Pad_FrmSysFunction_PlugInFunction_Text")); //插件功能
|
|
|
|
|
|
|
|
|
|
List<PlugIn.PlugInDescriptor> plugInCollection = sender as List<PlugIn.PlugInDescriptor>;
|
|
|
|
|
if (plugInCollection != null && plugInCollection.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (PlugInDescriptor plugIn in plugInCollection)
|
|
|
|
|
{
|
|
|
|
|
TreeNode tnFunction = new TreeNode();
|
|
|
|
|
tnFunction.Text = plugIn.FunctionName;
|
|
|
|
|
if (plugIn.ViewContents != null && plugIn.ViewContents.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (IViewContent view in plugIn.ViewContents)
|
|
|
|
|
{
|
|
|
|
|
TreeNode tnView = new TreeNode();
|
|
|
|
|
tnView.Text = view.TitleName;
|
|
|
|
|
tnView.Tag = view;
|
|
|
|
|
tnFunction.Nodes.Add(tnView);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
tnPlugin.Nodes.Add(tnFunction);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tnPlugin.Nodes.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
this.treeView1.Nodes.Add(tnPlugin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 绑定菜单功能数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void BindData()
|
|
|
|
|
{
|
|
|
|
|
this.treeView1.Nodes.Clear();
|
|
|
|
|
|
|
|
|
|
if (System.IO.File.Exists(Mesnac.Gui.Run.Global.AppConfigHandler.Instance.MenuConfig))
|
|
|
|
|
{
|
|
|
|
|
TreeNode root = Mesnac.Basic.SerializeHandler.Deserialize<TreeNode>(Mesnac.Gui.Run.Global.AppConfigHandler.Instance.MenuConfig);
|
|
|
|
|
root.Text = StringParser.Parse(ResourceService.GetString("Pad_FrmSysFunction_MenuFunction_Text")); //菜单功能
|
|
|
|
|
|
|
|
|
|
this.ProcessMenuFunction(root);
|
|
|
|
|
|
|
|
|
|
root.Expand();
|
|
|
|
|
this.treeView1.Nodes.Add(root);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 处理菜单功能国际化、权限、删除系统菜单节点
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 处理菜单功能国际化、权限、删除系统菜单节点
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="root"></param>
|
|
|
|
|
private void ProcessMenuFunction(TreeNode root)
|
|
|
|
|
{
|
|
|
|
|
List<TreeNode> removeNodeList = new List<TreeNode>();
|
|
|
|
|
foreach(TreeNode childNode in root.Nodes)
|
|
|
|
|
{
|
|
|
|
|
Mesnac.Basic.RunConfigMenuItem rcmi = childNode.Tag as Mesnac.Basic.RunConfigMenuItem;
|
|
|
|
|
if (rcmi != null)
|
|
|
|
|
{
|
|
|
|
|
#region 把系统菜单放入要移除的集合
|
|
|
|
|
|
|
|
|
|
if (rcmi.IsSystem)
|
|
|
|
|
{
|
|
|
|
|
removeNodeList.Add(childNode);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 用户权限处理
|
|
|
|
|
|
|
|
|
|
if (rcmi.CreateType == Mesnac.Basic.CreateType.Form)
|
|
|
|
|
{
|
|
|
|
|
if (!Mesnac.Basic.UserInfo.Instance.RoleGUID.Equals("-99") && Mesnac.Basic.UserInfo.Instance.AllFormPurview.Contains(rcmi.ID) && !Mesnac.Basic.UserInfo.Instance.PurviewList.Contains(rcmi.ID))
|
|
|
|
|
{
|
|
|
|
|
removeNodeList.Add(childNode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
ProcessMenuFunction(childNode); //移除菜单
|
|
|
|
|
|
|
|
|
|
#region 自定义菜单国际化处理
|
|
|
|
|
|
|
|
|
|
if (rcmi.Text != "-")
|
|
|
|
|
{
|
|
|
|
|
if (!String.IsNullOrEmpty(rcmi.MsgId))
|
|
|
|
|
{
|
|
|
|
|
if (Mesnac.Gui.Run.Global.AppConfigHandler.Instance.SysMessages.Messages.ContainsKey(rcmi.MsgId))
|
|
|
|
|
{
|
|
|
|
|
if (Mesnac.Gui.Run.Global.AppConfigHandler.Instance.SysMessages.Messages[rcmi.MsgId].ContainsKey(System.Threading.Thread.CurrentThread.CurrentUICulture.Name))
|
|
|
|
|
{
|
|
|
|
|
childNode.Text = Mesnac.Gui.Run.Global.AppConfigHandler.Instance.SysMessages.Messages[rcmi.MsgId][System.Threading.Thread.CurrentThread.CurrentUICulture.Name].Value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 移除系统菜单
|
|
|
|
|
|
|
|
|
|
foreach (TreeNode node in removeNodeList)
|
|
|
|
|
{
|
|
|
|
|
root.Nodes.Remove(node);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 事件处理
|
|
|
|
|
|
|
|
|
|
private void FrmSysFunction_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.BindData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 双击树节点事件处理程序
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
#region 打开插件功能
|
|
|
|
|
|
|
|
|
|
IViewContent viewContent = e.Node.Tag as IViewContent;
|
|
|
|
|
if (viewContent != null)
|
|
|
|
|
{
|
|
|
|
|
Workbench.WorkbenchSingleton.Workbench.ShowView(viewContent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 打开菜单功能
|
|
|
|
|
|
|
|
|
|
Mesnac.Basic.RunConfigMenuItem rcmi = e.Node.Tag as Mesnac.Basic.RunConfigMenuItem;
|
|
|
|
|
if (rcmi != null)
|
|
|
|
|
{
|
|
|
|
|
if (rcmi.CreateType == Mesnac.Basic.CreateType.Form && !String.IsNullOrEmpty(rcmi.FormFile))
|
|
|
|
|
{
|
|
|
|
|
//自定义菜单事件处理,打开组态画面
|
|
|
|
|
Mesnac.Gui.Run.Global.AppConfigHandler.SysConfigMenuCommand.Instance.Run(rcmi.FormFile, rcmi.ShowType);
|
|
|
|
|
}
|
|
|
|
|
else if (rcmi.CreateType == Mesnac.Basic.CreateType.Command)
|
|
|
|
|
{
|
|
|
|
|
//自定义菜单事件处理,执行组态命令
|
|
|
|
|
Mesnac.Gui.Run.Global.AppConfigHandler.Instance.RunCommand(sender, rcmi);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|