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

293 lines
12 KiB
C#

using ADSUtileriasWF.Helpers;
using ADSUtileriasWF.Views.RelojChecador.Views;
using ADSUtileriasWF.Views.Timbrado.Views;
using FontAwesome.Sharp;
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 ADSUtileriasWF.Views.RelojChecador.Gluyas
{
public partial class FrmInicio : FormBase
{
const int PnlMenuWidthOpen = 220;
const int PnlMenuWidthClose = 68;
private IconButton currentBtn;
private Form currentForm;
private Panel leftBorderBtn;
private FrmConfiguracion frmConfiguracion;
private FrmAsistencia frmAsistencia;
//private FrmPersonal frmPersonal;
private FrmTimbradoNomina frmTimbradoNomina;
private FrmNewPersonalChecador frmnewPersonal ;
private FrmChecadores frmChecadores;
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":
if (frmConfiguracion == null)
{
frmConfiguracion = new FrmConfiguracion();
isnewform = true;
}
currentForm = frmConfiguracion;
break;
case "BtnPersonal":
//if (frmPersonal == null)
//{
// frmPersonal = new FrmPersonal();
// isnewform = true;
//}
//currentForm = frmPersonal;
if (frmnewPersonal == null)
{
frmnewPersonal = new FrmNewPersonalChecador();
isnewform = true;
}
currentForm = frmnewPersonal;
break;
case "BtnAsistencia":
if (frmAsistencia == null)
{
frmAsistencia = new FrmAsistencia();
isnewform = true;
}
currentForm = frmAsistencia;
break;
case "BtnChecador":
if (frmChecadores == null)
{
frmChecadores = new FrmChecadores();
isnewform = true;
}
currentForm = frmChecadores;
break;
case "BtnNomina":
if (frmTimbradoNomina == null)
{
frmTimbradoNomina = new FrmTimbradoNomina();
isnewform = true;
}
currentForm = frmTimbradoNomina;
break;
case "ChecadoresGluyas":
isnewform = true;
currentForm = new ADSUtileriasWF.Views.RelojChecador.Gluyas.Checadores();
break;
case "BtnReporte":
isnewform = true;
currentForm = new ADSUtileriasWF.Views.RelojChecador.Gluyas.ReporteChecadores();
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)
{
}
}
}