CEL_Payroll/Payroll.Controls/CustomControls/ctlFormBorder.cs
2024-09-17 14:30:13 +06:00

166 lines
4.8 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Payroll.Controls
{
public enum CustomFormBorderStyle
{
MinMaxClose = 1,
MaxColse = 5,
MinClose = 2,
Close = 3,
Charms21 = 4
}
public partial class ctlFormBorder : UserControl
{
#region Properties
private CustomFormBorderStyle _frmStyle = CustomFormBorderStyle.MinMaxClose;
#endregion
public ctlFormBorder()
{
InitializeComponent();
_headLine = "BaseForm";
}
#region Properties
private Image _image;
public Image HeadImage
{
get { return _image; }
set
{
_image = value;
if (_image != null)
{
picHeader.Image = _image;
}
}
}
private string _headLine;
public string HeadLine
{
get { return _headLine; }
set
{
_headLine = value;
//if (_headLine.Trim().Length > 0)
//{
lblHeadLine.Text = _headLine;
//}
}
}
public CustomFormBorderStyle CustomFormBorderStyle
{
set
{
_frmStyle = value;
if (_frmStyle == CustomFormBorderStyle.MinMaxClose)
{
btnMax.Visible = true;
btnMin.Visible = true;
btnClose.Visible = true;
//picCharms21.Visible = false;
}
else if (_frmStyle == CustomFormBorderStyle.MaxColse)
{
btnMax.Visible = true;
btnMin.Enabled = false;
btnClose.Visible = true;
}
else if (_frmStyle == CustomFormBorderStyle.MinClose)
{
btnMax.Visible = false;
btnMin.Visible = true;
btnClose.Visible = true;
//picCharms21.Visible = false;
}
else if (_frmStyle == CustomFormBorderStyle.Close)
{
btnMax.Visible = false;
btnMin.Visible = false;
btnClose.Visible = true;
//picCharms21.Visible = false;
}
else if (_frmStyle == CustomFormBorderStyle.Charms21)
{
btnMax.Visible = false;
btnMin.Visible = false;
btnClose.Visible = false;
//picCharms21.Visible = true;
}
}
get
{
return _frmStyle;
}
}
private bool _bcancel = false;
public bool EnableCancel
{
set
{
_bcancel = value;
if (_bcancel)
{
if (this.ParentForm != null)
this.ParentForm.CancelButton = this.btnClose;
}
else
{
if (this.ParentForm != null)
this.ParentForm.CancelButton = null;
}
}
get
{
return _bcancel;
}
}
#endregion
public void Inactivate()
{
//this.BackgroundImage = global::Payroll.Controls.Properties.Resources.TopSahdow;
if (this.ParentForm != null)
this.ParentForm.BackColor = Color.Gainsboro;
}
public void Activate()
{
//this.BackgroundImage = global::Payroll.Controls.Properties.Resources.TopSahdow;
if (this.ParentForm != null)
this.ParentForm.BackColor = Color.SteelBlue;
}
private void tlbClose_Click(object sender, EventArgs e)
{
if (this.ParentForm != null)
this.ParentForm.Close();
}
private void btnMin_Click(object sender, EventArgs e)
{
if (this.ParentForm != null)
this.ParentForm.WindowState = FormWindowState.Minimized;
}
private void btnMax_Click(object sender, EventArgs e)
{
if (this.ParentForm != null)
{
if (this.ParentForm.WindowState == FormWindowState.Maximized)
this.ParentForm.WindowState = FormWindowState.Normal;
else
this.ParentForm.WindowState = FormWindowState.Maximized;
}
}
}
}