Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB.net Control Array 1

Status
Not open for further replies.

WJProctor

Programmer
Joined
Jun 20, 2003
Messages
151
Location
GB
Hi, ive been reading through a lot of documentation about control arrays and lots of peope seem to have examples of how you can get a number of buttons to go to one sub. But i have alot of check boxes and in vb 6 i used to be able to code like this:

Do Until Counter >= 10
Counter = Counter + 1
Check(Counter).Checked = False
Loop

How can i do similar to this in VB.net

If possible could you point me in the direction of some tutorials or just give me some advice.

Kind regards

JP
 
The function will do the job for you. You need to pass it the form. It also looks to see if you have any container objects on the form panel etc.. and clears them too. You call the function like this.

ClearChildText(Me.Controls)


Private Sub ClearChildText(ByVal contin As Control.ControlCollection)

Dim foundcontrol As Control


For Each foundcontrol In contin
If foundcontrol.GetType.ToString = "System.Windows.Forms.CheckBox" Then
CType(foundcontrol, CheckBox).Checked = True
End If

If foundcontrol.Controls.Count <> 0 Then
ClearChildText(foundcontrol.Controls)
End If
Next foundcontrol

End Sub

DotNetDoc
M.C.S.D.
[2thumbsup]
---------------------------------------

Tell me and I forget. Show me and I remember. Involve me and I understand.
- Anonymous Chinese Proverb

-----------------------------------

If you can't explain it simply, you don't understand it well enough.
- A. Einstein
 
Thats great thanx. I hope you dont mind me asking another question but how abouts if i want to loop through a number of controls and read their attibutes. Also is there a way i can modifiy the above code to only clear the controls in on form, or a number of controls instead of everyone on the form.

Thanks

JP
 
Inside this section you can do whatever you want

If foundcontrol.GetType.ToString = &quot;System.Windows.Forms.CheckBox&quot; Then

If CType(foundcontrol, CheckBox).Name = &quot;Checkbox1&quot; Then
CType(foundcontrol, CheckBox).Checked = True

End IF
End If


DotNetDoc
M.C.S.D.
[2thumbsup]
---------------------------------------

Tell me and I forget. Show me and I remember. Involve me and I understand.
- Anonymous Chinese Proverb

-----------------------------------

If you can't explain it simply, you don't understand it well enough.
- A. Einstein
 
Well i know this will sound think, but if a have a frame (frame1) how do i tell it to clear the contents on that, or is that impossible.

Thanks for helping

JP
 
That is what this portion does.

If foundcontrol.Controls.Count <> 0 Then
ClearChildText(foundcontrol.Controls)
End If


If a control is a container control. Panel, Picturebox etc.. it will clear controls on that as well.

Remember the Containers like Forms, Panels, etc.. have a controls collection. So it looks at each control on the form and first looks to see if it is a checkbox if it is not it looks to see if it is a container itself (Controls.Count <> 0 means it is a container control) and if it is it runs the function recursivly to clear checkboxes on that as well.


DotNetDoc
M.C.S.D.
[2thumbsup]
---------------------------------------

Tell me and I forget. Show me and I remember. Involve me and I understand.
- Anonymous Chinese Proverb

-----------------------------------

If you can't explain it simply, you don't understand it well enough.
- A. Einstein
 
Dim Checks() as CheckBox

Checks(0) = CheckBox1
Checks(1) = CheckBox2
.
.
.
Checks(10) = CheckBox11

Do Until Counter >= 10
Counter = Counter + 1
Checks(Counter).Checked = False
Loop

I prefer the easy way.

Becca
 
That way you need to manually add all of your checkboxes into an array. Every time you add, take away or rename a checkbox you have to modify your code.

You can load the function into a class library and not only use it anywhere in this program but in any program.

That sounds eaiser to me.

DotNetDoc
M.C.S.D.
[2thumbsup]
---------------------------------------

Tell me and I forget. Show me and I remember. Involve me and I understand.
- Anonymous Chinese Proverb

-----------------------------------

If you can't explain it simply, you don't understand it well enough.
- A. Einstein
 
If you do not have a set number of controls with set names, that never change, this is very true.

by the way, while I have your attention ... I am having a very hard time figuring out how to print the contents of a richtextbox as they appear (color, bold, diff fonts, etc..).

Becca
 
I think this article should answer your questions. Let me know if it does not do what you need it to do.



DotNetDoc
M.C.S.D.
[2thumbsup]
---------------------------------------

Tell me and I forget. Show me and I remember. Involve me and I understand.
- Anonymous Chinese Proverb

-----------------------------------

If you can't explain it simply, you don't understand it well enough.
- A. Einstein
 
I read the whole thing, and I am still lost. They give me all kinds of code, but do not say exactly what to do with it. I am still somewhat new to VB, but learn quick. just hard to learn what is not taught. I'd love any help I can get, you can email me direct at rebeccalynn1960@yahoo.com if you like.

Becca
 
Can you send me a sample of what you are working on so I can show you exactly instead of in the abstract.



DotNetDoc
M.C.S.D.
---------------------------------------

Tell me and I forget. Show me and I remember. Involve me and I understand.
- Anonymous Chinese Proverb
-----------------------------------
If you can't explain it simply, you don't understand it well enough.
- A. Einstein
 
Imports System.io
Imports System.Drawing.Printing

Public Class frmDDnotes
Inherits System.Windows.Forms.Form

