Public Class Form1
Private statusBar As C1StatusBar
Private _percents As Integer() = New Integer() {10, 20, 30, 40, 50, 60,
70, 80, 90, 100, 120, 150,
200, 250, 300, 400, 700, 1000}
Public Sub New()
InitializeComponent()
'Add Status Bar to the Ribbon Control
AddStatusBar(Me)
End Sub
Public Sub AddStatusBar(form1 As Form1)
' Create and Add a Status Bar
statusBar = New C1StatusBar()
statusBar.Width = 150
' Create button to show the percentage value
Dim zoomButton As New RibbonButton(Nothing, Image.FromFile("images\zoomButton.png"))
Dim wordcountLabel As New RibbonLabel()
wordcountLabel.Text = "0 words"
Dim charcountLabel As New RibbonLabel()
charcountLabel.Text = "0 chars"
' Add TextChanged event handler
AddHandler RichTextBox1.TextChanged, AddressOf RichTextBox1_TextChanged
' Create a Ribbon Track Bar
Dim zoomTrackBar As New RibbonTrackBar()
zoomTrackBar.Minimum = 0
zoomTrackBar.Maximum = 17
zoomTrackBar.StepFrequency = 1
' Add Event Handler
AddHandler zoomTrackBar.ValueChanged, AddressOf ZoomTrackBar1_ValueChanged
' Add items to the right and left panels
statusBar.RightPaneItems.Add(zoomTrackBar)
statusBar.RightPaneItems.Add(New RibbonLabel("10%"))
statusBar.LeftPaneItems.Add(wordcountLabel)
statusBar.LeftPaneItems.Add(charcountLabel)
' Add Status Bar to the Main Form
Me.Controls.Add(statusBar)
End Sub
Private Sub ZoomTrackBar1_ValueChanged(sender As Object, e As EventArgs)
Dim zoomBar As RibbonTrackBar = DirectCast(sender, RibbonTrackBar)
Dim index = zoomBar.Value
Dim zf As Integer = _percents(index)
Dim zoomLabel = DirectCast(statusBar.RightPaneItems(1), RibbonLabel)
zoomLabel.Text = zf.ToString() & "%"
Me.RichTextBox1.ZoomFactor = zf / 100.0F
End Sub
Private Sub RichTextBox1_TextChanged(sender As Object, e As EventArgs)
Dim charcountLabel As RibbonLabel = DirectCast(statusBar.LeftPaneItems(0), RibbonLabel)
Dim wordcountLabel As RibbonLabel = DirectCast(statusBar.LeftPaneItems(1), RibbonLabel)
charcountLabel.Text = RichTextBox1.TextLength.ToString() & " chars"
wordcountLabel.Text = RichTextBox1.Text.Split(New Char() {" "c}, StringSplitOptions.RemoveEmptyEntries).Length.ToString() & " words"
End Sub
End Class