sábado, 10 de setembro de 2011

on
Irei mostrar como criar um visualizador de imagens!


Acima mostra a aplicação já em execução!

Componentes para adicionar ao form:

PictureBox1 / Name = PictureBox1
ColorDialog1 / Name = Color
OpenFileDialog1 / Name = OpenFile
Timer1 / Name = tColor
FlowLayoutPanel1 / Name = FlowLayoutPanel1
TableLayoutPanel1 / Name = TableLayoutPanel1
CheckBox1 / Name = CheckAjustar

4 Buttons / names = btnShow, btnColorir, btnClear e btnEncerrar

Código Fonte de Cada botão logo abaixo:


Public Class Form1

    Private Sub btnShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShow.Click
        Try
            If Me.OpenFile.ShowDialog = Windows.Forms.DialogResult.OK Then
                Me.PictureBox1.Load(Me.OpenFile.FileName)
            End If
        Catch ex As Exception

        End Try
    End Sub

    Private Sub btnColorir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnColorir.Click
        Try
            If Me.Color.ShowDialog = Windows.Forms.DialogResult.OK Then
                Me.PictureBox1.BackColor = Me.Color.Color
                Me.FlowLayoutPanel1.BackColor = Me.Color.Color
                Me.TableLayoutPanel1.BackColor = Me.Color.Color
            End If
        Catch ex As Exception

        End Try
    End Sub

    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        Try
            Me.PictureBox1.Image = Nothing
        Catch ex As Exception

        End Try
    End Sub

    Private Sub btnEncerrar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEncerrar.Click
        End
    End Sub

    Private Sub tColor_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tColor.Tick
        Try
            If Me.PictureBox1.BackColor = Drawing.Color.Black Then
                Me.CheckAjustar.ForeColor = Drawing.Color.White
                Me.btnShow.ForeColor = Drawing.Color.White
                Me.btnClear.ForeColor = Drawing.Color.White
                Me.btnColorir.ForeColor = Drawing.Color.White
                Me.btnEncerrar.ForeColor = Drawing.Color.White
            End If

            If Me.PictureBox1.BackColor = Drawing.Color.White Then
                Me.CheckAjustar.ForeColor = Drawing.Color.Black
                Me.btnShow.ForeColor = Drawing.Color.Black
                Me.btnClear.ForeColor = Drawing.Color.Black
                Me.btnColorir.ForeColor = Drawing.Color.Black
                Me.btnEncerrar.ForeColor = Drawing.Color.Black
            End If

        Catch ex As Exception

        End Try
    End Sub

    Private Sub CheckAjustar_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckAjustar.CheckedChanged
        Try
            If Me.CheckAjustar.Checked Then
                Me.PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
            Else
                Me.PictureBox1.SizeMode = PictureBoxSizeMode.Normal
            End If
        Catch ex As Exception

        End Try
    End Sub
End Class

 Espero ter ajudado e att.


0 comentários:

Postar um comentário