|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Mesnac.Gui.Workbench;
|
|
|
|
|
using Mesnac.PlugIn.View;
|
|
|
|
|
using ICSharpCode.Core;
|
|
|
|
|
using Mesnac.Basic;
|
|
|
|
|
using Mesnac.Gui.Run.Global;
|
|
|
|
|
using Mesnac.Gui.Run.Dialog;
|
|
|
|
|
using Mesnac.PlugIn;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Gui.Run.ViewContent
|
|
|
|
|
{
|
|
|
|
|
public partial class FrmSysConfig : DefaultViewContent
|
|
|
|
|
{
|
|
|
|
|
private DataTable _localeTable = null; //当前资源项的区域语言数据表
|
|
|
|
|
private string _projectPath = Path.Combine(Application.StartupPath, AppConfigHandler.Instance.MCProjectPath); //组态工程路径
|
|
|
|
|
private string caption = StringParser.Parse(ResourceService.GetString("Mesnac_Dialog_Caption")); //提示 保存消息框的标题
|
|
|
|
|
private string lblCurrentNodeText = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_lblCurrentNode_Text")); // "未选择";
|
|
|
|
|
public FrmSysConfig()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
this.InitUI();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 窗体初始化
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化界面
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void InitUI()
|
|
|
|
|
{
|
|
|
|
|
this.Text = StringParser.Parse(ResourceService.GetString("Mesnac_MainMenu_SysConfig")); //系统工程配置
|
|
|
|
|
this.TitleName = this.Text;
|
|
|
|
|
this.btnScan.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_btnScan_Text")); //扫描工程
|
|
|
|
|
this.label1.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_label1_Text")); //当前节点:
|
|
|
|
|
this.btnAddTop.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_btnAddTop_Text")); //添加顶级
|
|
|
|
|
this.btnAdd.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_btnAdd_Text")); //添加子节点
|
|
|
|
|
this.btnModify.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_btnModify_Text")); //修改
|
|
|
|
|
this.btnDelete.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_btnDelete_Text")); //删除
|
|
|
|
|
this.btnMoveUp.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_btnMoveUp_Text")); //平级上移
|
|
|
|
|
this.btnMoveDown.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_btnMoveDown_Text")); //平级下移
|
|
|
|
|
this.btnMoveParent.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_btnMoveParent_Text")); //上移一级
|
|
|
|
|
this.btnMoveChild.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_btnMoveChild_Text")); //下移一级
|
|
|
|
|
this.btnExpandAll.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_btnExpandAll_Text")); //展开所有
|
|
|
|
|
this.btnMoveUpTool.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_btnMoveUpTool_Text")); //上移
|
|
|
|
|
this.btnMoveDownTool.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_btnMoveDownTool_Text")); //下移
|
|
|
|
|
this.btnDeleteTool.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_btnDeleteTool_Text")); //删除
|
|
|
|
|
this.btnAddSepTool.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_btnAddSepTool_Text")); //添加分隔符
|
|
|
|
|
this.btnSetOrginal.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_btnSetOrginal_Text")); //重置原始菜单
|
|
|
|
|
this.btnLoadConfig.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_btnLoadConfig_Text")); //读取菜单配置
|
|
|
|
|
this.btnSave.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_btnSave_Text")); //保存菜单配置
|
|
|
|
|
this.btnApply.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_btnApply_Text")); //应用菜单配置
|
|
|
|
|
this.btnSetOrginalTool.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_btnSetOrginalTool_Text")); //重置原始工具栏
|
|
|
|
|
this.btnLoadConfigTool.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_btnLoadConfigTool_Text")); //读取工具栏配置
|
|
|
|
|
this.btnSaveTool.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_btnSaveTool_Text")); //保存工具栏配置
|
|
|
|
|
this.btnApplyTool.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_btnApplyTool_Text")); //应用工具栏配置
|
|
|
|
|
|
|
|
|
|
this.gbProject.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_gbProject_Text")); //工程项
|
|
|
|
|
this.gbMenuStrip.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_gbMenuStrip_Text")); //目标菜单项
|
|
|
|
|
this.gbToolStrip.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_gbToolStrip_Text")); //目标工具栏
|
|
|
|
|
|
|
|
|
|
this.btnI18N.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_btnI18N_Text")); //国际化面板
|
|
|
|
|
this.gbI18N.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_gbI18N_Text")); //国际化设置
|
|
|
|
|
this.tsbAddMessage.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_tsbAddMessage_Text")); //添加
|
|
|
|
|
this.tsbDeleteMessage.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_tsbDeletedMessage_Text")); //删除
|
|
|
|
|
this.tsbSetLocale.Text = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_tsbSetLocale_Text")); //设置
|
|
|
|
|
|
|
|
|
|
this.dgvLocale.Columns["colLanguage"].HeaderText = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_dgvLocale_colLanguage_HeaderText")); //区域
|
|
|
|
|
this.dgvLocale.Columns["colValue"].HeaderText = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_dgvLocale_colValue_HeaderText")); //值
|
|
|
|
|
this.dgvLocale.Columns["colCode"].HeaderText = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_colCode_HeaderText")); //区域代码
|
|
|
|
|
this.dgvLocale.Columns["colCountry"].HeaderText = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_colCountry_HeaderText")); //国家
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载国际化资源项
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void LoadSysMessage()
|
|
|
|
|
{
|
|
|
|
|
this.lstMessages.Items.Clear();
|
|
|
|
|
this.lstMessages.Items.AddRange(AppConfigHandler.Instance.SysMessages.Messages.Keys.ToArray<string>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载系统原始菜单
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void LoadSystemOriginalMenu()
|
|
|
|
|
{
|
|
|
|
|
(WorkbenchSingleton.Workbench as DefaultWorkbench).CreateMainMenu();
|
|
|
|
|
if (WorkbenchSingleton.Workbench.TopMenu != null)
|
|
|
|
|
{
|
|
|
|
|
this.tvMenuList.Nodes.Clear();
|
|
|
|
|
foreach (ToolStripMenuItem menuItem in WorkbenchSingleton.Workbench.TopMenu.Items)
|
|
|
|
|
{
|
|
|
|
|
this.tvMenuList.Nodes.Add(AppConfigHandler.Instance.ConvertToolStripItemToTreeNode(menuItem));
|
|
|
|
|
}
|
|
|
|
|
this.tvMenuList.ExpandAll();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载系统原始工具栏按钮
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void LoadSystemOriginalToolStrip()
|
|
|
|
|
{
|
|
|
|
|
(WorkbenchSingleton.Workbench as DefaultWorkbench).CreateMainToolStrip();
|
|
|
|
|
if (WorkbenchSingleton.Workbench.ToolStrip != null)
|
|
|
|
|
{
|
|
|
|
|
this.lbToolStrip.Items.Clear();
|
|
|
|
|
foreach (ToolStripItem item in WorkbenchSingleton.Workbench.ToolStrip.Items)
|
|
|
|
|
{
|
|
|
|
|
this.lbToolStrip.Items.Add(AppConfigHandler.Instance.ConvertToolStripItemToTreeNode(item).Tag);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载系统菜单
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void LoadSystemMenu()
|
|
|
|
|
{
|
|
|
|
|
this.lblCurrentNode.Text = this.lblCurrentNodeText; //未选择
|
|
|
|
|
|
|
|
|
|
this.tvMenuList.Nodes.Clear();
|
|
|
|
|
if (File.Exists(AppConfigHandler.Instance.MenuConfig))
|
|
|
|
|
{
|
|
|
|
|
TreeNode root = AppConfigHandler.Instance.DeserializeObject(AppConfigHandler.Instance.MenuConfig) as TreeNode;
|
|
|
|
|
if (root != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (TreeNode tn in root.Nodes)
|
|
|
|
|
{
|
|
|
|
|
this.tvMenuList.Nodes.Add(tn);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.LoadSystemOriginalMenu();
|
|
|
|
|
}
|
|
|
|
|
this.tvMenuList.ExpandAll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 载入系统工具栏
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void LoadSystemToolStrip()
|
|
|
|
|
{
|
|
|
|
|
this.lbToolStrip.Items.Clear();
|
|
|
|
|
if (File.Exists(AppConfigHandler.Instance.ToolStripConfig))
|
|
|
|
|
{
|
|
|
|
|
object obj = AppConfigHandler.Instance.DeserializeObject(AppConfigHandler.Instance.ToolStripConfig);
|
|
|
|
|
if (obj != null)
|
|
|
|
|
{
|
|
|
|
|
List<RunConfigMenuItem> lst = obj as List<RunConfigMenuItem>;
|
|
|
|
|
foreach (RunConfigMenuItem item in lst)
|
|
|
|
|
{
|
|
|
|
|
this.lbToolStrip.Items.Add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.LoadSystemOriginalToolStrip();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void FrmSysConfig_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.LoadSysMessage(); //载入国际化资源项
|
|
|
|
|
this.LoadSystemMenu(); //载入系统菜单
|
|
|
|
|
this.LoadSystemToolStrip(); //载入系统工具栏
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void FrmSysConfig_Activated(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.tvMenuList.ExpandAll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 扫描工程
|
|
|
|
|
|
|
|
|
|
private void btnScan_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<FrmSysConfig>.Debug(System.Threading.Thread.CurrentThread.CurrentUICulture.Name);
|
|
|
|
|
//扫描工程
|
|
|
|
|
List<RunConfigMenuItem> formMenuItems = XmlHandler.GetProjectFormMenus(this._projectPath);
|
|
|
|
|
this.lbFormList.Items.Clear();
|
|
|
|
|
foreach (RunConfigMenuItem menuItem in formMenuItems)
|
|
|
|
|
{
|
|
|
|
|
this.lbFormList.Items.Add(menuItem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 把扫描的所有菜单列表添加至当前节点的下面
|
|
|
|
|
|
|
|
|
|
private void btnMoveAll_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
object[] items = new object[this.lbFormList.Items.Count];
|
|
|
|
|
this.lbFormList.Items.CopyTo(items, 0);
|
|
|
|
|
this.MoveMenuToTree(items);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 把指定的扫描菜单项添加至当前节点
|
|
|
|
|
|
|
|
|
|
private void btnMoveSelect_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
object[] items = new object[this.lbFormList.SelectedItems.Count];
|
|
|
|
|
this.lbFormList.SelectedItems.CopyTo(items, 0);
|
|
|
|
|
this.MoveMenuToTree(items);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MoveMenuToTree(object[] items)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
TreeNode tnCurrent = this.tvMenuList.SelectedNode;
|
|
|
|
|
TreeNode tn = null;
|
|
|
|
|
foreach (RunConfigMenuItem menuItem in items)
|
|
|
|
|
{
|
|
|
|
|
if (this.tvMenuList.GetFirstNodeByNodeName(menuItem.ID) == null)
|
|
|
|
|
{
|
|
|
|
|
tn = new TreeNode();
|
|
|
|
|
tn.Name = menuItem.ID;
|
|
|
|
|
tn.Text = menuItem.Text;
|
|
|
|
|
tn.Tag = menuItem;
|
|
|
|
|
tn.ToolTipText = menuItem.FormText;
|
|
|
|
|
if (tnCurrent == null)
|
|
|
|
|
{
|
|
|
|
|
this.tvMenuList.Nodes.Add(tn);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tnCurrent.Nodes.Add(tn);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (String.IsNullOrEmpty(sb.ToString()))
|
|
|
|
|
{
|
|
|
|
|
sb.Append(menuItem.Text);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sb.Append(","); sb.Append(menuItem.Text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.tvMenuList.ExpandAll();
|
|
|
|
|
if (!String.IsNullOrEmpty(sb.ToString()))
|
|
|
|
|
{
|
|
|
|
|
string msg = String.Format(StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_MoveMenuToTree")), sb.ToString()); //"目标菜单树中已经包含了此项\r\n{0}!"
|
|
|
|
|
MessageBox.Show(msg, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 添加顶级节点
|
|
|
|
|
|
|
|
|
|
private void btnAddTop_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
FrmRunConfigMenuItem frmRunConfigMenuItem = new FrmRunConfigMenuItem();
|
|
|
|
|
DialogResult result = frmRunConfigMenuItem.ShowDialog(this);
|
|
|
|
|
if (result == System.Windows.Forms.DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
RunConfigMenuItem menuItem = new RunConfigMenuItem();
|
|
|
|
|
menuItem.ID = Guid.NewGuid().ToString();
|
|
|
|
|
menuItem.MsgId = frmRunConfigMenuItem.MsgId;
|
|
|
|
|
menuItem.Text = frmRunConfigMenuItem.NodeText;
|
|
|
|
|
menuItem.ICON = frmRunConfigMenuItem.NodeImg;
|
|
|
|
|
menuItem.IsSystem = false;
|
|
|
|
|
|
|
|
|
|
TreeNode tn = new TreeNode();
|
|
|
|
|
tn.Text = menuItem.Text;
|
|
|
|
|
tn.Tag = menuItem;
|
|
|
|
|
this.tvMenuList.Nodes.Add(tn);
|
|
|
|
|
this.tvMenuList.ExpandAll();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 添加子级节点
|
|
|
|
|
|
|
|
|
|
private void btnAdd_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TreeNode tn = this.tvMenuList.SelectedNode;
|
|
|
|
|
if (tn == null)
|
|
|
|
|
{
|
|
|
|
|
string msg = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_btnAdd")); //请选择一个父级项!
|
|
|
|
|
MessageBox.Show(msg, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
FrmRunConfigMenuItem frmRunConfigMenuItem = new FrmRunConfigMenuItem(0, tn.Text, String.Empty);
|
|
|
|
|
DialogResult result = frmRunConfigMenuItem.ShowDialog(this);
|
|
|
|
|
if (result == System.Windows.Forms.DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
RunConfigMenuItem menuItem = new RunConfigMenuItem();
|
|
|
|
|
menuItem.ID = Guid.NewGuid().ToString();
|
|
|
|
|
menuItem.Text = frmRunConfigMenuItem.NodeText;
|
|
|
|
|
menuItem.ICON = frmRunConfigMenuItem.NodeImg;
|
|
|
|
|
menuItem.IsSystem = false;
|
|
|
|
|
|
|
|
|
|
TreeNode newNode = new TreeNode();
|
|
|
|
|
newNode.Text = menuItem.Text;
|
|
|
|
|
newNode.Tag = menuItem;
|
|
|
|
|
|
|
|
|
|
tn.Nodes.Add(newNode);
|
|
|
|
|
tn.ExpandAll();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 修改节点
|
|
|
|
|
|
|
|
|
|
private void btnModify_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TreeNode tn = this.tvMenuList.SelectedNode;
|
|
|
|
|
if (tn == null)
|
|
|
|
|
{
|
|
|
|
|
string msg = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_btnModify")); //"请选择一个要修改的项!"
|
|
|
|
|
MessageBox.Show(msg, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string parentText;
|
|
|
|
|
if (tn.Parent != null)
|
|
|
|
|
{
|
|
|
|
|
parentText = tn.Parent.Text;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
parentText = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_parentText")); //"顶级";
|
|
|
|
|
}
|
|
|
|
|
FrmRunConfigMenuItem frmRunConfigMenuItem = new FrmRunConfigMenuItem(1, parentText, (tn.Tag as RunConfigMenuItem).MsgId, tn.Text, (tn.Tag as RunConfigMenuItem).ShortCut, (tn.Tag as RunConfigMenuItem).ShowType, (tn.Tag as RunConfigMenuItem).FormFile, (tn.Tag as RunConfigMenuItem).IsAutoLoad);
|
|
|
|
|
DialogResult result = frmRunConfigMenuItem.ShowDialog(this);
|
|
|
|
|
if (result == System.Windows.Forms.DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
tn.Text = frmRunConfigMenuItem.NodeText;
|
|
|
|
|
RunConfigMenuItem menuItem = tn.Tag as RunConfigMenuItem;
|
|
|
|
|
if (menuItem != null)
|
|
|
|
|
{
|
|
|
|
|
menuItem.MsgId = frmRunConfigMenuItem.MsgId;
|
|
|
|
|
menuItem.Text = tn.Text;
|
|
|
|
|
if (!String.IsNullOrEmpty(frmRunConfigMenuItem.NodeImg) && File.Exists(frmRunConfigMenuItem.NodeImg))
|
|
|
|
|
{
|
|
|
|
|
menuItem.Img = Image.FromFile(frmRunConfigMenuItem.NodeImg);
|
|
|
|
|
}
|
|
|
|
|
menuItem.ShowType = (FormShowType)frmRunConfigMenuItem.ShowType;
|
|
|
|
|
menuItem.ShortCut = frmRunConfigMenuItem.ShortCut;
|
|
|
|
|
menuItem.IsAutoLoad = frmRunConfigMenuItem.IsAutoLoad;
|
|
|
|
|
tn.Tag = menuItem;
|
|
|
|
|
}
|
|
|
|
|
this.lblCurrentNode.Text = tn.Text;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 删除节点
|
|
|
|
|
|
|
|
|
|
private void btnDelete_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TreeNode tn = this.tvMenuList.SelectedNode;
|
|
|
|
|
if (tn == null)
|
|
|
|
|
{
|
|
|
|
|
string msg1 = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_btnDelete1")); //请选择一个要删除的项!
|
|
|
|
|
MessageBox.Show(msg1, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
RunConfigMenuItem menuItem = tn.Tag as RunConfigMenuItem;
|
|
|
|
|
if (menuItem != null)
|
|
|
|
|
{
|
|
|
|
|
if (menuItem.IsSystem)
|
|
|
|
|
{
|
|
|
|
|
string msg2 = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_btnDelete2")); //系统原始数据项不能删除!
|
|
|
|
|
MessageBox.Show(msg2, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string msg3 = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_Delete")); //确定要删除吗?
|
|
|
|
|
DialogResult result = MessageBox.Show(msg3, this.caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
|
|
if (result == System.Windows.Forms.DialogResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
if (tn.Parent != null)
|
|
|
|
|
{
|
|
|
|
|
tn.Parent.Nodes.Remove(tn);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.tvMenuList.Nodes.Remove(tn);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 平级上移
|
|
|
|
|
|
|
|
|
|
private void btnMoveUp_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TreeNode tn = this.tvMenuList.SelectedNode;
|
|
|
|
|
if (tn == null)
|
|
|
|
|
{
|
|
|
|
|
string msgMove = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_Move")); //请选择一个要移动的项
|
|
|
|
|
MessageBox.Show(msgMove, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
TreeNode prevNode = tn.PrevNode;
|
|
|
|
|
if (prevNode == null)
|
|
|
|
|
{
|
|
|
|
|
string msg = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_btnMoveUp")); //此项已经是当前级别的最顶项!
|
|
|
|
|
MessageBox.Show(msg, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (tn.Parent != null)
|
|
|
|
|
{
|
|
|
|
|
tn.Parent.Nodes.Remove(tn);
|
|
|
|
|
prevNode.Parent.Nodes.Insert(prevNode.Index, tn);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.tvMenuList.Nodes.Remove(tn);
|
|
|
|
|
this.tvMenuList.Nodes.Insert(prevNode.Index, tn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.tvMenuList.ExpandAll();
|
|
|
|
|
this.tvMenuList.SelectedNode = tn;
|
|
|
|
|
this.tvMenuList.Focus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 平级下移
|
|
|
|
|
|
|
|
|
|
private void btnMoveDown_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TreeNode tn = this.tvMenuList.SelectedNode;
|
|
|
|
|
if (tn == null)
|
|
|
|
|
{
|
|
|
|
|
string msgMove = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_Move")); //请选择一个要移动的项
|
|
|
|
|
MessageBox.Show(msgMove, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
TreeNode prevNode = tn.NextNode;
|
|
|
|
|
if (prevNode == null)
|
|
|
|
|
{
|
|
|
|
|
string msg = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_btnMoveDown")); //此项已经是当前级别的最后项!
|
|
|
|
|
MessageBox.Show(msg, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (tn.Parent != null)
|
|
|
|
|
{
|
|
|
|
|
TreeNode parent = tn.Parent;
|
|
|
|
|
parent.Nodes.Remove(prevNode);
|
|
|
|
|
parent.Nodes.Insert(tn.Index, prevNode);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.tvMenuList.Nodes.Remove(prevNode);
|
|
|
|
|
this.tvMenuList.Nodes.Insert(tn.Index, prevNode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.tvMenuList.ExpandAll();
|
|
|
|
|
this.tvMenuList.SelectedNode = tn;
|
|
|
|
|
this.tvMenuList.Focus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 上移一级
|
|
|
|
|
|
|
|
|
|
private void btnMoveParent_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string msg = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_btnMoveParent")); //此项已是第一级!
|
|
|
|
|
TreeNode tn = this.tvMenuList.SelectedNode;
|
|
|
|
|
if (tn == null)
|
|
|
|
|
{
|
|
|
|
|
string msgMove = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_Move")); //请选择一个要移动的项
|
|
|
|
|
MessageBox.Show(msgMove, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (tn.Parent == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(msg, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
TreeNode parent = tn.Parent;
|
|
|
|
|
parent.Nodes.Remove(tn);
|
|
|
|
|
if (parent.Parent != null)
|
|
|
|
|
{
|
|
|
|
|
parent.Parent.Nodes.Add(tn);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.tvMenuList.Nodes.Add(tn);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 下移一级
|
|
|
|
|
|
|
|
|
|
private void btnMoveChild_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string msg = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_btnMoveChild")); //此项已是最末级!
|
|
|
|
|
TreeNode tn = this.tvMenuList.SelectedNode;
|
|
|
|
|
if (tn == null)
|
|
|
|
|
{
|
|
|
|
|
string msgMove = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_Move")); //请选择一个要移动的项
|
|
|
|
|
MessageBox.Show(msgMove, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
TreeNode[] nodes = null;
|
|
|
|
|
if (tn.Parent != null)
|
|
|
|
|
{
|
|
|
|
|
TreeNode parent = tn.Parent;
|
|
|
|
|
|
|
|
|
|
nodes = new TreeNode[parent.Nodes.Count - 1];
|
|
|
|
|
int i = 0;
|
|
|
|
|
foreach (TreeNode n in parent.Nodes)
|
|
|
|
|
{
|
|
|
|
|
if (n != tn)
|
|
|
|
|
{
|
|
|
|
|
nodes[i++] = n;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (nodes.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(msg, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
FrmMoveChild frmMoveChild = new FrmMoveChild(nodes);
|
|
|
|
|
DialogResult result = frmMoveChild.ShowDialog(this);
|
|
|
|
|
if (result == System.Windows.Forms.DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
parent.Nodes.Remove(tn);
|
|
|
|
|
TreeNode newParent = frmMoveChild.CurrentNode;
|
|
|
|
|
newParent.Nodes.Add(tn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
nodes = new TreeNode[this.tvMenuList.Nodes.Count - 1];
|
|
|
|
|
int i = 0;
|
|
|
|
|
foreach (TreeNode n in this.tvMenuList.Nodes)
|
|
|
|
|
{
|
|
|
|
|
if (n != tn)
|
|
|
|
|
{
|
|
|
|
|
nodes[i++] = n;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (nodes.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(msg, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
FrmMoveChild frmMoveChild = new FrmMoveChild(nodes);
|
|
|
|
|
DialogResult result = frmMoveChild.ShowDialog(this);
|
|
|
|
|
if (result == System.Windows.Forms.DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
this.tvMenuList.Nodes.Remove(tn);
|
|
|
|
|
TreeNode newParent = frmMoveChild.CurrentNode;
|
|
|
|
|
newParent.Nodes.Add(tn);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 展开所有
|
|
|
|
|
|
|
|
|
|
private void btnExpandAll_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.tvMenuList.ExpandAll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 设置当前节点
|
|
|
|
|
|
|
|
|
|
private void tvMenuList_AfterSelect(object sender, TreeViewEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Node != null)
|
|
|
|
|
{
|
|
|
|
|
this.lblCurrentNode.Text = e.Node.Text;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.lblCurrentNode.Text = this.lblCurrentNodeText; //未选择
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tvMenuList_Leave(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TreeNode tn = this.tvMenuList.SelectedNode;
|
|
|
|
|
if (tn != null)
|
|
|
|
|
{
|
|
|
|
|
this.lblCurrentNode.Text = tn.Text;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.lblCurrentNode.Text = this.lblCurrentNodeText; //未选择
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 国际化面板
|
|
|
|
|
|
|
|
|
|
private void btnI18N_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.gbI18N.Visible = !this.gbI18N.Visible;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 读取原始菜单
|
|
|
|
|
|
|
|
|
|
private void btnSetOrginal_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.LoadSystemOriginalMenu();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 读取菜单配置
|
|
|
|
|
|
|
|
|
|
private void btnLoadConfig_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (File.Exists(AppConfigHandler.Instance.MenuConfig))
|
|
|
|
|
{
|
|
|
|
|
this.tvMenuList.Nodes.Clear();
|
|
|
|
|
TreeNode root = AppConfigHandler.Instance.DeserializeObject(AppConfigHandler.Instance.MenuConfig) as TreeNode;
|
|
|
|
|
if (root != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (TreeNode tn in root.Nodes)
|
|
|
|
|
{
|
|
|
|
|
this.tvMenuList.Nodes.Add(tn);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string msg = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_btnLoadConfig")); //还未保存过配置!
|
|
|
|
|
MessageBox.Show(msg, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 保存菜单配置
|
|
|
|
|
|
|
|
|
|
private void btnSave_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DirectoryInfo dir = new DirectoryInfo(Path.GetDirectoryName(AppConfigHandler.Instance.MenuConfig));
|
|
|
|
|
if (!dir.Exists)
|
|
|
|
|
{
|
|
|
|
|
dir.Create();
|
|
|
|
|
}
|
|
|
|
|
TreeNode root = new TreeNode();
|
|
|
|
|
foreach (TreeNode tn in this.tvMenuList.Nodes)
|
|
|
|
|
{
|
|
|
|
|
root.Nodes.Add(tn.Clone() as TreeNode);
|
|
|
|
|
}
|
|
|
|
|
AppConfigHandler.Instance.SerializeObject(root, AppConfigHandler.Instance.MenuConfig);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 应用菜单配置
|
|
|
|
|
|
|
|
|
|
private void btnApply_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
WorkbenchSingleton.Workbench.CloseAllKeysView();
|
|
|
|
|
TreeNode root = new TreeNode();
|
|
|
|
|
foreach (TreeNode node in this.tvMenuList.Nodes)
|
|
|
|
|
{
|
|
|
|
|
root.Nodes.Add(node.Clone() as TreeNode);
|
|
|
|
|
}
|
|
|
|
|
(WorkbenchSingleton.Workbench as DefaultWorkbench).CreateMainMenu();
|
|
|
|
|
AppConfigHandler.Instance.ReBuilderMenu(WorkbenchSingleton.Workbench.TopMenu, root, root);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 拖拽处理
|
|
|
|
|
|
|
|
|
|
private void tvMenuList_ItemDrag(object sender, ItemDragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Item != null)
|
|
|
|
|
{
|
|
|
|
|
this.DoDragDrop(e.Item, DragDropEffects.Copy);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tvMenuList_DragEnter(object sender, DragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Data != null)
|
|
|
|
|
{
|
|
|
|
|
e.Effect = DragDropEffects.Copy;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lbToolStrip_DragEnter(object sender, DragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Data != null)
|
|
|
|
|
{
|
|
|
|
|
e.Effect = DragDropEffects.Copy;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lbToolStrip_DragDrop(object sender, DragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TreeNode node = e.Data.GetData(typeof(System.Windows.Forms.TreeNode)) as TreeNode;
|
|
|
|
|
if (node != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (object item in this.lbToolStrip.Items)
|
|
|
|
|
{
|
|
|
|
|
RunConfigMenuItem rcmi = item as RunConfigMenuItem;
|
|
|
|
|
RunConfigMenuItem rcmiTemp = node.Tag as RunConfigMenuItem;
|
|
|
|
|
if (rcmi != null && rcmi.ID == rcmiTemp.ID)
|
|
|
|
|
{
|
|
|
|
|
string msgExists = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_ToolItemExists")); //工具栏中已存在此项!
|
|
|
|
|
MessageBox.Show(msgExists, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.lbToolStrip.Items.Add(node.Tag);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 工具栏项上移
|
|
|
|
|
|
|
|
|
|
private void btnMoveUpTool_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this.lbToolStrip.SelectedIndex == -1)
|
|
|
|
|
{
|
|
|
|
|
string msgMove = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_Move")); //请选择一个要移动的项
|
|
|
|
|
MessageBox.Show(msgMove, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (this.lbToolStrip.SelectedIndex == 0)
|
|
|
|
|
{
|
|
|
|
|
string msg = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_btnMoveUp")); //此项已经是当前级别的最顶项!
|
|
|
|
|
MessageBox.Show(msg, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int index = this.lbToolStrip.SelectedIndex - 1;
|
|
|
|
|
object item = this.lbToolStrip.SelectedItem;
|
|
|
|
|
this.lbToolStrip.Items.Remove(item);
|
|
|
|
|
this.lbToolStrip.Items.Insert(index, item);
|
|
|
|
|
this.lbToolStrip.SelectedIndex = index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 工具栏项下移
|
|
|
|
|
|
|
|
|
|
private void btnMoveDownTool_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this.lbToolStrip.SelectedIndex == -1)
|
|
|
|
|
{
|
|
|
|
|
string msgMove = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_Move")); //请选择一个要移动的项
|
|
|
|
|
MessageBox.Show(msgMove, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (this.lbToolStrip.SelectedIndex == this.lbToolStrip.Items.Count - 1)
|
|
|
|
|
{
|
|
|
|
|
string msg = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_btnMoveDown")); //此项已经是当前级别的最后项!
|
|
|
|
|
MessageBox.Show(msg, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int index = this.lbToolStrip.SelectedIndex + 1;
|
|
|
|
|
object item = this.lbToolStrip.SelectedItem;
|
|
|
|
|
this.lbToolStrip.Items.Remove(item);
|
|
|
|
|
this.lbToolStrip.Items.Insert(index, item);
|
|
|
|
|
this.lbToolStrip.SelectedIndex = index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 工具栏项删除
|
|
|
|
|
|
|
|
|
|
private void btnDeleteTool_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this.lbToolStrip.SelectedIndex == -1)
|
|
|
|
|
{
|
|
|
|
|
string msg1 = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_btnDelete1")); //请选择一个要删除的项!
|
|
|
|
|
MessageBox.Show(msg1, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string msg3 = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_Delete")); //确定要删除吗?
|
|
|
|
|
DialogResult result = MessageBox.Show(msg3, this.caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
|
|
{
|
|
|
|
|
object item = this.lbToolStrip.SelectedItem;
|
|
|
|
|
this.lbToolStrip.Items.Remove(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 添加工具栏分隔符
|
|
|
|
|
|
|
|
|
|
private void btnAddSepTool_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
RunConfigMenuItem toolSeparator = new RunConfigMenuItem();
|
|
|
|
|
toolSeparator.ID = Guid.NewGuid().ToString();
|
|
|
|
|
toolSeparator.Text = "-";
|
|
|
|
|
this.lbToolStrip.Items.Add(toolSeparator);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 重置原始工具栏
|
|
|
|
|
|
|
|
|
|
private void btnSetOrginalTool_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.LoadSystemOriginalToolStrip();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 读取工具栏配置
|
|
|
|
|
|
|
|
|
|
private void btnLoadConfigTool_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (File.Exists(AppConfigHandler.Instance.ToolStripConfig))
|
|
|
|
|
{
|
|
|
|
|
this.lbToolStrip.Items.Clear();
|
|
|
|
|
Object obj = AppConfigHandler.Instance.DeserializeObject(AppConfigHandler.Instance.ToolStripConfig);
|
|
|
|
|
if (obj != null)
|
|
|
|
|
{
|
|
|
|
|
List<RunConfigMenuItem> lst = obj as List<RunConfigMenuItem>;
|
|
|
|
|
foreach (RunConfigMenuItem item in lst)
|
|
|
|
|
{
|
|
|
|
|
this.lbToolStrip.Items.Add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string msg = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_btnLoadConfig")); //还未保存过配置!
|
|
|
|
|
MessageBox.Show(msg, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 保存工具栏配置
|
|
|
|
|
|
|
|
|
|
private void btnSaveTool_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DirectoryInfo dir = new DirectoryInfo(Path.GetDirectoryName(AppConfigHandler.Instance.ToolStripConfig));
|
|
|
|
|
if (!dir.Exists)
|
|
|
|
|
{
|
|
|
|
|
dir.Create();
|
|
|
|
|
}
|
|
|
|
|
List<RunConfigMenuItem> toolButtons = new List<RunConfigMenuItem>();
|
|
|
|
|
foreach (object item in this.lbToolStrip.Items)
|
|
|
|
|
{
|
|
|
|
|
toolButtons.Add(item as RunConfigMenuItem);
|
|
|
|
|
}
|
|
|
|
|
AppConfigHandler.Instance.SerializeObject(toolButtons, AppConfigHandler.Instance.ToolStripConfig);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 应用工具栏配置
|
|
|
|
|
|
|
|
|
|
private void btnApplyTool_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
WorkbenchSingleton.Workbench.CloseAllKeysView();
|
|
|
|
|
List<RunConfigMenuItem> toolButtons = new List<RunConfigMenuItem>();
|
|
|
|
|
foreach (object item in this.lbToolStrip.Items)
|
|
|
|
|
{
|
|
|
|
|
toolButtons.Add(item as RunConfigMenuItem);
|
|
|
|
|
}
|
|
|
|
|
AppConfigHandler.Instance.ReBuilderToolStrip(WorkbenchSingleton.Workbench.ToolStrip, WorkbenchSingleton.Workbench.TopMenu, toolButtons);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 国际化面板-工具栏1-添加资源ID
|
|
|
|
|
private void tsbAddMessage_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
FrmNewMessage frmNewMessage = new FrmNewMessage();
|
|
|
|
|
DialogResult result = frmNewMessage.ShowDialog(this);
|
|
|
|
|
if (result == System.Windows.Forms.DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
if (this.lstMessages.Items.Contains(frmNewMessage.MsgId))
|
|
|
|
|
{
|
|
|
|
|
string msg = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_tsbAddMessage")); //列表中已包含此资源ID!
|
|
|
|
|
MessageBox.Show(msg, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.lstMessages.Items.Add(frmNewMessage.MsgId);
|
|
|
|
|
Dictionary<string, LocaleItem> values = new Dictionary<string,LocaleItem>();
|
|
|
|
|
foreach(string code in AppConfigHandler.Instance.SysMessages.LocaleCodes)
|
|
|
|
|
{
|
|
|
|
|
values.Add(code, LocaleHelper.AllLocales[code]);
|
|
|
|
|
}
|
|
|
|
|
AppConfigHandler.Instance.SysMessages.Messages.Add(frmNewMessage.MsgId, values);
|
|
|
|
|
AppConfigHandler.Instance.SaveSysMessage(AppConfigHandler.Instance.SysMessages); //保存
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 国际化面板-工具栏1-删除资源ID
|
|
|
|
|
|
|
|
|
|
private void tsbDeleteMessage_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this.lstMessages.SelectedIndex == -1)
|
|
|
|
|
{
|
|
|
|
|
string msg = StringParser.Parse(ResourceService.GetString("ViewContent_FrmSysConfig_Msg_tsbDeleteMessage")); //未选择要删除的资源项!
|
|
|
|
|
MessageBox.Show(msg, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string msgId = this.lstMessages.Items[this.lstMessages.SelectedIndex] as string;
|
|
|
|
|
this.lstMessages.Items.RemoveAt(this.lstMessages.SelectedIndex);
|
|
|
|
|
AppConfigHandler.Instance.SysMessages.Messages.Remove(msgId);
|
|
|
|
|
AppConfigHandler.Instance.SaveSysMessage(AppConfigHandler.Instance.SysMessages); //保存
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 国际化面板-资源列表项选择事件处理
|
|
|
|
|
|
|
|
|
|
private void lstMessages_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
RefreshDataGridView();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 刷新DataGridView
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void RefreshDataGridView()
|
|
|
|
|
{
|
|
|
|
|
this._localeTable = new DataTable();
|
|
|
|
|
this._localeTable.Columns.Add("code");
|
|
|
|
|
this._localeTable.Columns.Add("country");
|
|
|
|
|
this._localeTable.Columns.Add("language");
|
|
|
|
|
this._localeTable.Columns.Add("value");
|
|
|
|
|
if (this.lstMessages.SelectedIndex != -1)
|
|
|
|
|
{
|
|
|
|
|
string msgId = this.lstMessages.Items[this.lstMessages.SelectedIndex] as string;
|
|
|
|
|
Dictionary<string, LocaleItem> dic = AppConfigHandler.Instance.SysMessages.Messages[msgId];
|
|
|
|
|
foreach (LocaleItem item in dic.Values)
|
|
|
|
|
{
|
|
|
|
|
DataRow row = this._localeTable.NewRow();
|
|
|
|
|
row["code"] = item.Code;
|
|
|
|
|
row["country"] = item.Country;
|
|
|
|
|
row["language"] = item.Language;
|
|
|
|
|
row["value"] = item.Value;
|
|
|
|
|
this._localeTable.Rows.Add(row);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.dgvLocale.Columns["colLanguage"].DataPropertyName = "language";
|
|
|
|
|
this.dgvLocale.Columns["colValue"].DataPropertyName = "value";
|
|
|
|
|
this.dgvLocale.Columns["colCode"].DataPropertyName = "code";
|
|
|
|
|
this.dgvLocale.Columns["colCountry"].DataPropertyName = "country";
|
|
|
|
|
this.dgvLocale.DataSource = this._localeTable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 国际化面板-工具栏2-设置区域
|
|
|
|
|
private void tsbSetLocale_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
FrmSetLocale frmSetLocale = new FrmSetLocale();
|
|
|
|
|
DialogResult result = frmSetLocale.ShowDialog(this);
|
|
|
|
|
if (result == System.Windows.Forms.DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
List<LocaleItem> selectedLocales = frmSetLocale.SelectedLocales;
|
|
|
|
|
foreach(LocaleItem item in selectedLocales)
|
|
|
|
|
{
|
|
|
|
|
if (!AppConfigHandler.Instance.SysMessages.LocaleCodes.Contains(item.Code))
|
|
|
|
|
{
|
|
|
|
|
AppConfigHandler.Instance.SysMessages.LocaleCodes.Add(item.Code);
|
|
|
|
|
foreach (string msgId in AppConfigHandler.Instance.SysMessages.Messages.Keys)
|
|
|
|
|
{
|
|
|
|
|
if (AppConfigHandler.Instance.SysMessages.Messages[msgId] == null)
|
|
|
|
|
{
|
|
|
|
|
AppConfigHandler.Instance.SysMessages.Messages[msgId] = new Dictionary<string, LocaleItem>();
|
|
|
|
|
}
|
|
|
|
|
AppConfigHandler.Instance.SysMessages.Messages[msgId].Add(item.Code, item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List<string> removeLst = new List<string>();
|
|
|
|
|
foreach(string code in AppConfigHandler.Instance.SysMessages.LocaleCodes)
|
|
|
|
|
{
|
|
|
|
|
bool isExists = false;
|
|
|
|
|
foreach(LocaleItem item in selectedLocales)
|
|
|
|
|
{
|
|
|
|
|
if (item.Code == code)
|
|
|
|
|
{
|
|
|
|
|
isExists = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isExists == false)
|
|
|
|
|
{
|
|
|
|
|
removeLst.Add(code);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
foreach (string code in removeLst)
|
|
|
|
|
{
|
|
|
|
|
foreach (string msgId in AppConfigHandler.Instance.SysMessages.Messages.Keys)
|
|
|
|
|
{
|
|
|
|
|
if (AppConfigHandler.Instance.SysMessages.Messages[msgId] == null)
|
|
|
|
|
{
|
|
|
|
|
AppConfigHandler.Instance.SysMessages.Messages[msgId] = new Dictionary<string, LocaleItem>();
|
|
|
|
|
}
|
|
|
|
|
AppConfigHandler.Instance.SysMessages.Messages[msgId].Remove(code);
|
|
|
|
|
}
|
|
|
|
|
AppConfigHandler.Instance.SysMessages.LocaleCodes.Remove(code);
|
|
|
|
|
}
|
|
|
|
|
AppConfigHandler.Instance.SaveSysMessage(AppConfigHandler.Instance.SysMessages); //保存
|
|
|
|
|
this.RefreshDataGridView();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 资源项-区域语言值设置完毕(单元格编辑完毕)
|
|
|
|
|
|
|
|
|
|
private void dgvLocale_CellEndEdit(object sender, DataGridViewCellEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this._localeTable != null)
|
|
|
|
|
{
|
|
|
|
|
if (this.lstMessages.SelectedIndex != -1)
|
|
|
|
|
{
|
|
|
|
|
string msgId = this.lstMessages.SelectedItem as string;
|
|
|
|
|
foreach(DataRow row in this._localeTable.Rows)
|
|
|
|
|
{
|
|
|
|
|
string code = DataProcessor.RowValue(row, "code", String.Empty);
|
|
|
|
|
if (!String.IsNullOrEmpty(code))
|
|
|
|
|
{
|
|
|
|
|
AppConfigHandler.Instance.SysMessages.Messages[msgId][code].Value = DataProcessor.RowValue(row, "value", String.Empty);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
AppConfigHandler.Instance.SaveSysMessage(AppConfigHandler.Instance.SysMessages); //保存
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|