Public Class Form1
Private Sub СохранитьToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles СохранитьToolStripMenuItem.Click
Dim Save As New SaveFileDialog
Save.Filter = "HTML|*.html|Текстовые файлы|*.txt|RTF-файлы|*.RTF"
If Save.ShowDialog() = DialogResult.Cancel Then Exit Sub
Dim File As String = Save.FileName
If File.EndsWith(".RTF") Or File.EndsWith(".rtf") Then
RichTextBox1.SaveFile(File, RichTextBoxStreamType.RichText)
ElseIf File.EndsWith(".TXT") Or File.EndsWith(".txt") Then
RichTextBox1.SaveFile(File, RichTextBoxStreamType.PlainText)
ElseIf File.EndsWith(".HTML") Or File.EndsWith(".html") Then
RichTextBox1.SaveFile(File, RichTextBoxStreamType.PlainText)
End If
End Sub
Private Sub ОткрытьToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ОткрытьToolStripMenuItem.Click
Dim Open As New OpenFileDialog
Open.Filter = "HTML|*.html|Текстовые файлы|*.txt|RTF-файлы|*.RTF"
Open.Title = "Сохранить файл "
Open.CheckPathExists = True
If Open.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim File As String = Open.FileName
If File.EndsWith(".RTF") Or File.EndsWith(".rtf") Then
RichTextBox1.LoadFile(File, RichTextBoxStreamType.RichText)
ElseIf File.EndsWith(".TXT") Or File.EndsWith(".txt") Then
RichTextBox1.LoadFile(File, RichTextBoxStreamType.PlainText)
ElseIf File.EndsWith(".HTML") Or File.EndsWith(".html") Then
RichTextBox1.LoadFile(File, RichTextBoxStreamType.PlainText)
Else
MsgBox("Не могу открыть файл такого формата")
End If
End If
End Sub
Private Sub ОчиститьToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ОчиститьToolStripMenuItem.Click
RichTextBox1.Text = Nothing
End Sub
Private Sub ОтменитьToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ОтменитьToolStripMenuItem.Click
RichTextBox1.Undo()
End Sub
Private Sub ПовторитьToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ПовторитьToolStripMenuItem.Click
RichTextBox1.Redo()
End Sub
Private Sub ШрифтToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ШрифтToolStripMenuItem.Click
FontDialog1.ShowDialog()
RichTextBox1.SelectionFont = FontDialog1.Font
End Sub
Private Sub ЦветToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ЦветToolStripMenuItem.Click
ColorDialog1.ShowDialog()
RichTextBox1.SelectionColor = ColorDialog1.Color
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
If ListBox1.SelectedItem = "<a></a>" Then
RichTextBox1.Text = RichTextBox1.Text + "<a href=""""></a>"
End If
If ListBox1.SelectedItem = "<div></div>" Then
RichTextBox1.Text = RichTextBox1.Text + "<div></div>"
End If
If ListBox1.SelectedItem = "<img>" Then
RichTextBox1.Text = RichTextBox1.Text + "<img src="""">"
End If
End Sub
Private Sub ТегиToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ТегиToolStripMenuItem.Click
If ListBox1.Visible = False Then
ListBox1.Visible = True
Else
ListBox1.Visible = False
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class