/// <summary>
/// Represents the extension class for SfRichTextBoxAdv.
/// </summary>
public class SfRichTextBoxAdvExtension : SfRichTextBoxAdv
{
#region Fields
ScrollBar verticalScrollBar;
ScrollBar horizontalScrollBar;
#endregion
#region Properties
/// <summary>
/// Gets or sets the verical scrollbar value.
/// </summary>
public double VScrollValue
{
get
{
if (verticalScrollBar != null)
return verticalScrollBar.Value;
return 0;
}
set
{
if (verticalScrollBar != null)
verticalScrollBar.Value = value;
}
}
/// <summary>
/// Gets or sets the horizontal scrollbar value.
/// </summary>
public double HScrollValue
{
get
{
if (horizontalScrollBar != null)
return horizontalScrollBar.Value;
return 0;
}
set
{
if (horizontalScrollBar != null)
horizontalScrollBar.Value = value;
}
}
/// <summary>
/// Gets the vertical scroll bar maximum value.
/// </summary>
public double VScrollMaxValue
{
get
{
if (verticalScrollBar != null)
return verticalScrollBar.Maximum;
return 0;
}
}
/// <summary>
/// Gets the horizontal scroll bar maximum value.
/// </summary>
public double HScrollMaxvalue
{
get
{
if (horizontalScrollBar != null)
return horizontalScrollBar.Maximum;
return 0;
}
}
#endregion
#region Constructor
/// <summary>
/// Initializes the instance of SfRichTextBoxAdvExtension class.
/// </summary>
public SfRichTextBoxAdvExtension()
{
// Wires the Loaded event.
this.Loaded += SfRichTextBoxAdvExtension_Loaded;
}
#endregion
#region Events
/// <summary>
/// Called when SfRichTextBoxAdv is loaded.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SfRichTextBoxAdvExtension_Loaded(object sender, RoutedEventArgs e)
{
verticalScrollBar = GetTemplateChild("VerticalScrollBar") as ScrollBar;
horizontalScrollBar = GetTemplateChild("HorizontalScrollBar") as ScrollBar;
}
#endregion
#region Implementation
/// <summary>
/// Do the vertical scroll.
/// </summary>
/// <param name="deltaValue"></param>
public void DoVerticalScroll(double deltaValue)
{
if (deltaValue != 0 && verticalScrollBar != null)
{
double previousValue = VScrollValue;
if (previousValue + deltaValue <= VScrollMaxValue)
VScrollValue = previousValue + deltaValue;
else
VScrollValue = VScrollMaxValue;
}
}
/// <summary>
/// Do the horizontal scroll
/// </summary>
/// <param name="deltaValue"></param>
public void DoHorizontalScroll(double deltaValue)
{
if (deltaValue != 0 && horizontalScrollBar != null)
{
double previousValue = HScrollValue;
if (previousValue + deltaValue <= HScrollMaxvalue)
HScrollValue = previousValue + deltaValue;
else
HScrollValue = HScrollMaxvalue;
}
}
/// <summary>
/// Disposes the instance.
/// </summary>
public void Dispose()
{
verticalScrollBar = null;
horizontalScrollBar = null;
this.Loaded -= SfRichTextBoxAdvExtension_Loaded;
base.Dispose();
}
#endregion
} |