#Region &quot; Windows Form Designer generated code &quot;

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents lblTitle As System.Windows.Forms.Label
Friend WithEvents rtbNotes As System.Windows.Forms.RichTextBox
Friend WithEvents btnBold As System.Windows.Forms.Button
Friend WithEvents imlNotes As System.Windows.Forms.ImageList
Friend WithEvents btnCut As System.Windows.Forms.Button
Friend WithEvents btnCopy As System.Windows.Forms.Button
Friend WithEvents btnPaste As System.Windows.Forms.Button
Friend WithEvents btnUnderline As System.Windows.Forms.Button
Friend WithEvents btnNew As System.Windows.Forms.Button
Friend WithEvents btnColor As System.Windows.Forms.Button
Friend WithEvents btnOpen As System.Windows.Forms.Button
Friend WithEvents btnSave As System.Windows.Forms.Button
Friend WithEvents ctmDN As System.Windows.Forms.ContextMenu
Friend WithEvents ctmDNclose As System.Windows.Forms.MenuItem
Friend WithEvents ctnDNmain As System.Windows.Forms.ContextMenu
Friend WithEvents btnPrint As System.Windows.Forms.Button
Friend WithEvents btnDelete As System.Windows.Forms.Button
Friend WithEvents btnItalic As System.Windows.Forms.Button
Friend WithEvents ctmDNMnew As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNMopen As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNMcut As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNMcopy As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNMpaste As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNMdelete As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNMbold As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNMunderline As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNMitalics As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNMcolor As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNMsave As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNMprint As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNMbar1 As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNMbar2 As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNMbar3 As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNMbar4 As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNbar As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNdot As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNPrefs As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNbar1 As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNbar2 As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNPrefsT As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNPrefsTBC As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNPrefsTTC As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNPrefsWC As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNPrefsNC As System.Windows.Forms.MenuItem
Friend WithEvents ctmDOTDC As System.Windows.Forms.MenuItem
Friend WithEvents ctmDOTDCred As System.Windows.Forms.MenuItem
Friend WithEvents ctmDOTDCorange As System.Windows.Forms.MenuItem
Friend WithEvents ctmDOTDCyellow As System.Windows.Forms.MenuItem
Friend WithEvents ctmDOTDCgreen As System.Windows.Forms.MenuItem
Friend WithEvents ctmDOTDCdarkgreen As System.Windows.Forms.MenuItem
Friend WithEvents ctmDOTDCdarkblue As System.Windows.Forms.MenuItem
Friend WithEvents ctmDOTDCblue As System.Windows.Forms.MenuItem
Friend WithEvents ctmDOTDCltblue As System.Windows.Forms.MenuItem
Friend WithEvents ctmDOTDCviolet As System.Windows.Forms.MenuItem
Friend WithEvents ctmDOTDCbrown As System.Windows.Forms.MenuItem
Friend WithEvents ctmDOTDCblack As System.Windows.Forms.MenuItem
Friend WithEvents ctmDOTDCdarkgrey As System.Windows.Forms.MenuItem
Friend WithEvents ctmDOTDCgrey As System.Windows.Forms.MenuItem
Friend WithEvents ctmDOTDCwhite As System.Windows.Forms.MenuItem
Friend WithEvents ctmDOTDCpink As System.Windows.Forms.MenuItem
Friend WithEvents ctmDOTDCgold As System.Windows.Forms.MenuItem
Friend WithEvents ctmDOTDCdarkviolet As System.Windows.Forms.MenuItem
Friend WithEvents picDot As System.Windows.Forms.PictureBox
Friend WithEvents btnFont As System.Windows.Forms.Button
Friend WithEvents ctmDNMfont As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNMsaveas As System.Windows.Forms.MenuItem
Friend WithEvents ctmDNpsave As System.Windows.Forms.MenuItem
Friend WithEvents ctmBar3 As System.Windows.Forms.MenuItem
Friend WithEvents ofdDN As System.Windows.Forms.OpenFileDialog
Friend WithEvents sfdDN As System.Windows.Forms.SaveFileDialog
Friend WithEvents ctmOnTop As System.Windows.Forms.MenuItem
Friend WithEvents PrintDocument1 As System.Drawing.Printing.PrintDocument
Friend WithEvents PrintDialog1 As System.Windows.Forms.PrintDialog
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmDDnotes))
Me.lblTitle = New System.Windows.Forms.Label
Me.ctnDNmain = New System.Windows.Forms.ContextMenu
Me.ctmDNMnew = New System.Windows.Forms.MenuItem
Me.ctmDNMopen = New System.Windows.Forms.MenuItem
Me.ctmDNMbar1 = New System.Windows.Forms.MenuItem
Me.ctmDNMsave = New System.Windows.Forms.MenuItem
Me.ctmDNMsaveas = New System.Windows.Forms.MenuItem
Me.ctmDNMbar2 = New System.Windows.Forms.MenuItem
Me.ctmDNMprint = New System.Windows.Forms.MenuItem
Me.ctmDNMbar3 = New System.Windows.Forms.MenuItem
Me.ctmDNMcut = New System.Windows.Forms.MenuItem
Me.ctmDNMcopy = New System.Windows.Forms.MenuItem
Me.ctmDNMpaste = New System.Windows.Forms.MenuItem
Me.ctmDNMdelete = New System.Windows.Forms.MenuItem
Me.ctmDNMbar4 = New System.Windows.Forms.MenuItem
Me.ctmDNMbold = New System.Windows.Forms.MenuItem
Me.ctmDNMunderline = New System.Windows.Forms.MenuItem
Me.ctmDNMitalics = New System.Windows.Forms.MenuItem
Me.ctmDNMcolor = New System.Windows.Forms.MenuItem
Me.ctmDNMfont = New System.Windows.Forms.MenuItem
Me.picDot = New System.Windows.Forms.PictureBox
Me.ctmDN = New System.Windows.Forms.ContextMenu
Me.ctmDNbar = New System.Windows.Forms.MenuItem
Me.ctmDNdot = New System.Windows.Forms.MenuItem
Me.ctmOnTop = New System.Windows.Forms.MenuItem
Me.ctmDNbar1 = New System.Windows.Forms.MenuItem
Me.ctmDNPrefs = New System.Windows.Forms.MenuItem
Me.ctmDOTDC = New System.Windows.Forms.MenuItem
Me.ctmDOTDCred = New System.Windows.Forms.MenuItem
Me.ctmDOTDCorange = New System.Windows.Forms.MenuItem
Me.ctmDOTDCyellow = New System.Windows.Forms.MenuItem
Me.ctmDOTDCgreen = New System.Windows.Forms.MenuItem
Me.ctmDOTDCdarkgreen = New System.Windows.Forms.MenuItem
Me.ctmDOTDCdarkblue = New System.Windows.Forms.MenuItem
Me.ctmDOTDCblue = New System.Windows.Forms.MenuItem
Me.ctmDOTDCltblue = New System.Windows.Forms.MenuItem
Me.ctmDOTDCviolet = New System.Windows.Forms.MenuItem
Me.ctmDOTDCdarkviolet = New System.Windows.Forms.MenuItem
Me.ctmDOTDCbrown = New System.Windows.Forms.MenuItem
Me.ctmDOTDCblack = New System.Windows.Forms.MenuItem
Me.ctmDOTDCdarkgrey = New System.Windows.Forms.MenuItem
Me.ctmDOTDCgrey = New System.Windows.Forms.MenuItem
Me.ctmDOTDCwhite = New System.Windows.Forms.MenuItem
Me.ctmDOTDCpink = New System.Windows.Forms.MenuItem
Me.ctmDOTDCgold = New System.Windows.Forms.MenuItem
Me.ctmDNPrefsT = New System.Windows.Forms.MenuItem
Me.ctmDNPrefsTBC = New System.Windows.Forms.MenuItem
Me.ctmDNPrefsTTC = New System.Windows.Forms.MenuItem
Me.ctmDNPrefsNC = New System.Windows.Forms.MenuItem
Me.ctmDNPrefsWC = New System.Windows.Forms.MenuItem
Me.ctmBar3 = New System.Windows.Forms.MenuItem
Me.ctmDNpsave = New System.Windows.Forms.MenuItem
Me.ctmDNbar2 = New System.Windows.Forms.MenuItem
Me.ctmDNclose = New System.Windows.Forms.MenuItem
Me.rtbNotes = New System.Windows.Forms.RichTextBox
Me.btnBold = New System.Windows.Forms.Button
Me.imlNotes = New System.Windows.Forms.ImageList(Me.components)
Me.btnCut = New System.Windows.Forms.Button
Me.btnCopy = New System.Windows.Forms.Button
Me.btnPaste = New System.Windows.Forms.Button
Me.btnUnderline = New System.Windows.Forms.Button
Me.btnItalic = New System.Windows.Forms.Button
Me.btnNew = New System.Windows.Forms.Button
Me.btnColor = New System.Windows.Forms.Button
Me.btnOpen = New System.Windows.Forms.Button
Me.btnSave = New System.Windows.Forms.Button
Me.btnPrint = New System.Windows.Forms.Button
Me.btnDelete = New System.Windows.Forms.Button
Me.btnFont = New System.Windows.Forms.Button
Me.ofdDN = New System.Windows.Forms.OpenFileDialog
Me.sfdDN = New System.Windows.Forms.SaveFileDialog
Me.PrintDocument1 = New System.Drawing.Printing.PrintDocument
Me.PrintDialog1 = New System.Windows.Forms.PrintDialog
Me.SuspendLayout()
'
'lblTitle
'
Me.lblTitle.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.lblTitle.BackColor = System.Drawing.Color.FromArgb(CType(0, Byte), CType(0, Byte), CType(192, Byte))
Me.lblTitle.ContextMenu = Me.ctnDNmain
Me.lblTitle.Font = New System.Drawing.Font(&quot;Microsoft Sans Serif&quot;, 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblTitle.ForeColor = System.Drawing.Color.White
Me.lblTitle.Location = New System.Drawing.Point(0, 0)
Me.lblTitle.Name = &quot;lblTitle&quot;
Me.lblTitle.Size = New System.Drawing.Size(342, 20)
Me.lblTitle.TabIndex = 15
Me.lblTitle.Text = &quot;Desk Notes&quot;
Me.lblTitle.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'ctnDNmain
'
Me.ctnDNmain.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.ctmDNMnew, Me.ctmDNMopen, Me.ctmDNMbar1, Me.ctmDNMsave, Me.ctmDNMsaveas, Me.ctmDNMbar2, Me.ctmDNMprint, Me.ctmDNMbar3, Me.ctmDNMcut, Me.ctmDNMcopy, Me.ctmDNMpaste, Me.ctmDNMdelete, Me.ctmDNMbar4, Me.ctmDNMbold, Me.ctmDNMunderline, Me.ctmDNMitalics, Me.ctmDNMcolor, Me.ctmDNMfont})
'
'ctmDNMnew
'
Me.ctmDNMnew.Index = 0
Me.ctmDNMnew.Text = &quot;New&quot;
'
'ctmDNMopen
'
Me.ctmDNMopen.Index = 1
Me.ctmDNMopen.Text = &quot;Open&quot;
'
'ctmDNMbar1
'
Me.ctmDNMbar1.Index = 2
Me.ctmDNMbar1.Text = &quot;-&quot;
'
'ctmDNMsave
'
Me.ctmDNMsave.Index = 3
Me.ctmDNMsave.Text = &quot;Save&quot;
'
'ctmDNMsaveas
'
Me.ctmDNMsaveas.Index = 4
Me.ctmDNMsaveas.Text = &quot;Save As...&quot;
'
'ctmDNMbar2
'
Me.ctmDNMbar2.Index = 5
Me.ctmDNMbar2.Text = &quot;-&quot;
'
'ctmDNMprint
'
Me.ctmDNMprint.Index = 6
Me.ctmDNMprint.Text = &quot;Print&quot;
'
'ctmDNMbar3
'
Me.ctmDNMbar3.Index = 7
Me.ctmDNMbar3.Text = &quot;-&quot;
'
'ctmDNMcut
'
Me.ctmDNMcut.Index = 8
Me.ctmDNMcut.Text = &quot;Cut&quot;
'
'ctmDNMcopy
'
Me.ctmDNMcopy.Index = 9
Me.ctmDNMcopy.Text = &quot;Copy&quot;
'
'ctmDNMpaste
'
Me.ctmDNMpaste.Index = 10
Me.ctmDNMpaste.Text = &quot;Paste&quot;
'
'ctmDNMdelete
'
Me.ctmDNMdelete.Index = 11
Me.ctmDNMdelete.Text = &quot;Delete&quot;
'
'ctmDNMbar4
'
Me.ctmDNMbar4.Index = 12
Me.ctmDNMbar4.Text = &quot;-&quot;
'
'ctmDNMbold
'
Me.ctmDNMbold.Index = 13
Me.ctmDNMbold.Text = &quot;Bold&quot;
'
'ctmDNMunderline
'
Me.ctmDNMunderline.Index = 14
Me.ctmDNMunderline.Text = &quot;Underline&quot;
'
'ctmDNMitalics
'
Me.ctmDNMitalics.Index = 15
Me.ctmDNMitalics.Text = &quot;Italics&quot;
'
'ctmDNMcolor
'
Me.ctmDNMcolor.Index = 16
Me.ctmDNMcolor.Text = &quot;Text Color&quot;
'
'ctmDNMfont
'
Me.ctmDNMfont.Index = 17
Me.ctmDNMfont.Text = &quot;Font&quot;
'
'picDot
'
Me.picDot.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.picDot.BackColor = System.Drawing.Color.FromArgb(CType(0, Byte), CType(0, Byte), CType(192, Byte))
Me.picDot.ContextMenu = Me.ctmDN
Me.picDot.Image = CType(resources.GetObject(&quot;picDot.Image&quot;), System.Drawing.Image)
Me.picDot.Location = New System.Drawing.Point(322, 0)
Me.picDot.Name = &quot;picDot&quot;
Me.picDot.Size = New System.Drawing.Size(20, 20)
Me.picDot.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.picDot.TabIndex = 4
Me.picDot.TabStop = False
'
'ctmDN
'
Me.ctmDN.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.ctmDNbar, Me.ctmDNdot, Me.ctmOnTop, Me.ctmDNbar1, Me.ctmDNPrefs, Me.ctmDNbar2, Me.ctmDNclose})
'
'ctmDNbar
'
Me.ctmDNbar.Index = 0
Me.ctmDNbar.Text = &quot;Show As Bar&quot;
'
'ctmDNdot
'
Me.ctmDNdot.Index = 1
Me.ctmDNdot.Text = &quot;Show As Dot&quot;
'
'ctmOnTop
'
Me.ctmOnTop.Index = 2
Me.ctmOnTop.Text = &quot;Stay On Top&quot;
'
'ctmDNbar1
'
Me.ctmDNbar1.Index = 3
Me.ctmDNbar1.Text = &quot;-&quot;
'
'ctmDNPrefs
'
Me.ctmDNPrefs.Index = 4
Me.ctmDNPrefs.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.ctmDOTDC, Me.ctmDNPrefsT, Me.ctmDNPrefsNC, Me.ctmDNPrefsWC, Me.ctmBar3, Me.ctmDNpsave})
Me.ctmDNPrefs.Text = &quot;Preferences&quot;
'
'ctmDOTDC
'
Me.ctmDOTDC.Index = 0
Me.ctmDOTDC.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.ctmDOTDCred, Me.ctmDOTDCorange, Me.ctmDOTDCyellow, Me.ctmDOTDCgreen, Me.ctmDOTDCdarkgreen, Me.ctmDOTDCdarkblue, Me.ctmDOTDCblue, Me.ctmDOTDCltblue, Me.ctmDOTDCviolet, Me.ctmDOTDCdarkviolet, Me.ctmDOTDCbrown, Me.ctmDOTDCblack, Me.ctmDOTDCdarkgrey, Me.ctmDOTDCgrey, Me.ctmDOTDCwhite, Me.ctmDOTDCpink, Me.ctmDOTDCgold})
Me.ctmDOTDC.Text = &quot;Dot Color&quot;
'
'ctmDOTDCred
'
Me.ctmDOTDCred.Index = 0
Me.ctmDOTDCred.RadioCheck = True
Me.ctmDOTDCred.Text = &quot;Red&quot;
'
'ctmDOTDCorange
'
Me.ctmDOTDCorange.Index = 1
Me.ctmDOTDCorange.RadioCheck = True
Me.ctmDOTDCorange.Text = &quot;Orange&quot;
'
'ctmDOTDCyellow
'
Me.ctmDOTDCyellow.Index = 2
Me.ctmDOTDCyellow.RadioCheck = True
Me.ctmDOTDCyellow.Text = &quot;Yellow&quot;
'
'ctmDOTDCgreen
'
Me.ctmDOTDCgreen.Index = 3
Me.ctmDOTDCgreen.RadioCheck = True
Me.ctmDOTDCgreen.Text = &quot;Green&quot;
'
'ctmDOTDCdarkgreen
'
Me.ctmDOTDCdarkgreen.Index = 4
Me.ctmDOTDCdarkgreen.RadioCheck = True
Me.ctmDOTDCdarkgreen.Text = &quot;Dark Green&quot;
'
'ctmDOTDCdarkblue
'
Me.ctmDOTDCdarkblue.Index = 5
Me.ctmDOTDCdarkblue.RadioCheck = True
Me.ctmDOTDCdarkblue.Text = &quot;Dark Blue&quot;
'
'ctmDOTDCblue
'
Me.ctmDOTDCblue.Index = 6
Me.ctmDOTDCblue.RadioCheck = True
Me.ctmDOTDCblue.Text = &quot;Blue&quot;
'
'ctmDOTDCltblue
'
Me.ctmDOTDCltblue.Index = 7
Me.ctmDOTDCltblue.RadioCheck = True
Me.ctmDOTDCltblue.Text = &quot;Light Blue&quot;
'
'ctmDOTDCviolet
'
Me.ctmDOTDCviolet.Index = 8
Me.ctmDOTDCviolet.RadioCheck = True
Me.ctmDOTDCviolet.Text = &quot;Violet&quot;
'
'ctmDOTDCdarkviolet
'
Me.ctmDOTDCdarkviolet.Index = 9
Me.ctmDOTDCdarkviolet.RadioCheck = True
Me.ctmDOTDCdarkviolet.Text = &quot;Dark Violet&quot;
'
'ctmDOTDCbrown
'
Me.ctmDOTDCbrown.Index = 10
Me.ctmDOTDCbrown.RadioCheck = True
Me.ctmDOTDCbrown.Text = &quot;Brown&quot;
'
'ctmDOTDCblack
'
Me.ctmDOTDCblack.Index = 11
Me.ctmDOTDCblack.RadioCheck = True
Me.ctmDOTDCblack.Text = &quot;Black&quot;
'
'ctmDOTDCdarkgrey
'
Me.ctmDOTDCdarkgrey.Index = 12
Me.ctmDOTDCdarkgrey.RadioCheck = True
Me.ctmDOTDCdarkgrey.Text = &quot;Dark Grey&quot;
'
'ctmDOTDCgrey
'
Me.ctmDOTDCgrey.Index = 13
Me.ctmDOTDCgrey.RadioCheck = True
Me.ctmDOTDCgrey.Text = &quot;Grey&quot;
'
'ctmDOTDCwhite
'
Me.ctmDOTDCwhite.Index = 14
Me.ctmDOTDCwhite.RadioCheck = True
Me.ctmDOTDCwhite.Text = &quot;White&quot;
'
'ctmDOTDCpink
'
Me.ctmDOTDCpink.Index = 15
Me.ctmDOTDCpink.Text = &quot;Pink&quot;
'
'ctmDOTDCgold
'
Me.ctmDOTDCgold.Index = 16
Me.ctmDOTDCgold.Text = &quot;Gold&quot;
'
'ctmDNPrefsT
'
Me.ctmDNPrefsT.Index = 1
Me.ctmDNPrefsT.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.ctmDNPrefsTBC, Me.ctmDNPrefsTTC})
Me.ctmDNPrefsT.Text = &quot;Title&quot;
'
'ctmDNPrefsTBC
'
Me.ctmDNPrefsTBC.Index = 0
Me.ctmDNPrefsTBC.Text = &quot;Back Color&quot;
'
'ctmDNPrefsTTC
'
Me.ctmDNPrefsTTC.Index = 1
Me.ctmDNPrefsTTC.Text = &quot;Text Color&quot;
'
'ctmDNPrefsNC
'
Me.ctmDNPrefsNC.Index = 2
Me.ctmDNPrefsNC.Text = &quot;Note Color&quot;
'
'ctmDNPrefsWC
'
Me.ctmDNPrefsWC.Index = 3
Me.ctmDNPrefsWC.Text = &quot;Window Color&quot;
'
'ctmBar3
'
Me.ctmBar3.Index = 4
Me.ctmBar3.Text = &quot;-&quot;
'
'ctmDNpsave
'
Me.ctmDNpsave.Index = 5
Me.ctmDNpsave.Text = &quot;Save Prefs&quot;
'
'ctmDNbar2
'
Me.ctmDNbar2.Index = 5
Me.ctmDNbar2.Text = &quot;-&quot;
'
'ctmDNclose
'
Me.ctmDNclose.Index = 6
Me.ctmDNclose.Text = &quot;Close&quot;
'
'rtbNotes
'
Me.rtbNotes.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.rtbNotes.ContextMenu = Me.ctnDNmain
Me.rtbNotes.Font = New System.Drawing.Font(&quot;Microsoft Sans Serif&quot;, 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.rtbNotes.HideSelection = False
Me.rtbNotes.Location = New System.Drawing.Point(10, 40)
Me.rtbNotes.Name = &quot;rtbNotes&quot;
Me.rtbNotes.Size = New System.Drawing.Size(322, 277)
Me.rtbNotes.TabIndex = 1
Me.rtbNotes.Text = &quot;&quot;
'
'btnBold
'
Me.btnBold.BackColor = System.Drawing.Color.Silver
Me.btnBold.ImageIndex = 0
Me.btnBold.ImageList = Me.imlNotes
Me.btnBold.Location = New System.Drawing.Point(190, 20)
Me.btnBold.Name = &quot;btnBold&quot;
Me.btnBold.Size = New System.Drawing.Size(20, 20)
Me.btnBold.TabIndex = 10
'
'imlNotes
'
Me.imlNotes.ImageSize = New System.Drawing.Size(16, 16)
Me.imlNotes.ImageStream = CType(resources.GetObject(&quot;imlNotes.ImageStream&quot;), System.Windows.Forms.ImageListStreamer)
Me.imlNotes.TransparentColor = System.Drawing.Color.Transparent
'
'btnCut
'
Me.btnCut.BackColor = System.Drawing.Color.Silver
Me.btnCut.ImageIndex = 2
Me.btnCut.ImageList = Me.imlNotes
Me.btnCut.Location = New System.Drawing.Point(100, 20)
Me.btnCut.Name = &quot;btnCut&quot;
Me.btnCut.Size = New System.Drawing.Size(20, 20)
Me.btnCut.TabIndex = 6
'
'btnCopy
'
Me.btnCopy.BackColor = System.Drawing.Color.Silver
Me.btnCopy.ImageIndex = 1
Me.btnCopy.ImageList = Me.imlNotes
Me.btnCopy.Location = New System.Drawing.Point(120, 20)
Me.btnCopy.Name = &quot;btnCopy&quot;
Me.btnCopy.Size = New System.Drawing.Size(20, 20)
Me.btnCopy.TabIndex = 7
'
'btnPaste
'
Me.btnPaste.BackColor = System.Drawing.Color.Silver
Me.btnPaste.ImageIndex = 6
Me.btnPaste.ImageList = Me.imlNotes
Me.btnPaste.Location = New System.Drawing.Point(140, 20)
Me.btnPaste.Name = &quot;btnPaste&quot;
Me.btnPaste.Size = New System.Drawing.Size(20, 20)
Me.btnPaste.TabIndex = 8
'
'btnUnderline
'
Me.btnUnderline.BackColor = System.Drawing.Color.Silver
Me.btnUnderline.ImageIndex = 9
Me.btnUnderline.ImageList = Me.imlNotes
Me.btnUnderline.Location = New System.Drawing.Point(210, 20)
Me.btnUnderline.Name = &quot;btnUnderline&quot;
Me.btnUnderline.Size = New System.Drawing.Size(20, 20)
Me.btnUnderline.TabIndex = 11
'
'btnItalic
'
Me.btnItalic.BackColor = System.Drawing.Color.Silver
Me.btnItalic.ImageIndex = 3
Me.btnItalic.ImageList = Me.imlNotes
Me.btnItalic.Location = New System.Drawing.Point(230, 20)
Me.btnItalic.Name = &quot;btnItalic&quot;
Me.btnItalic.Size = New System.Drawing.Size(20, 20)
Me.btnItalic.TabIndex = 12
'
'btnNew
'
Me.btnNew.BackColor = System.Drawing.Color.Silver
Me.btnNew.ImageIndex = 4
Me.btnNew.ImageList = Me.imlNotes
Me.btnNew.Location = New System.Drawing.Point(10, 20)
Me.btnNew.Name = &quot;btnNew&quot;
Me.btnNew.Size = New System.Drawing.Size(20, 20)
Me.btnNew.TabIndex = 2
'
'btnColor
'
Me.btnColor.BackColor = System.Drawing.Color.Silver
Me.btnColor.ImageIndex = 11
Me.btnColor.ImageList = Me.imlNotes
Me.btnColor.Location = New System.Drawing.Point(250, 20)
Me.btnColor.Name = &quot;btnColor&quot;
Me.btnColor.Size = New System.Drawing.Size(20, 20)
Me.btnColor.TabIndex = 13
Me.btnColor.TextAlign = System.Drawing.ContentAlignment.TopLeft
'
'btnOpen
'
Me.btnOpen.BackColor = System.Drawing.Color.Silver
Me.btnOpen.ImageIndex = 5
Me.btnOpen.ImageList = Me.imlNotes
Me.btnOpen.Location = New System.Drawing.Point(30, 20)
Me.btnOpen.Name = &quot;btnOpen&quot;
Me.btnOpen.Size = New System.Drawing.Size(20, 20)
Me.btnOpen.TabIndex = 3
'
'btnSave
'
Me.btnSave.BackColor = System.Drawing.Color.Silver
Me.btnSave.ImageIndex = 8
Me.btnSave.ImageList = Me.imlNotes
Me.btnSave.Location = New System.Drawing.Point(50, 20)
Me.btnSave.Name = &quot;btnSave&quot;
Me.btnSave.Size = New System.Drawing.Size(20, 20)
Me.btnSave.TabIndex = 4
'
'btnPrint
'
Me.btnPrint.BackColor = System.Drawing.Color.Silver
Me.btnPrint.ImageIndex = 7
Me.btnPrint.ImageList = Me.imlNotes
Me.btnPrint.Location = New System.Drawing.Point(70, 20)
Me.btnPrint.Name = &quot;btnPrint&quot;
Me.btnPrint.Size = New System.Drawing.Size(20, 20)
Me.btnPrint.TabIndex = 5
'
'btnDelete
'
Me.btnDelete.BackColor = System.Drawing.Color.Silver
Me.btnDelete.ImageIndex = 10
Me.btnDelete.ImageList = Me.imlNotes
Me.btnDelete.Location = New System.Drawing.Point(160, 20)
Me.btnDelete.Name = &quot;btnDelete&quot;
Me.btnDelete.Size = New System.Drawing.Size(20, 20)
Me.btnDelete.TabIndex = 9
'
'btnFont
'
Me.btnFont.BackColor = System.Drawing.Color.Silver
Me.btnFont.Font = New System.Drawing.Font(&quot;Microsoft Sans Serif&quot;, 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.btnFont.Location = New System.Drawing.Point(270, 20)
Me.btnFont.Name = &quot;btnFont&quot;
Me.btnFont.Size = New System.Drawing.Size(20, 20)
Me.btnFont.TabIndex = 14
Me.btnFont.Text = &quot;F&quot;
Me.btnFont.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'ofdDN
'
Me.ofdDN.DefaultExt = &quot;rtf&quot;
Me.ofdDN.Filter = &quot;Rich Text Format|*.rtf|Text FIles|*.txt&quot;
Me.ofdDN.Title = &quot;Open Desk Note File&quot;
'
'frmDDnotes
'
Me.AllowDrop = True
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.Color.FromArgb(CType(192, Byte), CType(192, Byte), CType(255, Byte))
Me.ClientSize = New System.Drawing.Size(342, 327)
Me.ContextMenu = Me.ctnDNmain
Me.ControlBox = False
Me.Controls.Add(Me.btnFont)
Me.Controls.Add(Me.btnDelete)
Me.Controls.Add(Me.btnPrint)
Me.Controls.Add(Me.btnSave)
Me.Controls.Add(Me.btnOpen)
Me.Controls.Add(Me.btnColor)
Me.Controls.Add(Me.btnNew)
Me.Controls.Add(Me.btnItalic)
Me.Controls.Add(Me.btnUnderline)
Me.Controls.Add(Me.btnPaste)
Me.Controls.Add(Me.btnCopy)
Me.Controls.Add(Me.btnCut)
Me.Controls.Add(Me.btnBold)
Me.Controls.Add(Me.rtbNotes)
Me.Controls.Add(Me.picDot)
Me.Controls.Add(Me.lblTitle)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
Me.MaximizeBox = False
Me.MaximumSize = New System.Drawing.Size(700, 670)
Me.MinimizeBox = False
Me.MinimumSize = New System.Drawing.Size(20, 20)
Me.Name = &quot;frmDDnotes&quot;
Me.ShowInTaskbar = False
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.ResumeLayout(False)

End Sub

#End Region

#Region &quot; *** Desk Notes Variables *** &quot;

Public noteSaved, saveTheNote, onClip As Boolean
Public currentFontStyle As Int16
Public noteFile, listFile As String
Private PrintPageSettings As New PageSettings
Private StringToPrint As String
Private PrintFont As New Font(&quot;Courier New&quot;, 10, FontStyle.Regular, GraphicsUnit.Point)

Private nItem As noteItem
Private nPrefs As notePrefs

Private blnMoving As Boolean = False
Private MouseDownX As Integer
Private MouseDownY As Integer

#End Region

#Region &quot; *** All Events *** &quot;

#Region &quot; *** Button Events *** &quot;

Private Sub btnNew_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNew.Click
newNote()
End Sub

Private Sub btnOpen_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnOpen.Click
openNote()
End Sub

Private Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
saveNote()
End Sub

Private Sub btnPrint_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPrint.Click
PrintNote()
End Sub

Private Sub btnCut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCut.Click
cutText()
End Sub

Private Sub btnCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCopy.Click
copyText()
End Sub

Private Sub btnPaste_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPaste.Click
pasteText()
End Sub

Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
deleteText()
End Sub

Private Sub btnBold_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnBold.Click
setBold()
End Sub

Private Sub btnItalic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnItalic.Click
setItalic()
End Sub

Private Sub btnUnderline_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUnderline.Click
setUnderline()
End Sub

Private Sub btnColor_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnColor.Click
getColor()
End Sub

Private Sub btnFont_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFont.Click
setFont()
End Sub

#End Region

#Region &quot; *** Context Menu Events *** &quot;

#Region &quot; *** Main Menu *** &quot;

Private Sub ctmDNbar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNbar.Click
setBar()
End Sub

Private Sub ctmDNdot_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNdot.Click
setdot()
End Sub

Private Sub ctmOnTop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ctmOnTop.Click
If (ctmOnTop.Checked = False) Then
ctmOnTop.Checked = True
Me.TopMost = True
Else
ctmOnTop.Checked = False
Me.TopMost = False
End If
End Sub

Private Sub ctmDNclose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ctmDNclose.Click
closeDN()
End Sub

#Region &quot; *** File Menu *** &quot;

Private Sub ctmDNMnew_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNMnew.Click
newNote()
End Sub

Private Sub ctmDNMopen_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNMopen.Click
openNote()
End Sub

Private Sub ctmDNMsave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNMsave.Click
saveNote()
End Sub

Private Sub ctmDNMsaveas_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ctmDNMsaveas.Click
saveAsNote()
End Sub

Private Sub ctmDNMprint_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNMprint.Click
PrintNote()
End Sub

#End Region

#Region &quot; *** Edit Menu *** &quot;

Private Sub ctmDNMcut_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNMcut.Click
cutText()
End Sub

Private Sub ctmDNMcopy_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNMcopy.Click
copyText()
End Sub

Private Sub ctmDNMpaste_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNMpaste.Click
pasteText()
End Sub

Private Sub ctmDNMdelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNMdelete.Click
deleteText()
End Sub

Private Sub ctmDNMbold_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNMbold.Click
setBold()
End Sub

Private Sub ctmDNMitalics_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNMitalics.Click
setItalic()
End Sub

Private Sub ctmDNMunderline_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNMunderline.Click
setUnderline()
End Sub

Private Sub ctmDNMcolor_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNMcolor.Click
getColor()
End Sub

Private Sub ctmDNMfont_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ctmDNMfont.Click
setFont()
End Sub

#End Region

#End Region

#Region &quot; *** Pref Menus *** &quot;

Private Sub ctmDNPrefsTBC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ctmDNPrefsTBC.Click
lblTitle.BackColor = chooseColor(lblTitle.BackColor)
End Sub

Private Sub ctmDNPrefsTTC_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNPrefsTTC.Click
lblTitle.ForeColor = chooseColor(lblTitle.ForeColor)
End Sub

Private Sub ctmDNPrefsNC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ctmDNPrefsNC.Click
rtbNotes.BackColor = chooseColor(rtbNotes.BackColor)
End Sub

Private Sub ctmDNPrefsWC_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNPrefsWC.Click
Me.BackColor = chooseColor(Me.BackColor)
End Sub

Private Sub ctmDNpsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ctmDNpsave.Click
prepPrefs()
End Sub

#End Region

#Region &quot; *** Dot Colors *** &quot;

Private Sub ctmDOTDCred_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCred.Click
setDotColor(0)
End Sub

Private Sub ctmDOTDCorange_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCorange.Click
setDotColor(1)
End Sub

Private Sub ctmDOTDCYellow_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCyellow.Click
setDotColor(2)
End Sub

Private Sub ctmDOTDCgreen_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCgreen.Click
setDotColor(3)
End Sub

Private Sub ctmDOTDCdarkgreen_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCdarkgreen.Click
setDotColor(4)
End Sub

Private Sub ctmDOTDCdarkblue_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCdarkblue.Click
setDotColor(5)
End Sub

Private Sub ctmDOTDCblue_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCblue.Click
setDotColor(6)
End Sub

Private Sub ctmDOTDCltblue_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCltblue.Click
setDotColor(7)
End Sub

Private Sub ctmDOTDCviolet_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCviolet.Click
setDotColor(8)
End Sub

Private Sub ctmDOTDCdarkviolet_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCdarkviolet.Click
setDotColor(9)
End Sub

Private Sub ctmDOTDCbrown_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCbrown.Click
setDotColor(10)
End Sub

Private Sub ctmDOTDCblack_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCblack.Click
setDotColor(11)
End Sub

Private Sub ctmDOTDCdarkgrey_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCdarkgrey.Click
setDotColor(12)
End Sub

Private Sub ctmDOTDCgrey_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCgrey.Click
setDotColor(13)
End Sub

Private Sub ctmDOTDCwhite_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCwhite.Click
setDotColor(14)
End Sub

Private Sub ctmDOTDCpink_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCpink.Click
setDotColor(15)
End Sub

Private Sub ctmDOTDCgold_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCgold.Click
setDotColor(16)

End Sub

#End Region

#End Region

#Region &quot; *** Form Events *** &quot;

Private Sub frmDTDnotes_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
setStart(False)
noteFile = &quot;&quot;
isSaved()
getPrefs()
End Sub

Private Sub frmDTDnotes_Move(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Move
nPrefs.ntTop = Me.Top
nPrefs.ntLeft = Me.Left
End Sub

Private Sub FormMove_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picDot.MouseDown, lblTitle.MouseDown
If e.Button = MouseButtons.Left Then
blnMoving = True
MouseDownX = e.X
MouseDownY = e.Y
End If
End Sub

Private Sub FormMove_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picDot.MouseUp, lblTitle.MouseUp
If e.Button = MouseButtons.Left Then
blnMoving = False
End If
End Sub

Private Sub FormMove_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picDot.MouseMove, lblTitle.MouseMove
If blnMoving Then
Dim temp As Point = New Point
temp.X = Me.Location.X + (e.X - MouseDownX)
temp.Y = Me.Location.Y + (e.Y - MouseDownY)
Me.Location = temp
End If
End Sub

#End Region

#Region &quot; *** Label Events *** &quot;

Private Sub lblTitle_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lblTitle.DoubleClick
setBar()
End Sub

#End Region

#Region &quot; *** PictureBox Events *** &quot;

Private Sub picDot_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picDot.DoubleClick
closeDN()
End Sub

#End Region

#Region &quot; *** Rich Text Box Events *** &quot;

Private Sub rtbNotes_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rtbNotes.SelectionChanged
Dim setFlag As Boolean
If (rtbNotes.SelectionLength > 0) Then
setFlag = True
Else
setFlag = False
End If
setStart(setFlag)
End Sub

Private Sub rtbNotes_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rtbNotes.TextChanged
notSaved()
End Sub

#End Region

#End Region

#Region &quot; *** All Subs *** &quot;

#Region &quot; *** Main Subs *** &quot;

Public Sub setBar()
If (nItem.ntBar = False) Then
setAsBar()
Else
setNotBar()
End If
ctmDNbar.Checked = nItem.ntBar
End Sub

Public Sub setNotBar()
Me.Height = nItem.ntMaxHT
nItem.ntBar = False
End Sub

Public Sub setAsBar()
Me.FormBorderStyle = FormBorderStyle.None
Me.Height = nItem.ntMinHT
nItem.ntBar = True
End Sub

Public Sub setdot()
If (nItem.ntDot = False) Then
setAsDot()
Else
setNotDot()
End If
ctmDNdot.Checked = nItem.ntDot
End Sub

Public Sub setNotDot()
If (ctmDNbar.Checked = False) Then
setNotBar()
End If
ctmDNbar.Enabled = True
Me.Width = nItem.ntMaxWD
Me.Left -= 320
nItem.ntDot = False
lblTitle.Visible = True
End Sub

Public Sub setAsDot()
setAsBar()
ctmDNbar.Enabled = False
Me.Width = nItem.ntMinWD
Me.Left += 320
nItem.ntDot = True
lblTitle.Visible = False
End Sub

Public Sub setDotColor(ByVal iDotColor As Int16)
Dim theFile As String
theFile = imgPath & dotColor(iDotColor)
picDot.Image = System.Drawing.Image.FromFile(theFile)
nPrefs.ntDotColor = iDotColor
End Sub

Public Sub findFontValue()
currentFontStyle = 0
If (rtbNotes.SelectionFont.Bold = True) Then
currentFontStyle += 1
End If
If (rtbNotes.SelectionFont.Italic = True) Then
currentFontStyle += 2
End If
If (rtbNotes.SelectionFont.Underline = True) Then
currentFontStyle += 4
End If
End Sub

Public Sub setStart(ByVal setFlag As Boolean)
btnCut.Enabled = setFlag
ctmDNMcut.Enabled = setFlag
btnCopy.Enabled = setFlag
ctmDNMcopy.Enabled = setFlag
btnDelete.Enabled = setFlag
ctmDNMdelete.Enabled = setFlag
If (onClip = False) Then
btnPaste.Enabled = False
ctmDNMpaste.Enabled = False
Else
btnPaste.Enabled = True
ctmDNMpaste.Enabled = True
End If
End Sub

Public Sub closeDN()
checkSaved()
numNotes -= 1
Me.Hide()
End Sub

#End Region

#Region &quot; *** Pref Subs *** &quot;

Public Sub prepPrefs()
nPrefs.ntTitleBackColor = lblTitle.BackColor.ToArgb
nPrefs.ntTitleForeColor = lblTitle.ForeColor.ToArgb
nPrefs.ntNoteColor = rtbNotes.BackColor.ToArgb
nPrefs.ntWindowColor = Me.BackColor.ToArgb
savePrefs()
End Sub

Public Sub savePrefs()
Dim FN As Integer = FreeFile()
FileOpen(FN, dnFile, OpenMode.Output)
Write(FN, nPrefs.ntTitleBackColor)
Write(FN, nPrefs.ntTitleForeColor)
Write(FN, nPrefs.ntNoteColor)
Write(FN, nPrefs.ntWindowColor)
Write(FN, nPrefs.ntDotColor)
Write(FN, nPrefs.ntTop)
Write(FN, nPrefs.ntLeft)
FileClose(FN)
End Sub

Public Sub getPrefs()
Dim FN As Integer = FreeFile()
FileOpen(FN, dnFile, OpenMode.Input)
Input(FN, nPrefs.ntTitleBackColor)
Input(FN, nPrefs.ntTitleForeColor)
Input(FN, nPrefs.ntNoteColor)
Input(FN, nPrefs.ntWindowColor)
Input(FN, nPrefs.ntDotColor)
Input(FN, nPrefs.ntTop)
Input(FN, nPrefs.ntLeft)
FileClose(FN)
setPrefs()
End Sub

Public Sub setPrefs()
lblTitle.BackColor = Color.FromArgb(nPrefs.ntTitleBackColor)
lblTitle.ForeColor = Color.FromArgb(nPrefs.ntTitleForeColor)
rtbNotes.BackColor = Color.FromArgb(nPrefs.ntNoteColor)
Me.BackColor = Color.FromArgb(nPrefs.ntWindowColor)
Me.Location = New Point(nPrefs.ntLeft, nPrefs.ntTop)
setDotColor(nPrefs.ntDotColor)
End Sub

#End Region

#Region &quot; *** File Subs *** &quot;

Public Sub newNote()
checkSaved()
rtbNotes.Text = &quot;&quot;
noteFile = &quot;&quot;
notSaved()
End Sub

Public Sub openNote()
checkSaved()
If (ofdDN.ShowDialog = DialogResult.OK) Then
noteFile = ofdDN.FileName
readNote()
isSaved()
End If
End Sub

Public Sub readNote()
Try
Dim myFileStream As New FileStream(noteFile, FileMode.Open)
If noteFile.EndsWith(&quot;txt&quot;) = True Then
rtbNotes.LoadFile(myFileStream, RichTextBoxStreamType.PlainText)
Else
rtbNotes.LoadFile(myFileStream, RichTextBoxStreamType.RichText)
End If
myFileStream.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub

Public Sub checkSaved()
Dim message As String = &quot;You have not saved this note, do you wish to?&quot;
Dim title As String = &quot;Note Not Saved!&quot;
saveTheNote = False
If (noteSaved = False) Then
If (MessageBox.Show(message, title, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) = DialogResult.Yes) Then
saveTheNote = True
End If
End If
If (saveTheNote = True) Then saveNote()
End Sub

Public Sub isSaved()
noteSaved = True
getListFile()
End Sub

Public Sub notSaved()
noteSaved = False
getListFile()
lblTitle.Text += &quot;*&quot;
End Sub

Public Sub getListFile()
Dim iFound As Integer
If (noteFile = &quot;&quot;) Then
listFile = &quot;Un-named&quot;
Else
iFound = InStrRev(noteFile, &quot;\&quot;)
listFile = Mid(noteFile, iFound + 1)
End If
lblTitle.Text = &quot;Desk Note - &quot; & listFile
End Sub

Public Sub saveNote()
If (noteFile = &quot;&quot;) Then
saveAsNote()
Else
writeNote()
End If
End Sub

Public Sub saveAsNote()
If (sfdDN.ShowDialog = DialogResult.OK) Then
noteFile = sfdDN.FileName
writeNote()
getListFile()
End If
End Sub

Public Sub writeNote()
isSaved()
Try
Dim myFileStream As New FileStream(noteFile, FileMode.Open)
If noteFile.EndsWith(&quot;txt&quot;) = True Then
rtbNotes.SaveFile(myFileStream, RichTextBoxStreamType.PlainText)
Else
rtbNotes.SaveFile(myFileStream, RichTextBoxStreamType.RichText)
End If
myFileStream.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub

Public Sub PrintNote()
Try
PrintDocument1.DefaultPageSettings = PrintPageSettings
StringToPrint = rtbNotes.Text
PrintDialog1.Document = PrintDocument1
Dim result As DialogResult = PrintDialog1.ShowDialog
If result = DialogResult.OK Then
PrintDocument1.Print()
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim numChars As Integer
Dim numLines As Integer
Dim stringForPage As String
Dim strFormat As New StringFormat
Dim rectDraw As New RectangleF(e.MarginBounds.Left, e.MarginBounds.Top, e.MarginBounds.Width, e.MarginBounds.Height)
Dim sizeMeasure As New SizeF(e.MarginBounds.Width, e.MarginBounds.Height - PrintFont.GetHeight(e.Graphics))
strFormat.Trimming = StringTrimming.Word
e.Graphics.MeasureString(StringToPrint, rtbNotes.Font, sizeMeasure, strFormat, numChars, numLines)
stringForPage = StringToPrint.Substring(0, numChars)
'e.Graphics.DrawString(stringForPage, rtbNotes.Font, myBrush, rectDraw, strFormat)
If numChars < StringToPrint.Length Then
StringToPrint = StringToPrint.Substring(numChars)
e.HasMorePages = True
Else
e.HasMorePages = False
StringToPrint = rtbNotes.Text
End If
End Sub

#End Region

#Region &quot; *** Edit Subs *** &quot;

Public Sub cutText()
rtbNotes.Cut()
onClip = True
notSaved()
setStart(False)
End Sub

Public Sub copyText()
rtbNotes.Copy()
onClip = True
notSaved()
setStart(False)
End Sub

Public Sub pasteText()
rtbNotes.Paste()
notSaved()
setStart(False)
End Sub

Public Sub deleteText()
rtbNotes.Cut()
Windows.Forms.Clipboard.SetDataObject(&quot;&quot;)
onClip = False
notSaved()
setStart(False)
End Sub

Public Sub setBold()
findFontValue()
If (rtbNotes.SelectionFont.Bold = True) Then
rtbNotes.SelectionFont = New Font(rtbNotes.SelectionFont, currentFontStyle - 1)
Else
rtbNotes.SelectionFont = New Font(rtbNotes.SelectionFont, currentFontStyle + 1)
End If
notSaved()
setStart(False)
End Sub

Public Sub setItalic()
findFontValue()
If (rtbNotes.SelectionFont.Italic = True) Then
rtbNotes.SelectionFont = New Font(rtbNotes.SelectionFont, currentFontStyle - 2)
Else
rtbNotes.SelectionFont = New Font(rtbNotes.SelectionFont, currentFontStyle + 2)
End If
notSaved()
setStart(False)
End Sub

Public Sub setUnderline()
findFontValue()
If (rtbNotes.SelectionFont.Underline = True) Then
rtbNotes.SelectionFont = New Font(rtbNotes.SelectionFont, currentFontStyle - 4)
Else
rtbNotes.SelectionFont = New Font(rtbNotes.SelectionFont, currentFontStyle + 4)
End If
notSaved()
setStart(False)
End Sub

Public Sub getColor()
rtbNotes.SelectionColor = chooseColor(rtbNotes.SelectionColor)
notSaved()
setStart(False)
End Sub

Public Sub setFont()
rtbNotes.SelectionFont = chooseFont(rtbNotes.SelectionFont)
notSaved()
setStart(False)
End Sub

#End Region

#End Region

End Class
 
#Region &quot; *** Desk Notes Variables *** &quot;

Public noteSaved, saveTheNote, onClip As Boolean
Public currentFontStyle As Int16
Public noteFile, listFile As String
Private PrintPageSettings As New PageSettings
Private StringToPrint As String
Private PrintFont As New Font(&quot;Courier New&quot;, 10, FontStyle.Regular, GraphicsUnit.Point)

Private nItem As noteItem
Private nPrefs As notePrefs

Private blnMoving As Boolean = False
Private MouseDownX As Integer
Private MouseDownY As Integer

#End Region

#Region &quot; *** All Events *** &quot;

#Region &quot; *** Button Events *** &quot;

Private Sub btnNew_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNew.Click
newNote()
End Sub

Private Sub btnOpen_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnOpen.Click
openNote()
End Sub

Private Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
saveNote()
End Sub

Private Sub btnPrint_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPrint.Click
PrintNote()
End Sub

Private Sub btnCut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCut.Click
cutText()
End Sub

Private Sub btnCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCopy.Click
copyText()
End Sub

Private Sub btnPaste_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPaste.Click
pasteText()
End Sub

Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
deleteText()
End Sub

Private Sub btnBold_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnBold.Click
setBold()
End Sub

Private Sub btnItalic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnItalic.Click
setItalic()
End Sub

Private Sub btnUnderline_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUnderline.Click
setUnderline()
End Sub

Private Sub btnColor_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnColor.Click
getColor()
End Sub

Private Sub btnFont_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFont.Click
setFont()
End Sub

#End Region

#Region &quot; *** Context Menu Events *** &quot;

#Region &quot; *** Main Menu *** &quot;

Private Sub ctmDNbar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNbar.Click
setBar()
End Sub

Private Sub ctmDNdot_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNdot.Click
setdot()
End Sub

Private Sub ctmOnTop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ctmOnTop.Click
If (ctmOnTop.Checked = False) Then
ctmOnTop.Checked = True
Me.TopMost = True
Else
ctmOnTop.Checked = False
Me.TopMost = False
End If
End Sub

Private Sub ctmDNclose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ctmDNclose.Click
closeDN()
End Sub

#Region &quot; *** File Menu *** &quot;

Private Sub ctmDNMnew_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNMnew.Click
newNote()
End Sub

Private Sub ctmDNMopen_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNMopen.Click
openNote()
End Sub

Private Sub ctmDNMsave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNMsave.Click
saveNote()
End Sub

Private Sub ctmDNMsaveas_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ctmDNMsaveas.Click
saveAsNote()
End Sub

Private Sub ctmDNMprint_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNMprint.Click
PrintNote()
End Sub

#End Region

#Region &quot; *** Edit Menu *** &quot;

Private Sub ctmDNMcut_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNMcut.Click
cutText()
End Sub

Private Sub ctmDNMcopy_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNMcopy.Click
copyText()
End Sub

Private Sub ctmDNMpaste_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNMpaste.Click
pasteText()
End Sub

Private Sub ctmDNMdelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNMdelete.Click
deleteText()
End Sub

Private Sub ctmDNMbold_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNMbold.Click
setBold()
End Sub

Private Sub ctmDNMitalics_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNMitalics.Click
setItalic()
End Sub

Private Sub ctmDNMunderline_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNMunderline.Click
setUnderline()
End Sub

Private Sub ctmDNMcolor_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNMcolor.Click
getColor()
End Sub

Private Sub ctmDNMfont_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ctmDNMfont.Click
setFont()
End Sub

#End Region

#End Region

#Region &quot; *** Pref Menus *** &quot;

Private Sub ctmDNPrefsTBC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ctmDNPrefsTBC.Click
lblTitle.BackColor = chooseColor(lblTitle.BackColor)
End Sub

Private Sub ctmDNPrefsTTC_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNPrefsTTC.Click
lblTitle.ForeColor = chooseColor(lblTitle.ForeColor)
End Sub

Private Sub ctmDNPrefsNC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ctmDNPrefsNC.Click
rtbNotes.BackColor = chooseColor(rtbNotes.BackColor)
End Sub

Private Sub ctmDNPrefsWC_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDNPrefsWC.Click
Me.BackColor = chooseColor(Me.BackColor)
End Sub

Private Sub ctmDNpsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ctmDNpsave.Click
prepPrefs()
End Sub

#End Region

#Region &quot; *** Dot Colors *** &quot;

Private Sub ctmDOTDCred_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCred.Click
setDotColor(0)
End Sub

Private Sub ctmDOTDCorange_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCorange.Click
setDotColor(1)
End Sub

Private Sub ctmDOTDCYellow_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCyellow.Click
setDotColor(2)
End Sub

Private Sub ctmDOTDCgreen_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCgreen.Click
setDotColor(3)
End Sub

Private Sub ctmDOTDCdarkgreen_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCdarkgreen.Click
setDotColor(4)
End Sub

Private Sub ctmDOTDCdarkblue_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCdarkblue.Click
setDotColor(5)
End Sub

Private Sub ctmDOTDCblue_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCblue.Click
setDotColor(6)
End Sub

Private Sub ctmDOTDCltblue_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCltblue.Click
setDotColor(7)
End Sub

Private Sub ctmDOTDCviolet_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCviolet.Click
setDotColor(8)
End Sub

Private Sub ctmDOTDCdarkviolet_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCdarkviolet.Click
setDotColor(9)
End Sub

Private Sub ctmDOTDCbrown_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCbrown.Click
setDotColor(10)
End Sub

Private Sub ctmDOTDCblack_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCblack.Click
setDotColor(11)
End Sub

Private Sub ctmDOTDCdarkgrey_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCdarkgrey.Click
setDotColor(12)
End Sub

Private Sub ctmDOTDCgrey_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCgrey.Click
setDotColor(13)
End Sub

Private Sub ctmDOTDCwhite_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCwhite.Click
setDotColor(14)
End Sub

Private Sub ctmDOTDCpink_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCpink.Click
setDotColor(15)
End Sub

Private Sub ctmDOTDCgold_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctmDOTDCgold.Click
setDotColor(16)

End Sub

#End Region

#End Region

#Region &quot; *** Form Events *** &quot;

Private Sub frmDTDnotes_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
setStart(False)
noteFile = &quot;&quot;
isSaved()
getPrefs()
End Sub

Private Sub frmDTDnotes_Move(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Move
nPrefs.ntTop = Me.Top
nPrefs.ntLeft = Me.Left
End Sub

Private Sub FormMove_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picDot.MouseDown, lblTitle.MouseDown
If e.Button = MouseButtons.Left Then
blnMoving = True
MouseDownX = e.X
MouseDownY = e.Y
End If
End Sub

Private Sub FormMove_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picDot.MouseUp, lblTitle.MouseUp
If e.Button = MouseButtons.Left Then
blnMoving = False
End If
End Sub

Private Sub FormMove_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picDot.MouseMove, lblTitle.MouseMove
If blnMoving Then
Dim temp As Point = New Point
temp.X = Me.Location.X + (e.X - MouseDownX)
temp.Y = Me.Location.Y + (e.Y - MouseDownY)
Me.Location = temp
End If
End Sub

#End Region

#Region &quot; *** Label Events *** &quot;

Private Sub lblTitle_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lblTitle.DoubleClick
setBar()
End Sub

#End Region

#Region &quot; *** PictureBox Events *** &quot;

Private Sub picDot_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picDot.DoubleClick
closeDN()
End Sub

#End Region

#Region &quot; *** Rich Text Box Events *** &quot;

Private Sub rtbNotes_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rtbNotes.SelectionChanged
Dim setFlag As Boolean
If (rtbNotes.SelectionLength > 0) Then
setFlag = True
Else
setFlag = False
End If
setStart(setFlag)
End Sub

Private Sub rtbNotes_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rtbNotes.TextChanged
notSaved()
End Sub

#End Region

#End Region

#Region &quot; *** All Subs *** &quot;

#Region &quot; *** Main Subs *** &quot;

Public Sub setBar()
If (nItem.ntBar = False) Then
setAsBar()
Else
setNotBar()
End If
ctmDNbar.Checked = nItem.ntBar
End Sub

Public Sub setNotBar()
Me.Height = nItem.ntMaxHT
nItem.ntBar = False
End Sub

Public Sub setAsBar()
Me.FormBorderStyle = FormBorderStyle.None
Me.Height = nItem.ntMinHT
nItem.ntBar = True
End Sub

Public Sub setdot()
If (nItem.ntDot = False) Then
setAsDot()
Else
setNotDot()
End If
ctmDNdot.Checked = nItem.ntDot
End Sub

Public Sub setNotDot()
If (ctmDNbar.Checked = False) Then
setNotBar()
End If
ctmDNbar.Enabled = True
Me.Width = nItem.ntMaxWD
Me.Left -= 320
nItem.ntDot = False
lblTitle.Visible = True
End Sub

Public Sub setAsDot()
setAsBar()
ctmDNbar.Enabled = False
Me.Width = nItem.ntMinWD
Me.Left += 320
nItem.ntDot = True
lblTitle.Visible = False
End Sub

Public Sub setDotColor(ByVal iDotColor As Int16)
Dim theFile As String
theFile = imgPath & dotColor(iDotColor)
picDot.Image = System.Drawing.Image.FromFile(theFile)
nPrefs.ntDotColor = iDotColor
End Sub

Public Sub findFontValue()
currentFontStyle = 0
If (rtbNotes.SelectionFont.Bold = True) Then
currentFontStyle += 1
End If
If (rtbNotes.SelectionFont.Italic = True) Then
currentFontStyle += 2
End If
If (rtbNotes.SelectionFont.Underline = True) Then
currentFontStyle += 4
End If
End Sub

Public Sub setStart(ByVal setFlag As Boolean)
btnCut.Enabled = setFlag
ctmDNMcut.Enabled = setFlag
btnCopy.Enabled = setFlag
ctmDNMcopy.Enabled = setFlag
btnDelete.Enabled = setFlag
ctmDNMdelete.Enabled = setFlag
If (onClip = False) Then
btnPaste.Enabled = False
ctmDNMpaste.Enabled = False
Else
btnPaste.Enabled = True
ctmDNMpaste.Enabled = True
End If
End Sub

Public Sub closeDN()
checkSaved()
numNotes -= 1
Me.Hide()
End Sub

#End Region

#Region &quot; *** Pref Subs *** &quot;

Public Sub prepPrefs()
nPrefs.ntTitleBackColor = lblTitle.BackColor.ToArgb
nPrefs.ntTitleForeColor = lblTitle.ForeColor.ToArgb
nPrefs.ntNoteColor = rtbNotes.BackColor.ToArgb
nPrefs.ntWindowColor = Me.BackColor.ToArgb
savePrefs()
End Sub

Public Sub savePrefs()
Dim FN As Integer = FreeFile()
FileOpen(FN, dnFile, OpenMode.Output)
Write(FN, nPrefs.ntTitleBackColor)
Write(FN, nPrefs.ntTitleForeColor)
Write(FN, nPrefs.ntNoteColor)
Write(FN, nPrefs.ntWindowColor)
Write(FN, nPrefs.ntDotColor)
Write(FN, nPrefs.ntTop)
Write(FN, nPrefs.ntLeft)
FileClose(FN)
End Sub

Public Sub getPrefs()
Dim FN As Integer = FreeFile()
FileOpen(FN, dnFile, OpenMode.Input)
Input(FN, nPrefs.ntTitleBackColor)
Input(FN, nPrefs.ntTitleForeColor)
Input(FN, nPrefs.ntNoteColor)
Input(FN, nPrefs.ntWindowColor)
Input(FN, nPrefs.ntDotColor)
Input(FN, nPrefs.ntTop)
Input(FN, nPrefs.ntLeft)
FileClose(FN)
setPrefs()
End Sub

Public Sub setPrefs()
lblTitle.BackColor = Color.FromArgb(nPrefs.ntTitleBackColor)
lblTitle.ForeColor = Color.FromArgb(nPrefs.ntTitleForeColor)
rtbNotes.BackColor = Color.FromArgb(nPrefs.ntNoteColor)
Me.BackColor = Color.FromArgb(nPrefs.ntWindowColor)
Me.Location = New Point(nPrefs.ntLeft, nPrefs.ntTop)
setDotColor(nPrefs.ntDotColor)
End Sub

#End Region

#Region &quot; *** File Subs *** &quot;

Public Sub newNote()
checkSaved()
rtbNotes.Text = &quot;&quot;
noteFile = &quot;&quot;
notSaved()
End Sub

Public Sub openNote()
checkSaved()
If (ofdDN.ShowDialog = DialogResult.OK) Then
noteFile = ofdDN.FileName
readNote()
isSaved()
End If
End Sub

Public Sub readNote()
Try
Dim myFileStream As New FileStream(noteFile, FileMode.Open)
If noteFile.EndsWith(&quot;txt&quot;) = True Then
rtbNotes.LoadFile(myFileStream, RichTextBoxStreamType.PlainText)
Else
rtbNotes.LoadFile(myFileStream, RichTextBoxStreamType.RichText)
End If
myFileStream.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub

Public Sub checkSaved()
Dim message As String = &quot;You have not saved this note, do you wish to?&quot;
Dim title As String = &quot;Note Not Saved!&quot;
saveTheNote = False
If (noteSaved = False) Then
If (MessageBox.Show(message, title, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) = DialogResult.Yes) Then
saveTheNote = True
End If
End If
If (saveTheNote = True) Then saveNote()
End Sub

Public Sub isSaved()
noteSaved = True
getListFile()
End Sub

Public Sub notSaved()
noteSaved = False
getListFile()
lblTitle.Text += &quot;*&quot;
End Sub

Public Sub getListFile()
Dim iFound As Integer
If (noteFile = &quot;&quot;) Then
listFile = &quot;Un-named&quot;
Else
iFound = InStrRev(noteFile, &quot;\&quot;)
listFile = Mid(noteFile, iFound + 1)
End If
lblTitle.Text = &quot;Desk Note - &quot; & listFile
End Sub

Public Sub saveNote()
If (noteFile = &quot;&quot;) Then
saveAsNote()
Else
writeNote()
End If
End Sub

Public Sub saveAsNote()
If (sfdDN.ShowDialog = DialogResult.OK) Then
noteFile = sfdDN.FileName
writeNote()
getListFile()
End If
End Sub

Public Sub writeNote()
isSaved()
Try
Dim myFileStream As New FileStream(noteFile, FileMode.Open)
If noteFile.EndsWith(&quot;txt&quot;) = True Then
rtbNotes.SaveFile(myFileStream, RichTextBoxStreamType.PlainText)
Else
rtbNotes.SaveFile(myFileStream, RichTextBoxStreamType.RichText)
End If
myFileStream.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub

Public Sub PrintNote()
Try
PrintDocument1.DefaultPageSettings = PrintPageSettings
StringToPrint = rtbNotes.Text
PrintDialog1.Document = PrintDocument1
Dim result As DialogResult = PrintDialog1.ShowDialog
If result = DialogResult.OK Then
PrintDocument1.Print()
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim numChars As Integer
Dim numLines As Integer
Dim stringForPage As String
Dim strFormat As New StringFormat
Dim rectDraw As New RectangleF(e.MarginBounds.Left, e.MarginBounds.Top, e.MarginBounds.Width, e.MarginBounds.Height)
Dim sizeMeasure As New SizeF(e.MarginBounds.Width, e.MarginBounds.Height - PrintFont.GetHeight(e.Graphics))
strFormat.Trimming = StringTrimming.Word
e.Graphics.MeasureString(StringToPrint, rtbNotes.Font, sizeMeasure, strFormat, numChars, numLines)
stringForPage = StringToPrint.Substring(0, numChars)
'e.Graphics.DrawString(stringForPage, rtbNotes.Font, myBrush, rectDraw, strFormat)
If numChars < StringToPrint.Length Then
StringToPrint = StringToPrint.Substring(numChars)
e.HasMorePages = True
Else
e.HasMorePages = False
StringToPrint = rtbNotes.Text
End If
End Sub

#End Region

#Region &quot; *** Edit Subs *** &quot;

Public Sub cutText()
rtbNotes.Cut()
onClip = True
notSaved()
setStart(False)
End Sub

Public Sub copyText()
rtbNotes.Copy()
onClip = True
notSaved()
setStart(False)
End Sub

Public Sub pasteText()
rtbNotes.Paste()
notSaved()
setStart(False)
End Sub

Public Sub deleteText()
rtbNotes.Cut()
Windows.Forms.Clipboard.SetDataObject(&quot;&quot;)
onClip = False
notSaved()
setStart(False)
End Sub

Public Sub setBold()
findFontValue()
If (rtbNotes.SelectionFont.Bold = True) Then
rtbNotes.SelectionFont = New Font(rtbNotes.SelectionFont, currentFontStyle - 1)
Else
rtbNotes.SelectionFont = New Font(rtbNotes.SelectionFont, currentFontStyle + 1)
End If
notSaved()
setStart(False)
End Sub

Public Sub setItalic()
findFontValue()
If (rtbNotes.SelectionFont.Italic = True) Then
rtbNotes.SelectionFont = New Font(rtbNotes.SelectionFont, currentFontStyle - 2)
Else
rtbNotes.SelectionFont = New Font(rtbNotes.SelectionFont, currentFontStyle + 2)
End If
notSaved()
setStart(False)
End Sub

Public Sub setUnderline()
findFontValue()
If (rtbNotes.SelectionFont.Underline = True) Then
rtbNotes.SelectionFont = New Font(rtbNotes.SelectionFont, currentFontStyle - 4)
Else
rtbNotes.SelectionFont = New Font(rtbNotes.SelectionFont, currentFontStyle + 4)
End If
notSaved()
setStart(False)
End Sub

Public Sub getColor()
rtbNotes.SelectionColor = chooseColor(rtbNotes.SelectionColor)
notSaved()
setStart(False)
End Sub

Public Sub setFont()
rtbNotes.SelectionFont = chooseFont(rtbNotes.SelectionFont)
notSaved()
setStart(False)
End Sub

#End Region

#End Region

End Class
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top