Mini Kabibi Habibi
Imports Microsoft.VisualBasic
Imports System
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Media
Imports DevExpress.Xpf.Bars
Imports DevExpress.Xpf.Editors
Imports DevExpress.Xpf.Editors.Settings
Imports System.Windows.Markup
Imports DevExpress.Xpf.Core
Imports DevExpress.Xpf
Namespace BarsDemo
Partial Public Class SimplePad
Inherits BarsDemoModule
Public Sub New()
InitializeComponent()
End Sub
Protected Overrides Sub OnLoaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
MyBase.OnLoaded(sender, e)
AddHandler Me.richControl.SelectionChanged, AddressOf OnRichEditControlSelectionChanged
CType(eFontSize.EditSettings, ComboBoxEditSettings).ItemsSource = (New FontSizes()).Items
If (Not Me.IsInDesignTool()) Then
Me.richControl.Focus()
End If
OnRichEditControlSelectionChanged(richControl, New EventArgs())
UpdateUndoRemoBarItems()
End Sub
Protected Overrides Sub OnUnloaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
RemoveHandler Me.richControl.SelectionChanged, AddressOf OnRichEditControlSelectionChanged
MyBase.OnUnloaded(sender, e)
End Sub
Protected Overridable Sub OnRichEditControlSelectionChanged(ByVal sender As Object, ByVal e As EventArgs)
Me.isUpdatingProccess = True
Me.eFontFamily.EditValue = Me.richControl.TextFontFamily
Me.eFontSize.EditValue = Me.richControl.TextFontSize
Dim textAlignment As TextAlignment = Me.richControl.GetTextAlignment()
Me.bLeft.IsChecked = textAlignment = TextAlignment.Left
Me.bCenter.IsChecked = textAlignment = TextAlignment.Center
Me.bRight.IsChecked = textAlignment = TextAlignment.Right
Me.bBold.IsChecked = Me.richControl.TextIsBold
Me.bItalic.IsChecked = Me.richControl.TextIsItalic
Me.bUnderline.IsChecked = Me.richControl.TextIsUnderline
Me.isUpdatingProccess = False
UpdateUndoRemoBarItems()
End Sub
Protected Overridable Sub bPrint_ItemClick(ByVal sender As Object, ByVal e As ItemClickEventArgs)
Me.richControl.Print()
End Sub
Protected Overridable Sub bUndo_ItemClick(ByVal sender As Object, ByVal e As ItemClickEventArgs)
Me.richControl.Undo()
UpdateUndoRemoBarItems()
End Sub
Protected Overridable Sub bRedo_ItemClick(ByVal sender As Object, ByVal e As ItemClickEventArgs)
Me.richControl.Redo()
UpdateUndoRemoBarItems()
End Sub
Protected Overridable Sub UpdateUndoRemoBarItems()
Me.bUndo.IsEnabled = Me.richControl.CanUndo
Me.bRedo.IsEnabled = Me.richControl.CanRedo
End Sub
Protected Overridable Sub bCut_ItemClick(ByVal sender As Object, ByVal e As ItemClickEventArgs)
Me.richControl.Cut()
End Sub
Protected Overridable Sub bCopy_ItemClick(ByVal sender As Object, ByVal e As ItemClickEventArgs)
Me.richControl.Copy()
End Sub
Protected Overridable Sub bPaste_ItemClick(ByVal sender As Object, ByVal e As ItemClickEventArgs)
Me.richControl.Paste()
End Sub
Protected Overridable Sub bClear_ItemClick(ByVal sender As Object, ByVal e As ItemClickEventArgs)
Me.richControl.Clear()
End Sub
Protected Overridable Sub bSelectAll_ItemClick(ByVal sender As Object, ByVal e As ItemClickEventArgs)
Me.richControl.SelectAll()
End Sub
Protected Overridable Sub bHome_ItemClick(ByVal sender As Object, ByVal e As ItemClickEventArgs)
System.Diagnostics.Process.Start("http://www.devexpress.com")
End Sub
Protected Overridable Sub bNew_ItemClick(ByVal sender As Object, ByVal e As EventArgs)
Me.richControl.Clear()
End Sub
Protected Overridable Sub bClose_ItemClick(ByVal sender As Object, ByVal e As EventArgs)
Me.richControl.Clear()
End Sub
Protected Overridable Sub eFontFamily_EditValueChanged(ByVal sender As Object, ByVal e As EventArgs)
If Me.isUpdatingProccess Then
Return
End If
Me.richControl.TextFontFamily = Me.eFontFamily.EditValue
Me.richControl.Focus()
End Sub
Protected Overridable Sub eFontSize_EditValueChanged(ByVal sender As Object, ByVal e As EventArgs)
If Me.isUpdatingProccess Then
Return
End If
Me.richControl.TextFontSize = Me.eFontSize.EditValue
Me.richControl.Focus()
End Sub
Protected Overridable Sub bFontColor_ItemClick(ByVal sender As Object, ByVal e As EventArgs)
Me.richControl.TextColor = SelectedColor
End Sub
Protected Overridable Sub fontColorChooser_ColorChanged(ByVal sender As Object, ByVal e As EventArgs)
SelectedColor = (CType(sender, ColorChooser)).Color
Me.richControl.Focus()
End Sub
Protected Overridable Sub bLeft_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
If Me.isUpdatingProccess OrElse Me.richControl Is Nothing Then
Return
End If
If CBool(Me.bLeft.IsChecked) Then
Me.richControl.ToggleTextAlignmentLeft()
End If
End Sub
Protected Overridable Sub bCenter_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
If Me.isUpdatingProccess OrElse Me.richControl Is Nothing Then
Return
End If
If CBool(Me.bCenter.IsChecked) Then
Me.richControl.ToggleTextAlignmentCenter()
End If
End Sub
Protected Overridable Sub bRight_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
If Me.isUpdatingProccess OrElse Me.richControl Is Nothing Then
Return
End If
If CBool(Me.bRight.IsChecked) Then
Me.richControl.ToggleTextAlignmentRight()
End If
End Sub
Protected Overridable Sub bBold_ItemClick(ByVal sender As Object, ByVal e As EventArgs)
If Me.isUpdatingProccess Then
Return
End If
Me.richControl.TextIsBold = CBool(Me.bBold.IsChecked)
End Sub
Protected Overridable Sub bItalic_ItemClick(ByVal sender As Object, ByVal e As EventArgs)
If Me.isUpdatingProccess Then
Return
End If
Me.richControl.TextIsItalic = CBool(Me.bItalic.IsChecked)
End Sub
Protected Overridable Sub bUnderline_ItemClick(ByVal sender As Object, ByVal e As EventArgs)
If Me.isUpdatingProccess Then
Return
End If
Me.richControl.TextIsUnderline = CBool(Me.bUnderline.IsChecked)
End Sub
Private selectedColor_Renamed As Color = Colors.Black
Private Property SelectedColor() As Color
Get
Return Me.selectedColor_Renamed
End Get
Set(ByVal value As Color)
Me.selectedColor_Renamed = value
If Me.richControl IsNot Nothing Then
Me.richControl.TextColor = value
End If
End Set
End Property
Private isUpdatingProccess As Boolean = False
Private Sub bAbout_ItemClick(ByVal sender As Object, ByVal e As ItemClickEventArgs)
Dim platformName As String = "WPF"
Dim ati As New AboutToolInfo()
ati.LicenseState = LicenseState.Licensed
ati.ProductDescriptionLine1 = "A demo application that demonstrates the Toolbar and Menu system providing commands for a simple text editor."
ati.ProductDescriptionLine2 = "In this demo, the DevExpress Toolbar and Menu library is used to implement text editing commands in a simple text editor."
ati.ProductDescriptionLine3 = "Practice using bar commands to control the appearance of the editor's text. To learn more about DevExpress visit:"
ati.ProductEULA = "DevExpress"
ati.ProductEULAUri = "http://www.devexpress.com/"
ati.ProductName = "DXBars for " & platformName
ati.Version = AssemblyInfo.MarketingVersion
Dim tAbout As DevExpress.Xpf.ToolAbout = New ToolAbout(ati)
Dim aWindow As New AboutWindow()
aWindow.Content = tAbout
aWindow.ShowDialog()
End Sub
End Class
Public Class FontSizes
Public ReadOnly Property Items() As Integer?()
Get
Return New Integer?() { Nothing, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 88, 96, 104, 112, 120, 128, 136, 144 }
End Get
End Property
End Class
Public Class TextExtension
Inherits MarkupExtension
Private privateText As String
Public Property Text() As String
Get
Return privateText
End Get
Set(ByVal value As String)
privateText = value
End Set
End Property
Public Sub New()
End Sub
Public Sub New(ByVal value As String)
Text = value
End Sub
Public Overrides Function ProvideValue(ByVal serviceProvider As IServiceProvider) As Object
Return Text
End Function
End Class
End Namespace