ControlBox for Windows Form



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Mesoft.Control
{
    public partial class ControlBox : UserControl
    {
        [Category("Mesoft")]
        [Description("Gets or sets maximize button visibility")]
        public bool Maximize
        {
            set
            {
                lblMaximize.Visible = value;   
            }
            get
            {
                return lblMaximize.Visible; 
            }
        }
        [Category("Mesoft")]
        [Description("Gets or sets minimize button visibility")]
        public bool Minimize
        {
            set
            {
                lblMinimize.Visible = value;
            }
            get
            {
                return lblMinimize.Visible;
            }
        }
        [Category("Mesoft")]
        [Description("Gets or sets close button visibility")]
        public bool Close
        {
            set
            {
                lblClose.Visible = value;
            }
            get
            {
                return lblClose.Visible;
            }
        }
        public ControlBox()
       {
            InitializeComponent();
        }
        private void lblClose_MouseMove(object sender, MouseEventArgs e)
        {
            lblClose.Image = global::Mesoft.Properties.Resources.CloseHover1;     
        }
        private void lblClose_MouseLeave(object sender, EventArgs e)
        {
            lblClose.Image = global::Mesoft.Properties.Resources._1310834635_Close_Box_Red;      
        }
        private void lblMaximize_MouseLeave(object sender, EventArgs e)
        {
            lblMaximize.Image = global::Mesoft.Properties.Resources.index;     
        }
        private void lblMaximize_MouseMove(object sender, MouseEventArgs e)
        {
            lblMaximize.Image = global::Mesoft.Properties.Resources.MaximizeHover;     
        }
        private void lblMinimize_MouseMove(object sender, MouseEventArgs e)
        {
            lblMinimize.Image = global::Mesoft.Properties.Resources.MinimizeNewHover;     
        }
        private void lblMinimize_MouseLeave(object sender, EventArgs e)
        {
            lblMinimize.Image = global::Mesoft.Properties.Resources.MinimizeNew;     
        }
        private void lblClose_Click(object sender, EventArgs e)
        {
          this.ParentForm.Close();   
        }
        private void lblMaximize_Click(object sender, EventArgs e)
        {
            if (this.ParentForm.WindowState == FormWindowState.Maximized)
            {
                this.ParentForm.WindowState = FormWindowState.Normal;
            }
            else if(this.ParentForm.WindowState == FormWindowState.Normal)
            {
              this.ParentForm.WindowState = FormWindowState.Maximized;
           }
            this.ParentForm.Show();   
        }
        private void lblMinimize_Click(object sender, EventArgs e)
        {
            this.ParentForm.WindowState = FormWindowState.Minimized;
            this.ParentForm.Show(); 
        }
        private void FormControlBox_Load(object sender, EventArgs e)
        { 
        }
    }
}

No comments: