Class MainWindow 
  Private familiaPre As FontFamily
  Private tamañoPre As Double

  Private Sub Window_Loaded(sender As System.Object, e As System.Windows.RoutedEventArgs)
    familiaPre = ctEditor.FontFamily
    tamañoPre = ctEditor.FontSize
  End Sub

  Private Sub ArchivoSalir_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
    Close()
  End Sub

  Private Sub OpcionesFuenteCourier_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
    ctEditor.FontFamily = New FontFamily("Courier New")
    OpcionesFuenteCourier.IsChecked = True
    OpcionesFuenteArial.IsChecked = False
    OpcionesFuentePre.IsChecked = False
  End Sub

  Private Sub OpcionesFuenteArial_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
    ctEditor.FontFamily = New FontFamily("Arial")
    OpcionesFuenteCourier.IsChecked = False
    OpcionesFuenteArial.IsChecked = True
    OpcionesFuentePre.IsChecked = False
  End Sub

  Private Sub OpcionesFuentePre_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
    ctEditor.FontFamily = familiaPre
    OpcionesFuenteCourier.IsChecked = False
    OpcionesFuenteArial.IsChecked = False
    OpcionesFuentePre.IsChecked = True
  End Sub

  Private Sub OpcionesTamaño16_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
    ctEditor.FontSize = 16.0
    OpcionesTamaño16.IsChecked = True
    OpcionesTamaño24.IsChecked = False
    OpcionesTamañoPre.IsChecked = False
  End Sub

  Private Sub OpcionesTamaño24_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
    ctEditor.FontSize = 24.0
    OpcionesTamaño16.IsChecked = False
    OpcionesTamaño24.IsChecked = True
    OpcionesTamañoPre.IsChecked = False
  End Sub

  Private Sub OpcionesTamañoPre_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
    ctEditor.FontSize = tamañoPre
    OpcionesTamaño16.IsChecked = False
    OpcionesTamaño24.IsChecked = False
    OpcionesTamañoPre.IsChecked = True
  End Sub

  Private Sub AyudaAcercaDe_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
    Dim créditos As String = "Aplicación Editor" & vbLf &
                             "Editor básico de textos" & vbLf &
                             "(c) Fco. Javier Ceballos"
    MessageBox.Show(créditos, "Acerca de")
  End Sub

  Private Sub EditarCortar_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
    ctEditor.Cut()
  End Sub

  Private Sub EditarCopiar_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
    ctEditor.Copy()
  End Sub

  Private Sub EditarPegar_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
    ctEditor.Paste()
  End Sub

  Private Sub menuEditar_Loaded(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles menuEditar.Loaded
    EditarDeshacer.IsEnabled = ctEditor.CanUndo
    EditarRehacer.IsEnabled = ctEditor.CanRedo
    EditarCortar.IsEnabled = (ctEditor.SelectedText.Length <> 0)
    EditarCopiar.IsEnabled = (ctEditor.SelectedText.Length <> 0)
    EditarPegar.IsEnabled = Clipboard.ContainsText()
  End Sub

  Private Sub BarraDeHerramientas_MouseEnter(sender As System.Object, e As System.Windows.Input.MouseEventArgs)
    btbarCortar.IsEnabled = (ctEditor.SelectedText.Length <> 0)
    btbarCopiar.IsEnabled = (ctEditor.SelectedText.Length <> 0)
    btbarPegar.IsEnabled = Clipboard.ContainsText()
  End Sub

  Private Sub EditarDeshacer_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
    ctEditor.Undo()
  End Sub

  Private Sub EditarRehacer_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
    ctEditor.Redo()
  End Sub
End Class
