Friday, October 30, 2009

RichTextBox - Bold

So I have been working on creating letter editor. I started with a richtextbox then I extended it to inculde some standard functions that I think should have been in there from the start.

for example I added a public property for bold which overrides the default read-only bold property, allowing you to set a value

I'll inculde the code for that ...



Public Property Bold() As Boolean
Get
Return MyBase.SelectionFont.Bold
End Get
Set(ByVal value As Boolean)
Dim TempFont As Font
If value = True Then
If MyBase.SelectionFont.Italic = True Then
If MyBase.SelectionFont.Underline = True Then
If MyBase.SelectionFont.Strikeout = True Then
TempFont = New Font(MyBase.SelectionFont, FontStyle.Bold Or FontStyle.Italic Or FontStyle.Underline Or FontStyle.Strikeout)
Else
TempFont = New Font(MyBase.SelectionFont, FontStyle.Bold Or FontStyle.Italic Or FontStyle.Underline)
End If
Else
If MyBase.SelectionFont.Strikeout = True Then
TempFont = New Font(MyBase.SelectionFont, FontStyle.Bold Or FontStyle.Italic Or FontStyle.Strikeout)
Else
TempFont = New Font(MyBase.SelectionFont, FontStyle.Bold Or FontStyle.Italic)
End If
End If
Else
If MyBase.SelectionFont.Underline = True Then
If MyBase.SelectionFont.Strikeout = True Then
TempFont = New Font(MyBase.SelectionFont, FontStyle.Bold Or FontStyle.Underline Or FontStyle.Strikeout)
Else
TempFont = New Font(MyBase.SelectionFont, FontStyle.Bold Or FontStyle.Underline)
End If
Else
If MyBase.SelectionFont.Strikeout = True Then
TempFont = New Font(MyBase.SelectionFont, FontStyle.Bold Or FontStyle.Strikeout)
Else
TempFont = New Font(MyBase.SelectionFont, FontStyle.Bold)
End If
End If
End If
Else
If MyBase.SelectionFont.Italic = True Then
If MyBase.SelectionFont.Underline = True Then
If MyBase.SelectionFont.Strikeout = True Then
TempFont = New Font(MyBase.SelectionFont, FontStyle.Italic Or FontStyle.Underline Or FontStyle.Strikeout)
Else
TempFont = New Font(MyBase.SelectionFont, FontStyle.Italic Or FontStyle.Underline)
End If
Else
If MyBase.SelectionFont.Strikeout = True Then
TempFont = New Font(MyBase.SelectionFont, FontStyle.Italic Or FontStyle.Strikeout)
Else
TempFont = New Font(MyBase.SelectionFont, FontStyle.Italic)
End If
End If
Else
If MyBase.SelectionFont.Underline = True Then
If MyBase.SelectionFont.Strikeout = True Then
TempFont = New Font(MyBase.SelectionFont, FontStyle.Underline Or FontStyle.Strikeout)
Else
TempFont = New Font(MyBase.SelectionFont, FontStyle.Underline)
End If
Else
If MyBase.SelectionFont.Strikeout = True Then
TempFont = New Font(MyBase.SelectionFont, FontStyle.Strikeout)
Else
TempFont = New Font(MyBase.SelectionFont, FontStyle.Regular)
End If
End If
End If
End If

MyBase.SelectionFont = TempFont
End Set
End Property

Thursday, October 29, 2009

Click Once - Start With Windows

So we use a clickonce application because I never get anything right the first time ...

This is great kinda ...

Click Once lets me send a email with a url out to all the guys .. all they have to do is click on the install button on the web page, next thing you know they have everything installed and everyone is happy.

The best thing about click once, at least in my mind, is all i have to do to update the project is click the publish button in VS. From there it updates the manfest file and publishes everything to the web page. The project checks for updates everytime it starts, installs them and launchs the application in one quick click on of the mouse.

Click once has its bummers ... starting up with windows is a big one. I've read all the other blogs and articles about starting with windows, I couldn't really find any that used my approach. It does still have its problem but its not a big one (atleast I don't think so ... more on that later)

So there isn't any way in the framework to add start with windows options, but thats not that big of deal, what I do is add a entry to the registry to start with windows. Here is the code for that:

Private Sub AddToStartUp()

Dim regKey As RegistryKey
regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
regKey.SetValue("ePick List", Application.ExecutablePath)
regKey.Close()

End Sub



Now this works most of the time, sometimes it has issues right after an update, but if you don't update that offten you probably won't have an issue. Everyone else likes to complain about uninstall, I know its not the best solution for that but its better then coping the icon to the startup folder. When you uninstall this application it leaves the registry entry there, but since the application isn't there ... nothing happens