JayBeeOH

TxtEditor - Edit Menu Options

Mar 3rd, 2015
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 5.21 KB | None | 0 0
  1. '------------------------------------------------------------------------------------------
  2. '           Notice of My Copyright and Intellectual Property Rights
  3. '
  4. ' Any intellectual property contained within the program by Joseph L. Bolen remains the
  5. ' intellectual property of the Joseph L. Bolen. This means that no person may distribute,
  6. ' publish or provide such intellectual property to any other person or entity for any
  7. ' reason, commercial or otherwise, without the express written permission of Joseph L. Bolen.
  8. '
  9. '                 Copyright © 2015. All rights reserved.
  10. '        All trademarks remain the property of their respective owners.
  11. '-------------------------------------------------------------------------------------------
  12. ' Program Name:   Text Editor
  13.  
  14. ' Author:         Joseph L. Bolen
  15. ' Date Created:   Feb 2015
  16. '
  17. ' Description:    Simple plain text editor program with printing ability.
  18. '
  19. '                 Documentation is at:
  20. '                   App's screen image is at: http://imgur.com/TzWs9kO
  21. '                   App's screen design time specs at: http://pastebin.com/bhinRQ5d
  22. '                   App's Visual Basic .NET Event Procedures & TODO's is at
  23. '                       http://pastebin.com/UZ4tcEpE
  24. '                   App's Visual Basic .NET code is at http://pastebin.com/u/jaybeeoh
  25. '                   Video tutorial at YouTube: http://www.youtube.com/user/bolenpresents
  26. '-------------------------------------------------------------------------------------------
  27. Public Class MainForm
  28.  
  29. #Region " Edit Menu"
  30.  
  31. #Region " Undo / Cut / Copy / Paste / Delete"
  32.  
  33.     ' Edit Undo option.
  34.     Private Sub UndoToolStripMenuItem_Click(sender As Object, e As EventArgs) _
  35.         Handles UndoToolStripMenuItem.Click
  36.  
  37.         With MyTextBox
  38.             If .CanUndo Then
  39.                 .Undo()
  40.                 .ClearUndo()
  41.             End If
  42.         End With
  43.     End Sub
  44.  
  45.     ' Edit Cut option - Cut selected text to the Clipboard.
  46.     Private Sub CutToolStripMenuItem_Click(sender As Object, e As EventArgs) _
  47.         Handles CutToolStripMenuItem.Click,
  48.                 CutToolStripButton.Click,
  49.                 DeleteToolStripMenuItem.Click
  50.  
  51.         If MyTextBox.SelectedText <> String.Empty Then
  52.             MyTextBox.Cut()
  53.         End If
  54.     End Sub
  55.  
  56.     ' Edit Copy option - Copy the selected text to the Clipboard.
  57.     Private Sub CopyToolStripMenuItem_Click(sender As Object, e As EventArgs) _
  58.         Handles CopyToolStripMenuItem.Click,
  59.                 CopyToolStripButton.Click
  60.  
  61.         If MyTextBox.SelectionLength > 0 Then
  62.             MyTextBox.Copy()
  63.         End If
  64.     End Sub
  65.  
  66.     ' Edit Paste option - If Clipboard has text, paste to textbox.
  67.     Private Sub PasteToolStripMenuItem_Click(sender As Object, e As EventArgs) _
  68.         Handles PasteToolStripMenuItem.Click,
  69.                 PasteToolStripButton.Click
  70.  
  71.         If Clipboard.GetDataObject().GetDataPresent(DataFormats.Text) Then
  72.             If MyTextBox.SelectionLength > 0 Then
  73.                 ' Paste over currently selected text.
  74.                 If MessageBox.Show(Me, "Do you want to paste over current selection?",
  75.                                    "Paste Over Confirm",
  76.                                    MessageBoxButtons.YesNo,
  77.                                    MessageBoxIcon.Question,
  78.                                    MessageBoxDefaultButton.Button1) = DialogResult.No Then
  79.                     ' Move selection to the point after the current selection and paste.
  80.                     MyTextBox.SelectionStart = MyTextBox.SelectionStart + MyTextBox.SelectionLength
  81.                 End If
  82.             End If
  83.             ' Paste current text in Clipboard into text box.
  84.             MyTextBox.Paste()
  85.         End If
  86.     End Sub
  87.  
  88. #End Region
  89.  
  90. #Region " Find / Find Next / Replace"
  91.  
  92.     ' Edit Find option.
  93.     Private Sub FindToolStripMenuItem_Click(sender As Object, e As EventArgs) _
  94.         Handles FindToolStripMenuItem.Click
  95.  
  96.         'TODO: Code Edit Find option.
  97.         MsgBox("Code Edit Find option.")
  98.     End Sub
  99.  
  100.     ' Edit Find Next option.
  101.     Private Sub FindNextToolStripMenuItem_Click(sender As Object, e As EventArgs) _
  102.         Handles FindNextToolStripMenuItem.Click
  103.  
  104.         'TODO: Code Edit Find Next option.
  105.         MsgBox("Code Edit Find Next option.")
  106.     End Sub
  107.  
  108.     ' Edit Replace option.
  109.     Private Sub ReplaceToolStripMenuItem_Click(sender As Object, e As EventArgs) _
  110.         Handles ReplaceToolStripMenuItem.Click
  111.  
  112.         'TODO: Code Edit Replace option.
  113.         MsgBox("Code Edit Replace option.")
  114.     End Sub
  115.  
  116. #End Region
  117.  
  118. #Region " Select All / Time/Date Insert"
  119.  
  120.     ' Edit Select All option.
  121.     Private Sub SelectAllToolStripMenuItem_Click(sender As Object, e As EventArgs) _
  122.         Handles SelectAllToolStripMenuItem.Click
  123.  
  124.         MyTextBox.SelectAll()
  125.     End Sub
  126.  
  127.     ' Edit Time/Date option - Inserted time and date at cursor location option.
  128.     Private Sub TimeDateToolStripMenuItem_Click(sender As Object, e As EventArgs) _
  129.         Handles TimeDateToolStripMenuItem.Click
  130.  
  131.         MyTextBox.SelectedText = Now.ToShortTimeString & " " & Today.ToShortDateString
  132.         MyTextBox.Modified = True
  133.     End Sub
  134.  
  135. #End Region
  136.  
  137. #End Region
  138.  
  139. End Class
Advertisement
Add Comment
Please, Sign In to add comment