Sei sulla pagina 1di 10

Laboratorio 3 - Sistemas de Informacion II

lic. Julia Zenteno Zenteno 21-Agosto-2013 -

Public Class frmMenuJZ Private Sub picTrianguloAnimado_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picTrianguloAnimado.Click frmAnimadoRectanguloJZ.Show() End Sub Private Sub picArchivo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles picArchivo.Click frmArchivosJZ.Show() End Sub Private Sub picConfiguracion_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles picConfiguracion.Click frmConfiguracionJZ.Show() End Sub Private Sub picGraficoBarras_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles picGraficoBarras.Click frmGrafBarrasJZ.Show() End Sub Private Sub picValidando_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles picValidando.Click frmValidandoJZ.Show() End Sub Private Sub picSalir_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles picSalir.Click Me.Close() End Sub End Class

Laboratorio 3 - Sistemas de Informacion II

lic. Julia Zenteno Zenteno 21-Agosto-2013 -

Imports System.Drawing.Printing Imports System.Configuration Public Class frmArchivosJZ Dim nombrefile As String Private Sub btnAbrir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAbrir.Click Dim i As Integer txtNombreEmisor.Text = "" txtDestinatorio.Text = "" txtAsunto.Text = "" txtNombreArchivo.Text = "" nombrefile = txtNombreArchivo.Text i = FileLen("c:\notificaciones\" & nombrefile & ".txt") Dim contenido As New String(" ", FileLen("c:\notificaciones\" & nombrefile & ".txt")) FileOpen(1, "c:\Notificaciones\" & nombrefile & ".txt", OpenMode.Binary) FileGet(1, contenido) FileClose(1) txtNota.Text = contenido End Sub Private Sub btnSalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSalir.Click Me.Close() End Sub Private Sub btnGuardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGuardar.Click nombrefile = txtNombreArchivo.Text FileOpen(1, "c:\Notificaciones\" & nombrefile & ".txt", OpenMode.Binary) FilePut(1, "Fecha de emisin: " & L_Fecha.Text & ControlChars.CrLf & "Emisor: " & txtNombreEmisor.Text & ControlChars.CrLf & "Destinatario: " & txtDestinatorio.Text & ControlChars.CrLf & "Asunto: " & txtAsunto.Text & ControlChars.CrLf & ControlChars.CrLf & "Nota: " & ControlChars.CrLf & txtNota.Text) FileClose(1) txtNombreEmisor.Text = "" txtDestinatorio.Text = "" txtAsunto.Text = "" txtNota.Text = "" End Sub Private Sub btnImprimir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImprimir.Click imprimir.AllowPrintToFile = False imprimir.AllowSelection = False imprimir.AllowSomePages = False imprimir.PrinterSettings = New PrinterSettings If imprimir.ShowDialog() = DialogResult.OK Then imprimir.PrinterSettings = imprimir.PrinterSettings Try PrintDocument1.Print() Catch ex As Exception MessageBox.Show("Error de impresin", "Imprimir imagen", _ MessageBoxButtons.OK, MessageBoxIcon.Exclamation) End Try End If End Sub Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage Dim margenIzq As Single = e.MarginBounds.Left Dim margenSup As Single = e.MarginBounds.Top e.Graphics.DrawString(txtNota.Text, Me.Font, Brushes.Black, margenIzq, margenSup) End Sub

Laboratorio 3 - Sistemas de Informacion II

lic. Julia Zenteno Zenteno 21-Agosto-2013 -

Private Sub Archivos_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load L_Fecha.Text = Now.Today End Sub Private Sub btnBuscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBuscar.Click Dim file As New OpenFileDialog() file.InitialDirectory = "C:\Notificaciones" With file .DefaultExt = "*.txt" .Multiselect = False .Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*" .Title = "Seleccione un archivo..." End With If (file.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then Dim archivo As New System.IO.StreamReader(file.FileName) Me.txtNota.Text = archivo.ReadToEnd archivo.Close() End If End Sub Private Sub txtNombreEmisor_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtNombreEmisor.KeyPress If Char.IsLetter(e.KeyChar) Then e.Handled = False ElseIf Char.IsControl(e.KeyChar) Then e.Handled = False ElseIf Char.IsSeparator(e.KeyChar) Then e.Handled = False Else e.Handled = True End If End Sub End Class

Imports System.Windows.Forms.PaintEventArgs Public Class frmAnimadoRectanguloJZ Dim rectangulo As Rectangle Dim Ancho As Integer = 30 Dim a%, b% Private Sub frmAnimadoRectangulo_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Temporizador.Enabled = True a = 10 b = 10 rectangulo.Height = 1 rectangulo.Width = 1 End Sub Private Sub frmAnimadoRectangulo_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint ' Dibujar el rectangulo en el evento Paint de form1 e.Graphics.DrawRectangle(New Pen(Color.Blue, Ancho), rectangulo) End Sub

Laboratorio 3 - Sistemas de Informacion II

lic. Julia Zenteno Zenteno 21-Agosto-2013 -

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Temporizador.Tick ' Animar con coordenadas a y b incrementandolas If rectangulo.X < Me.Height Then a = a + 10 b = b + 8 rectangulo.X = a rectangulo.Y = b Me.Invalidate() Else a = 10 b = 10 rectangulo.X = a rectangulo.Y = b Me.Invalidate() End If End Sub End Class

Imports System.Media Public Class frmConfiguracionJZ Public GLOBO As String Public TIEMPO_I, TIEMPO_F, HR_APA, HR_ALARMA As Date Private Sub btnAudio_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAudio.Click My.Computer.Audio.Play(Application.StartupPath & "\update2.wav", AudioPlayMode.Background) End Sub Private Sub btnMouse_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnMouse.MouseLeave lblMensajeSistema.Text = "Sistema Bloqueado " lblMensajeSistema.ForeColor = Color.Red End Sub Private Sub btnMouse_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnMouse.MouseMove lblMensajeSistema.Text = "Desbloquear Sistema" lblMensajeSistema.ForeColor = Color.Lime End Sub End Class

Laboratorio 3 - Sistemas de Informacion II

lic. Julia Zenteno Zenteno 21-Agosto-2013 -

Imports System.IO Imports System.Drawing Imports System.Drawing.Drawing2D Public Class frmGrafBarrasJZ Private Sub btnGraficar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGraficar.Click verificando() graficando() testos() End Sub Private Sub verificando() a = Double.Parse(Me.txtba.Text) b = Double.Parse(Me.txtbb.Text) c = Double.Parse(Me.txtbc.Text) d = Double.Parse(Me.txtbd.Text) If a >= b Then temp = a Else temp = b End If If c >= d Then temp1 = c Else temp1 = d End If If temp >= temp1 Then elm = temp Else elm = temp1 End If End Sub Private Sub graficando() p1 = (a / elm) * 260 p2 = (b / elm) * 260 p3 = (c / elm) * 260 p4 = (d / elm) * 260 pA = 260 - p1 pB = 260 - p2 pC = 260 - p3 pD = 260 - p4 Dim bm_dest As Bitmap = New Bitmap(Me.pibGrafico.Image) Dim gr_dest As Graphics = Graphics.FromImage(bm_dest) Dim recA As New Rectangle(30, pA, 50, p1) Dim recB As New Rectangle(90, pB, 50, p2) Dim recC As New Rectangle(150, pC, 50, p3) Dim recD As New Rectangle(210, pD, 50, p4)

Laboratorio 3 - Sistemas de Informacion II

lic. Julia Zenteno Zenteno 21-Agosto-2013 -

gr_dest.DrawImage(bm_dest, recA) gr_dest.DrawImage(bm_dest, recB) gr_dest.DrawImage(bm_dest, recC) gr_dest.DrawImage(bm_dest, recD) Dim lb As Drawing2D.LinearGradientBrush = New Drawing2D.LinearGradientBrush(recA, Color.Blue, Color.Azure, Drawing2D.LinearGradientMode.Vertical) Dim lb1 As Drawing2D.LinearGradientBrush = New Drawing2D.LinearGradientBrush(recB, Color.Chocolate, Color.Azure, Drawing2D.LinearGradientMode.Vertical) Dim lb2 As Drawing2D.LinearGradientBrush = New Drawing2D.LinearGradientBrush(recC, Color.DarkRed, Color.Azure, Drawing2D.LinearGradientMode.Vertical) Dim lb3 As Drawing2D.LinearGradientBrush = New Drawing2D.LinearGradientBrush(recD, Color.FloralWhite, Color.Azure, Drawing2D.LinearGradientMode.Vertical) Me.pibGrafico.Image = bm_dest gr_dest.FillRectangle(lb, recA) gr_dest.FillRectangle(lb1, recB) gr_dest.FillRectangle(lb2, recC) gr_dest.FillRectangle(lb3, recD) gr_dest.DrawImage(bm_dest, recA) Me.pibGrafico.Image = bm_dest End Sub Private Sub testos() Dim ttext As String = "A" Dim ttextb As String = "B" Dim ttextc As String = "C" Dim ttextd As String = "D" Dim text As String = Me.txtba.Text Dim textb As String = Me.txtbb.Text Dim textc As String = Me.txtbc.Text Dim textd As String = Me.txtbd.Text Dim timage As Image = New Bitmap(Image.FromFile("Negro.jpg")) Dim ttfont As Font = New Font("arial", 10, FontStyle.Bold) Dim tbrush As TextureBrush = New TextureBrush(timage) Dim tshadowbrush As SolidBrush = New SolidBrush(Color.FromArgb(255, Color.Chocolate)) Dim bm_dest As Bitmap = New Bitmap(Me.pibGrafico.Image) Dim gr_dest As Graphics = Graphics.FromImage(bm_dest) '---Numeros gr_dest.DrawString(text, ttfont, tshadowbrush, 25, 10) gr_dest.DrawString(text, ttfont, tbrush, 22, 10) gr_dest.DrawString(textb, ttfont, tshadowbrush, 105, 10) gr_dest.DrawString(textb, ttfont, tbrush, 102, 10) gr_dest.DrawString(textc, ttfont, tshadowbrush, 160, 10) gr_dest.DrawString(textc, ttfont, tbrush, 157, 10) gr_dest.DrawString(textd, ttfont, tshadowbrush, 220, 10) gr_dest.DrawString(textd, ttfont, tbrush, 217, 10) '---Letras gr_dest.DrawString(ttext, ttfont, tshadowbrush, 45, 270) gr_dest.DrawString(ttext, ttfont, tbrush, 42, 270) gr_dest.DrawString(ttextb, ttfont, tshadowbrush, 105, 270) gr_dest.DrawString(ttextb, ttfont, tbrush, 102, 270) gr_dest.DrawString(ttextc, ttfont, tshadowbrush, 160, 270) gr_dest.DrawString(ttextc, ttfont, tbrush, 157, 270) gr_dest.DrawString(ttextd, ttfont, tshadowbrush, 220, 270) gr_dest.DrawString(ttextd, ttfont, tbrush, 217, 270) Dim rect As New Rectangle(0, 0, 300, 300) gr_dest.DrawImage(bm_dest, rect) Me.pibGrafico.Image = bm_dest End Sub

Laboratorio 3 - Sistemas de Informacion II

lic. Julia Zenteno Zenteno 21-Agosto-2013 As

Private Sub txtba_KeyPress(ByVal sender As Object, ByVal e System.Windows.Forms.KeyPressEventArgs) Handles txtba.KeyPress Dim digit As Short digit = Asc(e.KeyChar) If digit = 46 Then If punto = False Then Me.txtba.AppendText(".") Else Me.txtba.AppendText("") End If punto = True End If If Not (digit >= 48 And digit <= 57) Then e.Handled = True End If End Sub Private Sub txtbb_KeyPress(ByVal sender As Object, ByVal e System.Windows.Forms.KeyPressEventArgs) Handles txtbb.KeyPress Dim digit As Short digit = Asc(e.KeyChar) If digit = 46 Then If puntob = False Then Me.txtbb.AppendText(".") Else Me.txtbb.AppendText("") End If puntob = True End If If Not (digit >= 48 And digit <= 57) Then e.Handled = True End If End Sub Private Sub txtbc_KeyPress(ByVal sender As Object, ByVal e System.Windows.Forms.KeyPressEventArgs) Handles txtbc.KeyPress Dim digit As Short digit = Asc(e.KeyChar) If digit = 46 Then If puntoc = False Then Me.txtbc.AppendText(".") Else Me.txtbc.AppendText("") End If puntoc = True End If If Not (digit >= 48 And digit <= 57) Then e.Handled = True End If End Sub Private Sub txtbd_KeyPress(ByVal sender As Object, ByVal e System.Windows.Forms.KeyPressEventArgs) Handles txtbd.KeyPress Dim digit As Short digit = Asc(e.KeyChar) If digit = 46 Then If puntod = False Then Me.txtbd.AppendText(".") Else Me.txtbd.AppendText("") End If puntod = True End If If Not (digit >= 48 And digit <= 57) Then e.Handled = True End If

As

As

As

Laboratorio 3 - Sistemas de Informacion II

lic. Julia Zenteno Zenteno 21-Agosto-2013 -

End Sub Private Sub btnAbrir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAbrir.Click With Me.ofdabrir .DefaultExt = "*.jpg" .Multiselect = False .Filter = "Imagenes JPG |*.jpg|Imagenes GIF|*.gif|Imagenes BMP|*.bmp|Todos los archivos|*.*" .Title = "Seleccione un archivo..." End With If (Me.ofdabrir.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then Dim bm_load As Bitmap = New Bitmap(Me.ofdabrir.FileName) Me.pibGrafico.Image = bm_load End If End Sub Private Sub btnLimpiar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLimpiar.Click limpiezatotal() End Sub Private Sub limpiezatotal() Me.pibGrafico.Image = Image.FromFile("Blanco.jpg") Me.txtba.Text = "0.00" Me.txtbb.Text = "0.00" Me.txtbc.Text = "0.00" Me.txtbd.Text = "0.00" End Sub Private Sub btnGuardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGuardar.Click With Me.sfdguardar .Title = "Seleccione un archivo..." .DefaultExt = "*.jpg" .Filter = "Imagenes JPG |*.jpg|Imagenes GIF|*.gif|Imagenes BMP|*.bmp|Todos los archivos|*.*" End With If sfdguardar.ShowDialog = DialogResult.OK Then Me.pibGrafico.Image.Save(Me.sfdguardar.FileName) MessageBox.Show("Texto grabado en archivo") End If End Sub Private Sub btnSalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSalir.Click Me.Close() End Sub Private Sub frmGrafBarras_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.pibGrafico.Image = Image.FromFile("Blanco.jpg") End Sub End Class

Module variables Public punto As Boolean = False Public puntob As Boolean = False Public puntoc As Boolean = False Public puntod As Boolean = False Public temp As Double Public temp1 As Double Public elm As Double Public p1 As Integer Public p2 As Integer Public p3 As Integer Public p4 As Integer Public pA As Integer

Laboratorio 3 - Sistemas de Informacion II


Public Public Public Public Public Public Public End Module pB As Integer pC As Integer pD As Integer a As Double b As Double c As Double d As Double

lic. Julia Zenteno Zenteno 21-Agosto-2013 -

Public Class frmValidandoJZ Private Sub txtLetras_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtLetras.KeyPress If (Asc(e.KeyChar)) >= 65 And (Asc(e.KeyChar)) <= 90 Or (Asc(e.KeyChar)) >= 97 And (Asc(e.KeyChar)) <= 122 Or (Asc(e.KeyChar)) = Keys.Back Then e.Handled = False Else : MsgBox("Solo se pueden digitar letras", MsgBoxStyle.Information) e.Handled = True End If End Sub Private Sub txtNumeros_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtNumeros.KeyPress If (Asc(e.KeyChar)) >= 48 And (Asc(e.KeyChar)) <= 57 Or (Asc(e.KeyChar)) = Keys.Back Or (Asc(e.KeyChar)) = Keys.Enter Then e.Handled = False Else MsgBox("Solo se pueden digitar nmeros", MsgBoxStyle.Information) e.Handled = True End If If (e.KeyChar = Convert.ToChar(Keys.Enter)) Then txtLetras.Focus() End If End Sub Private Sub btnSalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSalir.Click Me.Close() End Sub End Class

Laboratorio 3 - Sistemas de Informacion II 10

lic. Julia Zenteno Zenteno 21-Agosto-2013 EJERCICIOS

1.Crear un formulario que nos permita visualizar graficos y almacenar

2. Pruebe con seleccin de texto con el control TextBox


Sugerencia Private Sub txtOrigen_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtOrigen.KeyDown ' comprobamos las teclas pulsadas ' si est pulsada la tecla maysculas, ' y adems se est pulsando la tecla ' flecha derecha, quiere decir que se ' est seleccionando texto; ' obtener la informacin de las propiedades ' de seleccin del control TextBox If e.Shift Then If e.KeyCode.Right Then Me.lblTextoSelec.Text = Me.txtOrigen.SelectedText Me.lblLongitud.Text = Me.txtOrigen.SelectionLength Me.lblPosicion.Text = Me.txtOrigen.SelectionStart End If End If

Implemente la validacin de datos del anterior formulario.

3. Implemente un Formulario que permita generar cdigo de acuerdo a los datos ingresados

Potrebbero piacerti anche