DISEÑO DE VENTANA
CODIGO 01:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Esponja10
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void
tXTToolStripMenuItem_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
richTextBox1.LoadFile(openFileDialog1.FileName
,
RichTextBoxStreamType.PlainText);
richTextBox1.BackColor =
Color.PapayaWhip;
this.Text = openFileDialog1.FileName;
toolStripStatusLabel1.Text = "Total de lineas: "+
richTextBox1.Lines.Length.ToString();
}
}
private void
rTFToolStripMenuItem_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
richTextBox1.LoadFile(openFileDialog1.FileName
,
RichTextBoxStreamType.RichText);
richTextBox1.BackColor =
Color.NavajoWhite;
this.Text = openFileDialog1.FileName;
toolStripStatusLabel1.Text = "Total de lineas: "+
richTextBox1.Lines.Length.ToString();
}
}
private Color Colores()
{
Color[] Fondo
={Color.PapayaWhip,Color.Wheat, Color.OldLace,
Color.WhiteSmoke,Color.FloralWhite,Color.NavajoWhite
,Color.GhostWhite,Color.AntiqueWhite,Color.LightGray};//colores de fondo
Random R = new Random();//objeto random
int pos = R.Next(Fondo.Length);//asignar
posicion aleatoria
return Fondo[pos];//retornamos el color
}
private void
nuevoToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Text = "Nuevo";
richTextBox1.BackColor = Colores();
toolStripProgressBar1.Value = 0;
toolStripStatusLabel1.Text = "sin lineas";
richTextBox1.Focus();
}
private void
numerarToolStripMenuItem_Click(object sender, EventArgs e)
{
int Fin = richTextBox1.Lines.Length;
String cad = "";
for (int a = 0; a
< Fin; a++)
{
cad +=(a+1).ToString() + " " + richTextBox1.Lines[a]+ "\n";
}
richTextBox1.Text = cad;
toolStripStatusLabel1.Text = "Numerado total: "+Fin;
}
private void
cortarToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Cut();
toolStripStatusLabel1.Text = "Cortar";
}
private void
copiarToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Copy();
toolStripStatusLabel1.Text = "Copiar";
}
private void
pegarToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Paste();
toolStripStatusLabel1.Text = "Pegar";
}
private void
seleccionartodoToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.SelectAll();
toolStripStatusLabel1.Text = "Seleccionar todo";
}
private void
deshacerToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Undo();
toolStripStatusLabel1.Text = "Deshacer";
}
private void
rehacerToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Redo();
toolStripStatusLabel1.Text = "Rehacer";
}
private void soloParesToolStripMenuItem_Click(object sender, EventArgs e)
{
//numerar solo
pares y borrar lineas impares
int Fin = richTextBox1.Lines.Length;
String cad = "";
for (int a = 0; a
< Fin; a+=2)
{
cad += a.ToString() + " " + richTextBox1.Lines[a] + "\n";
}
richTextBox1.Text = cad;
toolStripStatusLabel1.Text = "Numerado total: " + Fin;
}
private void
soloImparesToolStripMenuItem_Click(object sender, EventArgs e)
{
int Fin = richTextBox1.Lines.Length;
String cad = "";
for (int a = 1; a
< Fin; a += 2)
{
cad += a.ToString() + " " + richTextBox1.Lines[a] + "\n";
}
richTextBox1.Text = cad;
toolStripStatusLabel1.Text = "Numerado total: " + Fin;
}
private void
lineasDeMayorAMenorToolStripMenuItem_Click(object sender, EventArgs e)
{
int Fin = richTextBox1.Lines.Length-1;
String cad = "";
for (int a = Fin;
a >=0; a--)
{
cad += a.ToString() + " " + richTextBox1.Lines[a] + "\n";
}
richTextBox1.Text = cad;
toolStripStatusLabel1.Text = "Numerado inverso total: " + Fin;
}
private void
eliminarLineaEspecificaToolStripMenuItem_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Eliminar linea
" +
toolStripTextBox1.Text, "Pregunta",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question)
== DialogResult.Yes)//cuadro para preguntar si desea eliminar
{//codigo para
eliminar la linea
toolStripStatusLabel1.Text = "Se elimino la línea " +
toolStripTextBox1.Text;//informar de la linea eliminada
//eliminamos
la linea validando que exista
}
}
}
}

No hay comentarios.:
Publicar un comentario