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.Software.UI
{
public partial class frmMainDropzone : BaseFormMain,LYFZ.StandardInterface.IToolMenuClick
{
public frmMainDropzone()
{
InitializeComponent();
this.Load+=frmMainDropzone_Load;
}
void frmMainDropzone_Load(object sender, EventArgs e)
{
DynamicMenu.SetToolsChatListControl(toolsChatListControl1, DynamicMenu.ToolsChatListType.Dropzone);
try
{
// this.stoolsTopList.Visible = false;
this.stoolsTopList.ItemClicked += stoolsTopList_ItemClicked;
this.TopMost = true;
this.Resize += new EventHandler(frmMainDropzone_Resize);
this.timHide.Tick += new EventHandler(timHide_Tick);
this.lbExUserName.MouseDown += lbExUserName_MouseDown;
this.labTime.MouseDown += labTime_MouseDown;
//获取屏幕宽高
SW = Screen.PrimaryScreen.Bounds.Width;
SH = Screen.PrimaryScreen.Bounds.Height;
this.Height = SH - 30;
// this.IsCloseForm = false;
this.IsMinimize = false;
this.btnAppFormMinimize.Click += new EventHandler(OverridebtnAppFormMinimize_Click);
if (DynamicMenu.IsToosClickOpen)
{
this.toolsChatListControl1.ClickSubItem += new ComponentLibrary.ChatListControl.ChatListBox.ChatListEventHandler(toolsChatListControl1_ClickSubItem);
}
else
{
this.toolsChatListControl1.DoubleClickSubItem += new ComponentLibrary.ChatListControl.ChatListBox.ChatListEventHandler(toolsChatListControl1_DoubleClickSubItem);
}
setIconImg(1);
this.stoolsTopList.MouseEnter += stoolsTopList_MouseEnter;
}
catch { }
}
///
/// 刷新
///
public void FRefreshDropzone() {
try
{
if (LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.IsLoginAutoOpenIndex)
{
stoolsTopList_ItemClicked(null, new ToolStripItemClickedEventArgs(this.index));
}
this.stoolsTopList.TabIndex = 0;
SetStoolsTopListRights();
}
catch { }
}
LYFZ.BLL.BLL_SystemToolsMenu bllMenu = new BLL.BLL_SystemToolsMenu(false);
///
/// 设置小工具栏上的权限
///
void SetStoolsTopListRights()
{
//LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.Model.Model_UserRights.GetQuickToolsPet(),item.KeyName)
//LYFZ.Software.PhotoStudio.frmWelcomeForm
List QuickToolsItems = bllMenu.GetSystemQuickTools();
for (int i = 0; i < this.stoolsTopList.Items.Count; i++)
{
ToolStripItem tlsItem = this.stoolsTopList.Items[i];
foreach (LYFZ.Model.Model_SystemToolsMenu.Item item in QuickToolsItems)
{
if (tlsItem.Tag != null && tlsItem.Tag.ToString().ToLower() == item.ClassFullName.ToLower())
{
tlsItem.Visible= LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.Model.Model_UserRights.GetQuickToolsPet(), item.KeyName);
break;
}
}
}
}
void stoolsTopList_MouseEnter(object sender, EventArgs e)
{
this.stoolsTopList.Focus();
}
void stoolsTopList_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
LYFZ.Model.Model_SystemToolsMenu.Item item = new Model.Model_SystemToolsMenu.Item();
item.KeyName = e.ClickedItem.Name;
item.DllFileKey = "SUMB";
item.OpenMode = "ShowEmbedded";
item.ClassFullName = e.ClickedItem.Tag.ToString();
if (e.ClickedItem.Name.ToLower() == "index")
{
item.DllFileKey = "SPS";
}
if (e.ClickedItem.Name.ToLower() == "cameracontrol")
{
item.OpenMode = "Show";
}
DynamicMenu.ToolsClickProcessingMethod(item, this);
}
void labTime_MouseDown(object sender, MouseEventArgs e)
{
if (e.Clicks == 1)
FormMove();
}
void lbExUserName_MouseDown(object sender, MouseEventArgs e)
{
if (e.Clicks == 1)
FormMove();
}
#region 托盘图标设置
///
/// 设置托盘显示的图标
///
/// 图像列表中图片的索引
private void setIconImg(int index)
{
Image img = this.imgIcon.Images[index];
Bitmap b = new Bitmap(img);
Icon icon = Icon.FromHandle(b.GetHicon());
this.ntiNotifyIcon.Icon = icon;
}
// public System.Windows.Forms.NotifyIcon NtiNotifyIcon {
// get { return this.ntiNotifyIcon; }
// }
private void frmMainDropzone_FormClosed(object sender, FormClosedEventArgs e)
{
this.ntiNotifyIcon.Dispose();
}
private void frmMainDropzone_MouseLeave(object sender, EventArgs e)
{
this.timHide.Start();
}
private void ntiNotifyIcon_DoubleClick(object sender, EventArgs e)
{
SetShowMainForm();
}
private void tsmShowMainForm_Click(object sender, EventArgs e)
{
SetShowMainForm();
}
Point thisFormOldPoint = new Point();
private void SetShowMainForm()
{
if (!this.Visible)
{
this.Location = thisFormOldPoint;
}
this.Show();
this.WindowState = FormWindowState.Normal;
if (this.Top <= 1)
this.Top = 0;
if (this.Left <= 1)
this.Left = 0;
if (this.Left >= Screen.PrimaryScreen.Bounds.Width - this.Width - 2)
{
this.Left = Screen.PrimaryScreen.Bounds.Width - this.Width - 1;
}
this.Activate();
this.timHide.Stop();
}
protected virtual void tsmAbout_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("http://www.lyfz.net/about.asp?id=46");
}
protected virtual void tsmHelp_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("http://www.lyfz.net/");
}
public virtual void tsmExitApp_Click(object sender, EventArgs e)
{
}
#endregion
///
/// 点击最小化窗体时隐藏窗体
///
///
///
protected virtual void OverridebtnAppFormMinimize_Click(object sender, EventArgs e)
{
thisFormOldPoint = this.Location;
this.WindowState = FormWindowState.Minimized;
this.Hide();
}
///
/// 限制窗体最大宽度
///
///
///
void frmMainDropzone_Resize(object sender, EventArgs e)
{
if (this.Width >= 420)
{
this.Width = 420;
}
}
///
/// 获取窗体名
///
public string FormName
{
get { return this.Name; }
}
///
/// 关闭窗体。
///
public void CloseForm()
{
this.Close();
}
///
/// 退出程序
///
public void ExitApplication()
{
// frmLogin.ExitApplication();
this.Close();
}
///
/// 刷新工具栏按钮
///
public void RefreshTools()
{
this.toolsChatListControl1.RefreshTools();
}
///
/// 在本窗体中显示指定窗体
///
/// 指定窗体的类的完全名称
/// 指定窗体类所在的dll Key
/// 窗体显示方式
public void ShowForm(string classFullName, string dllKey, string openMode)
{
return;
}
///
/// 显示登录窗体
///
public virtual void ShowLogin(Form subfrm = null)
{
}
///
/// 保存当前正在打开显示的frmClassicMain主窗体
///
public static LYFZ.Software.UI.frmClassicMain thisOpenShowClassicMain = null;
///
/// 保存当前正在打开显示的frmFashionMain主窗体
///
public static LYFZ.Software.UI.frmFashionMain thisOpenShowFashionMain = null;
///
/// 显示相应子窗体
///
/// 要显示的子窗体类名
///
public virtual void ShowChildForm(string classFullName, string dllKey)
{
string thisSelectMainForm = "";
LYFZ.BLL.BLL_Config bllConfig = new BLL.BLL_Config();
thisSelectMainForm = bllConfig.GetInterfaceSelect();
switch (thisSelectMainForm)
{
case "frmClassicMain":
DynamicMenu.OpenShowClassicMain(classFullName, dllKey);
break;
case "frmFashionMain":
DynamicMenu.OpenShowFashionMain(classFullName, dllKey);
break;
}
}
///
/// 设置窗体状态
///
///
public void SetWindowState(System.Windows.Forms.FormWindowState wState)
{
string thisSelectMainForm = "";
LYFZ.BLL.BLL_Config bllConfig = new BLL.BLL_Config();
thisSelectMainForm = bllConfig.GetInterfaceSelect();
switch (thisSelectMainForm)
{
case "frmClassicMain":
DynamicMenu.SetWindowStateClassicMain(System.Windows.Forms.FormWindowState.Maximized);
break;
case "frmFashionMain":
DynamicMenu.SetWindowStateFashionMain(System.Windows.Forms.FormWindowState.Maximized);
break;
}
}
#region 菜单按钮单击事件
///
/// 设置菜单项单击事
///
///
protected override void SetMenuItem_Click(ToolStripMenuItem menuItem)
{
//请实现功能
LYFZ.Model.Model_SystemToolsMenu.Item item = (LYFZ.Model.Model_SystemToolsMenu.Item)menuItem.Tag;
if (!item.IsChildMenu && item.ClassFullName != "" && item.ClassFullName.ToLower() != "null")
menuItem.Click += new EventHandler(FrmMainDropzoneMenuItem_Click);
}
///
/// 时尚窗体系统菜单项单击事件
///
///
///
public virtual void FrmMainDropzoneMenuItem_Click(object sender, EventArgs e)
{
DynamicMenu.MenuItemClickProcessingMethod(sender, e, this);
}
#endregion
private void toolsChatListControl1_DoubleClickSubItem(object sender, ComponentLibrary.ChatListControl.ChatListEventArgs e)
{
LYFZ.ComponentLibrary.ChatListControl.ChatListSubItem selectSubItem = e.SelectSubItem;
if (selectSubItem.Status != LYFZ.ComponentLibrary.ChatListControl.ChatListSubItem.UserStatus.OffLine)
DynamicMenu.ToolsClickProcessingMethod(selectSubItem.Tag, this);
}
private void toolsChatListControl1_ClickSubItem(object sender, ComponentLibrary.ChatListControl.ChatListEventArgs e)
{
LYFZ.ComponentLibrary.ChatListControl.ChatListSubItem selectSubItem = e.SelectSubItem;
if (selectSubItem.Status != LYFZ.ComponentLibrary.ChatListControl.ChatListSubItem.UserStatus.OffLine)
DynamicMenu.ToolsClickProcessingMethod(selectSubItem.Tag, this);
}
#region 贴边隐藏
protected override void OnMouseDown(MouseEventArgs e)
{
Point point = e.Location;
if (e.Button == MouseButtons.Left)
{
this.isMouseDown = true;
}
base.OnMouseDown(e);
}
protected override void OnMouseUp(MouseEventArgs e)
{
this.isMouseDown = false;
base.OnMouseUp(e);
}
protected override void OnLocationChanged(EventArgs e)
{
base.OnLocationChanged(e);
this.mStopAnthor();
}
///
/// 在窗体位置发生改变时设置窗体当前位置状态
///
private void mStopAnthor()
{
if (this.Left <= 2)
{
this.Aanhor = AnchorStyles.Left;
return;
}
if (this.Left >= Screen.PrimaryScreen.Bounds.Width - this.Width-2)
{
this.Aanhor = AnchorStyles.Right;
return;
}
if (this.Top <= 2)
{
this.Aanhor = AnchorStyles.Top;
return;
}
this.Aanhor = AnchorStyles.None;
}
int? hg = null;
private int form_top_old;
private int form_left_old;
private int form_right_old;
private int SW;
private int SH;
public bool isMouseDown;
public AnchorStyles Aanhor;
///
/// 更新服务器时间
///
protected virtual void updateSDateTime()
{
}
///
/// 定时器事件
///
///
///
private void timHide_Tick(object sender, EventArgs e)
{
//隐藏窗口的方法
form_top_old = 1 - this.Height;
form_left_old = 1 - this.Width;
form_right_old = SW - 1;
updateSDateTime();
this.labTime.Text = LYFZ.WinAPI.CustomPublicMethod.GetDayOfWeek(SDateTime.Now.DayOfWeek) + " " + SDateTime.Now.ToString("HH:mm:ss") + "\r\n" + SDateTime.Now.ToString("yyyy年MM月dd日");
//没点击移动时
if (!this.isMouseDown)
{
//鼠标在窗体内时
if (this.Bounds.Contains(Cursor.Position))
{
switch (this.Aanhor)
{
//执行右移特效
case AnchorStyles.Left:
if (hg == null)
{
hg = this.Height;
}
this.Height = MaximumSize.Height;
this.Top = 0;
// int b = this.Left;
//for (int i = b; i < 0; i += 10)
//{
// this.Left = i;
//}
this.Left = 0;
break;
//执行左移特效
case AnchorStyles.Right:
if (hg == null)
{
hg = this.Height;
}
this.Height = MaximumSize.Height;
this.Top = 0;
//int c = this.Left;
//for (int i = c; i > SW - this.Width; i -= 10)
//{
// this.Left = i;
//}
this.Left = SW - this.Width;
break;
//执行下移特效
case AnchorStyles.Top:
// int a = this.Top;
//for (int i = a; i < 0; i += 10)
//{
// this.Top = i;
//}
this.Top = 0;
break;
}
//hg不为空的话,恢复成原来高度
if (hg != null && this.Left > 0 && this.Left < Screen.PrimaryScreen.Bounds.Width - this.Width)
{
this.Height = (int)hg;
hg = null;
}
}
else
{
switch (this.Aanhor)
{
//执行左移特效
case AnchorStyles.Left:
if (this.Left != form_left_old)
{
//for (int i = 0; i >= form_left_old; i -= 20)
//{
// this.Left = i;
//}
this.Left = form_left_old;
}
break;
//执行右移特效
case AnchorStyles.Right:
if (this.Left != form_right_old)
{
//for (int i = SW - this.Width; i <= form_right_old; i += 20)
//{
// this.Left = i;
//}
this.Left = form_right_old;
}
break;
//执行上移特效
case AnchorStyles.Top:
if (this.Top != form_top_old)
{
//for (int i = 0; i >= form_top_old; i -= 20)
//{
// this.Top = i;
//}
this.Top = form_top_old;
}
break;
}
}
}
}
#endregion
}
}