Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports DevComponents.DotNetBar
- Imports DevComponents.DotNetBar.Controls
- Imports NHunspell
- Imports System.Net
- Imports System.Windows.Forms
- Imports System.Text.RegularExpressions
- Imports System.ComponentModel
- Imports System.Drawing
- Imports System.Text
- Imports System.Runtime.InteropServices
- Public Class frmMain
- Inherits DevComponents.DotNetBar.Office2007Form
- #Region "Declarations"
- Dim notes As Integer = 0
- Private Declare Function LockWindowUpdate Lib "user32" (ByVal hWnd As Integer) As Integer
- Dim lineNum As Int32
- Public Word As String
- Public contentRectangle As Rectangle
- <DllImport("USER32.dll")> _
- Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As Int32
- End Function
- Private Const WM_USER As Integer = &H400
- Private Const EM_FORMATRANGE As Integer = WM_USER + 57
- <StructLayout(LayoutKind.Sequential)> _
- Private Structure RECT
- Public Left As Integer
- Public Top As Integer
- Public Right As Integer
- Public Bottom As Integer
- End Structure
- <StructLayout(LayoutKind.Sequential)> _
- Private Structure CHARRANGE
- Public cpMin As Integer
- Public cpMax As Integer
- End Structure
- <StructLayout(LayoutKind.Sequential)> _
- Private Structure FORMATRANGE
- Public hdc As IntPtr
- Public hdcTarget As IntPtr
- Public rc As RECT
- Public rcPage As RECT
- Public chrg As CHARRANGE
- End Structure
- Private Const inch As Double = 14.4
- Public ScintillaMode As Boolean
- #End Region
- #Region "Handle Form Events"
- #Region "Handle Various hotkeys"
- Private Sub frmMain_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
- If My.Computer.Keyboard.CtrlKeyDown Then
- Try
- 'These are basically all the hotkey for 1-9.
- If e.KeyCode = Keys.D1 Then
- tcMain.SelectedTabIndex = 0
- ElseIf e.KeyCode = Keys.D2 Then
- tcMain.SelectedTabIndex = 1
- ElseIf e.KeyCode = Keys.D3 Then
- tcMain.SelectedTabIndex = 2
- ElseIf e.KeyCode = Keys.D4 Then
- tcMain.SelectedTabIndex = 3
- ElseIf e.KeyCode = Keys.D5 Then
- tcMain.SelectedTabIndex = 4
- ElseIf e.KeyCode = Keys.D6 Then
- tcMain.SelectedTabIndex = 5
- ElseIf e.KeyCode = Keys.D7 Then
- tcMain.SelectedTabIndex = 6
- ElseIf e.KeyCode = Keys.D8 Then
- tcMain.SelectedTabIndex = 7
- ElseIf e.KeyCode = Keys.D9 Then
- tcMain.SelectedTabIndex = tcMain.Tabs.Count - 1
- 'CTRL + PageDown
- ElseIf e.KeyCode = Keys.PageDown Then
- tcMain.SelectedTabIndex -= 1
- ElseIf e.KeyCode = Keys.PageUp Then
- tcMain.SelectedTabIndex += 1
- End If
- Catch
- End Try
- End If
- 'CTRL + Plus
- If e.KeyCode = 187 Then
- If My.Computer.Keyboard.CtrlKeyDown = True Then btnZoomin.RaiseClick()
- End If
- 'CTRL + Minus
- If e.KeyCode = 189 Then
- If My.Computer.Keyboard.CtrlKeyDown = True Then btnZoomOut.RaiseClick()
- End If
- 'CTRL + Zero
- If e.KeyCode = 48 Then
- If My.Computer.Keyboard.CtrlKeyDown = True Then btnResetzoom.RaiseClick()
- End If
- 'Handle CTRL + Shift + > (font larger)
- If e.KeyCode = 190 Then
- If My.Computer.Keyboard.CtrlKeyDown = True AndAlso My.Computer.Keyboard.ShiftKeyDown = True Then
- Try
- e.SuppressKeyPress = True
- cbxTextSize.SelectedIndex += 1
- Catch
- End Try
- End If
- 'Handle CTRL + Shift + < (font smaller)
- ElseIf e.KeyCode = 188 Then
- If My.Computer.Keyboard.CtrlKeyDown = True AndAlso My.Computer.Keyboard.ShiftKeyDown = True Then
- Try
- e.SuppressKeyPress = True
- cbxTextSize.SelectedIndex -= 1
- Catch
- End Try
- End If
- End If
- End Sub
- #End Region
- Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
- 'Make sure TopMost is set to false, as SaveFileDialog won't show otherwise.
- Me.TopMost = False
- 'For Each Tab
- For Each tb In tcMain.Tabs
- 'If it's a normal RichTextBox
- If TypeOf (tb.AttachedControl.Controls.Item(0)) Is RTB Then
- 'If the document has been modified since last save
- If CType(tb.AttachedControl.Controls.Item(0), RTB).DocumentModified = True AndAlso CType(tb.AttachedControl.Controls.Item(0), RTB).Text <> Nothing Then
- 'Show the save prompt
- Dim dr As DialogResult = DevComponents.DotNetBar.MessageBoxEx.Show("The document: " & tb.Text & " has not been saved. Do you want to save it before closing?", "Question", MessageBoxButtons.YesNoCancel)
- 'If yes then
- If dr = Windows.Forms.DialogResult.Yes Then
- 'If we've allready saved
- If CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SavePath <> Nothing Then
- Dim sp As String = CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SavePath
- Dim strExt = System.IO.Path.GetExtension(sp)
- strExt = strExt.ToUpper()
- If strExt = ".RTF" Then
- 'If we last saved as a rtf then save as a rtf
- CType(tb.AttachedControl.Controls.Item(0), RTB).SaveDocument(sp)
- Else
- 'Otherwise save as txt
- Dim saved As New IO.StreamWriter(sp)
- saved.Write(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Text)
- saved.Flush()
- saved.Close()
- End If
- Else
- 'We haven't allready saved, so show the save dialog and perform the same procedure.
- Dim sfd As New SaveFileDialog
- sfd.Title = "Select a file to save as..."
- sfd.Filter = "Rich Text Format (*.rtf)|*.rtf|Text File (*.txt)|*.txt|All Files|"
- If sfd.ShowDialog = DialogResult.OK Then
- Dim strExt = System.IO.Path.GetExtension(sfd.FileName)
- strExt = strExt.ToUpper()
- If strExt = ".RTF" Then
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SaveDocument(sfd.FileName)
- Else
- Dim saved As New IO.StreamWriter(sfd.FileName)
- saved.Write(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Text)
- saved.Flush()
- saved.Close()
- End If
- Else
- 'User pressed cancel on the SaveFileDialog... so cancel close
- e.Cancel = True
- Exit Sub
- End If
- End If
- ElseIf dr = Windows.Forms.DialogResult.Cancel Then
- 'User pressed cancel... so cancel close
- e.Cancel = True
- Exit Sub
- End If
- End If
- Else
- 'Perform exactly the same procedure for the Scintilla based textbox, but slightly different code.
- If CType(tb.AttachedControl.Controls.Item(0), ScintillaEX).DocumentModified = True AndAlso CType(tb.AttachedControl.Controls.Item(0), ScintillaEX).Text <> Nothing Then
- Dim dr As DialogResult = DevComponents.DotNetBar.MessageBoxEx.Show("The document: " & tb.Text & " has not been saved. Do you want to save it before closing?", "Question", MessageBoxButtons.YesNoCancel)
- If dr = Windows.Forms.DialogResult.Yes Then
- If CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).SavePath <> Nothing Then
- Dim sp As String = CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).SavePath
- Dim strExt = System.IO.Path.GetExtension(sp)
- strExt = strExt.ToUpper()
- Dim saved As New IO.StreamWriter(sp)
- saved.Write(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Text)
- saved.Flush()
- saved.Close()
- Else
- Dim sfd As New SaveFileDialog
- sfd.Title = "Select a file to save as..."
- sfd.Filter = "Text File (*.txt)|*.txt|All Files|"
- If sfd.ShowDialog = DialogResult.OK Then
- Dim strExt = System.IO.Path.GetExtension(sfd.FileName)
- strExt = strExt.ToUpper()
- Dim saved As New IO.StreamWriter(sfd.FileName)
- saved.Write(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).Text)
- saved.Flush()
- saved.Close()
- Else
- e.Cancel = True
- Exit Sub
- End If
- End If
- ElseIf dr = Windows.Forms.DialogResult.Cancel Then
- e.Cancel = True
- Exit Sub
- End If
- End If
- End If
- Next
- End Sub
- Private Sub tmrDelayedLoader_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrDelayedLoader.Tick
- 'Load fonts into combobox...
- For Each itm In System.Drawing.FontFamily.Families
- Dim citm As New DevComponents.Editors.ComboItem
- If My.Settings.LoadFontStyles = True Then
- citm.FontName = itm.Name
- End If
- citm.Text = itm.Name
- cbxFonts.Items.Add(citm)
- Next
- tmrDelayedLoader.Stop()
- If ScintillaMode = False Then
- 'Load fonts assuming we're not in the scintilla textbox
- For Each itm As DevComponents.Editors.ComboItem In cbxFonts.Items
- If CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectionFont.Name = itm.Text Then
- cbxFonts.SelectedItem = itm
- End If
- Next
- Else
- 'The user is damn fast...
- End If
- End Sub
- Private Sub frmMain_Move(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Move
- 'Make sure the main bar's width is correct (bar has no anchor property for some retarded reason I have yet to find out...
- barMain.Width = Me.Width
- End Sub
- Private Sub frmMain_ResizeEnd(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.ResizeEnd
- 'Same as previous
- barMain.Size = New Size(Me.Width, barMain.Height)
- End Sub
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- 'Check whether to enable Windows Aero
- Me.EnableGlass = My.Settings.EnableAeroGlass
- 'Create a new document (normal)
- btnNew.RaiseClick()
- 'Load recent items
- btnRecent.SubItems.Clear()
- btnRecent.SubItems.Add(btnClearRecent)
- For Each itm In My.Settings.RecentDocuments
- If itm <> "None..." Then
- Dim bitm As New bitm_recent
- bitm.Text = itm
- btnRecent.SubItems.Add(bitm)
- End If
- Next
- 'Load the style for the program & the tabcontrol
- styleMain.ManagerStyle = My.Settings.StyleName
- styleMain.ManagerColorTint = My.Settings.StyleColorTint
- For Each itm In My.Settings.TabControlSettings
- If itm.ToLower.Contains("default") = False Then
- Dim value As String = itm.Substring(itm.LastIndexOf(" - ")).Replace(" - ", "")
- If itm.ToLower.StartsWith("main style for tabcontrol") Then
- If value = "square" Then
- tcMain.Style = eTabStripStyle.Office2007Document
- ElseIf value = "rounded" Then
- tcMain.Style = eTabStripStyle.Office2007Document
- ElseIf value = "plain" Then
- tcMain.Style = eTabStripStyle.SimulatedTheme
- End If
- ElseIf itm.ToLower.StartsWith("tab bar color 1") Then
- tcMain.ColorScheme.TabBackground = Color.FromName(value)
- ElseIf itm.ToLower.StartsWith("tab bar color 2") Then
- tcMain.ColorScheme.TabBackground2 = Color.FromName(value)
- ElseIf itm.ToLower.StartsWith("tab bar color gradient") Then
- tcMain.ColorScheme.TabBackgroundGradientAngle = value
- ElseIf itm.ToLower.StartsWith("tab item background 1") Then
- tcMain.ColorScheme.TabItemBackground = Color.FromName(value)
- ElseIf itm.ToLower.StartsWith("tab item background 2") Then
- tcMain.ColorScheme.TabItemBackground2 = Color.FromName(value)
- ElseIf itm.ToLower.StartsWith("tab item background gradient") Then
- tcMain.ColorScheme.TabItemBackgroundGradientAngle = value
- ElseIf itm.ToLower.StartsWith("selected border color") Then
- tcMain.ColorScheme.TabItemSelectedBorder = Color.FromName(value)
- ElseIf itm.ToLower.StartsWith("selected tab item background 1") Then
- tcMain.ColorScheme.TabItemSelectedBackground = Color.FromName(value)
- ElseIf itm.ToLower.StartsWith("selected tab item background 2") Then
- tcMain.ColorScheme.TabItemSelectedBackground2 = Color.FromName(value)
- ElseIf itm.ToLower.StartsWith("selected tab item background gradient") Then
- tcMain.ColorScheme.TabItemSelectedBackgroundGradientAngle = value
- ElseIf itm.ToLower.StartsWith("tab orientation") Then
- If value = "top" Then
- tcMain.TabAlignment = eTabStripAlignment.Top
- ElseIf value = "bottom" Then
- tcMain.TabAlignment = eTabStripAlignment.Bottom
- ElseIf value = "left" Then
- tcMain.TabAlignment = eTabStripAlignment.Left
- ElseIf value = "right" Then
- tcMain.TabAlignment = eTabStripAlignment.Right
- End If
- Else
- '????
- 'Proffit
- End If
- End If
- Next
- End Sub
- #End Region
- #Region "File Menu"
- Private Sub btnCloseDocument_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCloseDocument.Click
- 'If the tab count is 1 then cancel...
- If tcMain.Tabs.Count = 1 Then
- Exit Sub
- End If
- 'Perform the same prcedure of
- If TypeOf (tcMain.SelectedTab.AttachedControl.Controls.Item(0)) Is RTB Then
- If CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).DocumentModified = True AndAlso CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Text <> Nothing Then
- Dim dr As DialogResult = DevComponents.DotNetBar.MessageBoxEx.Show("The selected document has not been saved. Do you want to save it before closing?", "Question", MessageBoxButtons.YesNoCancel)
- If dr = Windows.Forms.DialogResult.Yes Then
- If CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SavePath <> Nothing Then
- Dim sp As String = CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SavePath
- Dim strExt = System.IO.Path.GetExtension(sp)
- strExt = strExt.ToUpper()
- If strExt = ".RTF" Then
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SaveDocument(sp)
- Else
- Dim saved As New IO.StreamWriter(sp)
- saved.Write(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Text)
- saved.Flush()
- saved.Close()
- End If
- Else
- Dim sfd As New SaveFileDialog
- sfd.Title = "Select a file to save as..."
- sfd.Filter = "Rich Text Format (*.rtf)|*.rtf|Text File (*.txt)|*.txt|All Files|"
- If sfd.ShowDialog = DialogResult.OK Then
- Dim strExt = System.IO.Path.GetExtension(sfd.FileName)
- strExt = strExt.ToUpper()
- If strExt = ".RTF" Then
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SaveDocument(sfd.FileName)
- Else
- Dim saved As New IO.StreamWriter(sfd.FileName)
- saved.Write(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Text)
- saved.Flush()
- saved.Close()
- End If
- Else
- Exit Sub
- End If
- End If
- ElseIf dr = Windows.Forms.DialogResult.Cancel Then
- Exit Sub
- End If
- End If
- Else
- If CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).DocumentModified = True AndAlso CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).Text <> Nothing Then
- Dim dr As DialogResult = DevComponents.DotNetBar.MessageBoxEx.Show("The selected document has not been saved. Do you want to save it before closing?", "Question", MessageBoxButtons.YesNoCancel)
- If dr = Windows.Forms.DialogResult.Yes Then
- If CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).SavePath <> Nothing Then
- Dim sp As String = CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).SavePath
- Dim strExt = System.IO.Path.GetExtension(sp)
- strExt = strExt.ToUpper()
- Dim saved As New IO.StreamWriter(sp)
- saved.Write(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Text)
- saved.Flush()
- saved.Close()
- Else
- Dim sfd As New SaveFileDialog
- sfd.Title = "Select a file to save as..."
- sfd.Filter = "Text File (*.txt)|*.txt|All Files|"
- If sfd.ShowDialog = DialogResult.OK Then
- Dim strExt = System.IO.Path.GetExtension(sfd.FileName)
- strExt = strExt.ToUpper()
- Dim saved As New IO.StreamWriter(sfd.FileName)
- saved.Write(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).Text)
- saved.Flush()
- saved.Close()
- End If
- End If
- ElseIf dr = Windows.Forms.DialogResult.Cancel Then
- Exit Sub
- End If
- End If
- End If
- tcMain.Tabs.Remove(tcMain.SelectedTab)
- End Sub
- Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
- Me.Close()
- End Sub
- Private Sub btnAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAbout.Click
- frmAbout.ShowDialog()
- End Sub
- Dim asked As Boolean
- Private Sub ButtonItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
- If asked = False Then
- If notes > 50 Then
- If DevComponents.DotNetBar.MessageBoxEx.Show("Stuff could get laggy if you have more than 50 notes. Continue? (you'll only need to answer once)", "Question", MessageBoxButtons.YesNo) <> DialogResult.Yes Then
- Exit Sub
- Else
- asked = True
- End If
- End If
- End If
- notes += 1
- Dim tb As DevComponents.DotNetBar.TabItem = tcMain.CreateTab("")
- tb.Text = "New note - " & notes.ToString
- Dim myrtb As New RTB
- myrtb.Dock = DockStyle.Fill
- myrtb.Font = New Font(myrtb.Font.Name, 12)
- myrtb.DocumentModified = False
- tb.AttachedControl.Controls.Add(myrtb)
- tcMain.SelectedTab = tb
- myrtb.Select()
- End Sub
- Private Sub ButtonItem4_Click_2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClearRecent.Click
- My.Settings.RecentDocuments.Clear()
- End Sub
- Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
- Dim ofd As New OpenFileDialog
- ofd.Filter = "Rich Text Format (*.rtf)|*.rtf|Text File (*.txt)|*.txt|All Files|"
- ofd.Title = "Select file to open..."
- If ofd.ShowDialog() = DialogResult.OK Then
- Dim tb As DevComponents.DotNetBar.TabItem = tcMain.CreateTab("")
- tb.Text = ofd.SafeFileName
- Dim myrtb As New RTB
- myrtb.Dock = DockStyle.Fill
- myrtb.Font = New Font(myrtb.Font.Name, 12)
- Try
- myrtb.LoadFile(ofd.FileName)
- Catch
- Dim loadf As New IO.StreamReader(ofd.FileName)
- myrtb.Text = loadf.ReadToEnd
- loadf.Close()
- End Try
- myrtb.SavePath = ofd.FileName
- myrtb.DocumentModified = False
- tb.AttachedControl.Controls.Add(myrtb)
- tcMain.SelectedTab = tb
- myrtb.Select()
- End If
- End Sub
- Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
- If TypeOf (tcMain.SelectedTab.AttachedControl.Controls.Item(0)) Is RTB Then
- If CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SavePath <> Nothing Then
- Dim strExt = System.IO.Path.GetExtension(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SavePath)
- strExt = strExt.ToUpper()
- If strExt = ".RTF" Then
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SaveDocument(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SavePath)
- Else
- Dim saved As New IO.StreamWriter(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SavePath)
- saved.Write(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Text)
- saved.Flush()
- saved.Close()
- End If
- Dim found As Boolean = False
- For Each itm In My.Settings.RecentDocuments
- If CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SavePath = itm Then
- found = True
- End If
- Next
- If found = False Then
- My.Settings.RecentDocuments.Add(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SavePath)
- My.Settings.Save()
- End If
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).DocumentModified = False
- Else
- Dim sfd As New SaveFileDialog
- sfd.Title = "Select a file to save as..."
- sfd.Filter = "Rich Text Format (*.rtf)|*.rtf|Text File (*.txt)|*.txt|All Files|"
- If sfd.ShowDialog = DialogResult.OK Then
- Dim strExt = System.IO.Path.GetExtension(sfd.FileName)
- strExt = strExt.ToUpper()
- If strExt = ".RTF" Then
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SaveDocument(sfd.FileName)
- Else
- Dim saved As New IO.StreamWriter(sfd.FileName)
- saved.Write(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Text)
- saved.Flush()
- saved.Close()
- End If
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).DocumentModified = False
- Dim found As Boolean = False
- For Each itm In My.Settings.RecentDocuments
- If sfd.FileName = itm Then
- found = True
- End If
- Next
- If found = False Then
- My.Settings.RecentDocuments.Add(sfd.FileName)
- My.Settings.Save()
- End If
- End If
- End If
- Else
- If CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).SavePath <> Nothing Then
- Dim saved As New IO.StreamWriter(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).SavePath)
- saved.Write(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).Text)
- saved.Flush()
- saved.Close()
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).DocumentModified = False
- Dim found As Boolean = False
- For Each itm In My.Settings.RecentDocuments
- If CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).SavePath = itm Then
- found = True
- End If
- Next
- If found = False Then
- My.Settings.RecentDocuments.Add(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).SavePath)
- My.Settings.Save()
- End If
- Else
- Dim sfd As New SaveFileDialog
- sfd.Title = "Select a file to save as..."
- sfd.Filter = "Text File (*.txt)|*.txt|All Files|"
- If sfd.ShowDialog = DialogResult.OK Then
- Dim strExt = System.IO.Path.GetExtension(sfd.FileName)
- strExt = strExt.ToUpper()
- Dim saved As New IO.StreamWriter(sfd.FileName)
- saved.Write(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).Text)
- saved.Flush()
- saved.Close()
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).DocumentModified = False
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).SavePath = sfd.FileName
- Dim found As Boolean = False
- For Each itm In My.Settings.RecentDocuments
- If sfd.FileName = itm Then
- found = True
- End If
- Next
- If found = False Then
- My.Settings.RecentDocuments.Add(sfd.FileName)
- My.Settings.Save()
- End If
- End If
- End If
- End If
- btnRecent.SubItems.Clear()
- btnRecent.SubItems.Add(btnClearRecent)
- For Each itm In My.Settings.RecentDocuments
- If itm <> "None..." Then
- Dim bitm As New bitm_recent
- bitm.Text = itm
- btnRecent.SubItems.Add(bitm)
- End If
- Next
- End Sub
- Private Sub btnSaveAs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveAs.Click
- If TypeOf (tcMain.SelectedTab.AttachedControl.Controls.Item(0)) Is RTB Then
- Dim sfd As New SaveFileDialog
- sfd.Title = "Select a file to save as..."
- sfd.Filter = "Rich Text Format (*.rtf)|*.rtf|Text File (*.txt)|*.txt|All Files|"
- If sfd.ShowDialog = DialogResult.OK Then
- Dim strExt = System.IO.Path.GetExtension(sfd.FileName)
- strExt = strExt.ToUpper()
- If strExt = ".RTF" Then
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SaveDocument(sfd.FileName)
- Else
- Dim saved As New IO.StreamWriter(sfd.FileName)
- saved.Write(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Text)
- saved.Flush()
- saved.Close()
- End If
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).DocumentModified = False
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SavePath = sfd.FileName
- Dim found As Boolean = False
- For Each itm In My.Settings.RecentDocuments
- If sfd.FileName = itm Then
- found = True
- End If
- Next
- If found = False Then
- My.Settings.RecentDocuments.Add(sfd.FileName)
- My.Settings.Save()
- End If
- End If
- btnRecent.SubItems.Clear()
- btnRecent.SubItems.Add(btnClearRecent)
- For Each itm In My.Settings.RecentDocuments
- If itm <> "None..." Then
- Dim bitm As New bitm_recent
- bitm.Text = itm
- btnRecent.SubItems.Add(bitm)
- End If
- Next
- Else
- Dim sfd As New SaveFileDialog
- sfd.Title = "Select a file to save as..."
- sfd.Filter = "Text File (*.txt)|*.txt|All Files|"
- If sfd.ShowDialog = DialogResult.OK Then
- Dim strExt = System.IO.Path.GetExtension(sfd.FileName)
- strExt = strExt.ToUpper()
- Dim saved As New IO.StreamWriter(sfd.FileName)
- saved.Write(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).Text)
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).DocumentModified = False
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).SavePath = sfd.FileName
- saved.Flush()
- saved.Close()
- Dim found As Boolean = False
- For Each itm In My.Settings.RecentDocuments
- If sfd.FileName = itm Then
- found = True
- End If
- Next
- If found = False Then
- My.Settings.RecentDocuments.Add(sfd.FileName)
- My.Settings.Save()
- End If
- End If
- btnRecent.SubItems.Clear()
- btnRecent.SubItems.Add(btnClearRecent)
- For Each itm In My.Settings.RecentDocuments
- If itm <> "None..." Then
- Dim bitm As New bitm_recent
- bitm.Text = itm
- btnRecent.SubItems.Add(bitm)
- End If
- Next
- End If
- End Sub
- #End Region
- #Region "Edit Menu"
- Private Sub btnGoTo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGoTo.Click
- If ScintillaMode Then
- Dim ib As String = Microsoft.VisualBasic.Interaction.InputBox("Please enter line number...", "Enter Line Number...", 0)
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).GoTo.Line(ib)
- Else
- Try
- Dim ib As String = Microsoft.VisualBasic.Interaction.InputBox("Please enter line number...", "Enter Line Number...", 0)
- With CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB)
- Dim LineInfo As Integer = Convert.ToInt32(ib)
- Dim index As Integer = 0
- Dim total As Integer = 0
- For Each lineStr As String In .Lines
- If index = LineInfo Then
- Exit For
- End If
- total += lineStr.Length
- index += 1
- Next
- .SelectionStart = total
- .Focus()
- .ScrollToCaret()
- End With
- Catch
- 'User cancelled or nothing in textbox, either way we ignore it and dont annoy user about it
- End Try
- End If
- End Sub
- Private Sub btnUndo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUndo.Click
- If ScintillaMode = True Then
- If CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).UndoRedo.CanUndo = True Then
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).UndoRedo.Undo()
- End If
- ElseIf CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).CanUndo = True Then
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Undo()
- End If
- End Sub
- Private Sub btnRedo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRedo.Click
- If ScintillaMode = True Then
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).UndoRedo.Redo()
- Else
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Redo()
- End If
- End Sub
- Private Sub btnSelectAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelectAll.Click
- If ScintillaMode = True Then
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).Selection.SelectAll()
- Else
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectAll()
- End If
- End Sub
- Private Sub btnCut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCut.Click
- If ScintillaMode = True Then
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).Clipboard.Cut()
- Else
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Cut()
- End If
- End Sub
- Private Sub btnPaste_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPaste.Click
- If ScintillaMode = True Then
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).Clipboard.Paste()
- Else
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Paste()
- End If
- End Sub
- Private Sub btnCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCopy.Click
- If ScintillaMode = True Then
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).Clipboard.Copy()
- Else
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Copy()
- End If
- End Sub
- Private Sub btnReplace_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReplace.Click
- If ScintillaMode = True Then
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).FindReplace.ShowReplace()
- Else
- frmFindReplace.Show()
- frmFindReplace.tcMain.SelectedTab = frmFindReplace.tbReplace
- End If
- End Sub
- Private Sub btnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFind.Click
- If ScintillaMode = True Then
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).FindReplace.ShowFind()
- Else
- frmFindReplace.Show()
- frmFindReplace.tcMain.SelectedTab = frmFindReplace.tbfind
- End If
- End Sub
- #End Region
- #Region "Insert Menu"
- Private Sub btnClipart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClipart.Click
- frmClipArt.Show()
- End Sub
- Private Sub ButtonItem1_Click_4(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsertSymbol.Click
- frmInsertSymbol.Show()
- End Sub
- Private Sub btnImageFromFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImageFromFile.Click
- Dim ofd As New OpenFileDialog
- ofd.Title = "Select image to add..."
- ofd.Filter = "Image Files|*.bmp;*.jpg;*.png;*.gif"
- If ofd.ShowDialog = DialogResult.OK Then
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).InsertImage(ofd.FileName)
- End If
- End Sub
- Private Sub btnWordArt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWordArt.Click
- frmWordArt.ShowDialog()
- End Sub
- Private Sub tmrPasteImage_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrPasteImage.Tick
- tmrPasteImage.Stop()
- Me.BringToFront()
- Me.BringToFront()
- Me.BringToFront()
- Me.BringToFront()
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Focus()
- SendKeys.Send("^v")
- End Sub
- Private Sub ButtonItem1_Click_5(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsertTime.Click
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Text &= Date.Now.ToString
- End Sub
- #End Region
- #Region "Tools Menu"
- Private Sub btnDocumentViewer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDocumentViewer.Click
- frmDocumentViewer.Show()
- End Sub
- Private Sub btnLoadWebCode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadWebCode.Click
- Try
- Dim ib As String = Interaction.InputBox("Please enter the URL of the website", "Website URL", "http://www.google.co.uk")
- Dim wc As New WebClient
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Text = wc.DownloadString(ib)
- Catch ex As Exception
- MessageBoxEx.Show("An error occured: " & ex.Message, "Error")
- End Try
- End Sub
- Private Sub btnOptions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOptions.Click
- frmOptions.ShowDialog()
- End Sub
- Private Sub btnDocumentToImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDocumentToImage.Click
- Dim sfd As New SaveFileDialog
- sfd.Filter = "JPEG Images|*.jpg"
- sfd.Title = "Save as..."
- If sfd.ShowDialog = DialogResult.OK Then
- With CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB)
- Dim wid As Integer = .Width
- Dim hgt As Integer = .Height
- Dim bm As New Bitmap(wid, hgt)
- .DrawToBitmap(bm, New Rectangle(0, 0, wid, hgt))
- RtbToBitmap(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB), contentRectangle, sfd.FileName)
- End With
- End If
- End Sub
- Private Sub RtbToBitmap(ByVal rtb As RichTextBox, ByVal rectangle As Rectangle, ByVal fileName As String)
- Dim bmp As New Bitmap(rectangle.Width, rectangle.Height)
- Using gr As Graphics = Graphics.FromImage(bmp)
- Dim hDC As IntPtr = gr.GetHdc()
- Dim fmtRange As FORMATRANGE
- Dim rect As RECT
- Dim fromAPI As Integer
- rect.Top = 0
- rect.Left = 0
- rect.Bottom = CInt(Math.Truncate(bmp.Height + (bmp.Height * (bmp.HorizontalResolution / 100)) * inch))
- rect.Right = CInt(Math.Truncate(bmp.Width + (bmp.Width * (bmp.VerticalResolution / 100)) * inch))
- fmtRange.chrg.cpMin = 0
- fmtRange.chrg.cpMax = -1
- fmtRange.hdc = hDC
- fmtRange.hdcTarget = hDC
- fmtRange.rc = rect
- fmtRange.rcPage = rect
- Dim wParam As Integer = 1
- Dim lParam As IntPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(fmtRange))
- Marshal.StructureToPtr(fmtRange, lParam, False)
- fromAPI = SendMessage(rtb.Handle, EM_FORMATRANGE, wParam, lParam)
- Marshal.FreeCoTaskMem(lParam)
- fromAPI = SendMessage(rtb.Handle, EM_FORMATRANGE, wParam, New IntPtr(0))
- gr.ReleaseHdc(hDC)
- End Using
- bmp.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg)
- bmp.Dispose()
- End Sub
- #End Region
- #Region "View Menu"
- 'Syntax Highlghting
- Dim PrevStyle As Color
- 'Zooming
- Private Sub btnZoomin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnZoomin.Click
- On Error Resume Next
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).ZoomFactor += 0.5
- End Sub
- Private Sub btnResetzoom_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnResetzoom.Click
- On Error Resume Next
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).ZoomFactor = 1
- End Sub
- Private Sub btnZoomOut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnZoomOut.Click
- On Error Resume Next
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).ZoomFactor -= 0.5
- End Sub
- 'End of Zooming
- 'Topmost or not...
- Private Sub btnTopMost_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTopMost.Click
- Me.TopMost = btnTopMost.Checked
- End Sub
- #End Region
- #Region "Handle tab changing & closing"
- Private Sub tcMain_SelectedTabChanged(ByVal sender As Object, ByVal e As DevComponents.DotNetBar.TabStripTabChangedEventArgs) Handles tcMain.SelectedTabChanged
- Dim x = e.NewTab.AttachedControl.Controls.Item(0)
- If TypeOf x Is RTB Then
- ScintillaMode = False
- btnZoom.Visible = True
- btnWordWrap.Visible = True
- btnInsert.Visible = True
- btnLeftAlign.Visible = True
- btnAlignCenter.Visible = True
- btnRightAlign.Visible = True
- btnJustifyAlign.Visible = True
- btnBold.Visible = True
- btnItalic.Visible = True
- btnUnderined.Visible = True
- btnStrikeOut.Visible = True
- btnUpperLowerCase.Visible = True
- btnBulletedList.Visible = True
- btnNumberedList.Visible = True
- btnIncreaseIndent.Visible = True
- btnDecreaseIndent.Visible = True
- btnSuperScript.Visible = True
- btnSubscript.Visible = True
- btnSpellCheck.Visible = True
- cbxFonts.Visible = True
- cbxTextSize.Visible = True
- btnDivider1.Visible = True
- btnDivider2.Visible = True
- btnDivider3.Visible = True
- btnDivider4.Visible = True
- btnDocumentToImage.Visible = True
- btnBrowserTest.Visible = False
- btnSyntaxHighlighting.Visible = False
- Else
- btnBrowserTest.Visible = True
- ScintillaMode = True
- btnZoom.Visible = False
- btnWordWrap.Visible = False
- btnInsert.Visible = False
- btnLeftAlign.Visible = False
- btnAlignCenter.Visible = False
- btnRightAlign.Visible = False
- btnJustifyAlign.Visible = False
- btnBold.Visible = False
- btnItalic.Visible = False
- btnUnderined.Visible = False
- btnStrikeOut.Visible = False
- btnUpperLowerCase.Visible = False
- btnBulletedList.Visible = False
- btnNumberedList.Visible = False
- btnIncreaseIndent.Visible = False
- btnDecreaseIndent.Visible = False
- btnSuperScript.Visible = False
- btnSubscript.Visible = False
- btnSpellCheck.Visible = False
- cbxFonts.Visible = False
- cbxTextSize.Visible = False
- btnDivider1.Visible = False
- btnDivider2.Visible = False
- btnDivider3.Visible = False
- btnDivider4.Visible = False
- btnDocumentToImage.Visible = False
- btnBrowserTest.Visible = True
- btnSyntaxHighlighting.Visible = True
- End If
- Try
- e.NewTab.AttachedControl.Controls.Item(0).Focus()
- tmrUpdateSize.Start()
- Catch
- 'Some retarded exception.
- End Try
- End Sub
- Private Sub tcMain_TabItemClose(ByVal sender As Object, ByVal e As DevComponents.DotNetBar.TabStripActionEventArgs) Handles tcMain.TabItemClose
- If tcMain.Tabs.Count = 1 Then
- Exit Sub
- End If
- If CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).DocumentModified = True AndAlso CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Text <> Nothing Then
- Dim dr As DialogResult = DevComponents.DotNetBar.MessageBoxEx.Show("The selected document has not been saved. Do you want to save it before closing?", "Question", MessageBoxButtons.YesNoCancel)
- If dr = Windows.Forms.DialogResult.Yes Then
- If CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SavePath <> Nothing Then
- Dim sp As String = CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SavePath
- Dim strExt = System.IO.Path.GetExtension(sp)
- strExt = strExt.ToUpper()
- If strExt = ".RTF" Then
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SaveDocument(sp)
- Else
- Dim saved As New IO.StreamWriter(sp)
- saved.Write(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Text)
- saved.Flush()
- saved.Close()
- End If
- Else
- Dim sfd As New SaveFileDialog
- sfd.Title = "Select a file to save as..."
- sfd.Filter = "Rich Text Format (*.rtf)|*.rtf|Text File (*.txt)|*.txt|All Files|"
- If sfd.ShowDialog = DialogResult.OK Then
- Dim strExt = System.IO.Path.GetExtension(sfd.FileName)
- strExt = strExt.ToUpper()
- If strExt = ".RTF" Then
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SaveDocument(sfd.FileName)
- Else
- Dim saved As New IO.StreamWriter(sfd.FileName)
- saved.Write(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Text)
- saved.Flush()
- saved.Close()
- End If
- Else
- Exit Sub
- End If
- End If
- ElseIf dr = Windows.Forms.DialogResult.Cancel Then
- Exit Sub
- End If
- End If
- tcMain.Tabs.Remove(tcMain.SelectedTab)
- End Sub
- #End Region
- #Region "Handle text Superscript & Subscript"
- Dim oldfont As Font
- Private Sub btnSuperScript_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSuperScript.Click
- Try
- With CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB)
- If .SelectionCharOffset = 8 Then
- .SelectionCharOffset = 0
- .SelectionFont = oldfont
- btnSubscript.Enabled = True
- Else
- btnSubscript.Enabled = False
- .SelectionCharOffset = 8
- oldfont = .SelectionFont
- .SelectionFont = New Font(.SelectionFont.Name, 8)
- End If
- End With
- Catch
- End Try
- End Sub
- Private Sub btnSubscript_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubscript.Click
- With CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB)
- If .SelectionCharOffset = -8 Then
- .SelectionCharOffset = 0
- .SelectionFont = oldfont
- btnSuperScript.Enabled = True
- Else
- btnSuperScript.Enabled = False
- .SelectionCharOffset = -8
- oldfont = .SelectionFont
- .SelectionFont = New Font(.SelectionFont.Name, 8)
- End If
- End With
- End Sub
- #End Region
- #Region "Handle text size"
- Private Sub cbxTextSize_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbxTextSize.SelectedIndexChanged
- On Error Resume Next
- With CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB)
- Dim sz As Single = cbxTextSize.SelectedItem.ToString
- .SelectionFont = New Font(.SelectionFont.Name, sz, .SelectionFont.Style)
- End With
- End Sub
- Private Sub cbxFonts_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbxFonts.SelectedIndexChanged
- On Error Resume Next
- With CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB)
- .SelectionFont = New Font(cbxFonts.SelectedItem.ToString, .SelectionFont.Size, .SelectionFont.Style)
- End With
- End Sub
- #End Region
- #Region "Handle text alignment"
- Private Sub btnLeftAlign_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLeftAlign.Click
- With CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB)
- .SelectionAlignment = ExtendedRichTextBox.RichTextAlign.Left
- End With
- btnAlignCenter.Checked = False
- btnRightAlign.Checked = False
- btnJustifyAlign.Checked = False
- End Sub
- Private Sub btnAlignCenter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAlignCenter.Click
- With CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB)
- .SelectionAlignment = ExtendedRichTextBox.RichTextAlign.Center
- End With
- btnRightAlign.Checked = False
- btnLeftAlign.Checked = False
- btnJustifyAlign.Checked = False
- End Sub
- Private Sub btnRightAlign_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRightAlign.Click
- With CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB)
- .SelectionAlignment = ExtendedRichTextBox.RichTextAlign.Right
- End With
- btnAlignCenter.Checked = False
- btnLeftAlign.Checked = False
- btnJustifyAlign.Checked = False
- End Sub
- Private Sub btnJustifyAlign_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnJustifyAlign.Click
- With CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB)
- .SelectionAlignment = ExtendedRichTextBox.RichTextAlign.Justify
- End With
- btnAlignCenter.Checked = False
- btnLeftAlign.Checked = False
- btnRightAlign.Checked = False
- End Sub
- #End Region
- #Region "Handle Text Bold, Underlined, Italic, Strikeout"
- Private Sub btnBold_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBold.Click
- On Error Resume Next
- With CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB)
- Dim ExistingFont As Font = .SelectionFont
- Dim NewFontStyle As New FontStyle
- With ExistingFont
- NewFontStyle = -((Not .Bold) * FontStyle.Bold)
- NewFontStyle += -(.Italic * FontStyle.Italic)
- NewFontStyle += -(.Underline * FontStyle.Underline)
- NewFontStyle += -(.Strikeout * FontStyle.Strikeout)
- End With
- .SelectionFont = New Font(ExistingFont, NewFontStyle)
- End With
- End Sub
- Private Sub btnItalic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnItalic.Click
- On Error Resume Next
- With CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB)
- Dim ExistingFont As Font = .SelectionFont
- Dim NewFontStyle As New FontStyle
- With ExistingFont
- NewFontStyle = -((Not .Italic) * FontStyle.Italic)
- NewFontStyle += -(.Underline * FontStyle.Underline)
- NewFontStyle += -(.Bold * FontStyle.Bold)
- NewFontStyle += -(.Strikeout * FontStyle.Strikeout)
- End With
- .SelectionFont = New Font(ExistingFont, NewFontStyle)
- End With
- End Sub
- Private Sub btnUnderined_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUnderined.Click
- On Error Resume Next
- With CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB)
- Dim ExistingFont As Font = .SelectionFont
- Dim NewFontStyle As New FontStyle
- With ExistingFont
- NewFontStyle = -((Not .Underline) * FontStyle.Underline)
- NewFontStyle += -(.Italic * FontStyle.Italic)
- NewFontStyle += -(.Bold * FontStyle.Bold)
- NewFontStyle += -(.Strikeout * FontStyle.Strikeout)
- End With
- .SelectionFont = New Font(ExistingFont, NewFontStyle)
- End With
- End Sub
- Private Sub ButtonItem4_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStrikeOut.Click
- On Error Resume Next
- With CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB)
- Dim ExistingFont As Font = .SelectionFont
- Dim NewFontStyle As New FontStyle
- With ExistingFont
- NewFontStyle = -((Not .Strikeout) * FontStyle.Strikeout)
- NewFontStyle += -(.Underline * FontStyle.Underline)
- NewFontStyle += -(.Bold * FontStyle.Bold)
- NewFontStyle += -(.Italic * FontStyle.Italic)
- End With
- .SelectionFont = New Font(ExistingFont, NewFontStyle)
- End With
- End Sub
- #End Region
- #Region "Handle Text Increase & Decrease Indent"
- Private Sub ButtonItem1_Click_2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIncreaseIndent.Click
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectionIndent += 30
- End Sub
- Private Sub btnDecreaseIndent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDecreaseIndent.Click
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectionIndent -= 30
- End Sub
- #End Region
- #Region "Handle text Case Changing"
- Private Sub ButtonItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpperCase.Click
- On Error Resume Next
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectedText = CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectedText.ToUpper
- End Sub
- Private Sub btnLowerCase_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLowerCase.Click
- On Error Resume Next
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectedText = CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectedText.ToLower
- End Sub
- Private Sub btnToggleCase_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnToggleCase.Click
- On Error Resume Next
- Dim invertedtext As String = Nothing
- Dim sttext As String = CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectedText
- For Each cr In CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectedText
- Dim str As String = cr.ToString
- If str.ToLower = str Then
- str = str.ToUpper
- Else
- str = str.ToLower
- End If
- invertedtext &= str
- Next
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectedText = invertedtext
- End Sub
- Private Sub btnSentenceCase_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSentenceCase.Click
- On Error Resume Next
- Dim SentenceCaseText As String = Nothing
- Dim CapNextString As Boolean = False
- Dim sttext As String = CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectedText
- For Each cr In CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectedText
- Dim str As String = cr.ToString
- If CapNextString = True Then
- If str <> " " Then
- str = str.ToUpper
- CapNextString = False
- End If
- Else
- str = str.ToLower
- End If
- If str = "." Then
- CapNextString = True
- End If
- SentenceCaseText &= str
- Next
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectedText = SentenceCaseText
- End Sub
- Private Sub btnCapitalEachWord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCapitalEachWord.Click
- On Error Resume Next
- Dim EachWordCapped As String = Nothing
- Dim CapNextString As Boolean = False
- Dim FirsstLetter As Boolean = True
- Dim sttext As String = CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectedText
- For Each cr In CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectedText
- Dim str As String = cr.ToString
- If sttext = CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Text Then
- If FirsstLetter = True Then
- FirsstLetter = False
- str = str.ToUpper
- End If
- End If
- If CapNextString = True Then
- str = str.ToUpper
- CapNextString = False
- Else
- str = str.ToLower
- End If
- If str = " " Then
- CapNextString = True
- End If
- EachWordCapped &= str
- Next
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectedText = EachWordCapped
- End Sub
- #End Region
- #Region "Handle Other Text Toolbar commands: Bulleted List, Spell Check, Indent"
- Private Sub btnWordCount_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWordCount.Click
- If ScintillaMode Then
- Dim collection As MatchCollection = Regex.Matches(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).Text, "\S+")
- Dim wordcount = "Words: " & collection.Count.ToString
- Dim charsnospaces As String = "Charactors (no spaces): " & CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).Text.Replace(" ", "").Length
- DevComponents.DotNetBar.MessageBoxEx.Show(wordcount & Environment.NewLine & "Charactors: " & CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).Text.Length & Environment.NewLine & charsnospaces)
- Else
- Dim collection As MatchCollection = Regex.Matches(CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Text, "\S+")
- Dim wordcount = "Words: " & collection.Count.ToString
- Dim charsnospaces As String = "Charactors (no spaces): " & CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Text.Replace(" ", "").Length
- DevComponents.DotNetBar.MessageBoxEx.Show(wordcount & Environment.NewLine & "Charactors: " & CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).Text.Length & Environment.NewLine & charsnospaces)
- End If
- End Sub
- #Region "Bulleted Lists"
- Private Sub btnBulletedList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBulletedList.Click
- For Each ctrl In gcBullets.SubItems
- If TypeOf ctrl Is ButtonItem Then
- ctrl.Checked = False
- End If
- Next
- btnNumberedList.Checked = False
- btnNoBullets.Checked = False
- If btnBulletedList.Checked = True Then
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectionBullet = True
- Else
- btnNoBullets.Checked = True
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectionBullet = False
- End If
- End Sub
- Private Sub btnNumberedList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNumberedList.Click
- For Each ctrl In gcBullets.SubItems
- If TypeOf ctrl Is ButtonItem Then
- ctrl.Checked = False
- End If
- Next
- btnBulletedList.Checked = False
- If Me.btnNumberedList.Checked Then
- Me.btnNumberedList.Checked = False
- btnNoBullets.Checked = True
- Dim pls As New ExtendedRichTextBox.ParaListStyle()
- pls.Type = ExtendedRichTextBox.ParaListStyle.ListType.None
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectionListType = pls
- Else
- Me.btnNumberedList.Checked = True
- Dim pls As New ExtendedRichTextBox.ParaListStyle()
- pls.Type = ExtendedRichTextBox.ParaListStyle.ListType.Numbers
- pls.Style = ExtendedRichTextBox.ParaListStyle.ListStyle.NumberAndPeriod
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectionListType = pls
- End If
- End Sub
- Private Sub btnNoBullets_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNoBullets.Click
- For Each ctrl In gcBullets.SubItems
- If TypeOf ctrl Is ButtonItem Then
- ctrl.Checked = False
- End If
- Next
- btnBulletedList.Checked = False
- Me.btnNoBullets.Checked = True
- btnNumberedList.Checked = False
- Dim pls As New ExtendedRichTextBox.ParaListStyle()
- pls.Type = ExtendedRichTextBox.ParaListStyle.ListType.None
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectionListType = pls
- End Sub
- Private Sub btnLettersUCaseDots_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLettersUCaseDots.Click
- For Each ctrl In gcBullets.SubItems
- If TypeOf ctrl Is ButtonItem Then
- ctrl.Checked = False
- End If
- Next
- btnBulletedList.Checked = False
- Me.btnLettersUCaseDots.Checked = True
- btnNumberedList.Checked = True
- Dim pls As New ExtendedRichTextBox.ParaListStyle()
- pls.Type = ExtendedRichTextBox.ParaListStyle.ListType.CapitalLetters
- pls.Style = ExtendedRichTextBox.ParaListStyle.ListStyle.NumberAndPeriod
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectionListType = pls
- End Sub
- Private Sub btnLCaseBrackets_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLCaseBrackets.Click
- For Each ctrl In gcBullets.SubItems
- If TypeOf ctrl Is ButtonItem Then
- ctrl.Checked = False
- End If
- Next
- btnBulletedList.Checked = False
- btnLCaseBrackets.Checked = True
- btnNumberedList.Checked = True
- Dim pls As New ExtendedRichTextBox.ParaListStyle()
- pls.Type = ExtendedRichTextBox.ParaListStyle.ListType.SmallLetters
- pls.Style = ExtendedRichTextBox.ParaListStyle.ListStyle.NumberInPar
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectionListType = pls
- End Sub
- Private Sub btnNumberalsDots_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNumberalsDots.Click
- For Each ctrl In gcBullets.SubItems
- If TypeOf ctrl Is ButtonItem Then
- ctrl.Checked = False
- End If
- Next
- btnBulletedList.Checked = False
- btnNumberalsDots.Checked = True
- btnNumberedList.Checked = True
- Dim pls As New ExtendedRichTextBox.ParaListStyle()
- pls.Type = ExtendedRichTextBox.ParaListStyle.ListType.CapitalRoman
- pls.Style = ExtendedRichTextBox.ParaListStyle.ListStyle.NumberAndPeriod
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectionListType = pls
- End Sub
- Private Sub btnNumberedDots_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNumberedDots.Click
- For Each ctrl In gcBullets.SubItems
- If TypeOf ctrl Is ButtonItem Then
- ctrl.Checked = False
- End If
- Next
- btnBulletedList.Checked = False
- btnNumberedDots.Checked = True
- btnNumberedList.Checked = True
- Dim pls As New ExtendedRichTextBox.ParaListStyle()
- pls.Type = ExtendedRichTextBox.ParaListStyle.ListType.Numbers
- pls.Style = ExtendedRichTextBox.ParaListStyle.ListStyle.NumberAndPeriod
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectionListType = pls
- End Sub
- Private Sub btnNumberedBrackets_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNumberedBrackets.Click
- For Each ctrl In gcBullets.SubItems
- If TypeOf ctrl Is ButtonItem Then
- ctrl.Checked = False
- End If
- Next
- btnBulletedList.Checked = False
- btnNumberedBrackets.Checked = True
- btnNumberedList.Checked = True
- Dim pls As New ExtendedRichTextBox.ParaListStyle()
- pls.Type = ExtendedRichTextBox.ParaListStyle.ListType.Numbers
- pls.Style = ExtendedRichTextBox.ParaListStyle.ListStyle.NumberInPar
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectionListType = pls
- End Sub
- Private Sub btnSmallNumeralsDots_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSmallNumeralsDots.Click
- For Each ctrl In gcBullets.SubItems
- If TypeOf ctrl Is ButtonItem Then
- ctrl.Checked = False
- End If
- Next
- btnBulletedList.Checked = False
- btnSmallNumeralsDots.Checked = True
- btnNumberedList.Checked = True
- Dim pls As New ExtendedRichTextBox.ParaListStyle()
- pls.Type = ExtendedRichTextBox.ParaListStyle.ListType.SmallRoman
- pls.Style = ExtendedRichTextBox.ParaListStyle.ListStyle.NumberAndPeriod
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectionListType = pls
- End Sub
- #End Region
- Private Sub btnSpellCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSpellCheck.Click
- frmSpellCheck.ShowDialog()
- End Sub
- #End Region
- #Region "Update the statuses of the Toolbar when the selected text is changed in the RichTextBox"
- Private Sub tmrUpdateSize_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrUpdateSize.Tick
- tmrUpdateSize.Stop()
- If ScintillaMode = False Then
- Try
- For Each itm As DevComponents.Editors.ComboItem In cbxTextSize.Items
- If CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectionFont.Size.ToString = itm.Text Then
- cbxTextSize.SelectedItem = itm
- End If
- Next
- Catch
- 'Multiple font sizes selected
- cbxTextSize.Text = ""
- cbxTextSize.SelectedItem = Nothing
- End Try
- Try
- For Each itm As DevComponents.Editors.ComboItem In cbxFonts.Items
- If CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectionFont.Name = itm.Text Then
- cbxFonts.SelectedItem = itm
- End If
- Next
- Catch
- 'Multiple fonts selected.
- cbxFonts.Text = ""
- cbxFonts.SelectedItem = Nothing
- End Try
- End If
- End Sub
- #End Region
- #Region "Help Menu"
- Private Sub btnHelpDoc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHelpDoc.Click
- System.Windows.Forms.Help.ShowHelp(Me, "NotepadXHelp.chm")
- End Sub
- Private Sub btnFeedback_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFeedback.Click
- frmFeedback.ShowDialog()
- End Sub
- Private Sub btnStyling_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStyling.Click
- frmStyling.ShowDialog()
- Me.BringToFront()
- End Sub
- #End Region
- #Region "Handle Contextmenu"
- Private Sub cmuMain_PopupClose(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmuMain.PopupClose
- mnuSynonyms.SubItems.Clear()
- End Sub
- Private Sub btnLookup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuLookup.Click
- frmLookup.Show()
- frmLookup.Word = Me.Word
- End Sub
- #End Region
- Private Sub btnWordWrap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWordWrap.Click
- ' If btnWordWrap.Checked = True Then
- ' CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).WordWrap = True
- ' Else
- ' CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).WordWrap = False
- ' End If
- End Sub
- Private Sub btnNewScintillaDocument_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewScintillaDocument.Click
- If asked = False Then
- If notes > 50 Then
- If DevComponents.DotNetBar.MessageBoxEx.Show("Stuff could get laggy if you have more than 50 documents. Continue? (you'll only need to answer once)", "Question", MessageBoxButtons.YesNo) <> DialogResult.Yes Then
- Exit Sub
- Else
- asked = True
- End If
- End If
- End If
- notes += 1
- Dim tb As DevComponents.DotNetBar.TabItem = tcMain.CreateTab("")
- tb.Text = "New note - " & notes.ToString
- Dim myrtb As New ScintillaEX
- myrtb.Dock = DockStyle.Fill
- ' myrtb.Font = New Font(myrtb.Font.Name, 12)
- tb.AttachedControl.Controls.Add(myrtb)
- tcMain.SelectedTab = tb
- myrtb.Select()
- End Sub
- #Region "Syntax highlightging"
- Private Sub ButtonItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAsm.Click
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).ConfigurationManager.Language = "asm"
- End Sub
- Private Sub btnXML_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnXML.Click
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).ConfigurationManager.Language = "xml"
- End Sub
- Private Sub btnvbs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnvbs.Click
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).ConfigurationManager.Language = "vbscript"
- End Sub
- Private Sub btnJs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnJs.Click
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).ConfigurationManager.Language = "js"
- End Sub
- Private Sub btnPython_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPython.Click
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).ConfigurationManager.Language = "phython"
- End Sub
- Private Sub btnHTM_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHTM.Click
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).ConfigurationManager.Language = "html"
- End Sub
- Private Sub btnCS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCS.Click
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).ConfigurationManager.Language = "cs"
- End Sub
- Private Sub btnSQL_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSQL.Click
- CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).ConfigurationManager.Language = "mssql"
- End Sub
- #End Region
- Private Sub btnBrowserTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowserTest.Click
- Dim x As String = CType(tcMain.SelectedTab.AttachedControl.Controls.Item(0), ScintillaEX).Text
- Dim therandom As New Random
- Dim tempfile As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\temp\" & therandom.Next(1, 999999).ToString & ".html"
- Dim savef As New IO.StreamWriter(tempfile)
- savef.Write(x)
- savef.Close()
- Process.Start(tempfile)
- End Sub
- Private Sub ButtonItem3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
- End Sub
- End Class
- #Region "Custom Controls"
- Public Class bitm_recent
- Inherits DevComponents.DotNetBar.ButtonItem
- Private Sub bitm_recent_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
- Dim tb As DevComponents.DotNetBar.TabItem = frmMain.tcMain.CreateTab("")
- tb.Text = Me.Text.Substring(Me.Text.LastIndexOf("\")).Replace("\", "")
- Dim myrtb As New RTB
- myrtb.Dock = DockStyle.Fill
- myrtb.Font = New Font(myrtb.Font.Name, 12)
- Try
- myrtb.LoadFile(Me.Text)
- Catch
- Dim loadf As New IO.StreamReader(Me.Text)
- myrtb.Text = loadf.ReadToEnd
- loadf.Close()
- End Try
- myrtb.SavePath = Me.Text
- myrtb.DocumentModified = False
- tb.AttachedControl.Controls.Add(myrtb)
- frmMain.tcMain.SelectedTab = tb
- myrtb.Select()
- End Sub
- End Class
- Public Class bitm_Synonym
- Inherits DevComponents.DotNetBar.ButtonItem
- Private Sub bitm_Synonym_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
- CType(frmMain.tcMain.SelectedTab.AttachedControl.Controls.Item(0), RTB).SelectedText = Me.Text
- End Sub
- End Class
- #End Region
Advertisement
Add Comment
Please, Sign In to add comment