Advertisement
TermSpar

phOS Text Editor (Notes)

Jan 14th, 2016
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 5.24 KB | None | 0 0
  1. Imports System.IO
  2. Public Class frmWord
  3.     Dim pressed As Integer = 1
  4.     Dim openedFile As String = ""
  5.     Private Sub SaveToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles SaveToolStripMenuItem.Click
  6.         Dim SFD As New SaveFileDialog
  7.         SFD.Title = "phOS Save .txt File"
  8.         Dim SV As String
  9.         SFD.Filter = "(*.txt)|*.txt"
  10.         If openedFile <> Nothing Then
  11.             SFD.FileName = openedFile
  12.         End If
  13.         SFD.ShowDialog()
  14.         SV = SFD.FileName
  15.         If RichTextBox1.Text <> Nothing And SV <> Nothing Then
  16.             Dim sw As New StreamWriter(SV)
  17.             sw.Write(RichTextBox1.Text)
  18.             sw.Close()
  19.             openedFile = SV
  20.             MsgBox("File saved to " & SV, MsgBoxStyle.Information, "Success")
  21.         End If
  22.     End Sub
  23.  
  24.     Private Sub ArialToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ArialToolStripMenuItem.Click
  25.         RichTextBox1.Font = New Font("Arial", 11)
  26.     End Sub
  27.  
  28.     Private Sub ImpactToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ImpactToolStripMenuItem.Click
  29.         RichTextBox1.Font = New Font("Impact", 11)
  30.     End Sub
  31.  
  32.     Private Sub LucidiaToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles LucidiaToolStripMenuItem.Click
  33.         RichTextBox1.Font = New Font("Lucida Console", 11)
  34.     End Sub
  35.  
  36.     Private Sub DefaultToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles DefaultToolStripMenuItem.Click
  37.         RichTextBox1.Font = New Font("Microsoft Sans Serif", 11)
  38.     End Sub
  39.  
  40.     Private Sub ToolStripMenuItem2_Click(sender As System.Object, e As System.EventArgs)
  41.         RichTextBox1.Font = New Font(RichTextBox1.Font, 11)
  42.     End Sub
  43.  
  44.     Private Sub MinusToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs)
  45.         RichTextBox1.Font = New Font(RichTextBox1.Font, 11)
  46.     End Sub
  47.  
  48.     Private Sub OpenToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles OpenToolStripMenuItem.Click
  49.         Dim ofd As New OpenFileDialog
  50.         ofd.Title = "phOS Open .txt File"
  51.         ofd.Filter = "(*.txt)|*.txt"
  52.         Dim fl As String
  53.         ofd.ShowDialog()
  54.         fl = ofd.FileName
  55.         If fl <> Nothing Then
  56.             Dim sr As New StreamReader(fl)
  57.             RichTextBox1.Text = sr.ReadToEnd
  58.             sr.Close()
  59.             openedFile = fl
  60.         End If
  61.     End Sub
  62.  
  63.     Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
  64.         Dim myform As frmWord = New frmWord
  65.         myform.Show()
  66.     End Sub
  67.  
  68.     Private Sub frmWord_Activated(sender As Object, e As System.EventArgs) Handles Me.Activated
  69.         frmMain.pbNotes.BackColor = Color.Gray
  70.     End Sub
  71.  
  72.     Private Sub frmWord_Deactivate(sender As Object, e As System.EventArgs) Handles Me.Deactivate
  73.         frmMain.pbNotes.BackColor = Color.LightGray
  74.     End Sub
  75.  
  76.     Private Sub frmWord_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
  77.         frmMain.pbNotes.Hide()
  78.         frmMain.PictureBox12.Enabled = True
  79.         For Each p In frmMain.picArrayNotes
  80.             If p.Location.X > frmMain.pbNotes.Location.X Then
  81.                 p.Left -= 125
  82.             ElseIf frmMain.pbNotes.Location = New Point(107, 980) Then
  83.                 p.Left -= 125
  84.             End If
  85.         Next
  86.     End Sub
  87.  
  88.     Private Sub frmWord_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  89.         chkPin.Hide()
  90.         PictureBox1.Hide()
  91.         lblDisplay.Hide()
  92.         frmMain.pbNotes.Show()
  93.     End Sub
  94.  
  95.     Private Sub WordCountToolStripMenuItem1_Click(sender As System.Object, e As System.EventArgs) Handles WordCountToolStripMenuItem1.Click
  96.         If lblDisplay.Text = Nothing Then
  97.             lblDisplay.Text = "Total Chars: 0" & vbNewLine & "Total Words: 0"
  98.         End If
  99.         pressed += 1
  100.         If ((pressed Mod 2) = 0) Then
  101.             PictureBox1.Show()
  102.             lblDisplay.Show()
  103.             chkPin.Show()
  104.         Else
  105.             PictureBox1.Hide()
  106.             lblDisplay.Hide()
  107.             chkPin.Hide()
  108.         End If
  109.     End Sub
  110.  
  111.     Private Sub RichTextBox1_Click(sender As Object, e As System.EventArgs) Handles RichTextBox1.Click
  112.         If lblDisplay.Visible = True And chkPin.Checked = False Then
  113.             pressed += 1
  114.             PictureBox1.Hide()
  115.             lblDisplay.Hide()
  116.             chkPin.Hide()
  117.         End If
  118.     End Sub
  119.  
  120.     Private Sub RichTextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles RichTextBox1.TextChanged
  121.         Dim wordCount As String
  122.         Dim counter As Integer
  123.         wordCount = RichTextBox1.Text
  124.         For Each a As Char In wordCount.Split(" ")
  125.             If RichTextBox1.Text <> Nothing Then
  126.                 counter += 1
  127.             End If
  128.         Next
  129.         Dim counter2 As Integer
  130.         For Each a In RichTextBox1.Text
  131.             If a <> " " Then
  132.                 counter2 += 1
  133.             End If
  134.         Next
  135.         lblDisplay.Text = "Total Chars: " & counter2 & vbNewLine & "Total Words: " & counter
  136.     End Sub
  137. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement