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;using System.Threading;//"tempo"
namespace CoresDUMAL{ public partial class frm_ValveColorEditor : Form { public frm_ValveColorEditor() { InitializeComponent(); } //Botão para gerar a cor private void btn_gerar_Click(object sender, EventArgs e) { try { chk_coresAutomatico.Checked = false; //CheckBox para gerar cor automatico colorDialog1.ShowDialog(); //Abrir o dialogo de cor do C# lbl_R.Text = "R: " + colorDialog1.Color.R.ToString(); //Label R = red = vermelho recebe o valor que será escolhido lbl_G.Text = "G: " + colorDialog1.Color.G.ToString(); //Label G = green = verde recebe o valor que será escolhido lbl_B.Text = "B: " + colorDialog1.Color.B.ToString(); //Label B = blue = azul recebe o valor que será escolhido btn_visualizar_cor.BackColor = colorDialog1.Color; //botão recebe a cor escolhida no dialog } catch (Exception ex) { MessageBox.Show(ex.Message); } } //TrackBar que refere ao transparente private void tb_transparencia_Scroll(object sender, EventArgs e) { try { txt_A.Text = tb_transparencia.Value.ToString(); //txt_A = transparencia recebe o valor dado pelo TrackBar de 0 até 255 } catch (Exception ex) { MessageBox.Show(ex.Message); } } //TextBox A que referese ao transparente private void txt_A_TextChanged(object sender, EventArgs e) { try { tb_transparencia.Value = Convert.ToInt32(txt_A.Text); //TrackBar transparencia recebe o valor digitado na txt_A de 0 até 255 } catch (Exception ex) { MessageBox.Show(ex.Message); } } //CheckBox para gerar cores automatico private void chk_coresAutomatico_CheckedChanged(object sender, EventArgs e) { try { if (chk_coresAutomatico.Checked == true) //verifica se esta checado, se tiver { timer1.Enabled = true; // o tempo1 é abilitado btn_gerar_cor.Enabled = false; //Botão para gerar a cor fica travado, porque a cor gera automaticamente pelo TrackBar } else { btn_gerar_cor.Enabled = true; //Botão para gerar cor é ativado } } catch (Exception ex) { MessageBox.Show(ex.Message); } } //load do form private void frm_CoresDUMAL_Load(object sender, EventArgs e) { try { btn_gerar_cor.Location = new Point(12, 316); //local do botão gerar. Não é necessario colocar isso timer1.Enabled = true; //Ativa o timer1 tm_hora.Enabled = true; //Ativa o tm_hora, para a hora correr sem dar leg ou ate msm travar o programa } catch (Exception ex) { MessageBox.Show(ex.Message); } } //O timer1 é para a gerar cor automatico sem travar ou dar leg no programa private void timer1_Tick(object sender, EventArgs e) { try { if (chk_coresAutomatico.Checked == true)//verifica se o checked estiver true ele executa logo abaixo { int A = tb_transparencia.Value;//o inteiro A recebe o valor do trackBar que refere a transparencia int R = tb_vermelho.Value;// o inteiro R recebe o valor do trackBar que refere a vermelho int G = tb_verde.Value;// o inteiro G recebe o valor do trackBar que refere a verde int B = tb_azul.Value;// o inteiro B recebe o valor do trackBar que refere o azul btn_visualizar_cor.BackColor = Color.FromArgb(A, R, G, B);//o botao recebe a cor gerada } } catch (Exception ex) { timer1.Enabled = false;//caso der exeção o timer1 recebe false ou seja para de funcionar MessageBox.Show(ex.Message); } } //Botão para gerar a cor private void btn_gerar_cor_Click(object sender, EventArgs e) { try { int R = Convert.ToInt32(txt_red.Text);//o inteiro A recebe o valor do TextBox que refere a vermelho int G = Convert.ToInt32(txt_green.Text);// o inteiro R recebe o valor do TextBox que refere a verde int B = Convert.ToInt32(txt_blue.Text);// o inteiro G recebe o valor do TextBox que refere a azul int A = Convert.ToInt32(txt_A.Text);// o inteiro B recebe o valor do TextBox que refere o transparente btn_visualizar_cor.BackColor = Color.FromArgb(A, R, G, B);//o botao recebe a cor gerada } catch (Exception ex) { MessageBox.Show(ex.Message); } } //TrackBar que refere ao vermelho private void tb_vermelho_Scroll(object sender, EventArgs e) { try { txt_red.Text = tb_vermelho.Value.ToString();//TextBox recebe o valor do trackBar vermelho } catch (Exception ex) { MessageBox.Show(ex.Message); } } //TrackBar que refere ao verde private void tb_verde_Scroll(object sender, EventArgs e) { try { txt_green.Text = tb_verde.Value.ToString(); //TextBox recebe o valor do TrackBar verde } catch (Exception ex) { MessageBox.Show(ex.Message); } } //TrackBar que refere ao azul private void tb_azul_Scroll(object sender, EventArgs e) { try { txt_blue.Text = tb_azul.Value.ToString();//TextBox recebe o valor do trackBar azul } catch (Exception ex) { MessageBox.Show(ex.Message); } } //TextBox que refere ao vermelho private void txt_red_TextChanged(object sender, EventArgs e) { try { tb_vermelho.Value = Convert.ToInt32(txt_red.Text);//TrackBar vermelho recebe o valor digitado no TextBox vermelho "0 a 255" } catch (Exception ex) { MessageBox.Show(ex.Message); } } //TextBox que refere ao verde private void txt_green_TextChanged(object sender, EventArgs e) { try { tb_verde.Value = Convert.ToInt32(txt_green.Text);//TrackBar verde recebe o valor digitado no TextBox verde "0 a 255" } catch (Exception ex) { MessageBox.Show(ex.Message); } } //TextBox que refere ao azul private void txt_blue_TextChanged(object sender, EventArgs e) { try { tb_azul.Value = Convert.ToInt32(txt_blue.Text);//TrackBar azul recebe o valor digitado no TextBox azul "0 a 255" } catch (Exception ex) { MessageBox.Show(ex.Message); } } //Timer que atualiza a hora private void tm_hora_Tick(object sender, EventArgs e) { try { DateTime dataHora = DateTime.Now;//pega a data e hora atual do sistema tsl_hora.Text = dataHora.ToLongTimeString() + " " + dataHora.ToLongDateString();//dataHora.ToLongTimeString() pega a hora completa, dataHora.ToLongDateString() pega a data por extenso } catch (Exception ex) { MessageBox.Show(ex.Message); } } //não é necessário é só uma complementação, é para fechar o forma com opacidade /*No evento do form em closing coloca esse código ai*/ private void frm_CoresDUMAL_FormClosing(object sender, FormClosingEventArgs e) { try { this.Opacity = 100;//indica a opacidade 100% for (double i = 1; i >= 0; i -= 0.1)//um laço for para tirar a opacidade como -0.1 { this.Opacity = i;//opacidade recebe -0.1 this.Refresh();//atualiza o form Thread.Sleep(50);//aguarda 50 milesimos de segundo para volta a fazer o loop } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }}/*O try eo catch são tratamento de erro, caso vc digite 256 em uma TextBox ele avisa qual erro e não fecha o form*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Resources;
using Microsoft.Win32;
using System.Data.ProviderBase;
namespace invertLink
{
public partial class frm_invert_letras : Form
{
public frm_invert_letras()
{
InitializeComponent();
}
//
string invertido;
//botao;
private void btn_invert_Click(object sender, EventArgs e)
{
invertido = txt_invertido.Text; //Atribui o texto a variavel string
txt_normal.Text = Inverter(invertido);// recebe o texto, inverte ele e joga na TextBox
if (txt_invertido.Text != null)
{
txt_invertido.Enabled = false;
txt_normal.Enabled = true;
}
}
//Inverter os caracteres;
public string Inverter(string Texto)
{
//string import;
//cria um array de caracteres,com o texto.
Char[] ArrayChar = invertido.ToCharArray();
//Invertendo a ordem do array
Array.Reverse(ArrayChar);
//retorna o exto invertido
return new string(ArrayChar);
}
//Novo;
private void btn_novo_Click(object sender, EventArgs e)
{
txt_normal.Text = null;
txt_invertido.Text = null;
txt_invertido.Enabled = true;
txt_normal.Enabled = false;
}
//Sair;
private void btn_sair_Click(object sender, EventArgs e)
{
this.Close();
}
//notifi icon fechar;
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
Show();
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Resources;
using Microsoft.Win32;
using System.Data.ProviderBase;
namespace invertLink
{
public partial class frm_invert_letras : Form
{
public frm_invert_letras()
{
InitializeComponent();
}
//
string invertido;
//botao;
private void btn_invert_Click(object sender, EventArgs e)
{
invertido = txt_invertido.Text; //Atribui o texto a variavel string
txt_normal.Text = Inverter(invertido);// recebe o texto, inverte ele e joga na TextBox
if (txt_invertido.Text != null)
{
txt_invertido.Enabled = false;
txt_normal.Enabled = true;
}
}
//Inverter os caracteres;
public string Inverter(string Texto)
{
//string import;
//cria um array de caracteres,com o texto.
Char[] ArrayChar = invertido.ToCharArray();
//Invertendo a ordem do array
Array.Reverse(ArrayChar);
//retorna o exto invertido
return new string(ArrayChar);
}
//Novo;
private void btn_novo_Click(object sender, EventArgs e)
{
txt_normal.Text = null;
txt_invertido.Text = null;
txt_invertido.Enabled = true;
txt_normal.Enabled = false;
}
//Sair;
private void btn_sair_Click(object sender, EventArgs e)
{
this.Close();
}
//notifi icon fechar;
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
Show();
}
}
}
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;
using System.Diagnostics;//executar processo
namespace iniciarFecharProcesso
{
public partial class frm_OpenClose : Form
{
public frm_OpenClose()
{
InitializeComponent();
}
Process process = new Process();// Uma variavel do tipo processo
//Botão abrir
private void btn_Abrir_Click(object sender, EventArgs e)
{
try
{
process.StartInfo.FileName = txt_Processo.Text; //TextBox informa o nome para a variavel
process.EnableRaisingEvents = true; //habilita o evento
process.Start(); //Abri o processo chamado
}
catch
{
MessageBox.Show("O processo não existe ou não pôde ser iniciado.", "Erro");
{
}
//botão fechar
private void btn_Fechar_Click(object sender, EventArgs e)
{
try
{
process.Kill(); //Termina o processo
}
catch
{
MessageBox.Show("Não foi possível terminar o processo.","Erro");
}
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;//executar processo
namespace iniciarFecharProcesso
{
public partial class frm_OpenClose : Form
{
public frm_OpenClose()
{
InitializeComponent();
}
Process process = new Process();// Uma variavel do tipo processo
//Botão abrir
private void btn_Abrir_Click(object sender, EventArgs e)
{
try
{
process.StartInfo.FileName = txt_Processo.Text; //TextBox informa o nome para a variavel
process.EnableRaisingEvents = true; //habilita o evento
process.Start(); //Abri o processo chamado
}
catch
{
MessageBox.Show("O processo não existe ou não pôde ser iniciado.", "Erro");
{
}
//botão fechar
private void btn_Fechar_Click(object sender, EventArgs e)
{
try
{
process.Kill(); //Termina o processo
}
catch
{
MessageBox.Show("Não foi possível terminar o processo.","Erro");
}
}
}
}
Bah vlww cara tava precisando de exemplos assim, muito bom seu blog, continue assim ;D
ResponderExcluirgostei muito
ResponderExcluir