Files
Jorge Luis caudillo esparza 83acc6b4f1 Version OScar
2026-04-24 07:54:31 -07:00

353 lines
14 KiB
C#

using FontAwesome.Sharp;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ADSUtileriasNetFrame.Views.Gluyas
{
public partial class FrmInicio : Form
{
const int PnlMenuWidthOpen = 220;
const int PnlMenuWidthClose = 68;
private IconButton currentBtn;
private Form currentForm;
private Panel leftBorderBtn;
List<string[]> btnestexto;
public FrmInicio()
{
InitializeComponent();
this.SetStyle(ControlStyles.ResizeRedraw, true);
leftBorderBtn = new Panel();
PnlMenu.Controls.Add(leftBorderBtn);
LblUsuario.Text = "";//"brenda.martinez@agrojam.com.mx";//UsuarioActual.Nombre;
LblEmpresa.Text = "";//"Agroquimicos JAM";//UsuarioActual.Empresa.empresa1Field;
btnestexto = new List<string[]>();
//PnlMenu.Controls.OfType<Control>().SelectMany(x => x is Button))
foreach (Control item in PnlMenu.Controls)
{
if (item is Button) { btnestexto.Add(new string[] { item.Name, item.Text }); }
}
//if (ModVarsPV.CveTipoTerminal > 1)
//{
// activeMenu("BtnComedor");
// BtnMenuShowHide_Click(null, null);
// this.PnlBody.Width = PnlBody.Width + this.PnlMenu.Width;
// this.PnlTopMenu.Width = PnlTopMenu.Width + this.PnlMenu.Width;
// this.PnlMenu.Width = 0;
// PnlMenu.Visible = false;
// PnlTopMenu.Location = new System.Drawing.Point(0, PnlTopMenu.Location.Y);
// PnlBody.Location = new System.Drawing.Point(0, PnlBody.Location.Y);
//}
}
#region viewchanges
private void BtnMenuShowHide_Click(object sender, EventArgs e)
{
int restante = PnlMenuWidthOpen - PnlMenuWidthClose;
if (PnlMenu.Size.Width == PnlMenuWidthOpen)
{
this.PnlMenu.Width = PnlMenuWidthClose;
//LblEmpresa.Location = new System.Drawing.Point(10, LblEmpresa.Location.Y);
PnlTopMenu.Width = PnlTopMenu.Width + restante;
PnlTopMenu.Location = new System.Drawing.Point(PnlMenuWidthClose, PnlTopMenu.Location.Y);
LblEmpresa.Location = new System.Drawing.Point(LblEmpresa.Location.X - restante, LblEmpresa.Location.Y);
this.PnlBody.Width = PnlBody.Width + restante;
PnlBody.Location = new System.Drawing.Point(PnlMenuWidthClose, PnlBody.Location.Y);
foreach (Control item in PnlMenu.Controls)
{
if (item is Button) { item.Text = ""; }
}
/*
BtnConfiguracion.Text = "";
BtnAsistencia.Text = "";
BtnPersonal.Text = "";
BtnChecador.Text = "";
BtnNomina.Text = "";*/
PnlmenuXD.Dock = System.Windows.Forms.DockStyle.Left;
PnlmenuXD.Size = new System.Drawing.Size(PnlMenuWidthClose, 30);
btnmenuXD.Size = new System.Drawing.Size(PnlMenuWidthClose, 30);
btnmenuXD.Padding = new System.Windows.Forms.Padding(0, 0, 20, 0);
btnmenuXD.Text = " ";
}
else
{
PnlMenu.Width = PnlMenuWidthOpen;
//LblEmpresa.Location = new System.Drawing.Point(160, LblEmpresa.Location.Y);
LblEmpresa.Location = new System.Drawing.Point(LblEmpresa.Location.X + restante, LblEmpresa.Location.Y);
PnlTopMenu.Width = PnlTopMenu.Width - restante;
PnlTopMenu.Location = new System.Drawing.Point(PnlMenuWidthOpen, PnlTopMenu.Location.Y);
PnlBody.Location = new System.Drawing.Point(PnlMenuWidthOpen, PnlBody.Location.Y);
this.PnlBody.Width = PnlBody.Width - restante;
foreach (Control item in PnlMenu.Controls)
{
if (item is Button)
{
string texto = btnestexto.FirstOrDefault(x => x[0] == item.Name)[1];
item.Text = texto == null ? "" : texto;
}
}/*
BtnConfiguracion.Text = "Configuración";
BtnAsistencia.Text = "Asistencia";
BtnPersonal.Text = "Personal";
BtnChecador.Text = "Checadores";
BtnNomina.Text = "Nómina";*/
PnlmenuXD.Dock = System.Windows.Forms.DockStyle.Right;
PnlmenuXD.Size = new System.Drawing.Size(40, 30);
btnmenuXD.Size = new System.Drawing.Size(40, 30);
btnmenuXD.Padding = new System.Windows.Forms.Padding(0, 0, 0, 0);
btnmenuXD.Text = "";
}
}
private void setActivateButton(object sender, EventArgs e)
{
if (currentBtn != sender)
{
if (currentBtn != null)
{
currentBtn.BackColor = System.Drawing.Color.FromArgb(54, 65, 80);
currentBtn.ForeColor = btnmenuXD.ForeColor;
currentBtn.TextAlign = ContentAlignment.MiddleLeft;
currentBtn.IconColor = Color.Gainsboro;
currentBtn.TextImageRelation = TextImageRelation.ImageBeforeText;
currentBtn.ImageAlign = ContentAlignment.MiddleLeft;
}
if (sender != null)
{
Color color = Color.FromArgb(53, 152, 220);
//Button
currentBtn = (IconButton)sender;
currentBtn.BackColor = Color.FromArgb(43, 54, 67);
//currentBtn.ForeColor = color;
currentBtn.TextAlign = ContentAlignment.MiddleCenter;
currentBtn.IconColor = color;
currentBtn.TextImageRelation = TextImageRelation.TextBeforeImage;
currentBtn.ImageAlign = ContentAlignment.MiddleRight;
//Left border button
leftBorderBtn.BackColor = color;
leftBorderBtn.Size = new Size(7, currentBtn.Size.Height);
leftBorderBtn.Location = new Point(0, currentBtn.Location.Y);
leftBorderBtn.Visible = true;
leftBorderBtn.BringToFront();
activeMenu(currentBtn.Name.ToString());
}
}
PnlBody_SizeChanged(PnlBody, null);
}
private void ActivateButton(object sender, EventArgs e)
{
setActivateButton(sender, e);
}
private void PnlBody_SizeChanged(object sender, EventArgs e)
{
int width = PnlBody.Width - 5;
int height = PnlBody.Height - 5;
if (currentForm != null)
{
if (width < currentForm.MinimumSize.Width)
{
width = currentForm.MinimumSize.Width;
}
if (height < currentForm.MinimumSize.Height)
{
height = currentForm.MinimumSize.Height;
}
currentForm.Size = new System.Drawing.Size(width, height);
}
PnlBodyForms.Size = new System.Drawing.Size(width, height);
}
#endregion
private void activeMenu(string buttonname)
{
bool isnewform = false;
if (currentForm != null)
{
currentForm.Hide();
currentForm = null;
}
switch (buttonname)
{
/*
private ;
private ;
.Text = "";
.Text = "";*/
case "BtnConfiguracion":
break;
case "BtnPersonal":
break;
case "BtnAsistencia":
break;
case "BtnChecador":
break;
case "BtnNomina":
break;
case "ChecadoresGluyas":
isnewform = true;
currentForm = new FrmChecadores();
break;
case "BtnReporte":
isnewform = true;
currentForm = new FrmReporteChecadores();
break;
default:
break;
}
if (currentForm != null)
{
if (isnewform)
{
currentForm.TopLevel = false;
currentForm.AutoScroll = true;
this.PnlBodyForms.Controls.Add(currentForm);
currentForm.FormBorderStyle = FormBorderStyle.None;
currentForm.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)));
}
PnlBodyForms.MinimumSize = currentForm.MinimumSize;
currentForm.BringToFront();
currentForm.Show();
}
else
{
PnlBodyForms.MinimumSize = new System.Drawing.Size(0, 0);
}
}
private void LblEmpresa_Click(object sender, EventArgs e)
{
activeMenu("");
}
private void PnlBody_Paint(object sender, PaintEventArgs e)
{
}
public void GuardaLog(string mensaje)
{
ADSNetLibrary.Helpers.ModExtensiones.GuardaLog(mensaje);
}
public static System.Windows.Forms.DialogResult Alert(string mensage, string Titulo, System.Windows.Forms.MessageBoxButtons botones = System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon Icon = System.Windows.Forms.MessageBoxIcon.None)
{
System.Windows.Forms.DialogResult result = System.Windows.Forms.DialogResult.None;
result = System.Windows.Forms.MessageBox.Show(mensage, Titulo, botones, Icon);
//switch (button)
//{
// case MessageBoxButtons.YesNo:
// using (frmYesNo yesNo = new frmYesNo())
// {
// yesNo.Text = caption;
// yesNo.Message = message;
// result = yesNo.ShowDialog();
// }
// break;
// case MessageBoxButtons.OK:
// using (frmOK ok = new frmOK())
// {
// ok.Text = caption;
// ok.Message = message;
// result = ok.ShowDialog();
// }
// break;
//}
return result;
}
//UtileriasServiceWCF.ResponseLogin UserV2
//public WCF_PV.Usuario UsuarioActual { get { return ModVarsPV.UsuarioActual; } set { ModVarsPV.UsuarioActual = value; } }
#region "F U N C I O N E S D E W I N D O W S"
#region "mover /arrastrar formulario"
private const int WM_NCLBUTTONDOWN = 0xA1;
private const int HT_CAPTION = 0x2;
[DllImportAttribute("user32.dll")]
private static extern int SendMessage(IntPtr hWnd,
int Msg, int wParam, int lParam);
[DllImportAttribute("user32.dll")]
private static extern bool ReleaseCapture();
#endregion
#region colorbar
//[DllImport("User32.dll", CharSet = CharSet.Auto)]
//public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
//[DllImport("User32.dll")]
//private static extern IntPtr GetWindowDC(IntPtr hWnd);
//protected override void WndProc(ref Message m)
//{
// base.WndProc(ref m);
// const int WM_NCPAINT = 0x85;
// if (m.Msg == WM_NCPAINT)
// {
// IntPtr hdc = GetWindowDC(m.HWnd);
// if ((int)hdc != 0)
// {
// Graphics g = Graphics.FromHdc(hdc);
// g.FillRectangle(Brushes.Green, new Rectangle(0, 0, 4800, 23));
// g.Flush();
// ReleaseDC(m.HWnd, hdc);
// }
// }
//}
#endregion
public void ArrastrarForm_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
}
}
public void BtnClose_Click(object sender, EventArgs e)
{
Environment.Exit(0);
}
public void BtnMaximizeRestore_Click(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Maximized)
{
WindowState = FormWindowState.Normal;
((IconButton)sender).IconChar = FontAwesome.Sharp.IconChar.WindowMaximize;
}
else
{
WindowState = FormWindowState.Maximized;
((IconButton)sender).IconChar = FontAwesome.Sharp.IconChar.WindowRestore;
}
}
public void BtnMinimize_Click(object sender, EventArgs e)
{
WindowState = FormWindowState.Minimized;
}
#endregion
}
}