|
|
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 POSV
|
|
|
{
|
|
|
public partial class TransparentForm : BaseForm
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 当前业务处理窗口
|
|
|
/// </summary>
|
|
|
private BusinessForm form;
|
|
|
|
|
|
public Control m_overlay ;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 遮罩层窗体
|
|
|
/// <param name="point">当前位置</param>
|
|
|
/// <param name="size">窗体大小</param>
|
|
|
/// <param name="form">窗体</param>
|
|
|
public TransparentForm(Control overlay , BusinessForm form) : this(overlay , Constant.Opacity , form)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
public TransparentForm(Control overlay , double opacity , BusinessForm form)
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
|
|
|
//无边框
|
|
|
this.FormBorderStyle = FormBorderStyle.None;
|
|
|
//透明度
|
|
|
this.Opacity = opacity;
|
|
|
//最大化/最小化
|
|
|
this.MaximizeBox = false;
|
|
|
this.MinimizeBox = false;
|
|
|
this.ShowIcon = false;
|
|
|
this.ShowInTaskbar = false;
|
|
|
//窗口位置和大小
|
|
|
this.StartPosition = FormStartPosition.Manual;
|
|
|
|
|
|
m_overlay = overlay;
|
|
|
|
|
|
Rectangle rect = new Rectangle(overlay.PointToScreen(Point.Empty) , overlay.Size);
|
|
|
|
|
|
this.Location = new Point(rect.X , rect.Y);
|
|
|
this.Size = new Size(rect.Width , rect.Height);
|
|
|
|
|
|
//当前窗体
|
|
|
this.form = form;
|
|
|
}
|
|
|
|
|
|
|
|
|
private bool isShow = false;
|
|
|
|
|
|
protected override void OnActivated(EventArgs e)
|
|
|
{
|
|
|
base.OnActivated(e);
|
|
|
|
|
|
try
|
|
|
{
|
|
|
if (isShow) return;
|
|
|
|
|
|
LOGGER.Info("transparnetForm显示:{0}", this.form.Name);
|
|
|
|
|
|
//工作窗体最大化、最小化
|
|
|
this.form.MaximizeBox = false;
|
|
|
this.form.MinimizeBox = false;
|
|
|
this.form.ShowIcon = false;
|
|
|
this.form.ShowInTaskbar = false;
|
|
|
|
|
|
//DockStyle
|
|
|
this.form.Dock = DockStyle.Fill;
|
|
|
this.form.Owner = this;
|
|
|
|
|
|
this.form.Visible = false;
|
|
|
//工作窗体显示
|
|
|
this.form.Show(this);
|
|
|
|
|
|
this.form.BringToFront();
|
|
|
this.form.Activate();
|
|
|
this.form.Focus();
|
|
|
|
|
|
this.isShow = true;
|
|
|
}
|
|
|
catch(Exception ex)
|
|
|
{
|
|
|
LOGGER.Error(ex, string.Format("TransparentForm窗体<{0}>显示异常", this.form.Name));
|
|
|
Global.Instance.BugReport(ex, string.Format("TransparentForm窗体<{0}>显示异常", this.form.Name));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protected override void OnMouseDown(MouseEventArgs e)
|
|
|
{
|
|
|
base.OnMouseDown(e);
|
|
|
|
|
|
if (this.form != null)
|
|
|
{
|
|
|
this.form.BringToFront();
|
|
|
this.form.Activate();
|
|
|
this.form.Focus();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|