WinFormTools/WinformGeneralDeveloperFrame/FrmShowForm.cs

78 lines
2.7 KiB
C#
Raw Normal View History

2021-04-13 17:46:18 +08:00
using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
2021-04-17 15:40:26 +08:00
using System.IO;
2021-04-13 17:46:18 +08:00
using System.Linq;
2021-04-17 15:40:26 +08:00
using System.Reflection;
2021-04-13 17:46:18 +08:00
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MES.Form;
2021-04-17 15:40:26 +08:00
using MES;
using WinformGeneralDeveloperFrame.Commons;
2021-04-13 17:46:18 +08:00
namespace WinformGeneralDeveloperFrame
{
public partial class FrmShowForm : DevExpress.XtraEditors.XtraForm
{
public MainForm mainform;
2021-04-17 15:40:26 +08:00
public int formId;
2021-04-13 17:46:18 +08:00
public FrmShowForm()
{
InitializeComponent();
}
2021-04-17 15:40:26 +08:00
private void FrmShowForm_Load(object sender, EventArgs e)
{
}
public void Init()
{
flowLayoutPanel1.Controls.Clear();
using (var db = new MESDB())
{
2021-04-25 18:49:28 +08:00
var data = db.sysMenuInfo.Where(p => p.pid == formId&&p.isEnabled).ToList();
2021-04-17 15:40:26 +08:00
foreach (var item in data)
{
2021-05-12 08:50:36 +08:00
if(!AppInfo.FunctionList.Contains(item.functionCode))continue;
2021-04-17 15:40:26 +08:00
SimpleButton btn = new SimpleButton();
btn.Name = "btn" + item.id;
btn.Size = new System.Drawing.Size(90, 75);
btn.Text = item.name;
btn.Click += (o, args) =>
{
try
{
string[] itemArray = item.winformType.Split(new char[] {',', ';'});
string type = itemArray[0].Trim();
string filePath = itemArray[1].Trim(); //必须是相对路径
//判断是否配置了显示模式默认窗体为Show非模式显示
string showDialog = (itemArray.Length > 2) ? itemArray[2].ToLower() : "";
bool isShowDialog = (showDialog == "1") || (showDialog == "dialog");
string dllFullPath = Path.Combine(Application.StartupPath, filePath);
Assembly tempAssembly = System.Reflection.Assembly.LoadFrom(dllFullPath);
if (tempAssembly != null)
{
Type objType = tempAssembly.GetType(type);
2021-05-15 13:57:34 +08:00
ChildWinManagement.LoadMdiForm(mainform, objType,item.functionCode);
2021-04-17 15:40:26 +08:00
}
}
catch (Exception ex)
{
ex.Message.ShowError();
}
};
flowLayoutPanel1.Controls.Add(btn);
}
}
}
2021-04-13 17:46:18 +08:00
}
}