|
-
Apr 22nd, 2007, 09:44 AM
#1
Thread Starter
Lively Member
text editor saving problem
Hi guys
I'm just in the process of writing a text editor and am having trouble working out why my program doesn't save files.
Any chance that someone can look at my code and work out why it wont??
Here is my code:
Code:
Imports system.Windows.Forms
Imports System.IO
Public Class form
Private mFileName As String
Private modified As Boolean
Private Sub ToolbarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miViewToolBar.Click
If (miViewToolBar.Checked = True) Then
tbToolBar.Visible = True
Else
tbToolBar.Visible = False
End If
End Sub
Private Sub BulletsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miBulletToolBar.Click
miBulletToolBar.Checked = Not miBulletToolBar.Checked
If (miBulletToolBar.Checked = True) Then
RtbEditor.SelectionBullet = True
Else
RtbEditor.SelectionBullet = False
End If
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
modification(sender, e)
Clipboard.Clear()
Application.Exit()
End Sub
Private Sub clearAlignment()
LeftAlign.Checked = False
Centered.Checked = False
RightAlign.Checked = False
End Sub
Private Sub LeftAlignToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LeftAlign.Click
clearAlignment()
LeftAlign.Checked = Not LeftAlign.Checked
If (LeftAlign.Checked = True) Then
RtbEditor.SelectionAlignment = HorizontalAlignment.Left
End If
End Sub
Private Sub Centered_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Centered.Click
clearAlignment()
Centered.Checked = Not Centered.Checked
If (Centered.Checked = True) Then
RtbEditor.SelectionAlignment = HorizontalAlignment.Center
End If
End Sub
Private Sub RightAlign_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RightAlign.Click
clearAlignment()
RightAlign.Checked = Not Centered.Checked
If (RightAlign.Checked = True) Then
RtbEditor.SelectionAlignment = HorizontalAlignment.Right
End If
End Sub
Private Sub MyPopupEventHandler(ByVal sender As System.Object, ByVal e As System.EventArgs)
If (RtbEditor.SelectionAlignment = HorizontalAlignment.Center) Then
Centered.Checked = True
ElseIf (RtbEditor.SelectionAlignment = HorizontalAlignment.Left) Then
LeftAlign.Checked = True
Else
RightAlign.Checked = True
End If
End Sub
Private Sub New_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
modification(sender, e)
Clipboard.Clear()
RtbEditor.Clear()
mFileName = ""
modified = False
Me.Text = "WixsPad - Untitled"
End Sub
Private Sub Open_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
modification(sender, e)
New_click(sender, e)
Dim isFileThere As DialogResult
modified = False
isFileThere = ofdFileOpen.ShowDialog()
mFileName = ofdFileOpen.FileName
Me.Text = "WixsPad - " & Path.GetFileName(mFileName)
If (isFileThere = Windows.Forms.DialogResult.OK) Then
RtbEditor.LoadFile(mFileName)
End If
End Sub
Private Sub SaveAs_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveAsToolStripMenuItem.Click
modified = False
sfdFileSave.FileName = mFileName
sfdFileSave.ShowDialog()
If (Windows.Forms.DialogResult.OK) Then
If (mFileName <> "") Then
mFileName = sfdFileSave.FileName
Me.Text = "WixsPad - " & Path.GetFileName(mFileName)
RtbEditor.SaveFile(mFileName)
End If
End If
End Sub
Private Sub Save_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
modified = False
If (mFileName = "") Then
SaveAs_click(sender, e)
Else
RtbEditor.SaveFile(mFileName)
End If
End Sub
Private Sub AboutWixsPadToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutWixsPadToolStripMenuItem.Click
AboutScreen.Show()
End Sub
Private Sub modified_TextChanged(ByVal sender As Object, _
ByVal e As EventArgs) Handles RtbEditor.TextChanged
modified = True
If (modified = True) Then
Me.Text = "WixsPad - " & Path.GetFileName(mFileName) & " (Modified)"
Else
Me.Text = "WixsPad - " & Path.GetFileName(mFileName)
End If
End Sub
Private Sub modification(ByVal sender As Object, ByVal e As EventArgs)
If (modified = True) Then
modifiedScreen.Show()
modifiedScreen.Visible = False
If (modifiedScreen.ShowDialog = Windows.Forms.DialogResult.OK) Then
Save_click(sender, e)
End If
End If
End Sub
Private Sub ParagraphToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ParagraphToolStripMenuItem.Click
indentation.ShowDialog()
If (indentation.DialogResult = Windows.Forms.DialogResult.OK) Then
RtbEditor.SelectionIndent = indentation.leftIndent.Text
RtbEditor.SelectionRightIndent = indentation.rightIndent.Text
RtbEditor.RightMargin = indentation.rightMargin.Text
End If
End Sub
Private Sub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cut.Click
RtbEditor.Cut()
End Sub
Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Copy.Click
RtbEditor.Copy()
End Sub
Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Paste.Click
RtbEditor.Paste()
End Sub
Private Sub SelectAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectAll.Click
RtbEditor.SelectAll()
End Sub
Private Sub Edit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Edit.Click
If RtbEditor.SelectionLength > 0 Then
Cut.Enabled = True
Copy.Enabled = True
End If
If Clipboard.ContainsText Then
Paste.Enabled = True
End If
If RtbEditor.TextLength > 0 Then
SelectAll.Enabled = True
End If
End Sub
Private Sub toolNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles toolNew.Click
New_click(sender, e)
End Sub
Private Sub toolOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles toolOpen.Click
Open_click(sender, e)
End Sub
Private Sub toolSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles toolSave.Click
Save_click(sender, e)
End Sub
Private Sub toolBold_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles toolBold.Click
toolBold.CheckOnClick = True
RtbEditor.SelectionFont = New Font(RtbEditor.SelectionFont, RtbEditor.SelectionFont.Style Xor FontStyle.Bold)
End Sub
Private Sub toolItalics_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles toolItalics.Click
toolItalics.CheckOnClick = True
RtbEditor.SelectionFont = New Font(RtbEditor.SelectionFont.Name, RtbEditor.SelectionFont.Size, RtbEditor.SelectionFont.Style Xor FontStyle.Italic)
End Sub
Private Sub toolUnderline_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles toolUnderline.Click
toolUnderline.CheckOnClick = True
RtbEditor.SelectionFont = New Font(RtbEditor.SelectionFont.Name, RtbEditor.SelectionFont.Size, RtbEditor.SelectionFont.Style Xor FontStyle.Underline)
End Sub
Private Sub FontToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FontToolStripMenuItem.Click
fontDialog.ShowDialog()
RtbEditor.SelectionFont = fontDialog.Font
End Sub
Private Sub OptionsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OptionsToolStripMenuItem.Click
options.ShowDialog()
If (options.DialogResult = Windows.Forms.DialogResult.OK) Then
If (options.tabs.Checked = True) Then
RtbEditor.AcceptsTab = True
End If
If (options.returns.Checked = True) Then
RtbEditor.Multiline = True
End If
If (options.wraps.Checked = True) Then
RtbEditor.WordWrap = True
End If
End If
End Sub
End Class
Thanks heaps guys....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|