WinFormTools/WinformGeneralDeveloperFrame/FrmShowForm.cs

121 lines
3.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MES.Form;
using MES;
using WinformGeneralDeveloperFrame.Commons;
namespace WinformGeneralDeveloperFrame
{
public partial class FrmShowForm : DevExpress.XtraEditors.XtraForm
{
public MainForm mainform;
public int formId;
public FrmShowForm()
{
InitializeComponent();
}
private void simpleButton1_Click(object sender, EventArgs e)
{
ChildWinManagement.LoadMdiForm(mainform,typeof(XtraForm1));
}
private void simpleButton2_Click(object sender, EventArgs e)
{
ChildWinManagement.LoadMdiForm(mainform, typeof(FrmsysDataTable));
}
private void simpleButton3_Click(object sender, EventArgs e)
{
ChildWinManagement.LoadMdiForm(mainform, typeof(FrmsysDataBase));
}
private void simpleButton4_Click(object sender, EventArgs e)
{
ChildWinManagement.LoadMdiForm(mainform, typeof(frmSelectDataBase));
}
private void simpleButton5_Click(object sender, EventArgs e)
{
ChildWinManagement.LoadMdiForm(mainform, typeof(FrmsysMenu));
}
private void simpleButton6_Click(object sender, EventArgs e)
{
ChildWinManagement.LoadMdiForm(mainform, typeof(MES.Form.FrmsysUser));
}
private void simpleButton8_Click(object sender, EventArgs e)
{
ChildWinManagement.LoadMdiForm(mainform, typeof(FrmsysDictType));
}
private void simpleButton7_Click(object sender, EventArgs e)
{
ChildWinManagement.LoadMdiForm(mainform, typeof(FrmsysDictData));
}
private void FrmShowForm_Load(object sender, EventArgs e)
{
}
public void Init()
{
flowLayoutPanel1.Controls.Clear();
using (var db = new MESDB())
{
var data = db.sysMenuInfo.Where(p => p.pid == formId).ToList();
foreach (var item in data)
{
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);
ChildWinManagement.LoadMdiForm(mainform, objType);
}
}
catch (Exception ex)
{
ex.Message.ShowError();
}
};
flowLayoutPanel1.Controls.Add(btn);
}
}
}
}
}