Created
August 21, 2016 18:22
-
-
Save drmcarvalho/cd96e96cf90c3ebd1e72790a44713e88 to your computer and use it in GitHub Desktop.
Classe que aplica tema nos formularios.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Drawing; | |
using System.Windows.Forms; | |
namespace LogixMine | |
{ | |
public class TemaPadrao | |
{ | |
static void AplicaTema(Label l) | |
{ | |
l.Font = new Font("Arial", 11.0f); | |
l.BackColor = Color.LightBlue; | |
l.ForeColor = Color.Black; | |
} | |
static void AplicaTema(Form f) | |
{ | |
f.Font = new Font("Arial", 11.0f); | |
f.BackColor = Color.LightBlue; | |
f.ForeColor = Color.Black; | |
} | |
static void AplicaTema(Button b) | |
{ | |
if (b.Text.Equals("Salvar")) | |
{ | |
b.BackColor = Color.MediumSeaGreen; | |
b.ForeColor = Color.White; | |
} | |
else if (b.Text.Equals("Cancelar")) | |
{ | |
b.BackColor = Color.IndianRed; | |
b.ForeColor = Color.White; | |
} | |
} | |
static void AplicaTema(TextBox b) | |
{ | |
b.BorderStyle = BorderStyle.FixedSingle; | |
} | |
static void UsarTemaGroupBox(GroupBox box) | |
{ | |
foreach (var item in box.Controls) | |
{ | |
if (item.GetType().ToString().Equals("System.Windows.Forms.Label")) | |
AplicaTema((Label)item); | |
if (item.GetType().ToString().Equals("System.Windows.Forms.Button")) | |
AplicaTema((Button)item); | |
if (item.GetType().ToString().Equals("System.Windows.Forms.TextBox")) | |
AplicaTema((TextBox)item); | |
} | |
} | |
public static void UsarTema(Form formulario) | |
{ | |
AplicaTema(formulario); | |
foreach (var obj in formulario.Controls) | |
{ | |
if (obj.GetType().ToString().Equals("System.Windows.Forms.GroupBox")) | |
UsarTemaGroupBox((GroupBox)obj); | |
if (obj.GetType().ToString().Equals("System.Windows.Forms.Label")) | |
AplicaTema((Label)obj); | |
if (obj.GetType().ToString().Equals("System.Windows.Forms.Button")) | |
AplicaTema((Button)obj); | |
if (obj.GetType().ToString().Equals("System.Windows.Forms.TextBox")) | |
AplicaTema((TextBox)obj); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment