2
// ScrollViewBackend.cs
5
// Eric Maupin <ermau@xamarin.com>
7
// Copyright (c) 2012 Xamarin, Inc.
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
// of this software and associated documentation files (the "Software"), to deal
11
// in the Software without restriction, including without limitation the rights
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
// copies of the Software, and to permit persons to whom the Software is
14
// furnished to do so, subject to the following conditions:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29
using System.Windows.Controls;
31
namespace Xwt.WPFBackend
33
internal class ScrollAdjustmentBackend
34
: Backend, IScrollAdjustmentBackend
43
public CustomScrollViewPort TargetViewport { get; set; }
45
public void Initialize (IScrollAdjustmentEventSink eventSink)
47
EventSink = eventSink;
50
public void SetOffset (double offset)
52
// The offset is relative to 0, it has to be converted to the lower/upper value range
53
scrollValue = LowerValue + offset;
54
Xwt.Engine.Toolkit.Invoke (EventSink.OnValueChanged);
59
get { return scrollValue; }
61
// Provide the value to the viewport, which will update
62
// the ScrollView. The viewport expects an offset starting at 0.
63
TargetViewport.SetOffset (this, value - LowerValue);
67
public double LowerValue
69
get { return lowerValue; }
70
set { lowerValue = value; InvalidateExtent (); }
73
public double UpperValue
75
get { return upperValue; }
76
set { upperValue = value; InvalidateExtent (); }
79
public double PageIncrement
81
get { return pageIncrement; }
82
set { pageIncrement = value; InvalidateScrollInfo (); }
85
public double StepIncrement
87
get { return stepIncrement; }
88
set { stepIncrement = value; InvalidateScrollInfo (); }
91
public double PageSize
93
get { return pageSize; }
94
set { pageSize = value; InvalidateExtent (); }
97
void InvalidateScrollInfo ()
99
if (TargetViewport != null && TargetViewport.ScrollOwner != null)
100
TargetViewport.ScrollOwner.InvalidateScrollInfo ();
103
void InvalidateExtent ()
105
if (TargetViewport != null)
106
TargetViewport.UpdateCustomExtent ();
109
internal IScrollAdjustmentEventSink EventSink
b'\\ No newline at end of file'