mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-27 15:44:00 +08:00
removed lazy evaluation of the ScrollViewer property.
This commit is contained in:
parent
66ba1c5ccf
commit
f7b3fa522c
@ -39,12 +39,10 @@ namespace JustView
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class TextViewer : FlowDocumentScrollViewer
|
public partial class TextViewer : FlowDocumentScrollViewer
|
||||||
{
|
{
|
||||||
Lazy<ScrollViewer> m_scroll_viewer;
|
|
||||||
Lazy<double> m_default_width;
|
Lazy<double> m_default_width;
|
||||||
|
|
||||||
public TextViewer ()
|
public TextViewer ()
|
||||||
{
|
{
|
||||||
m_scroll_viewer = new Lazy<ScrollViewer> (FindScrollViewer);
|
|
||||||
m_default_width = new Lazy<double> (() => GetFixedWidth (80));
|
m_default_width = new Lazy<double> (() => GetFixedWidth (80));
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
DefaultZoom = 100;
|
DefaultZoom = 100;
|
||||||
@ -56,7 +54,7 @@ namespace JustView
|
|||||||
Input = null;
|
Input = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScrollViewer ScrollViewer { get { return m_scroll_viewer.Value; } }
|
public ScrollViewer ScrollViewer { get { return FindScrollViewer(); } }
|
||||||
public double DefaultWidth { get { return m_default_width.Value; } }
|
public double DefaultWidth { get { return m_default_width.Value; } }
|
||||||
public double DefaultZoom { get; private set; }
|
public double DefaultZoom { get; private set; }
|
||||||
public Stream Input { get; set; }
|
public Stream Input { get; set; }
|
||||||
@ -69,7 +67,8 @@ namespace JustView
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
m_word_wrap = value;
|
m_word_wrap = value;
|
||||||
ApplyWordWrap (value);
|
if (Input != null)
|
||||||
|
ApplyWordWrap (value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,23 +188,15 @@ namespace JustView
|
|||||||
|
|
||||||
public void ApplyWordWrap (bool word_wrap)
|
public void ApplyWordWrap (bool word_wrap)
|
||||||
{
|
{
|
||||||
if (word_wrap)
|
var scroll = this.ScrollViewer;
|
||||||
|
if (word_wrap && scroll != null)
|
||||||
{
|
{
|
||||||
var scroll = this.ScrollViewer;
|
this.Document.PageWidth = scroll.ViewportWidth;
|
||||||
if (scroll != null)
|
var width_binding = new Binding ("ViewportWidth");
|
||||||
{
|
width_binding.Source = scroll;
|
||||||
this.Document.PageWidth = scroll.ViewportWidth;
|
width_binding.Mode = BindingMode.OneWay;
|
||||||
var width_binding = new Binding ("ViewportWidth");
|
width_binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
|
||||||
width_binding.Source = scroll;
|
BindingOperations.SetBinding (this.Document, FlowDocument.PageWidthProperty, width_binding);
|
||||||
width_binding.Mode = BindingMode.OneWay;
|
|
||||||
width_binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
|
|
||||||
BindingOperations.SetBinding (this.Document, FlowDocument.PageWidthProperty, width_binding);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BindingOperations.ClearBinding (this.Document, FlowDocument.PageWidthProperty);
|
|
||||||
this.Document.PageWidth = this.ActualWidth;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -214,7 +205,7 @@ namespace JustView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScrollViewer FindScrollViewer ()
|
private ScrollViewer FindScrollViewer ()
|
||||||
{
|
{
|
||||||
if (VisualTreeHelper.GetChildrenCount (this) == 0)
|
if (VisualTreeHelper.GetChildrenCount (this) == 0)
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user