Criar uma Loja Virtual Grátis
Translate to English Translate to Spanish Translate to French Translate to German Google-Translate-Portuguese to Italian Translate to Russian Translate to Chinese Translate to Japanese

Rating: 2.8/5 (92 votos)



ONLINE
1





Partilhe esta Página





Total de visitas: 5647
Editor de texto simples
Editor de texto simples

imagens do editor com o codigo fonte

 

splash screen

editor

 

ajuda

 

codigo fonte. 'do formulario editor'


Imports System.IO
Imports System.Drawing.Printing
Imports Microsoft.Office.Interop.Word

Public Class Form1

    Dim leitor As StringReader

    Private Sub MenuStrip1_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles MenuStrip1.ItemClicked

    End Sub

    Friend WithEvents Form1 As System.Windows.Forms.Application

    Private Sub AbrirFicheiroToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AbrirFicheiroToolStripMenuItem.Click

        If Me.OpenFileDialog1.ShowDialog() = DialogResult.OK Then
            Dim fs As New FileStream(OpenFileDialog1.FileName, FileMode.Open, FileAccess.Read)
            Dim m_streamReader As New StreamReader(fs)
            ' Lê o arquivo  usando a      classe StreamReader
            m_streamReader.BaseStream.Seek(0, SeekOrigin.Begin)

            ' Lê      cada linha do stream até a última
            Me.RichTextBox1.Text = ""

            Dim strLine As String = m_streamReader.ReadLine()

            While Not (strLine Is Nothing)
                Me.RichTextBox1.Text += strLine + ControlChars.Lf
                strLine = m_streamReader.ReadLine()
            End While

            '      Fecha o stream
            m_streamReader.Close()
        End If

    End Sub

    Private Sub SalvarComoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SalvarComoToolStripMenuItem.Click
        Try
            If Me.SaveFileDialog1.ShowDialog() = DialogResult.OK Then
                Dim fs As New FileStream(SaveFileDialog1.FileName, FileMode.OpenOrCreate, FileAccess.Write)
                Dim m_streamWriter As New StreamWriter(fs)
                SaveFileDialog1.Filter = "*htm|*.doc"
                SaveFileDialog1.FileName = "salvar como"
                SaveFileDialog1.Title = "salvar ficheiro"
                m_streamWriter.Flush()
                m_streamWriter.BaseStream.Seek(0, SeekOrigin.Begin)
                m_streamWriter.Write(Me.RichTextBox1.Text)
                m_streamWriter.Flush()
                m_streamWriter.Close()
            End If

        Catch ex As Exception
            MsgBox("erro ao salvar o arquivo", MsgBoxStyle.Critical, "erro ao salvar")
        End Try

    End Sub

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

    Private Sub ContToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub MudarACorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

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


    Private Sub SelecionarTudoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelecionarTudoToolStripMenuItem.Click
        RichTextBox1.SelectAll()
    End Sub

    Private Sub TipoDeLetraToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TipoDeLetraToolStripMenuItem.Click
        FontDialog1.ShowDialog()
        RichTextBox1.Font = FontDialog1.Font
    End Sub

    Private Sub MoldarTextoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MoldarTextoToolStripMenuItem.Click
        ColorDialog1.ShowDialog()
        RichTextBox1.ForeColor = ColorDialog1.Color
    End Sub

    Private Sub BarraDeEstadoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BarraDeEstadoToolStripMenuItem.Click
        If BarraDeEstadoToolStripMenuItem.Visible = True Then
            BarraDeEstadoToolStripMenuItem.Visible = False
        End If
        If BarraDeEstadoToolStripMenuItem.Visible = False Then
            BarraDeEstadoToolStripMenuItem.Visible = True
        End If
    End Sub

    Private Sub NovoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NovoToolStripMenuItem.Click

        If RichTextBox1.Text <> "" Then
            If (MessageBox.Show("Deseja Salvar o arquivo ?", "Salvar Arquivo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) = DialogResult.Yes) Then
                Try
                    ' Pega o      nome do arquivo para salvar
                    If Me.SaveFileDialog1.ShowDialog() = DialogResult.OK Then

                        ' abre um stream para escrita e cria um StreamWriter para  implementar o      stream
                        Dim fs As New FileStream(SaveFileDialog1.FileName, FileMode.OpenOrCreate, FileAccess.Write)
                        Dim m_streamWriter As New StreamWriter(fs)
                        m_streamWriter.Flush()

                        ' Escreve para o arquivo usando a classe StreamWriter
                        m_streamWriter.BaseStream.Seek(0, SeekOrigin.Begin)
                        ' escreve no      controle richtextbox
                        m_streamWriter.Write(Me.RichTextBox1.Text)
                        ' fecha o  arquivo
                        m_streamWriter.Flush()
                        m_streamWriter.Close()
                    End If
                Catch ex As Exception
                    MsgBox("Erro a salvar o arquivo ", MsgBoxStyle.Critical, "Erro ao Salvar")
                End Try
            End If
        End If
        RichTextBox1.Clear()
        RichTextBox1.Focus()

    End Sub

    Private Sub SalvarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SalvarToolStripMenuItem.Click
        Try
            ' Pega o      nome do arquivo para salvar
            If Me.SaveFileDialog1.ShowDialog() = DialogResult.OK Then

                ' abre um stream para escrita e cria um StreamWriter para  implementar o      stream
                Dim fs As New FileStream(SaveFileDialog1.FileName, FileMode.OpenOrCreate, FileAccess.Write)
                Dim m_streamWriter As New StreamWriter(fs)
                m_streamWriter.Flush()

                ' Escreve para o arquivo usando a classe StreamWriter
                m_streamWriter.BaseStream.Seek(0, SeekOrigin.Begin)
                ' escreve no      controle richtextbox
                m_streamWriter.Write(Me.RichTextBox1.Text)
                ' fecha o  arquivo
                m_streamWriter.Flush()
                m_streamWriter.Close()
            End If
        Catch ex As Exception
            MsgBox("Erro a salvar o arquivo ", MsgBoxStyle.Critical, "Erro ao Salvar")
        End Try

    End Sub

    Private Sub NegritarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NegritarToolStripMenuItem.Click
        Dim nome_fonte As String
        Dim tamanho_fonte As Single
        Dim negrito As Boolean

        nome_fonte = RichTextBox1.Font.Name
        tamanho_fonte = RichTextBox1.Font.Size
        negrito = RichTextBox1.Font.Bold

        If negrito = False Then
            RichTextBox1.SelectionFont = New System.Drawing.Font(nome_fonte, tamanho_fonte, FontStyle.Bold)
        Else
            RichTextBox1.SelectionFont = New System.Drawing.Font(nome_fonte, tamanho_fonte, FontStyle.Regular)
        End If
    End Sub

    Private Sub ItálicoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ItálicoToolStripMenuItem.Click
        Dim nome_fonte As String
        Dim tamanho_fonte As Single
        Dim italico As Boolean

        nome_fonte = RichTextBox1.Font.Name
        tamanho_fonte = RichTextBox1.Font.Size
        italico = RichTextBox1.Font.Italic

        If italico = False Then
            RichTextBox1.SelectionFont = New System.Drawing.Font(nome_fonte, tamanho_fonte, FontStyle.Italic)
        Else
            RichTextBox1.SelectionFont = New System.Drawing.Font(nome_fonte, tamanho_fonte, FontStyle.Italic)
        End If
    End Sub

    Private Sub SublinharToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SublinharToolStripMenuItem.Click
        Dim nome_fonte As String
        Dim tamanho_fonte As Single
        Dim sublinha As Boolean

        nome_fonte = RichTextBox1.Font.Name
        tamanho_fonte = RichTextBox1.Font.Size
        sublinha = RichTextBox1.Font.Underline

        If sublinha = False Then
            RichTextBox1.SelectionFont = New System.Drawing.Font(nome_fonte, tamanho_fonte, FontStyle.Underline)
        Else
            RichTextBox1.SelectionFont = New System.Drawing.Font(nome_fonte, tamanho_fonte, FontStyle.Underline)
        End If
    End Sub

    Private Sub PréVisualizarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PréVisualizarToolStripMenuItem.Click
        'visualiza a impressao  
        Try
            Dim strTexto As String = Me.RichTextBox1.Text
            leitor = New StringReader(strTexto)

            Dim printPreviewDialog1 As New PrintPreviewDialog()
            With printPreviewDialog1
                .Document = Me.PrintDocument1
                .Text = "Você está Visualizando com o *Rosario Visualizador*"
                .WindowState = FormWindowState.Maximized
                .PrintPreviewControl.Zoom = 1
                .FormBorderStyle = FormBorderStyle.Fixed3D
                .ShowDialog()
            End With
        Catch exp As Exception
            MsgBox(exp.Message.ToString, MsgBoxStyle.Critical, "Erro na  visualização da      impressão")
        End Try
    End Sub

    Private Sub PrintDocument1_PrintPage_1(ByVal sender As System.Object, ByVal texto As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        Dim linhasPorPagina As Single = 0
        Dim Posicao_Y As Single = 0
        Dim contador As Integer = 0
        Dim MargemEsquerda As Single = texto.MarginBounds.Left
        Dim MargemSuperior As Single = texto.MarginBounds.Top
        Dim linha As String = Nothing
        Dim FonteDeImpressao As System.Drawing.Font = Me.RichTextBox1.Font
        Dim meupincel As New SolidBrush(Color.Black)
        'Calcula o numero de  linhas      por página usando as medidas das margens
        linhasPorPagina = texto.MarginBounds.Height / FonteDeImpressao.GetHeight(texto.Graphics)
        ' Vamos imprimiri cada  linha      implementando um StringReader
        linha = leitor.ReadLine()
        While contador < linhasPorPagina
            ' calcula a posicao da  proxima      linha baseado  na altura da fonte de acordo com o dispostivo de      impressao
            Posicao_Y = (MargemSuperior + (contador * FonteDeImpressao.GetHeight(texto.Graphics)))
            ' desenha a      proxima linha no controle richtext
            texto.Graphics.DrawString(linha, FonteDeImpressao, meupincel, MargemEsquerda, Posicao_Y, New StringFormat())

            contador += 1
            linha = leitor.ReadLine()
        End While
        ' se existir mais  linhas      imprimi outra página
        If Not (linha Is Nothing) Then
            texto.HasMorePages = True
        Else
            texto.HasMorePages = False
        End If
        meupincel.Dispose()
    End Sub

    Private Sub ImprimirToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImprimirToolStripMenuItem.Click
        PrintDialog1.Document = PrintDocument1

        Dim strTexto As String = Me.RichTextBox1.Text
        leitor = New StringReader(strTexto)

        If PrintDialog1.ShowDialog() = DialogResult.OK Then
            Me.PrintDocument1.Print()

        End If

    End Sub

    Private Sub ColarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ColarToolStripMenuItem.Click
        RichTextBox1.Paste()
    End Sub

    Private Sub AjudaOfflineToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AjudaOfflineToolStripMenuItem.Click
        Form2.Show()
    End Sub

    Private Sub CopiarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopiarToolStripMenuItem.Click
        RichTextBox1.Copy()
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        ToolStripStatusLabel1.Text = Today.ToShortDateString

    End Sub

    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Dim palavra As String

        'palavra = TextBox1.Text

        'If (RichTextBox1.Find(palavra) >= 0) Then
        '    RichTextBox1.Text = (palavra)

        '    MsgBox("Se encontra Na Linha: " + CStr(RichTextBox1.Find(palavra)))

        'Else

        '    MsgBox("Nao Existe esta Palavra")

        'End If
    End Sub
End Class


Baixe aqui o projecto