123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365 |
- 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;
- namespace LYFZ.ComponentLibrary
- {
- public partial class BaseFormRelease : BaseForm360
- {
- public BaseFormRelease()
- {
- InitializeComponent();
- this.btnAppFormMenu.MouseClick += new MouseEventHandler(btnAppFormMenu_MouseClick);
- this.Load += BaseFormRelease_Load;
- InitializationSystemMeun();
- this.BackColor = LYFZ.ComponentLibrary.GetUIResources.FrmContentBackgroundColor;
- this.MouseMove += BaseFormRelease_MouseMove;
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
- }
- public static LYFZ.StandardInterface.IToolMenuClick iMainDropzoneForm = null;
- protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
- {
- if (keyData == Keys.F12)
- {
- // System.Environment.Exit(0);
- if (iMainDropzoneForm != null)
- {
- try
- {
- this.Close();
- }
- catch { }
- finally
- {
- iMainDropzoneForm.ShowLogin(this);
- }
- }
- }
- return base.ProcessCmdKey(ref msg, keyData);
- }
- bool isLoginValidation = false;
- /// <summary>
- /// 是否进行登录验证
- /// </summary>
- public bool IsLoginValidation
- {
- get { return isLoginValidation; }
- set { isLoginValidation = value; }
- }
- public void ShowLoginAgain(bool isMessageBoxCustom = true)
- {
- try
- {
- if (typeof(LYFZ.StandardInterface.IToolMenuClick).IsAssignableFrom(this.ParentForm.GetType()))
- {
- Control[] contols = this.Controls.Find("plExMainContainer", true);
- if (contols.Length > 0)
- {
- contols[0].Enabled = false;
- }
- LYFZ.StandardInterface.IToolMenuClick iParentForm = (LYFZ.StandardInterface.IToolMenuClick)this.ParentForm;
- iParentForm.ShowLogin(this);
- }
- }
- catch
- {
- try
- {
- if (typeof(LYFZ.StandardInterface.IToolMenuClick).IsAssignableFrom(this.GetType()))
- {
- LYFZ.StandardInterface.IToolMenuClick iParentForm = (LYFZ.StandardInterface.IToolMenuClick)this;
- iParentForm.ShowLogin(null);
- }
- else
- {
- LoginMessageBoxCustom(isMessageBoxCustom);
- }
- }
- catch
- {
- LoginMessageBoxCustom(isMessageBoxCustom);
- }
- }
- }
- /// <summary>
- /// 重新登录
- /// </summary>
- /// <param name="isMessageBoxCustom">是否弹出显示用户登录超时提示</param>
- public void LoginAgain(bool isMessageBoxCustom = true)
- {
- if (!IsLoginValidation || BLL.BLL_ErpUser.CloseTuthenticationLogin) { return; }
-
- LYFZ.BLL.BLL_ErpUser.UpdateDynamicTimeAccount();
- if (LYFZ.BLL.BLL_ErpUser.WhetherTimesOut)
- {
- ShowLoginAgain(isMessageBoxCustom);
- }
- }
- /// <summary>
- /// 登录超时提醒
- /// </summary>
- void LoginMessageBoxCustom(bool isMessageBoxCustom = true)
- {
- try
- {
- if (isMessageBoxCustom)
- {
- MessageBox.Show("用户登录超时,请重新登录。", "提示");
- this.Close();
- }
- }
- catch { }
- }
- void BaseFormRelease_MouseMove(object sender, MouseEventArgs e)
- {
- LoginAgain(false);
- }
- void BaseFormRelease_Load(object sender, EventArgs e)
- {
- this.plFormMainContent.BackColor = LYFZ.ComponentLibrary.GetUIResources.FrmContentBackgroundColor;
- }
- /// <summary>
- /// 是否覆盖基窗体的OnPaint
- /// </summary>
- protected bool isOverrideOnPaint = false;
- protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
- {
- base.OnPaint(e);
- if (!isOverrideOnPaint)
- {
- this.plFormMainContent.Location = new Point(0, this.TitleBgImageHeight);
- this.plFormMainContent.Width = this.Width;
- this.plFormMainContent.Height = this.Height - this.TitleBgImageHeight - this.BottomBgImageHeight;
- }
-
- }
-
- /// <summary>
- /// 刷新系统菜单
- /// </summary>
- public void RefreshSystemMeun()
- {
- InitializationSystemMeun();
- }
- /// <summary>
- /// 显示系统菜单
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnAppFormMenu_MouseClick(object sender, MouseEventArgs e)
- {
- Button btn = sender as Button;
- Point point = new Point();
- point.Y = btn.Height;
- if (e.Button == MouseButtons.Left)
- {
- this.cmsSystemMeunList.Show(btn, point);
- }
- }
- static bool isRights = false;
- /// <summary>
- /// 是否开启权限控制
- /// </summary>
- public static bool IsRights
- {
- get { return BaseFormRelease.isRights; }
- set { BaseFormRelease.isRights = value; }
- }
- bool GetRights(string keyName)
- {
- if (IsRights)
- {
- return LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.Model.Model_UserRights.GetSystemMenuPet(), keyName);
- }
- else { return true; }
- }
- /// <summary>
- /// 获取菜单项并包括所有子项
- /// </summary>
- /// <param name="item"></param>
- /// <returns></returns>
- protected ToolStripMenuItem GetToolStripMenuItem(LYFZ.Model.Model_SystemToolsMenu.Item item)
- {
-
- ToolStripMenuItem menuItem = new ToolStripMenuItem(item.Text);
- menuItem.Image = LYFZ.WinAPI.CustomPublicMethod.GetMenuItemImage(item.Icon);
- menuItem.Name = item.KeyName;
- menuItem.Tag = item;
- try
- {
- SetDefaultChecked(menuItem, item.OpenMode);
- SetMenuItem_Click(menuItem);
- if (item.IsChildMenu)
- {
- foreach (LYFZ.Model.Model_SystemToolsMenu.Item subItem in item.ChildItems)
- {
- if (subItem.Type.ToLower() == "separator")
- {
- menuItem.DropDownItems.Add(GetToolStripSeparator(subItem));
- }
- else
- {
- if (!item.Disable && GetRights(subItem.KeyName))
- {
- ToolStripMenuItem subMenuItem = GetToolStripMenuItem(subItem);
- if (!subItem.IsChildMenu || subMenuItem.DropDownItems.Count > 0)
- menuItem.DropDownItems.Add(subMenuItem);
- }
- }
- }
- }
- }
- catch { }
- return menuItem;
- }
- /// <summary>
- /// 设置默认是否选择
- /// </summary>
- /// <param name="menuItem"></param>
- private void SetDefaultChecked(ToolStripMenuItem menuItem, string openMode)
- {
- try
- {
- LYFZ.BLL.BLL_Config bllConfig = new BLL.BLL_Config();
- LYFZ.Model.Model_Config modelConfig = bllConfig.GetModel_SysConfig();
- switch (openMode)
- {
- case "SetShowToolsDescription":
- menuItem.Checked = bllConfig.Get_IsShowToolsDescription();
- break;
- case "SetInterfaceSelect":
- try
- {
- string thisInterface = bllConfig.GetInterfaceSelect();
- string menuItemInterface = menuItem.Name.Split('_')[0];
- if (thisInterface.ToLower() == menuItemInterface.ToLower())
- {
- menuItem.Checked = true;
- }
- }
- catch { }
- break;
- }
- }
- catch { }
- }
- /// <summary>
- /// 设置菜单项单击事件 要在派生窗体中重写实现功能
- /// </summary>
- /// <param name="menuItem"></param>
- protected virtual void SetMenuItem_Click(ToolStripMenuItem menuItem)
- {
- //请在派生窗体中重写实现功能
- }
-
- /// <summary>
- /// 获取菜单分隔线
- /// </summary>
- /// <param name="item"></param>
- /// <returns></returns>
- protected ToolStripSeparator GetToolStripSeparator(LYFZ.Model.Model_SystemToolsMenu.Item item)
- {
- ToolStripSeparator spItem = new ToolStripSeparator();
- spItem.Name = item.KeyName;
- return spItem;
- }
- /// <summary>
- /// 是否重写系统菜单
- /// </summary>
- public bool IsOverrideSystemMeun = false;
- /// <summary>
- /// 当IsOverrideSystemMeun为true时设置设置重写的的菜单项
- /// </summary>
- public List<LYFZ.Model.Model_SystemToolsMenu.Item> MenuItems = null;
- /// <summary>
- /// 初始化系统菜单
- /// </summary>
- protected void InitializationSystemMeun()
- {
- if (this.IsShowBtnFormMenu)
- {
- try
- {
- LYFZ.BLL.BLL_SystemToolsMenu bllMenu = new BLL.BLL_SystemToolsMenu(false);
- if (!IsOverrideSystemMeun)
- {
- MenuItems = bllMenu.GetSystemMenuList();
- }
- this.cmsSystemMeunList.Items.Clear();
- if (MenuItems != null)
- {
- foreach (LYFZ.Model.Model_SystemToolsMenu.Item item in MenuItems)
- {
- string ToolStripItemType = item.Type.ToLower();
- switch (ToolStripItemType)
- {
- case "separator":
- this.cmsSystemMeunList.Items.Add(GetToolStripSeparator(item));
- break;
- default:
- if (!item.Disable && GetRights(item.KeyName))
- {
- ToolStripMenuItem tItem = GetToolStripMenuItem(item);
- if (!item.IsChildMenu || tItem.DropDownItems.Count>0)
- {
- this.cmsSystemMeunList.Items.Add(tItem);
- }
-
- }
- break;
- }
- }
- }
- }
- catch { }
- }
- }
- protected override void CreateHandle()
- {
- if (!IsHandleCreated)
- {
- try
- {
- base.CreateHandle();
- }
- catch { }
- finally
- {
- if (!IsHandleCreated)
- {
- base.RecreateHandle();
- }
- }
- }
- }
- }
- }
|