/******************************
* 说明:主界面
* 创建人:龚宇超
* 创建日期:2018-04-25
* 修改人:
* 修改日期:
* 修改备注:
* 版本:1.0.0.0
******************************/
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 Lskj.Main2.Model;
using Lskj.Main2.Properties;
using DevExpress.XtraEditors;
using Lskj.Model;
using Lskj.Control;
using Lskj.Data;
using Lskj.Control.Model;
using Lskj.Business;
using Lskj.Util;
using Lskj.Main2.Control;
using Lskj.Business.Impl;
using DevExpress.XtraTab;
using DevExpress.XtraEditors.Controls;
using System.IO;
using System.Threading;
using System.Diagnostics;
namespace Lskj.Main2
{
///
/// 主界面
///
public partial class FrmMain : Form
{
///
/// 屏幕dpix、dpiy
///
private float _dpiX, _dpiY;
///
/// 是否鼠标按下
///
private bool _isMouseDown;
///
/// 记录窗口位置
///
private Point _mousePostion;
public FrmMain()
{
Graphics graphics = this.CreateGraphics();
_dpiX = graphics.DpiX;
_dpiY = graphics.DpiY;
InitializeComponent();
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
}
///
/// 说明:窗口加载
/// 创建人:龚宇超
/// 创建日期:2018-04-25
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
///
///
private void FrmMain_Load(object sender, EventArgs e)
{
try
{
this.mainPanelControlEx.DpiX = _dpiX;
this.mainPanelControlEx.DpiY = _dpiY;
this.mainPanelControlEx.OnLoad();
this.mainPanelControlEx.OnCloseButtonCallBack += new EventHandler(OnCloseButtonCallBack);
this.mainPanelControlEx.OnMaxButtonCallBack += new EventHandler(OnTopPanelMouseDoubleClickCallBack);
this.mainPanelControlEx.OnMinButtonCallBack += new EventHandler(OnMinButtonCallBack);
this.mainPanelControlEx.OnTopMouseDownCallback += new MouseEventHandler(OnTopMouseDownCallback);
this.mainPanelControlEx.OnTopMouseMoveCallBack += new MouseEventHandler(OnTopMouseMoveCallBack);
this.mainPanelControlEx.OnTopMouseUpCallBack += new MouseEventHandler(OnTopMouseUpCallBack);
this.mainPanelControlEx.OnTopPanelMouseDoubleClickCallBack += new EventHandler(OnTopPanelMouseDoubleClickCallBack);
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message,ex.Message);
}
}
///
/// 说明:重置窗口大小
/// 创建人:龚宇超
/// 创建日期:2018-02-27
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
private void ResetFormState()
{
foreach (string item in Manager.ModuleForms.Keys)
{
DllModule module = Manager.ModuleForms[item];
//(module.ModuleForm as Form).WindowState = FormWindowState.Maximized;
}
}
///
/// 说明:关闭窗口
/// 创建人:龚宇超
/// 创建日期:2018-04-26
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
///
///
private void OnCloseButtonCallBack(object sender, EventArgs e)
{
this.Close();
}
///
/// 说明:窗口最大化
/// 创建人:龚宇超
/// 创建日期:2018-04-26
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
private void OnTopPanelMouseDoubleClickCallBack(object sender, EventArgs e)
{
try
{
this.WindowState = this.WindowState == FormWindowState.Normal ? FormWindowState.Maximized : FormWindowState.Normal;
this.mainPanelControlEx.State = this.WindowState;
this.StartPosition = FormStartPosition.CenterScreen;
this.ResetFormState();
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message,ex.Message);
}
}
///
/// 说明:窗口最小化
/// 创建人:龚宇超
/// 创建日期:2018-04-26
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
private void OnMinButtonCallBack(object sender, EventArgs e)
{
try
{
this.WindowState = FormWindowState.Minimized;
this.ResetFormState();
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message,ex.Message);
}
}
///
/// 说明:关闭界面后清除之前打开的模块
/// 创建人:龚宇超
/// 创建日期:2017-08-21
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnFormClosing(object sender, FormClosingEventArgs e)
{
try
{
Manager.ModuleForms.Clear();
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message,ex.Message);
}
}
///
/// 说明:鼠标放开
/// 创建人:龚宇超
/// 创建日期:2017-08-14
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnTopMouseDownCallback(object sender, MouseEventArgs e)
{
try
{
base.OnMouseDown(e);
_mousePostion = Cursor.Position;
_isMouseDown = true;
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message,ex.Message);
}
}
///
/// 说明:鼠标按下
/// 创建人:龚宇超
/// 创建日期:2017-08-14
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnTopMouseMoveCallBack(object sender, MouseEventArgs e)
{
try
{
base.OnMouseMove(e);
if (_isMouseDown)
{
Point tempPos = Cursor.Position;
this.Location = new Point(Location.X + (tempPos.X - _mousePostion.X), Location.Y + (tempPos.Y - _mousePostion.Y));
_mousePostion = Cursor.Position;
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message,ex.Message);
}
}
///
/// 说明:鼠标移动
/// 创建人:龚宇超
/// 创建日期:2017-08-14
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void OnTopMouseUpCallBack(object sender, MouseEventArgs e)
{
try
{
base.OnMouseUp(e);
_isMouseDown = false;
this.Focus();
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message,ex.Message);
}
}
#region 无标题栏窗体最大化最小化
protected override CreateParams CreateParams
{
get
{
const int WS_MINIMIZEBOX = 0x00020000; // Winuser.h中定义
CreateParams cp = base.CreateParams;
cp.Style = cp.Style | WS_MINIMIZEBOX; // 允许最小化操作
return cp;
}
}
#endregion
}
}